Hi Joe, Pretty straightforward - and i'm no c++ hacker. The v8 code is very clear. I intend to add a brief design doc to the wiki.
It seemed the parser in particular (parser.cc) has been designed with extension in mind via subclassing. In the javascript world bytecode standardisation seems unlikely so a standardized 'GENERIC' AST would be good and in some ways even preferable. On Mar 24, 10:44 pm, Joe Antoon <[email protected]> wrote: > That sounds like a fun project. I hacked the lexer to add a code- > friendly string syntax for my university project (about 15 lines of > code, to embed C++ code), and it would be nice if more compilers/ > scripters were more front-end friendly (gcc, I'm looking at you). In > your opinion, how was your experience? Did you find V8's source easy > to step into or hard? > > On Mar 24, 2:01 pm, [email protected] wrote: > > > Announcement: > > > Hi, I have coded a user-friendly > > pseudocode-ish syntax which targets the V8 ecmascript AST: > > 'zedscript' > > aka 'zed is ecmascript for dummies'. > > The code can be found at:http://code.google.com/p/zedscript/ > > > Zedscript runs _in_ the V8 ecmascript engine. That is, there is no > > parsing zedscript source -> javascript source phase. It targets the > > AST directly. > > > The V8 scanning/parsing source code has been altered to allow the V8 > > engine to compile and run both ecmascript and zedscript. It reuses the > > V8 > > tokens/scanning/parsing/runtime/errorhandling machinery. This reduces > > abstraction leakages and aids debugging. zedscript can call ecmascript > > and vice-versa. (Calling jsfunction.toString() can be surprising > > however!). > > NB: this is a proof of concept hack :) and a work in progress. See > > the > > Futures page for ideas on the syntatic sugar that could be developed. > > > A zedscript script can be run via the V8 shell: > > ./shell <zedscriptfile> > > > So, zedscript provides a thin layer of syntax sugar over the core > > ecmascript semantics which will (hopefully): > > > * show the emerging rich 3.1 and 4(Harmony) semantics in the best > > possible best light. > > * minimizes quirks and gotachas. > > * emphasize simplify, security, safety and speed. For instance > > ecmascript 3.1 'strict mode' could be enabled by default. > > * is not a port of existing languages e.g python, ruby. (Imho > > emcascript does not need 1001IronXXX ports. > > It needs one good alternate syntax - which can take inspiration > > from the sugar/syntax of other pragmatic languages - but can be > > considered a dialect of the core ecmascript semantics rather > > than > > a new language or port). > > * hits the sweet spot between succinctness and pseudocode > > readability. > > > The goal is to track ecmascript 3.1 and 4/Harmony and deliver > > zedscript 3.1 and 4 on the V8 engine. I feel that some > > users - especially those without a comp. sci background - will never > > get on > > with the curlies syntax. An alternate syntax in addition to the > > javascript syntax > > - especially for esHarmony - could really help promote ecmascript as a > > general purpose scripting language. Ideally in the browser, but if not > > then for server and desktop development. > > > Here's an example 'ztest/sample.js'. Note how the script begins with > > //zed to signal to V8 it's a zedscript file. > > (This is a temporary solution). > > > //zed > > // - currently has a dylan/moo -ish syntax > > // - the parens around the expression could change to > > // a more ruby/lua -ish syntax, with optional do/then. > > > print("*** start\n") > > > var x = 10 > > var y = 20 > > > // if has elif clauses > > // and/or are aliases for &&/|| > > if (x == -99) > > print("FAIL") > > elif (x == 10 and y > 15) > > print("OK") > > elif (x == -99 or y > -99) > > print("FAIL") > > else > > print("FAIL") > > end > > > // not as alias for ! > > var b = false; > > print(!b) > > print(not b) > > > // fn as alias for function > > fn times2(i) > > return i * 2 > > end > > > var z = 1 > > while (z <= 5) > > print(z + " : " + times2(z++)) > > end > > > print("\n*** end "); > > > ---------------------- --~--~---------~--~----~------------~-------~--~----~ v8-users mailing list [email protected] http://groups.google.com/group/v8-users -~----------~----~----~----~------~----~------~--~---
