-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_cases
70 lines (64 loc) · 1.78 KB
/
test_cases
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
Grammar
=======
# 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' '=' 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 = '+' | '-'
Modified Grammar
================
# METHOD_BODY = STATEMENT_LIST
# STATEMENT_LIST = STATEMENT STATEMENT_LIST&
# STATEMENT_LIST& = STATEMENT STATEMENT_LIST& | '\L'
# 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' '=' EXPRESSION ';'
# EXPRESSION = SIMPLE_EXPRESSION EXPRESSION&
# EXPRESSION& = 'relop' SIMPLE_EXPRESSION | '\L'
# SIMPLE_EXPRESSION = TERM SIMPLE_EXPRESSION& | SIGN TERM SIMPLE_EXPRESSION&
# SIMPLE_EXPRESSION& = 'addop' TERM SIMPLE_EXPRESSION& | '\L'
# TERM = FACTOR TERM&
# TERM& = 'mulop' FACTOR TERM& | '\L'
# FACTOR = 'id' | 'num' | '(' EXPRESSION ')'
# SIGN = '+' | '-'
Program 1
=========
int count ;
while (pass != 10) {
pass = pass + 1 ;
}
if (mnt <= 0) {
count = count + 1.234;
}
else{
sum = sum + mnt;
}
Program 2
=========
int count ;
while (pass != 10) {
pass = pass + 1 ;
if (mnt <= 0) ) {
count = count + 1.234;
}
else{
sum = sum + mnt;
}