[ANN] otto, New parser coming in a week or so

585 views
Skip to first unread message

Robert K

unread,
Mar 26, 2014, 10:29:07 AM3/26/14
to golan...@googlegroups.com
I'll be releasing a new, rewritten parser for otto (A JavaScript parser and interpreter in Go) in about a week or so.

The new parser was rewritten with learnings (cargo-culting :) from "go/parser" and is cleaner, more straightforward, faster, etc. It is also exported. Available here (parser-master branch):

https://github.com/robertkrimen/otto/tree/parser-master

This is an under-the-hood change, so nothing should really break (but try it anyway if you're importing directly). This new system is passing the same ~9000 test262 tests and as well the existing package tests (and new ones).

Gustavo Niemeyer

unread,
Mar 26, 2014, 1:13:03 PM3/26/14
to Robert K, golan...@googlegroups.com
Very nice, Robert. This is one of the projects I haven't done
anything with yet, but is waiting in the toolbox for the right moment.

Do you have a rough roadmap of where you want to take otto in the
short to medium term?
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--

gustavo @ http://niemeyer.net

Robert K

unread,
Mar 26, 2014, 8:53:37 PM3/26/14
to golan...@googlegroups.com, Robert K


On Wednesday, March 26, 2014 10:13:03 AM UTC-7, Gustavo Niemeyer wrote:
Very nice, Robert.  This is one of the projects I haven't done
anything with yet, but is waiting in the toolbox for the right moment.

Do you have a rough roadmap of where you want to take otto in the
short to medium term?


Thanks. Yes, some next steps:
  • Give the runtime similar treatment to the parser, review the code and do a cleanup
  • Add the ability to "compile" scripts and execute them repeatedly, rather than reparsing the code everytime
    • This defect can be worked around by "compiling" to a JavaScript function, but it would be good to have an explicit way
  • Maybe have the ability to serialize/deserialize compiled scripts, to skip the parsing step on startup
  • Add a simple optimization stage during compilation (mostly to get back what was lost with the refactoring of the parser)
  • Handle "use strict" in the parser/runtime
  • Take care of the RegExp issue. Currently otto uses Go "regexp", which doesn't support (?!) or (?=)
    • Will probably have to find/author an engine in Go that does the same thing
  • Improve the interface, make it easier for Go & ECMAScript to interact
  • Add ECMAScript 6 features

dsav...@gmail.com

unread,
Mar 27, 2014, 3:16:42 PM3/27/14
to golan...@googlegroups.com
Thanks for your hard work on this package, Robert!

I would like to be able to do static analysis of Javascript in Go - not interpreting JS but operations on the AST or set of tokens like you can do with esprima or  acorn.  Would you say that it is or could b in scope of otto?  Do you think it would be possible to expose methods and data structures for AST manipulation?  Is it feasible to add a "parse-only" (not interpreting) mode and in that mode accept all valid Javascript regular expressions - pieces like:  foo = /^<(\w+)\s*\/?>(?:<\/\1>|)$/ ?

Thanks!

Robert K

unread,
Mar 27, 2014, 9:24:57 PM3/27/14
to golan...@googlegroups.com, dsav...@gmail.com


On Thursday, March 27, 2014 12:16:42 PM UTC-7, dsav...@gmail.com wrote:
Thanks for your hard work on this package, Robert!

I would like to be able to do static analysis of Javascript in Go - not interpreting JS but operations on the AST or set of tokens like you can do with esprima or  acorn.  Would you say that it is or could b in scope of otto?  Do you think it would be possible to expose methods and data structures for AST manipulation?  Is it feasible to add a "parse-only" (not interpreting) mode and in that mode accept all valid Javascript regular expressions - pieces like:  foo = /^<(\w+)\s*\/?>(?:<\/\1>|)$/ ?

Yes, that's the plan. There will be an "otto/parser" package with an exported parser and AST nodes, etc.

Ernest Micklei

unread,
Mar 28, 2014, 10:55:30 AM3/28/14
to golan...@googlegroups.com, Robert K
The roadmap looks very promising, especially the "compilation" and serialization. I am a greatful user of Otto. Thanks.
Reply all
Reply to author
Forward
0 new messages