-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrama.py
More file actions
54 lines (47 loc) · 1.38 KB
/
Copy pathgrama.py
File metadata and controls
54 lines (47 loc) · 1.38 KB
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
'''
sentence : statement SEMIC sentence
| empty
statement : statement_b
| statement_op
statement_b : IF iexpression THEN iblock END
| IF iexpression THEN iblock ELSE eblock END
statement_op: word
iblock : istat SEMIC iblock
| empty
istat : statement_b
| iword
iword : ID ASSIGN expression
| INT ID
eblock : estat SEMIC eblock
| empty
estat : statement_b
| eword
eword : ID ASSIGN expression
| INT ID
iexpression : expression
word : ID ASSIGN expression
| INT ID
expression : expression PLUS term
| expression MINUS term
| expression AND term
| expression XOR term
| INV term
| term
term : term TIMES factor
| term DIVIDE factor
| factor
factor : NUMBER
| LPAREN expression RPAREN
| ID
- 1.
Can not declare variables with same name in the hole code.
for a error example:
if a-3
then
int b;
b = 1;
else
int b; <---------- gramma DO NOT support this kind of behavior.
b = 2;
if you do something like this, if a != 3, then b will be covered to 0. if a == 3, then b will be 2.
'''