-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
79 lines (69 loc) · 3.04 KB
/
grammar.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
78
79
statements : statements \n statement
| statements ; statement
| statement
statement : EXIT
| TITLE
| expr
| expr TITLE
| ids_assign expr
| func_shape ASSIGN expr
| CALC ID
| PLOT expr FROM expr TO expr
| PLOT expr FROM expr TO expr AS ID
| PLOT expr FROM expr TO expr AS STRING
| POLAR expr
| expr POLAR
| VARS
| NEW
func_shape : ID LPAREN exprs expr RPAREN
| ID LPAREN expr RPAREN
exprs : expr COMMA
| exprs expr COMMA
ids_assign : ID ASSIGN
| ids_assign ID ASSIGN
expr : expr + expr
| expr - expr
| expr * expr
| expr / expr
| expr ^ expr
| expr % expr
| - expr %prec UMINUS
| NUMBER
| NUMBER AT expr
| NUMBER AT DEGSYM expr
| mini_term
| PIPE expr PIPE
| expr THEN expr
| expr THEN ' ID expr '
| with_expr %prec COMPO_WITH_EXPR
| with_expr with_assigns %prec COMPO_WITH_EXPR
| INT expr FROM expr TO expr %prec INTEGRAL
| expr CROCANTE
mono_with_expr : expr WITH ID ASSIGN expr %prec MONO_WITH_EXPR
with_assigns : COMMA ids_assign expr %prec WITH_ASSIGNS
| with_assigns COMMA ids_assign expr %prec WITH_ASSIGNS
mini_term : ID
| NUMBER mini_term %prec CONSTANT
| LPAREN expr RPAREN mini_term %prec CONSTANT
| NUMBER mini_term POW expr
| LPAREN expr RPAREN mini_term POW expr
| MATHFUNC LPAREN expr RPAREN
| func_shape
| LPAREN expr RPAREN
------
precedence = (
('right', CROCANTE),
('right', ASSIGN),
('left', INTEGRAL),
('left', THEN),
('left', WITH_EXPR),
('left', MONO_WITH_EXPR, COMMA),
('right', WITH_ASSIGNS),
('left', PLUS, MINUS),
('left', TIMES, DIV, MOD),
('right', CONSTANT),
('right', MATHFUNC, UMINUS),
('right', POW),
('nonassoc', NUMBER),
('nonassoc', AT, DEGSYM),
)