Comments (2)
Sam points out better to have getters to avoid fields. most of time fast enough. Add:
getA() -> single element, or list
getA(i) -> single at ith position
no need for -Xno-auto-ctx-labels
from antlr4.
Ok, got Sam's idea in for getters. from
statement
: block
| ASSERT expression (':' expression)? ';'
| 'if' parExpression statement ('else' statement)?
| 'for' '(' forControl ')' statement
| 'while' parExpression statement
| 'do' statement 'while' parExpression ';'
| 'try' block
( catches 'finally' block
| catches
| 'finally' block
)
| 'switch' parExpression '{' switchBlockStatementGroups '}'
| 'synchronized' parExpression block
| 'return' expression? ';'
| 'throw' expression ';'
| 'break' Identifier? ';'
| 'continue' Identifier? ';'
| ';'
| statementExpression ';'
| Identifier ':' statement
;
we get:
public static class statementContext extends ParserRuleContext<Token> {
public blockContext block(int i) {
return (blockContext)getRuleContext(blockContext.class,i);
}
public List<expressionContext> expression() {
return (List<expressionContext>)getRuleContexts(expressionContext.class);
}
public parExpressionContext parExpression() {
return (parExpressionContext)getRuleContext(parExpressionContext.class,0);
}
public statementContext statement(int i) {
return (statementContext)getRuleContext(statementContext.class,i);
}
public List<catchesContext> catches() {
return (List<catchesContext>)getRuleContexts(catchesContext.class);
}
public expressionContext expression(int i) {
return (expressionContext)getRuleContext(expressionContext.class,i);
}
public statementExpressionContext statementExpression() {
return (statementExpressionContext)getRuleContext(statementExpressionContext.class,0);
}
public List<blockContext> block() {
return (List<blockContext>)getRuleContexts(blockContext.class);
}
public List<statementContext> statement() {
return (List<statementContext>)getRuleContexts(statementContext.class);
}
public switchBlockStatementGroupsContext switchBlockStatementGroups() {
return (switchBlockStatementGroupsContext)getRuleContext(switchBlockStatementGroupsContext.class,0);
}
public Token ASSERT() { return getToken(JavaLRParser.ASSERT, 0); }
public forControlContext forControl() {
return (forControlContext)getRuleContext(forControlContext.class,0);
}
public Token Identifier() { return getToken(JavaLRParser.Identifier, 0); }
public catchesContext catches(int i) {
return (catchesContext)getRuleContext(catchesContext.class,i);
}
public statementContext(ParserRuleContext<Token> parent, int state) {
super(parent, state);
}
@Override
public void enterRule(ParseTreeListener<Token> listener) {
if ( listener instanceof JavaLRListener ) ((JavaLRListener)listener).enter(this);
}
@Override
public void exitRule(ParseTreeListener<Token> listener) {
if ( listener instanceof JavaLRListener ) ((JavaLRListener)listener).exit(this);
}
}
from antlr4.
Related Issues (20)
- Generate an abstract class/interface for rule containing only other parser rules as unnamed subrules
- [Swift] Add privacy manifest HOT 2
- [Go] Type signature error
- How can we write multiple parsers to use the same lexer? HOT 1
- [CSharp] Member GetMaxTokenType missing in IVocabulary
- Missing TypeScript methods
- [TorqueScript: C++]Old scripting language conversion HOT 2
- When is there a plan to support Rust?
- Left recursive rules that do not conform to a pattern ANTLR can handle HOT 1
- Android Tool run
- Separated package/artifactId when the minor version is upgraded for compatibility issues
- [Go] Can not use BailErrorStrategy since ParseCancellationException is not implement HOT 1
- Issue with using ANTLR4 from Julia via PyCall
- [TypeScript target] I would like to know how to create a custom visitor in TypeScript. HOT 4
- C++ warning + fix HOT 2
- Error with books source examples in chapter 4
- Clarify supported Python runtime language version HOT 4
- Unable to customize error messages on top of error messages generated by ANTLR4 Parser HOT 1
- [go] performance downgrade a lot after upgrade antlr from 4.9 to 4.13.1 HOT 4
- [C++] Building grammar with rule named "match" causes errors
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from antlr4.