expression
: expression DOUBLE_PIPE expression # ConcatenationExpression
| expression PLUS expression # AdditionExpression
| expression MINUS expression # SubtractionExpression
| expression ASTERISK expression # MultiplicationExpression
| expression SLASH expression # DivisionExpression
| expression PERCENT expression # ModuloExpression
| MINUS expression # UnaryMinusExpression
| PLUS expression # UnaryPlusExpression
| caseStatement # CaseExpression
| coalesce # CoalesceExpression
| nullIf # NullIfExpression
| literal # LiteralExpression
| parameter # ParameterExpression
| entityTypeReference # EntityTypeExpression
| path # PathExpression
| function # FunctionExpression
| LEFT_PAREN querySpec RIGHT_PAREN # SubQueryExpression
;
path
// a SimplePath may be any number of things like:
// * Class FQN
// * Java constant (enum/static)
// * a simple dotIdentifierSequence-style path
// :(
: dotIdentifierSequence # SimplePath
// a Map.Entry cannot be further dereferenced
| ENTRY LEFT_PAREN pathAsMap RIGHT_PAREN # MapEntryPath
// only one index-access is allowed per path
| path LEFT_BRACKET expression RIGHT_BRACKET (pathTerminal)? # IndexedPath
| pathRoot (pathTerminal)? # CompoundPath
;
pathRoot
: identifier # SimplePathRoot
| TREAT LEFT_PAREN dotIdentifierSequence AS dotIdentifierSequence RIGHT_PAREN # TreatedPathRoot
| KEY LEFT_PAREN pathAsMap RIGHT_PAREN # MapKeyPathRoot
| (VALUE | ELEMENTS) LEFT_PAREN collectionReference RIGHT_PAREN # CollectionValuePathRoot
;
pathTerminal
: (DOT identifier)+
;
I was hoping to get some help in tracking this down or even just understanding exactly what `org.antlr.v4.runtime.atn.ParserATNSimulator::adaptivePredict` is doing so I can hopefully better understand how to fix it.
I've seen discussions on this group that this is common with "expression" rules which is exactly the main culprit in our perf testing.expression
: expression DOUBLE_PIPE expression # ConcatenationExpression
| expression PLUS expression # AdditionExpression
| expression MINUS expression # SubtractionExpression
| expression ASTERISK expression # MultiplicationExpression
| expression SLASH expression # DivisionExpression
| expression PERCENT expression # ModuloExpression
| MINUS expression # UnaryMinusExpression
| PLUS expression # UnaryPlusExpression
| caseStatement # CaseExpression
| coalesce # CoalesceExpression
| nullIf # NullIfExpression
| literal # LiteralExpression
| parameter # ParameterExpression
| entityTypeReference # EntityTypeExpression
| path # PathExpression
| function # FunctionExpression
| LEFT_PAREN querySpec RIGHT_PAREN # SubQueryExpression
;
The sub-rules that I think cause problems are the first 6 and then `path`. `path` for sure is the one that specifically is showing up in our initial profiles. It is very a very complicated rule:path
// a SimplePath may be any number of things like:
// * Class FQN
// * Java constant (enum/static)
// * a simple dotIdentifierSequence-style path
// :(
: dotIdentifierSequence # SimplePath
// a Map.Entry cannot be further dereferenced
| ENTRY LEFT_PAREN pathAsMap RIGHT_PAREN # MapEntryPath
// only one index-access is allowed per path
| path LEFT_BRACKET expression RIGHT_BRACKET (pathTerminal)? # IndexedPath
| pathRoot (pathTerminal)? # CompoundPath
;
pathRoot
: identifier # SimplePathRoot
| TREAT LEFT_PAREN dotIdentifierSequence AS dotIdentifierSequence RIGHT_PAREN # TreatedPathRoot
| KEY LEFT_PAREN pathAsMap RIGHT_PAREN # MapKeyPathRoot
| (VALUE | ELEMENTS) LEFT_PAREN collectionReference RIGHT_PAREN # CollectionValuePathRoot
;
pathTerminal
: (DOT identifier)+
;I'm really just lost as to how to best optimize this to get it to perform adequately - as it stands I wont be able to justify using Antlr4 :( Please, any help would be very appreciated.
Is that available from the JetBrains plugin repo?
--
You received this message because you are subscribed to a topic in the Google Groups "antlr-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/antlr-discussion/9qqTpz8sHUE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.