-
Notifications
You must be signed in to change notification settings - Fork 0
/
NGG.txt
77 lines (62 loc) · 2.9 KB
/
NGG.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Syntax
*Main*
Start ::= {FuncDecl | VarDefStmt}*
*Identifier*
Identifier ::= Identifier[Character {Character | Number}*]
Number ::= Number[Digit+]
Digit ::= "regexp:[0-9]"
Character ::= EngCharacter | '_'
EngCharacter ::= "regexp:[a-zA-Z]"
*Function essentials*
FuncDecl ::= FDecl['never gonna'] Identifier
LPA['('] ArgumentsList? RPA[')'] BlockStmt
ArgumentsList ::= Identifier {Comma[','] Identifier}*
CallList ::= rValue {Comma[','] rValue}*
*Values*
rValue ::= AddSubExpr {(Eq['=='] | Leq['<='] | Geq['>=']
| Neq['!='] | Gr['>']| Le['<']) AddSubExpr}?
AddSubExpr ::= MulDivExpr
{(Plus['+'] | Minus['-']) MulDivExpr}*
MulDivExpr ::= UnaryExpr {(Mul['*'] | Div['/'] | Pow['^']) UnaryExpr}*
UnaryExpr ::= ((Plus['+'] | Minus['-']) PrimaryExpr)
| PrimaryExpr
PrimaryExpr ::= LPA['('] rValue RPA[')']| BasicFunc | Number | FuncCall
| Identifier
FuncCall ::= Identifier LPA['('] CallList? RPA[')']
BasicFunc ::= Input | Sin | Cos | Tan | Sqrt | Exp | Abs
Sin ::= Sin["sin"] LPA['('] rValue RPA[')']
Cos ::= Cos["cos"] LPA['('] rValue RPA[')']
Tan ::= Tan["tan"] LPA['('] rValue RPA[')']
Sqrt ::= Sqrt["sqrt"] LPA['('] rValue RPA[')']
Abs ::= Abs["abs"] LPA['('] rValue RPA[')']
Input ::= Input['ask me']
Exp ::= Exp["exp"] LPA['('] rValue RPA[')']
+++
*Blocks*
BlockStmt ::= BStart['strangers'] Statement* BEnd['to love']
Statement ::= (VarDef | Print | SetPix | AssignExpr |
FuncCall) StEnd['bdum']
| ReturnStmt | IfStmt | WhileStmt | BlockStmt
AssignExpr ::= Identifier (Assg['='] | AdAssg['+='] |
MiAssg['-=']
| MuAssg['*='] | DiAssg['/=']) rValue
VarDef ::= VDecl['make you'] (Identifier Assg['=']
rValue | Identifier )
VarDefStmt ::= VarDef StEnd['bdum']
Print ::= Print['goodbye'] rValue
SetPix. ::= Print['septix'] rValue rValue rValue
*Control Sequences*
IfStmt ::= If['you know the rules']
LPA['('] rValue RPA[')']
BlockStmt {Else['and so do I'] BlockStmt}?
WhileStmt ::= While['run around']
LPA['('] rValue RPA[')'] BlockStmt
ReturnStmt ::= Return['known each other for so long'] rValue
StEnd['bdum']
# Memory management
… | global variables | stack memory
| Use | Register |
|:--|:--|
| Bp register | rex |
| Tmp calculations | rax |
| Tmp calculations2 | rbx |