Skip to content

Commit

Permalink
ANYCC 47
Browse files Browse the repository at this point in the history
- Put test program
  • Loading branch information
Bazina committed Dec 25, 2023
1 parent 425e1f5 commit fb1d6bf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 39 deletions.
22 changes: 5 additions & 17 deletions CFG.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
# METHOD_BODY = STATEMENT_LIST
# STATEMENT_LIST = STATEMENT | STATEMENT_LIST STATEMENT
# STATEMENT = DECLARATION
| IF
| WHILE
| ASSIGNMENT
# DECLARATION = PRIMITIVE_TYPE 'id' ';'
# PRIMITIVE_TYPE = 'int' | 'float'
# IF = 'if' '(' EXPRESSION ')' '{' STATEMENT '}' 'else' '{' STATEMENT '}'
# WHILE = 'while' '(' EXPRESSION ')' '{' STATEMENT '}'
# ASSIGNMENT = 'id' 'assign' EXPRESSION ';'
# EXPRESSION = SIMPLE_EXPRESSION
| SIMPLE_EXPRESSION 'relop' SIMPLE_EXPRESSION
# SIMPLE_EXPRESSION = TERM | SIGN TERM | SIMPLE_EXPRESSION 'addop' TERM
# TERM = FACTOR | TERM 'mulop' FACTOR
# FACTOR = 'id' | 'num' | '(' EXPRESSION ')'
# SIGN = '+' | '-'
# E = T E1
# E1 = 'add' T E1 | Epsilon
# T = F T1
# T1 = 'mul' F T1 | Epsilon
# F = '(' E ')' | id
11 changes: 1 addition & 10 deletions program.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
int x;
x = 5;
if (x > 2)
{
x = 0;
}
else
{
x = 1;
}
* + id ) + ( id *
16 changes: 4 additions & 12 deletions rules.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
letter = a- z | A-Z
digit = 0 - 9
id: letter (letter | digit)*
digits = digit+
{boolean int float}
num: digit+ | digit+ . digits (\L | E digits)
relop: \=\= | !\= | > | >\= | < | <\=
assign: \=
{while if else}
[; , \( \) { }]
addop: \+ | \-
mulop: \* | /
id: id
mul: \*
add: \+
[\( \)]

0 comments on commit fb1d6bf

Please sign in to comment.