%%% %% Section 14.5: Statements %% %% @author Martin Bravenboer <martin.bravenboer@gmail.com> %%% module languages/java-15/statements/Statements imports languages/java-15/statements/LocalVariableDeclarations languages/java-15/statements/Blocks languages/java-15/expressions/Main exports sorts Stm context-free syntax Block -> Stm %%% %% Section 14.6: The Empty Statement %%% context-free syntax ";" -> Stm {cons("Empty")} %%% %% Section 14.7: Labeled Statements %%% context-free syntax Id ":" Stm -> Stm {cons("Labeled")} %%% %% Section 14.8: Expressions Statements %%% context-free syntax Expr ";" -> Stm {cons("ExprStm")} %%% %% Section 14.9: The If Statement %%% context-free syntax "if" "(" Expr ")" Stm -> Stm {prefer, cons("If")} "if" "(" Expr ")" Stm "else" Stm -> Stm {cons("If")} %%% %% Section 14.10: The Assert Statement %%% context-free syntax "assert" Expr ";" -> Stm {cons("AssertStm")} "assert" Expr ":" Expr ";" -> Stm {cons("AssertStm")} %%% %% Section 14.11: The Switch Statement %%% sorts SwitchBlock SwitchGroup SwitchLabel context-free syntax "switch" "(" Expr ")" SwitchBlock -> Stm {cons("Switch")} "{" SwitchGroup* SwitchLabel* "}" -> SwitchBlock {cons("SwitchBlock")} SwitchLabel+ BlockStm+ -> SwitchGroup {cons("SwitchGroup")} "case" Expr ":" -> SwitchLabel {cons("Case")} "default" ":" -> SwitchLabel {cons("Default")} %%% %% Section 14.12: The While Statement %%% context-free syntax "while" "(" Expr ")" Stm -> Stm {cons("While")} %%% %% Section 14.13: The Do Statement %%% context-free syntax "do" Stm "while" "(" Expr ")" ";" -> Stm {cons("DoWhile")} %%% %% Section 14.14: The For Statement %%% context-free syntax "for" "(" LocalVarDec ";" Expr? ";" {Expr ","}* ")" Stm -> Stm {cons("For")} "for" "(" {Expr ","}* ";" Expr? ";" {Expr ","}* ")" Stm -> Stm {cons("For")} "for" "(" FormalParam ":" Expr ")" Stm -> Stm {cons("ForEach")} %%% %% Section 14.15: The Break Statement %%% context-free syntax "break" Id? ";" -> Stm {cons("Break")} %%% %% Section 14.16: The Continue Statement %%% context-free syntax "continue" Id? ";" -> Stm {cons("Continue")} %%% %% Section 14.17: The Return Statement %%% context-free syntax "return" Expr? ";" -> Stm {cons("Return")} %%% %% Section 14.18: The Throw Statement %%% context-free syntax "throw" Expr ";" -> Stm {cons("Throw")} %%% %% Section 14.19: The Synchronized Statement %%% context-free syntax "synchronized" "(" Expr ")" Block -> Stm {cons("Synchronized")} %%% %% Section 14.20: The Try Statement %%% sorts CatchClause context-free syntax "try" Block CatchClause+ -> Stm {cons("Try")} "try" Block CatchClause* "finally" Block -> Stm {cons("Try")} "catch" "(" FormalParam ")" Block -> CatchClause {cons("Catch")}