Go to file
Kyler Olsen 05293c8f24 Add MIT License and added date in source files 2025-02-13 10:37:55 -07:00
.gitignore Add .vscode/ to .gitignore 2025-02-11 15:01:16 -07:00
LICENSE Add MIT License and added date in source files 2025-02-13 10:37:55 -07:00
compiler.py Add MIT License and added date in source files 2025-02-13 10:37:55 -07:00
example.graph syntactical analyst done 2024-06-18 23:42:45 -06:00
main.py Add MIT License and added date in source files 2025-02-13 10:37:55 -07:00
readme.md Updated readme 2025-02-12 23:13:33 -07:00
syntax.txt Removed redundant expression type 2024-06-19 00:27:22 -06:00
tokens.txt syntactical analyst done 2024-06-18 23:42:45 -06:00

readme.md

YTD Graphing Language

Implementation still in progress.

Lexical Definition

Comments

Comments can either be single-line comments or multi-line comments.

Single-line comments start with # and end at the end of a line.

Identifiers

Can be up to 31 characters in length, and are case sensitive. They cannot be a keyword.

Identifier ::= ID_Start*
ID_Start ::= <Any latin alphabet ligature: "A"-"Z", "a"-"z">

Keywords

Keywords are not case sensitive.

screen  graph   anim    const
sum     pi      alpha   beta
theta   inf     product integral

Literals

number ::=  decinteger | pointfloat | exponentfloat
decinteger ::=  nonzerodigit (["_"] digit)* | "0"+ (["_"] "0")*
nonzerodigit ::=  "1"..."9"
digit ::=  "0"..."9"
pointfloat    ::=  ([digitpart] fraction) | (digitpart ".")
exponentfloat ::=  (digitpart | pointfloat) exponent
digitpart     ::=  digit (["_"] digit)*
fraction      ::=  "." digitpart
exponent      ::=  ("e" | "E") ["+" | "-"] digitpart

Punctuation

+   -   *   /   %   ^
=   !   <   <=  >   >=
{   }   [   ]   (   )
_   ->  ,   ;   :   ∑
∏   ∞   ≠   ≤   ≥   ∫
α   β   π   →   θ

Punctuation Conversions

Original New
<=
>=
->

Keyword Conversions

Original New
sum
pi π
alpha α
beta β
inf
product
integral
theta θ

Syntax

The syntactical structure starts with a file at the root.

File

A file can contain any number of the following elements:

  • Screen
  • Graph
  • Animation
  • Constant

Screen

A screen begins with the screen keyword. It then has a comma (,) separated list enclosed in curly braces ({ and }) of screen parameters. At most only one screen block is allowed per file.

Screen parameter

A screen parameter begins with its parameter name then a colon (:) followed by its value.

Listed bellow are the possible parameters.

Top

  • Role: Sets the Y-Coordinate of the top of the screen to the given value.
  • Required: False
  • Default: Unset
  • Possible Values: Integers, Unset

Bottom

  • Role: Sets the Y-Coordinate of the bottom of the screen to the given value.
  • Required: False
  • Default: Unset
  • Possible Values: Integers, Unset

Right

  • Role: Sets the X-Coordinate of the right of the screen to the given value.
  • Required: False
  • Default: Unset
  • Possible Values: Integers, Unset

Left

  • Role: Sets the X-Coordinate of the left of the screen to the given value
  • Required: False
  • Default: Unset
  • Possible Values: Integers, Unset

Width

  • Role: Sets the X-Coordinate range of the screen to the given value
  • Required: False
  • Default: Unset
  • Possible Values: Natural Numbers, Unset
  • Note: Centered on zero if right and left are unset. The range uses right or left if one is set. Has no affect if right and left are set.

Height

  • Role: Sets the Y-Coordinate range of the screen to the given value
  • Required: False
  • Default: Unset
  • Possible Values: Natural Numbers, Unset
  • Note: Centered on zero if top and bottom are unset. The range uses top or bottom if one is set. Has no affect if top and bottom are set.

Width Scale

  • Role: Sets the X-Coordinate range of the screen to the screen pixel width divided by the given value
  • Required: False
  • Default: 20
  • Possible Values: Positive Real Numbers
  • Note: Centered on zero if right and left are unset. Has no affect if right and left are set or if width is set.

Height Scale

  • Role: Sets the Y-Coordinate range of the screen to the screen pixel height divided by the given value
  • Required: False
  • Default: 20
  • Possible Values: Positive Real Numbers
  • Note: Centered on zero if top and bottom are unset. Has no affect if top and bottom are set or if height is set.

FPS

  • Role: Sets the refresh rate of the screen
  • Required: False
  • Default: 30
  • Possible Values: Natural Numbers

Graph

A graph begins with the graph keyword. It then has a comma (,) separated list enclosed in curly braces ({ and }) of graph parameters. A graph block defines a graph to be drawn.

Graph parameter

A graph parameter begins with its parameter name then a colon (:) followed by an expression.

Listed bellow are the possible parameters and their possible roles. Any ranges can be the identifier of an animation or an inline animation.

X

  • The x = f(y) function for y independent cartesian equations.
  • The x = f(t) function for parametric equations.
  • The x range (animation) for x independent cartesian equations.

Y

  • The y = f(x) function for x independent cartesian equations.
  • The y = f(t) function for parametric equations.
  • The y range (animation) for y independent cartesian equations.

T

  • The t range (animation) for parametric equations.

R

  • The r = f(θ) function for polar equations.

θ

  • The θ range (animation) for polar equations.

Color functions

  • The c = f(x) function for x independent cartesian equations.
  • The c = f(y) function for y independent cartesian equations.
  • The c = f(t) function for parametric equations.
  • The c = f(θ) function for polar equations.

Color Functions

Color function parameter names are C_x where the x is color space part subscript. Only one color space can be used in each graph. If only alpha is set the default color space is Grey-scale.

Listed bellow are the available color spaces and their subscripts. Default value in parenthesis for the unused subscripts of the color spaces.

  • Grey-scale: w, a - Grey-scale (1), Alpha (1)
  • RGB: r, g, b, a - Red (0), Green (0), Blue (0), Alpha (1)
  • HSL: h, s, l, a - Hue (0), Saturation (1), Luminosity (0.5), Alpha (1)

All values can be a real number between 0 and 1 inclusive. Values bellow this range will be interpreted as 0. Values above this range will be interpreted as 1.

Animation

An animation begins with the anim keyword. Unless it is an inline animation block, the keyword is followed by its identifier. It then has a comma (,) separated list enclosed in curly braces ({ and }) of animation parameters.

When an animation is used in an expression, the value it is evaluated as is in the range defined, changing by the step every frame.

Animation parameter

An animation parameter begins with its parameter name then a colon (:) followed by an expression. If it is the only parameter the parameter name for the range is optional.

Listed bellow are the possible parameters. Only the range parameter is required.

R Range: R: expression ≤ x ≤ expression

S Step: S: expression

  • Default is 1/10 unless a range expression is multiplied by π then it is π/32.

D Direction: D: direction

  • increase (default)
  • decrease
  • bounce

Constant

A constant begins with the const keyword. It then is followed by an identifier, the assignment operator (=) followed by an expression then ended with a semicolon (;).

Expressions

Unary Expression

A unary expression is made up of one expression and one unary operator. The operator may come before or after the expression.

Binary Expression

A binary expression is made up of one expression, then one binary operator, then another expression.

Function

A function starts with an identifier followed by a comma (,) separated list enclosed in parentheses (( and )) of function arguments.

Function Argument

A function argument is an expression.

Enclosed Expression

An enclosed expression is simply an expression enclosed in parentheses (( and )).

Operator

Here are all operators and their types and names in order of precedence.

Operator Type Name
- Unary (Prefix) Negate Operator
! Unary (Postfix) Factorial Operator
^ Binary Exponential Operator
_ Binary Subscript Operator
/ Binary Division Operator
% Binary Modulus Operator
* Binary Multiplication Operator
- Binary Subtraction Operator
+ Binary Addition Operator
= Binary Assignment Operator

Note: The assignment operator (=) can only be used in a Constant

Literal

A literal is just simply the content of the literal.

Identifier

A identifier is just simply the name of the identifier.

Semantics

Screen Block

Graph Block

Animation Block