/* (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 = JavaModifier* MCType DeclaratorId "=" Expression ; CatchClause = "catch" "(" JavaModifier* CatchTypeList Name ")" MCJavaBlock ; CatchTypeList = (MCQualifiedName || "|")+ ; ThrowStatement implements MCStatement = "throw" Expression ";" ; }