// $ANTLR start "eventHandlerDeclaration"
// /Users/peter/Documents/workspace/ToolModel/src/tool/model/grammar/ForteAST.g:472:1: eventHandlerDeclaration returns [ToolEventHandler eventHandler] : ^( EVENT_HANDLER_DECLARATION modifier IDENTIFIER ( formalParameterDecls )? ) ;
public final ToolEventHandler eventHandlerDeclaration() throws RecognitionException {
ToolEventHandler eventHandler = null;
CommonTree IDENTIFIER41=null;
try {
// /Users/peter/Documents/workspace/ToolModel/src/tool/model/grammar/ForteAST.g:473:2: ( ^( EVENT_HANDLER_DECLARATION modifier IDENTIFIER ( formalParameterDecls )? ) )
// /Users/peter/Documents/workspace/ToolModel/src/tool/model/grammar/ForteAST.g:473:4: ^( EVENT_HANDLER_DECLARATION modifier IDENTIFIER ( formalParameterDecls )? )
{
match(input,EVENT_HANDLER_DECLARATION,FOLLOW_EVENT_HANDLER_DECLARATION_in_eventHandlerDeclaration1573); if (state.failed) return eventHandler;
match(input, Token.DOWN, null); if (state.failed) return eventHandler;
pushFollow(FOLLOW_modifier_in_eventHandlerDeclaration1575);
modifier();
state._fsp--;
if (state.failed) return eventHandler;
IDENTIFIER41=(CommonTree)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_eventHandlerDeclaration1577); if (state.failed) return eventHandler;
// /Users/peter/Documents/workspace/ToolModel/src/tool/model/grammar/ForteAST.g:473:53: ( formalParameterDecls )?
int alt44=2;
int LA44_0 = input.LA(1);
if ( (LA44_0==PARAMETER) ) {
alt44=1;
}
switch (alt44) {
case 1 :
// /Users/peter/Documents/workspace/ToolModel/src/tool/model/grammar/ForteAST.g:0:0: formalParameterDecls
{
pushFollow(FOLLOW_formalParameterDecls_in_eventHandlerDeclaration1580);
formalParameterDecls();
state._fsp--;
if (state.failed) return eventHandler;
}
break;
}
match(input, Token.UP, null); if (state.failed) return eventHandler;
if ( state.backtracking==0 ) {
eventHandler = new ToolEventHandler(currentType);
eventHandler.setToolName((IDENTIFIER41!=null?IDENTIFIER41.getText():null));
if (currentType instanceof ToolClass)
((ToolClass)currentType).add(eventHandler);
}