mike-lischke / antlr4-runtime-benchmarks Goto Github PK
View Code? Open in Web Editor NEWA collection of benchmarks for ANTLR4 runtimes
License: MIT License
A collection of benchmarks for ANTLR4 runtimes
License: MIT License
Jim Idle suggested his TSQL grammar for benchmarking: https://github.com/jimidle/tsqlparser/
I don't use the
@members
Sorry, you are right. I just noticed that you already have the code in base classes.
but still, you have to import these classes and the calls to methods are different (depending on the target)
Yes, that is true, but that's exactly what "transformGrammar is all about. Yes, it is a totally disgusting hack, but it allows for the grammar to be shared for all targets.
Rather than have all these different syntax, the grammar always uses "this." in all actions, and transformGrammmar.py replaces the pattern with the appropriate syntax. To be really "target agnostic", you shouldn't even use operators like <
, %
, etc. I forgot, but there is one target for one grammar in grammars-v4 that had this issue.
For Cpp, the semantic action https://github.com/mike-lischke/antlr4-runtime-benchmarks/blob/a971852628d9ecca0ce79c7972e3c026017bdadc/src/mysql/targets/antlr4-cpp/MySQLLexer.g4#L474C90-L474C111 does not have a "this->", but is it required because the field is already declared in the base class. In most grammars, the "transformGrammar.py" hack is required to mutate "this." to "this->".
For JavaScript and TypeScript, "this." must be used https://github.com/mike-lischke/antlr4-runtime-benchmarks/blob/a971852628d9ecca0ce79c7972e3c026017bdadc/src/mysql/targets/antlr4/MySQLLexer.g4#L486C90-L486C116 . But, since we already require "this." for all field and method references for "target agnostic format", it's fine as is.
For Go, lexer predicates must be reference with "l." which parser predicates are "p.".
Etc., etc., etc.
A much better solution would be to provide a StringTemplate expansion for the target. A PR was added for this here: antlr/antlr4#4345 , but personally, I'd make the entire file a string template, and prefix or suffix the file with .st, and just apply ST through the whole file. Trash already does this. (You have to have a tool like trgen because Java requires base class code to be in a specific directory structure if you use a -package
option for the Antlr tool.
Originally posted by @kaby76 in #1 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.