1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

20 commits

Author SHA1 Message Date
Noah Lavine
84816b3aae Parse Decimal Numbers
* module/language/ecmascript/parse.scm: handle numbers with leading
    decimals correctly.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2011-01-26 23:47:29 +01:00
Noah Lavine
eacbe34618 Ecmascript Syntax Fix
* module/language/ecmascript/parse.scm: allow empty function bodies.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2011-01-26 23:30:44 +01:00
Andy Wingo
96fa68966d better errors for ecmascript parser too
* module/language/ecmascript/parse.scm (syntax-error): Better errors
  here too.
2010-11-18 13:03:49 +01:00
Andy Wingo
1811d0332f ecmascript syntax errors throw to 'syntax-error
* module/language/ecmascript/parse.scm (syntax-error):
* module/language/ecmascript/tokenize.scm (syntax-error): Throw to
  'syntax-error as psyntax does.
2010-11-16 02:57:27 +01:00
Ludovic Courtès
0ecd70a271 Adapt ECMAScript parser and lexer to `(system base lalr)'.
* module/language/ecmascript/tokenize.scm: Use `make-lexical-token' and
  related procedures instead of pairs as tokens passed to the parser.
  Pass source location information in the form of `source-location'
  objects.

* module/language/ecmascript/parse.scm (read-ecmascript,
  read-ecmascript/1): Instantiate a new parser at each call.
  (parse-ecmascript): Rename to...
  (make-parser): ... this.  Change `->' to `:' in the grammar syntax.

* module/language/ecmascript/parse-lalr.scm: Remove.

* module/Makefile.am (ECMASCRIPT_LANG_SOURCES): Remove
  `language/ecmascript/parse-lalr.scm'.
2010-03-31 00:42:01 +02:00
Neil Jerram
53befeb700 Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
   module/srfi/*.scm
   module/rnrs/*.scm
   module/scripts/*.scm
   testsuite/*.scm
   guile-readline/*
)
2009-06-17 00:22:09 +01:00
Andy Wingo
e05320fa54 compile for-in
* module/language/ecmascript/base.scm (prop-keys): New method, returns
  the list of keys of props of this instance.

* module/language/ecmascript/impl.scm: Refactor the global object into a
  special kind of module object. Provide a prop-keys implementation for
  module objects.

* module/language/ecmascript/compile-ghil.scm (comp): Compile for-in.

* module/language/ecmascript/impl.scm: Reshuffly things, and implement
  make-enumerator, a helper for use in for-in statements.

* module/language/ecmascript/parse.scm (parse-ecmascript): Fix parsing of
  for (var foo in bar) {}...
2009-02-22 16:01:11 +01:00
Andy Wingo
0b229e81a7 throw SyntaxError on bad syntax
* module/language/ecmascript/parse.scm (syntax-error):
* module/language/ecmascript/tokenize.scm (syntax-error): Throw an error
  on bad syntax.
2009-02-22 11:20:15 +01:00
Andy Wingo
8c306808c2 + for strings, global js object, new Foo() works
* module/language/ecmascript/array.scm (*array-prototype*): Declare the
  constructor.

* module/language/ecmascript/base.scm (pput, pdel): Remove some needless
  checks.
  (new): Move definition of new here, and use the constructor.

* module/language/ecmascript/compile-ghil.scm (compile-ghil): Add a stub
  so that when we load a compiled JS program, we make sure the runtime
  has been booted.

* module/language/ecmascript/function.scm (js-constructor): Export a
  js-constructor method instead of a new method.

* module/language/ecmascript/impl.scm (<js-global-object>): Define a new
  class for the global "this" object, wrapping bindings from the current
  module.
  (init-js-bindings!): Define the dozen or so global properties, in the
  current module.
  (+): Define addition operations for non-numbers. This is efficient
  because the generics are only dispatched if the fast-path fails.
2009-02-22 10:51:49 +01:00
Andy Wingo
81d677eb12 implement break and continue, work around overly recursive pmatch expansion
* libguile/vm-i-system.c (goto/args): On a tail call to a different
  procedure, init the locals to valid scheme values. Shouldn't matter for
  well-compiled scheme, but inspecting uninitialized locals could give
  garbage, or badly-compiled code could cause a crash.

* module/language/Makefile.am (NOCOMP_SOURCES): For the moment, don't
  compile compile-ghil.scm. I need to fix this.

* module/language/ecmascript/compile-ghil.scm (load-toplevel): Sigh, and
  disable stack checking in the evaluator too. Grr.
  (comp): Implement (unnamed) break and continue.

* module/language/ecmascript/parse.scm (parse-ecmascript): Fix var
  statements in `for' -- though it still doesn't work.
2009-02-21 20:28:28 +01:00
Andy Wingo
3bef3ae428 implement do, while, for
* module/language/ecmascript/compile-ghil.scm (comp): Use ghil-bind when
  making temp vars, so that disassembly understands things. Implement do,
  while, and for.

* module/language/ecmascript/parse.scm (parse-ecmascript): Some tweaks.

* module/language/ecmascript/impl.scm (language): Export ->boolean.
2009-02-21 00:33:04 +01:00
Andy Wingo
b358fe6502 implement more operations
* module/language/ecmascript/base.scm: Implement some more robust
  property getters that convert strings to symbols. Implement
  has-property?.

* module/language/ecmascript/compile-ghil.scm (comp): Implement lots more
  mathematical operators. We now do all expressions; on to statements.

* module/language/ecmascript/impl.scm: Define some math helpers. They
  probably need to call ->number on some things.

* module/language/ecmascript/parse.scm (parse-ecmascript): Fix a typo.
2009-02-21 00:33:04 +01:00
Andy Wingo
785fb107ef handle "this" in ecmascript
* module/language/ecmascript/base.scm:
* module/language/ecmascript/compile-ghil.scm:
* module/language/ecmascript/impl.scm:
* module/language/ecmascript/parse.scm: Compile "method calls" in such a
  way that "this" gets propagated correctly.
2009-02-21 00:33:03 +01:00
Andy Wingo
cdad2166e7 support foo["bar"] in addition to foo.bar
* module/language/ecmascript/parse.scm (parse-ecmascript): And update the
  function declaration forms for the new var syntax.

* module/language/ecmascript/compile-ghil.scm (comp): Support foo["bar"]
  in addition to foo.bar.

* module/language/ecmascript/impl.scm (pget, pput): Some fixes for when
  we get non-symbols -- it can happen, yo. I suppose we should allow for
  non-string keys too..
2009-02-19 17:25:52 +01:00
Andy Wingo
b72880eb17 implement object literals
* module/language/ecmascript/impl.scm:
* module/language/ecmascript/compile-ghil.scm (comp): Object literals.

* module/language/ecmascript/parse.scm (parse-ecmascript): Fix some
  object literal parsing.
2009-02-19 17:14:16 +01:00
Andy Wingo
7fb4230060 property gets and puts implemented, yays
* module/language/ecmascript/compile-ghil.scm (@impl): Ok, don't recurse
  on args here.
  (comp): Implement property gets and puts and lexical assignment.
  (comp-body): Fix scanning of var forms.

* module/language/ecmascript/impl.scm (prop-attrs): Allow for the prop
  attr array to be #f.

* module/language/ecmascript/parse.scm (parse-ecmascript): Fix assignment
  parsing.
2009-02-19 16:40:22 +01:00
Andy Wingo
10e1bd278f add array support
* module/language/ecmascript/compile-ghil.scm (@impl): Whoops, fix this
  macro.
  (comp): Handle array literals.

* module/language/ecmascript/impl.scm: Add support for arrays.
2009-02-19 16:09:00 +01:00
Andy Wingo
131f7d6c71 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.
2009-02-19 13:55:55 +01:00
Andy Wingo
8fa6886d7a add more ecmascript compilation -- functions work now
* module/language/ecmascript/parse.scm (parse-ecmascript): Lambdas always
  just have one member in their bodies.

* module/language/ecmascript/compile-ghil.scm (comp): Add some more silly
  compilers.
2009-02-18 01:18:18 +01:00
Andy Wingo
5dcd3e4801 add ecmascript parser
* module/language/ecmascript/parse-lalr.scm: Add the Boucher/Bison lalr
  parser. This is from guile-lib, but with : changed to -> so as not to
  molest `prefix' keywords. Should probably be elsewhere.

* module/language/ecmascript/parse.scm: Add parser for ECMAScript. Rules
  from the spec, 3rd edition.

* module/language/ecmascript/tokenize.scm: Add ECMAScript tokenizer,
  hand-written. Neat stuff.

* module/language/Makefile.am: Autofoo.
2009-02-18 00:07:51 +01:00