-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Truffle new pack parser #3519
Truffle new pack parser #3519
Conversation
Looks good. Do we have any perf numbers compared to the manual parser? |
For the parsing itself? No - I'll do that. That's not what it's designed for of course. |
Yes, I recall doing one lexer with jflex for Date#strftime(format) parsing and numbers were interesting. |
It turns out it's quite a bit slower. final PackParser parser = new PackParser(this);
while (true) {
final long start = System.nanoTime();
for (int n = 0; n < 1_000_000; n++) {
parser.parse("LI<BaL>Q<nnD@", false);
}
System.err.println((System.nanoTime() - start) / 1e9);
}
final PackCompiler compiler = new PackCompiler(this, null);
while (true) {
final long start = System.nanoTime();
for (int n = 0; n < 1_000_000; n++) {
compiler.compile("LI<BaL>Q<nnD@");
}
System.err.println((System.nanoTime() - start) / 1e9);
}
I'd still rather have this nice code in there for now though, and it's not putting me off trying a Ruby parser in Antlr4. |
The Antlr dependency is 374 KB. |
This is
Array#pack
reimplemented using Antlr instead of a hand-written lexer and parser. It's good software engineering, but it's also practice for developing a new new parser for Ruby in Antlr.@nirvdrum @pitr-ch @eregon please review - @headius and @enebo for info as you asked about this at RubyConf.