mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 04:10:18 +02:00
further ecmascript work
* libguile/vm-i-system.c (drop, return): Declare drop and return as popping one arg from the stack. * module/language/ghil/compile-glil.scm: * module/language/glil/compile-assembly.scm (make-meta): Adjust so that we declare 'drop and 'return calls as popping one arg from the stack. * module/language/ecmascript/compile-ghil.scm (comp, comp-body): Flesh out a bit more. Most significantly, scoping within functions obeys javascript semantics better, modulo bits about with() forms. * module/language/ecmascript/impl.scm: Define some runtime helper routines. * module/language/Makefile.am (SOURCES): Add impl.scm. * module/language/ecmascript/parse.scm (parse-ecmascript): Minor tweaks. * module/language/ecmascript/tokenize.scm (read-identifier): Identifiers now read as symbols, not strings.
This commit is contained in:
parent
8fa6886d7a
commit
131f7d6c71
8 changed files with 271 additions and 18 deletions
|
@ -30,6 +30,9 @@
|
|||
(define (read-ecmascript/1 port)
|
||||
(parse-ecmascript (make-tokenizer/1 port) pk))
|
||||
|
||||
(define *eof-object*
|
||||
(call-with-input-string "" read-char))
|
||||
|
||||
(define parse-ecmascript
|
||||
(lalr-parser
|
||||
;; terminal (i.e. input) token types
|
||||
|
@ -45,7 +48,7 @@
|
|||
|
||||
|
||||
(Program (SourceElements) -> $1
|
||||
(*eoi*) -> (call-with-input-string "" read-char))
|
||||
(*eoi*) -> *eof-object*)
|
||||
|
||||
;;
|
||||
;; Verily, here we define statements. Expressions are defined
|
||||
|
@ -55,8 +58,8 @@
|
|||
(SourceElement (Statement) -> $1
|
||||
(FunctionDeclaration) -> $1)
|
||||
|
||||
(FunctionDeclaration (function Identifier lparen rparen lbrace FunctionBody rbrace) -> `(define ,$2 (lambda () ,$6))
|
||||
(function Identifier lparen FormalParameterList rparen lbrace FunctionBody rbrace) -> `(define ,$2 (lambda ,$4 ,$7)))
|
||||
(FunctionDeclaration (function Identifier lparen rparen lbrace FunctionBody rbrace) -> `(var ,$2 (lambda () ,$6))
|
||||
(function Identifier lparen FormalParameterList rparen lbrace FunctionBody rbrace) -> `(var ,$2 (lambda ,$4 ,$7)))
|
||||
(FunctionExpression (function lparen rparen lbrace FunctionBody rbrace) -> `(lambda () ,$5)
|
||||
(function Identifier lparen rparen lbrace FunctionBody rbrace) -> `(lambda () ,$6)
|
||||
(function lparen FormalParameterList rparen lbrace FunctionBody rbrace) -> `(lambda ,$3 ,$6)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue