I’ve picked up working on my javascript parser/compiler again. The reader outputs a SXML parse tree and the compiler takes that and generates external tree-il and then parses that to (internal) tree-il. I also have a pretty-printer for JS.
scheme@(guile-user)> ,L javascript Happy hacking with javascript! To switch back, type `,L scheme’. javascript@(guile-user)> function foo(x, y) { return x + y; } javascript@(guile-user)> ,L scheme Happy hacking with Scheme! To switch back, type `,L javascript’. scheme@(guile-user)> (foo 1 2) $1 = 3 output of the javascript parser: (FunctionDeclaration (Identifier "foo") (FormalParameterList (Identifier "x") (Identifier "y")) (SourceElements (ReturnStatement (add (PrimaryExpression (Identifier "x")) (PrimaryExpression (Identifier "y")))))) after feeding above output into javascript pretty-printer: function foo(x, y) { return x + y; } output of external tree-il from the compiler: (define foo (lambda ((name . foo)) (lambda-case ((() #f @args #f () (JS~431)) (prompt (const return) (begin (abort (const return) ((apply (@@ (nyacc lang javascript jslib) JS:+) (apply (toplevel list-ref) (lexical @args JS~431) (const 0)) (apply (toplevel list-ref) (lexical @args JS~431) (const 1)))) (const ()))) (lambda-case (((tag val) #f #f #f () (JS~432 JS~433)) (lexical val JS~433)))))))) I’m translating JS function arguments to essentially (lambda @args body …) and using a prompt to implement the ReturnStatement. In JS one can call with any number of arguments. Maybe I could generate case-lambda with cases for each of 0 .. N arguments. Matt