@@ -5,36 +5,47 @@ module STMT-SYNTAX
5
5
imports CORE-SORTS
6
6
imports CORE-CLASSES
7
7
//todo:be specific
8
- syntax Stmt ::= "if" "(" K ")" "{" K "}" "else" "{" K "}" [strict(1),klabel('If)]
9
- |"if" "(" K ")" "{" K "}" [strict(1),klabel('If)]
10
- |"while" "(" K ")" "{" K "}" [strict(1),klabel('While)]
11
- |"do" "{" K "}" "while" "(" K ")"[strict(2),klabel('DoWhile)]
12
- |"for" "(" K ";" K ";" K ")" "{" K "}" [klabel('For)]
13
-
14
-
15
- |Exp ";" [strict, klabel('ExprStm)]
16
- |"assert" Exp ";" [strict, klabel('AssertStm)]
17
- |"assert" Exp ":" Exp ";" [strict(1), klabel('AssertStm)]
18
- |Id ":" K [klabel('Labeled)]
19
- |"switch" "(" Exp ")" SwitchBlock [strict(1),klabel('Switch)]
20
- |"try" K KListWrap "finally" Block [klabel('Try)]
21
- |"try" K KListWrap [klabel('Try)]
22
- |"catch" "(" K ")" Block [klabel('Catch)]
23
- //todo:change K above and below
24
- syntax Block ::= "{" K "}" [klabel('Block)]
8
+ syntax Stmt ::= StmtWithoutTrailing|LabeledStmt|IfThenElseStmt|IfThenStmt|WhileStmt|ForStmt
9
+
10
+ syntax IfThenElseStmt ::= "if" "(" K ")" "{" K "}" "else" "{" K "}" [strict(1),klabel('If)]
11
+ syntax IfThenStmt ::= "if" "(" K ")" "{" K "}" [strict(1),klabel('If)]
12
+ syntax WhileStmt ::= "while" "(" K ")" "{" K "}" [strict(1),klabel('While)]
13
+ syntax ForStmt ::= "for" "(" K ";" K ";" K ")" "{" K "}" [klabel('For)]
14
+ syntax LabeledStmt ::= Id ":" K [klabel('Labeled)]
15
+
16
+
17
+ syntax StmtWithoutTrailing ::= Block
18
+ |EmptyStmt
19
+ |ExprStmt
20
+ |AssertStmt
21
+ |SwitchStmt
22
+ |DoStmt
23
+ |TryStmt
24
+ |StackConsumerStmt
25
+ |SynchronizedStmt
25
26
27
+ syntax Block ::= "{" K "}" [klabel('Block)]
28
+ syntax EmptyStmt ::= ";" [klabel('Empty)]
29
+ syntax ExprStmt ::= Exp ";" [strict, klabel('ExprStm)]
30
+ syntax AssertStmt ::="assert" Exp ";" [strict, klabel('AssertStm)]
31
+ |"assert" Exp ":" Exp ";" [strict(1), klabel('AssertStm)]
32
+ syntax SwitchStmt ::= "switch" "(" Exp ")" SwitchBlock [strict(1),klabel('Switch)]
26
33
syntax SwitchGroup ::= KListWrap KListWrap [klabel('SwitchGroup)]
27
34
syntax SwitchLabel ::= "case" Exp ":" [strict, klabel('Case)]
28
35
|"default:" [klabel('Default)]
29
36
syntax SwitchBlock::= "{" KListWrap KListWrap "}" [klabel('SwitchBlock)]
37
+ syntax DoStmt ::="do" "{" K "}" "while" "(" K ")"[strict(2),klabel('DoWhile)]
38
+ syntax TryStmt ::= "try" K KListWrap "finally" Block [klabel('Try)]
39
+ |"try" K KListWrap [klabel('Try)]
40
+ |"catch" "(" K ")" Block [klabel('Catch)]
41
+ syntax StackConsumerStmt ::= "dummyStackConsumerStmt"|ThrowStmt|ContinueStmt|BreakStmt|ReturnStmt
42
+ syntax ThrowStmt ::= "throw" K ";" [strict, klabel('Throw)]
43
+ syntax ContinueStmt ::= "continue" K ";" [klabel('Continue)]
44
+ syntax BreakStmt ::= "break" K ";" [klabel('Break)]
45
+ syntax ReturnStmt ::= "return" K ";" [klabel('Return)]
46
+ //todo: add syntax
47
+ syntax SynchronizedStmt ::= "dummySynchronizedStmt"
30
48
31
- syntax Stmt ::= StackConsumerStmt | EmptyStmt
32
- syntax EmptyStmt ::= ";" [klabel('Empty)]
33
- syntax StackConsumerStmt ::= "dummyStackConsumerStmt"
34
- |"throw" K ";" [strict, klabel('Throw)]
35
- |"continue" K ";" [klabel('Continue)]
36
- |"break" K ";" [klabel('Break)]
37
- |"return" K ";" [klabel('Return)]
38
49
39
50
40
51
0 commit comments