Skip to content

Commit

Permalink
Merge pull request #61 from a0x77n/issue56
Browse files Browse the repository at this point in the history
Fix try/catch handling
  • Loading branch information
Fabian Yamaguchi committed Jul 2, 2015
2 parents 761567b + f55cd2d commit 2daf336
Show file tree
Hide file tree
Showing 29 changed files with 2,434 additions and 1,927 deletions.
3 changes: 2 additions & 1 deletion src/antlr/C/Function.g4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ closing_curly: '}';
block_starter: selection_or_iteration;

selection_or_iteration: TRY #Try_statement
| CATCH '(' param_type ')' #Catch_statement
| CATCH '(' (param_type | ELLIPSIS) ')' #Catch_statement
| IF '(' condition ')' #If_statement
| ELSE #Else_statement
| SWITCH '(' condition ')' #Switch_statement
Expand All @@ -51,6 +51,7 @@ jump_statement: BREAK ';' #breakStatement
| CONTINUE ';' #continueStatement
| GOTO identifier ';' #gotoStatement
| RETURN expr? ';' #returnStatement
| THROW expr? ';' #throwStatement
;

label: CASE? (identifier | number | CHAR ) ':' ;
Expand Down
4 changes: 3 additions & 1 deletion src/antlr/C/Function.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ REGISTER=80
VIRTUAL=73
SWITCH=63
ELSE=57
ELLIPSIS=100
WHITESPACE=98
ALPHA_NUMERIC=85
PRE_IF=88
Expand Down Expand Up @@ -69,7 +70,7 @@ T__40=15
T__41=14
T__46=9
T__47=8
OTHER=100
OTHER=101
T__44=11
T__45=10
T__48=7
Expand Down Expand Up @@ -127,6 +128,7 @@ STRING=96
'^='=36
'+='=35
'break'=60
'...'=100
'{'=86
'>>='=34
'void'=68
Expand Down
18 changes: 17 additions & 1 deletion src/antlr/C/FunctionBaseListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
package antlr.C;


import org.antlr.v4.runtime.ParserRuleContext;
import java.util.Stack;


import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.tree.ErrorNode;
import org.antlr.v4.runtime.tree.TerminalNode;
Expand Down Expand Up @@ -578,6 +582,18 @@ public class FunctionBaseListener implements FunctionListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitGotoStatement(@NotNull FunctionParser.GotoStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterThrowStatement(@NotNull FunctionParser.ThrowStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitThrowStatement(@NotNull FunctionParser.ThrowStatementContext ctx) { }
/**
* {@inheritDoc}
*
Expand Down
617 changes: 312 additions & 305 deletions src/antlr/C/FunctionLexer.java

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/antlr/C/FunctionLexer.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ REGISTER=80
VIRTUAL=73
SWITCH=63
ELSE=57
ELLIPSIS=100
WHITESPACE=98
ALPHA_NUMERIC=85
PRE_IF=88
Expand Down Expand Up @@ -69,7 +70,7 @@ T__40=15
T__41=14
T__46=9
T__47=8
OTHER=100
OTHER=101
T__44=11
T__45=10
T__48=7
Expand Down Expand Up @@ -127,6 +128,7 @@ STRING=96
'^='=36
'+='=35
'break'=60
'...'=100
'{'=86
'>>='=34
'void'=68
Expand Down
15 changes: 14 additions & 1 deletion src/antlr/C/FunctionListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
package antlr.C;


import org.antlr.v4.runtime.misc.NotNull;
import java.util.Stack;

import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.tree.ParseTreeListener;

/**
Expand Down Expand Up @@ -481,6 +484,16 @@ public interface FunctionListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitGotoStatement(@NotNull FunctionParser.GotoStatementContext ctx);
/**
* Enter a parse tree produced by {@link FunctionParser#throwStatement}.
* @param ctx the parse tree
*/
void enterThrowStatement(@NotNull FunctionParser.ThrowStatementContext ctx);
/**
* Exit a parse tree produced by {@link FunctionParser#throwStatement}.
* @param ctx the parse tree
*/
void exitThrowStatement(@NotNull FunctionParser.ThrowStatementContext ctx);
/**
* Enter a parse tree produced by {@link FunctionParser#no_brackets}.
* @param ctx the parse tree
Expand Down

0 comments on commit 2daf336

Please sign in to comment.