-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathMCExceptionStatements.mc4
More file actions
65 lines (52 loc) · 1.82 KB
/
Copy pathMCExceptionStatements.mc4
File metadata and controls
65 lines (52 loc) · 1.82 KB
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
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.statements;
/* This is a MontiCore stable grammar.
* Adaptations -- if any -- are conservative. */
import de.monticore.statements.*;
/**
* This grammar defines the exception statements.
* This includes Java try with catch and finally, as well as throw.
*
* This grammar is part of a hierarchy of statements, namely
* * statements/MCStatementsBasis.mc4
* * -- statements/MCAssertStatements.mc4
* * -- statements/MCVarDeclarationStatements.mc4
* * -- -- statements/MCArrayStatements.mc4
* * -- -- statements/MCCommonStatements.mc4
* * -- -- -- statements/MCExceptionStatements.mc4
* * -- -- -- statements/MCSynchronizedStatements.mc4
* * -- statements/MCLowLevelStatements.mc4
* * -- statements/MCReturnStatements.mc4
*
* and the composition of all statement grammars to full Java:
* * -- -- statements/MCFullJavaStatements.mc4
*
*/
component grammar MCExceptionStatements
extends MCCommonStatements {
// Three different variants of the TryStatement differ in the
// optionality of their elements.
TryStatement1 implements MCStatement
= "try"
core:MCJavaBlock
CatchClause+
("finally" finally:MCJavaBlock)? ;
TryStatement2 implements MCStatement
= "try"
core:MCJavaBlock
CatchClause*
("finally" finally:MCJavaBlock) ;
TryStatement3 implements MCStatement
= "try" "(" (TryLocalVariableDeclaration || ";")+ ";"? ")"
core:MCJavaBlock
CatchClause*
("finally" finally:MCJavaBlock)? ;
TryLocalVariableDeclaration
= MCModifier* MCType DeclaratorId "=" Expression ;
CatchClause
= "catch" "(" MCModifier* CatchTypeList Name ")" MCJavaBlock ;
CatchTypeList
= (MCQualifiedName || "|")+ ;
ThrowStatement implements MCStatement
= "throw" Expression ";" ;
}