// $ANTLR start "constantDeclaration"
// /Users/peter/Documents/workspace/ToolModel/src/tool/model/grammar/ForteAST.g:498:1: constantDeclaration[boolean planConstant] returns [ToolConstant toolConst] : ^( CONSTANT ( modifier )? IDENTIFIER literal ) ;
public final ToolConstant constantDeclaration(boolean planConstant) throws RecognitionException {
ToolConstant toolConst = null;
CommonTree IDENTIFIER43=null;
ForteAST.literal_return literal44 = null;
ForteAST.modifier_return modifier45 = null;
try {
// /Users/peter/Documents/workspace/ToolModel/src/tool/model/grammar/ForteAST.g:499:5: ( ^( CONSTANT ( modifier )? IDENTIFIER literal ) )
// /Users/peter/Documents/workspace/ToolModel/src/tool/model/grammar/ForteAST.g:499:7: ^( CONSTANT ( modifier )? IDENTIFIER literal )
{
match(input,CONSTANT,FOLLOW_CONSTANT_in_constantDeclaration1656); if (state.failed) return toolConst;
match(input, Token.DOWN, null); if (state.failed) return toolConst;
// /Users/peter/Documents/workspace/ToolModel/src/tool/model/grammar/ForteAST.g:499:18: ( modifier )?
int alt48=2;
int LA48_0 = input.LA(1);
if ( ((LA48_0>=PRIVATE && LA48_0<=PUBLIC)||(LA48_0>=231 && LA48_0<=232)) ) {
alt48=1;
}
switch (alt48) {
case 1 :
// /Users/peter/Documents/workspace/ToolModel/src/tool/model/grammar/ForteAST.g:0:0: modifier
{
pushFollow(FOLLOW_modifier_in_constantDeclaration1658);
modifier45=modifier();
state._fsp--;
if (state.failed) return toolConst;
}
break;
}
IDENTIFIER43=(CommonTree)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_constantDeclaration1661); if (state.failed) return toolConst;
pushFollow(FOLLOW_literal_in_constantDeclaration1663);
literal44=literal();
state._fsp--;
if (state.failed) return toolConst;
match(input, Token.UP, null); if (state.failed) return toolConst;
if ( state.backtracking==0 ) {
toolConst = new ToolConstant(
(IDENTIFIER43!=null?IDENTIFIER43.getText():null), //Constant ID
(literal44!=null?(input.getTokenStream().toString(
input.getTreeAdaptor().getTokenStartIndex(literal44.start),
input.getTreeAdaptor().getTokenStopIndex(literal44.start))):null), //Constant Value
(modifier45!=null?(input.getTokenStream().toString(
input.getTreeAdaptor().getTokenStartIndex(modifier45.start),
input.getTreeAdaptor().getTokenStopIndex(modifier45.start))):null),
planConstant); //Visibility
if (planConstant){
((project_scope)project_stack.peek()).currentPlan.addConstant(toolConst);
toolConst.setParent(((project_scope)project_stack.peek()).currentPlan);
}
}
}