You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ANTLR grammar fails to parse tabular subquery on the right of in #194
Run java -jar antlr4-4.13.2-complete.jar -Dlanguage=Python3 -visitor -o out Kql.g4
Use the Python KQL parser:
fromantlr4importInputStream, CommonTokenStreamfromKqlLexerimportKqlLexerfromKqlParserimportKqlParserdefparse(query: str):
parser=KqlParser(CommonTokenStream(KqlLexer(InputStream(query))))
tree=parser.top()
print(tree.toStringTree(recog=parser))
parse('''StormEvents | where State in ( StormEvents | summarize count() by State | top 5 by count_ ) | count''')
the KQL grammar file was recovered from an older antlr3 grammer file that was not as current as the actual parser. The current parser solves this with a bit of magic look-ahead.. Solving it by adding the extra alternate with the pipe expression might work, but it might also cause an ambiguity with anltr due to having two branches that could possibly parse the same input in some cases.
Activity
mattwar commentedon Aug 21, 2026
the KQL grammar file was recovered from an older antlr3 grammer file that was not as current as the actual parser. The current parser solves this with a bit of magic look-ahead.. Solving it by adding the extra alternate with the pipe expression might work, but it might also cause an ambiguity with anltr due to having two branches that could possibly parse the same input in some cases.
mmaitre314 commentedon Aug 21, 2026
Would there be some better solution? I could try a different patch in my project so see what that gives.
mattwar commentedon Aug 21, 2026
The the approach you already tried successfully built with antlr4 then that’s the correct solution.