-
Notifications
You must be signed in to change notification settings - Fork 1
Otto
TbScript (and TbUtil) are based on the open-source "Otto" interpreter - a JavaScript parser and interpreter written natively in Go.
Otto source and documentation can be found at..
Our implementation..
- has the utility-belt library, underscore 1.4.4, embedded (this now quite an old version, but it's still very useful).
- has a number of partial ES6 features added.
The following are some limitations with otto:
- "use strict" will parse, but does nothing.
- The regular expression engine (re2/regexp) is not fully compatible with the ECMA5 specification.
- Otto targets ES5. ES6 features (eg: Typed Arrays) are not supported.
Go translates JavaScript-style regular expressions into something that is "regexp" compatible via parser.TransformRegExp. Unfortunately, RegExp requires backtracking for some patterns, and backtracking is not supported by the standard Go engine: https://code.google.com/p/re2/wiki/Syntax
Therefore, the following syntax is incompatible:
- (?=) // Lookahead (positive), currently a parsing error
- (?!) // Lookahead (backhead), currently a parsing error
- \1 // Backreference (\1, \2, \3, ...), currently a parsing error
A brief discussion of these limitations: "Regexp (?!re)" https://groups.google.com/forum/?fromgroups=#%21topic/golang-nuts/7qgSDWPIh_E
More information about re2: https://code.google.com/p/re2/
In addition to the above, re2 (Go) has a different definition for \s: [\t\n\f\r ]. The JavaScript definition, on the other hand, also includes \v, Unicode "Separator, Space", etc.
NB: This WIKI is a work in progress and is known to be incomplete and inaccurate in places as it stands.
Starting points
Popular pages