syntactical analyst done

This commit is contained in:
Kyler 2024-06-18 23:42:45 -06:00
parent 0ceaac04b1
commit dbd1e646e6
5 changed files with 1162 additions and 132 deletions

File diff suppressed because it is too large Load Diff

View File

@ -9,14 +9,15 @@ SCREEN {
FPS: 60,
}
R = 7;
r = 4;
d = 1;
const R = 7;
const r = 4;
const d = 1;
s = 0;
e = 8*π;
const s = 0;
const e = 8*pi;
const m = cos(π/32);
ANIM offset {R:s <= x <= e,S:π/128}
ANIM offset {R:s <= x <= e,S:π/128,D:INCREASE}
GRAPH {
X: (R - r) * cos(t) + d * cos(((R - r) / r) * t),

View File

@ -25,7 +25,7 @@ ID_Start ::= <Any latin alphabet ligature: "A"-"Z", "a"-"z">
Keywords are not case sensitive.
```
screen graph anim img
screen graph anim const
sum pi alpha beta
theta inf product integral
```
@ -86,7 +86,7 @@ A `file` can contain any number of the following elements:
- *Screen*
- *Graph*
- *Animation*
- *Statement*
- *Constant*
<!-- - *Image* -->
### Screen
@ -148,6 +148,7 @@ Listed bellow are the possible parameters.
- 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**
@ -160,6 +161,7 @@ Listed bellow are the possible parameters.
- 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**
@ -173,7 +175,7 @@ Listed bellow are the possible parameters.
- 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` are set.
Has no affect if `right` and `left` are set or if `width` is set.
**Height Scale**
- Role:
@ -186,7 +188,7 @@ Listed bellow are the possible parameters.
- 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` are set.
Has no affect if `top` and `bottom` are set or if `height` is set.
**FPS**
- Role:
@ -246,9 +248,10 @@ 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**: `wa` - Grey-scale (1), Alpha (1)
- **RGB**: `rgba` - Red (0), Green (0), Blue (0), Alpha (1)
- **HSL**: `hsla` - Hue (0), Saturation (1), Luminosity (0.5), Alpha (1)
- **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.
@ -284,6 +287,12 @@ is `π/32`.
- `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
@ -329,6 +338,8 @@ Here are all operators and their types and names in order of precedence.
| `+` | 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.
@ -337,10 +348,6 @@ A `literal` is just simply the content of the literal.
A `identifier` is just simply the name of the identifier.
#### Statement
A `statement` is made up of an `expression` followed by a semicolon (`;`).
## Semantics
### Screen Block

101
syntax.txt Normal file
View File

@ -0,0 +1,101 @@
File
├─ Screen
│ ├─ Width Scale: 100
│ ├─ Height Scale: 100
│ └─ FPS: 60
├─ Constant (R)
│ └─ Literal Expression (7)
├─ Constant (r)
│ └─ Literal Expression (4)
├─ Constant (d)
│ └─ Literal Expression (1)
├─ Constant (s)
│ └─ Literal Expression (0)
├─ Constant (e)
│ └─ Binary Expression (BinaryOperator.Multiplication)
│ ├─ Literal Expression (8)
│ └─ Literal Expression (π)
├─ Constant (m)
│ └─ Function Call (cos)
│ └─ Binary Expression (BinaryOperator.Division)
│ ├─ Literal Expression (π)
│ └─ Literal Expression (32)
├─ Animation (offset)
│ ├─ Range Start (≤)
│ │ └─ Literal Expression (s)
│ ├─ Range End (≤)
│ │ └─ Literal Expression (e)
│ ├─ Step
│ │ └─ Binary Expression (BinaryOperator.Division)
│ │ ├─ Literal Expression (π)
│ │ └─ Literal Expression (128)
│ └─ Direction: AnimationDirection.Increase
└─ Graph
├─ X
│ └─ Binary Expression (BinaryOperator.Addition)
│ ├─ Binary Expression (BinaryOperator.Multiplication)
│ │ ├─ Enclosed Expression
│ │ │ └─ Binary Expression (BinaryOperator.Subtraction)
│ │ │ ├─ Literal Expression (R)
│ │ │ └─ Literal Expression (r)
│ │ └─ Function Call (cos)
│ │ └─ Literal Expression (t)
│ └─ Binary Expression (BinaryOperator.Multiplication)
│ ├─ Literal Expression (d)
│ └─ Function Call (cos)
│ └─ Binary Expression (BinaryOperator.Multiplication)
│ ├─ Enclosed Expression
│ │ └─ Binary Expression (BinaryOperator.Division)
│ │ ├─ Enclosed Expression
│ │ │ └─ Binary Expression (BinaryOperator.Subtraction)
│ │ │ ├─ Literal Expression (R)
│ │ │ └─ Literal Expression (r)
│ │ └─ Literal Expression (r)
│ └─ Literal Expression (t)
├─ Y
│ └─ Binary Expression (BinaryOperator.Subtraction)
│ ├─ Binary Expression (BinaryOperator.Multiplication)
│ │ ├─ Enclosed Expression
│ │ │ └─ Binary Expression (BinaryOperator.Subtraction)
│ │ │ ├─ Literal Expression (R)
│ │ │ └─ Literal Expression (r)
│ │ └─ Function Call (sin)
│ │ └─ Literal Expression (t)
│ └─ Binary Expression (BinaryOperator.Multiplication)
│ ├─ Literal Expression (d)
│ └─ Function Call (sin)
│ └─ Binary Expression (BinaryOperator.Multiplication)
│ ├─ Enclosed Expression
│ │ └─ Binary Expression (BinaryOperator.Division)
│ │ ├─ Enclosed Expression
│ │ │ └─ Binary Expression (BinaryOperator.Subtraction)
│ │ │ ├─ Literal Expression (R)
│ │ │ └─ Literal Expression (r)
│ │ └─ Literal Expression (r)
│ └─ Literal Expression (t)
├─ T
│ └─ Inline Animation
│ ├─ Range Start (≤)
│ │ └─ Binary Expression (BinaryOperator.Addition)
│ │ ├─ Literal Expression (s)
│ │ └─ Literal Expression (offset)
│ ├─ Range End (≤)
│ │ └─ Binary Expression (BinaryOperator.Addition)
│ │ ├─ Literal Expression (e)
│ │ └─ Literal Expression (offset)
│ ├─ Step
│ │ └─ Binary Expression (BinaryOperator.Division)
│ │ ├─ Literal Expression (π)
│ │ └─ Literal Expression (32)
│ └─ Direction: AnimationDirection.Increase
└─ C_w
└─ Enclosed Expression
└─ Binary Expression (BinaryOperator.Division)
├─ Enclosed Expression
│ └─ Binary Expression (BinaryOperator.Subtraction)
│ ├─ Literal Expression (t)
│ └─ Literal Expression (s)
└─ Enclosed Expression
└─ Binary Expression (BinaryOperator.Subtraction)
├─ Literal Expression (e)
└─ Literal Expression (s)

View File

@ -1,4 +1,4 @@
Type: Identifier, Value: SCREEN
Type: Keyword, Value: SCREEN
Type: Punctuation, Value: {
Type: Identifier, Value: Width
Type: Identifier, Value: Scale
@ -15,38 +15,65 @@ Type: Punctuation, Value: :
Type: NumberLiteral, Value: 60
Type: Punctuation, Value: ,
Type: Punctuation, Value: }
Type: Keyword, Value: const
Type: Identifier, Value: R
Type: Punctuation, Value: =
Type: NumberLiteral, Value: 7
Type: Punctuation, Value: ;
Type: Keyword, Value: const
Type: Identifier, Value: r
Type: Punctuation, Value: =
Type: NumberLiteral, Value: 4
Type: Punctuation, Value: ;
Type: Keyword, Value: const
Type: Identifier, Value: d
Type: Punctuation, Value: =
Type: NumberLiteral, Value: 1
Type: Punctuation, Value: ;
Type: Identifier, Value: ANIM
Type: Keyword, Value: const
Type: Identifier, Value: s
Type: Punctuation, Value: =
Type: NumberLiteral, Value: 0
Type: Punctuation, Value: ;
Type: Keyword, Value: const
Type: Identifier, Value: e
Type: Punctuation, Value: =
Type: NumberLiteral, Value: 8
Type: Punctuation, Value: *
Type: Punctuation, Value: π
Type: Punctuation, Value: ;
Type: Keyword, Value: const
Type: Identifier, Value: m
Type: Punctuation, Value: =
Type: Identifier, Value: cos
Type: Punctuation, Value: (
Type: Punctuation, Value: π
Type: Punctuation, Value: /
Type: NumberLiteral, Value: 32
Type: Punctuation, Value: )
Type: Punctuation, Value: ;
Type: Keyword, Value: ANIM
Type: Identifier, Value: offset
Type: Punctuation, Value: {
Type: Identifier, Value: R
Type: Punctuation, Value: :
Type: NumberLiteral, Value: 0
Type: Identifier, Value: s
Type: Punctuation, Value: ≤
Type: Identifier, Value: x
Type: Punctuation, Value: ≤
Type: NumberLiteral, Value: 8
Type: Punctuation, Value: *
Type: Punctuation, Value: π
Type: Identifier, Value: e
Type: Punctuation, Value: ,
Type: Identifier, Value: S
Type: Punctuation, Value: :
Type: Punctuation, Value: π
Type: Punctuation, Value: /
Type: NumberLiteral, Value: 128
Type: Punctuation, Value: ,
Type: Identifier, Value: D
Type: Punctuation, Value: :
Type: Identifier, Value: INCREASE
Type: Punctuation, Value: }
Type: Identifier, Value: GRAPH
Type: Keyword, Value: GRAPH
Type: Punctuation, Value: {
Type: Identifier, Value: X
Type: Punctuation, Value: :
@ -110,19 +137,17 @@ Type: Punctuation, Value: )
Type: Punctuation, Value: ,
Type: Identifier, Value: T
Type: Punctuation, Value: :
Type: Identifier, Value: ANIM
Type: Keyword, Value: ANIM
Type: Punctuation, Value: {
Type: Identifier, Value: R
Type: Punctuation, Value: :
Type: NumberLiteral, Value: 0
Type: Identifier, Value: s
Type: Punctuation, Value: +
Type: Identifier, Value: offset
Type: Punctuation, Value: ≤
Type: Identifier, Value: x
Type: Punctuation, Value: ≤
Type: NumberLiteral, Value: 8
Type: Punctuation, Value: *
Type: Punctuation, Value: π
Type: Identifier, Value: e
Type: Punctuation, Value: +
Type: Identifier, Value: offset
Type: Punctuation, Value: ,
@ -141,22 +166,13 @@ Type: Punctuation, Value: (
Type: Punctuation, Value: (
Type: Identifier, Value: t
Type: Punctuation, Value: -
Type: Identifier, Value: r
Type: Punctuation, Value: [
Type: NumberLiteral, Value: 0
Type: Punctuation, Value: ]
Type: Identifier, Value: s
Type: Punctuation, Value: )
Type: Punctuation, Value: /
Type: Punctuation, Value: (
Type: Identifier, Value: r
Type: Punctuation, Value: [
Type: NumberLiteral, Value: 1
Type: Punctuation, Value: ]
Type: Identifier, Value: e
Type: Punctuation, Value: -
Type: Identifier, Value: r
Type: Punctuation, Value: [
Type: NumberLiteral, Value: 0
Type: Punctuation, Value: ]
Type: Identifier, Value: s
Type: Punctuation, Value: )
Type: Punctuation, Value: )
Type: Punctuation, Value: }