Skip to content

Commit 64aba97

Browse files
committed
subsort stmt
1 parent 0490deb commit 64aba97

File tree

2 files changed

+36
-45
lines changed

2 files changed

+36
-45
lines changed

src/common/stmt-syntax.k

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,47 @@ module STMT-SYNTAX
55
imports CORE-SORTS
66
imports CORE-CLASSES
77
//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
2526

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)]
2633
syntax SwitchGroup ::= KListWrap KListWrap [klabel('SwitchGroup)]
2734
syntax SwitchLabel ::= "case" Exp ":" [strict, klabel('Case)]
2835
|"default:" [klabel('Default)]
2936
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"
3048

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)]
3849

3950

4051

src/exec/statements.k

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,11 @@ rule [ExecutionPhase-Start]:
2626
<mainClass> ListItem(MainClassS:String) </mainClass>
2727
<globalPhase> UnfoldingPhase => ExecutionPhase </globalPhase>
2828

29-
syntax KLabel ::= "'Block"
30-
// | "'Labeled"
31-
// | "'ExprStm"
32-
// | "'AssertStm"
33-
// | "'Switch"
34-
// | "'SwitchBlock"
35-
// | "'SwitchGroup"
36-
// | "'Case"
37-
// | "'Default"
38-
// | "'While"
39-
// | "'DoWhile"
40-
// | "'For"
41-
// | "'Break"
42-
// | "'Continue"
43-
// | "'Return"
44-
// | "'Throw"
45-
| "'Try"
46-
| "'Catch"
47-
48-
4929
//@ \subsection{Blocks} JLS \$14.2
5030

5131
rule [Block]:
5232
<k> 'Block(S:K) => S ~> env(Env:Map) ...</k>
53-
// <k> {S:K} => S ~> env(Env:Map) ...</k>
33+
//todo: <k> {S:K} => S ~> env(Env:Map) ...</k>
5434
<env> Env </env>
5535
[structural]
5636

0 commit comments

Comments
 (0)