simon-git: spigot (master): Simon Tatham

Commits to Tartarus CVS repository. tartarus-commits at lists.tartarus.org
Fri May 22 15:36:12 BST 2015


TL;DR:
  f36d7ec Centralise parse-time constructors into OPERATORS macro.
  aff7bf2 Separate parsing from evaluation.
  b6a7e6e Move lexing of id-shaped operators into the id code.
  3d61872 Introduce an internal scoping system in expr.cpp.
  bc86973 Implement 'let' to define variables.
  3dcf233 Implement more 'let' syntax to define functions.
  616fb68 Merge function and variable scopes.
  9505c44 Permit nested functions to refer to outer parameters.
  d90a3dd Document the new 'let' syntax.

Repository:     git://git.tartarus.org/simon/spigot.git
On the web:     http://tartarus.org/~simon-git/gitweb/?p=spigot.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2015-05-22 15:36:12

commit f36d7ec875d4d94b6eec93b7264dd36bb45b54eb
web diff http://tartarus.org/~simon-git/gitweb/?p=spigot.git;a=commitdiff;h=f36d7ec875d4d94b6eec93b7264dd36bb45b54eb;hp=349af694b58e319a59280b7bd9ef4f79450dd9f4
Author: Simon Tatham <anakin at pobox.com>
Date:   Fri May 22 10:15:27 2015 +0100

    Centralise parse-time constructors into OPERATORS macro.
    
    Rather than having three separate switches on the operators enum in
    various parts of the parsing code, I've now arranged that the
    OPERATORS higher-order macro which defines the enum values in the
    first place also provides their translations in terms of calls to
    spigot functions, and then we autogenerate an array full of function
    pointers. So now I can replace all three of those switches with a
    simple lookup in that array and an indirect call, having first
    constructed an 'args' vector in a consistent format.
    
    This is a pure refactoring with no functional change, but should make
    it easier to restructure the parser in interesting ways later.

 algebraic.cpp |    2 +-
 expr.cpp      |  376 +++++++++++++++------------------------------------------
 funcs.h       |    2 +-
 3 files changed, 98 insertions(+), 282 deletions(-)

commit aff7bf22d67a7b6dfa9b496c65a017d908927bd8
web diff http://tartarus.org/~simon-git/gitweb/?p=spigot.git;a=commitdiff;h=aff7bf22d67a7b6dfa9b496c65a017d908927bd8;hp=f36d7ec875d4d94b6eec93b7264dd36bb45b54eb
Author: Simon Tatham <anakin at pobox.com>
Date:   Fri May 22 11:58:09 2015 +0100

    Separate parsing from evaluation.
    
    The parse phase now returns an AST root node, and we then call its
    evaluate() method to get an actual Spigot.
    
    Again, no functional change, but this should permit more interesting
    parse-tree structures.

 expr.cpp |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 52 insertions(+), 11 deletions(-)

commit b6a7e6e7d1b27c8f595814e4184369ec072eddf9
web diff http://tartarus.org/~simon-git/gitweb/?p=spigot.git;a=commitdiff;h=b6a7e6e7d1b27c8f595814e4184369ec072eddf9;hp=aff7bf22d67a7b6dfa9b496c65a017d908927bd8
Author: Simon Tatham <anakin at pobox.com>
Date:   Fri May 22 12:49:37 2015 +0100

    Move lexing of id-shaped operators into the id code.
    
    Things which look lexically like identifiers but behave syntactically
    as operators, such as 'mod' and 'rem', were previously being parsed by
    the same maximal-munch loop that identifies punctuation operators,
    with the slightly strange effect that '1024 modfoo' would lex the same
    as '1024 mod foo'. Now everything that looks like an identifier is
    lexed initially as an identifier, and identified as a keyword only
    after a maximal sequence of id-like characters has been consumed.

 expr.cpp |   40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

commit 3d61872492087ea67a919fc3df060f0a7e60a3a4
web diff http://tartarus.org/~simon-git/gitweb/?p=spigot.git;a=commitdiff;h=3d61872492087ea67a919fc3df060f0a7e60a3a4;hp=b6a7e6e7d1b27c8f595814e4184369ec072eddf9
Author: Simon Tatham <anakin at pobox.com>
Date:   Fri May 22 12:49:30 2015 +0100

    Introduce an internal scoping system in expr.cpp.
    
    The abstract Scope class exposed in expr.cpp, providing a client of
    expr.cpp with a means of mapping names to actual Spigots, is just what
    the Python module wants; but for internal use, we'll need to map names
    to AST nodes. So I've renamed that class to 'GlobalScope', and
    introduced a new hierarchy of Scope classes internal to expr.cpp which
    use the AST defined inside that file.

 expr.cpp          |   37 +++++++++++++++++++++++++++++++------
 expr.h            |    4 ++--
 python/pyspig.cpp |    6 +++---
 3 files changed, 36 insertions(+), 11 deletions(-)

commit bc86973fc663362249610c9b14bef6c9b5d1995b
web diff http://tartarus.org/~simon-git/gitweb/?p=spigot.git;a=commitdiff;h=bc86973fc663362249610c9b14bef6c9b5d1995b;hp=3d61872492087ea67a919fc3df060f0a7e60a3a4
Author: Simon Tatham <anakin at pobox.com>
Date:   Fri May 22 14:13:53 2015 +0100

    Implement 'let' to define variables.
    
    Syntax is 'let VAR=VALUE [,VAR=VALUE...] in EXPR'.
    
    Variable definitions come into scope immediately, so you can define a
    chain of them each referring to the previous one, e.g. 'let x=expr,
    y=expression involving x in ...'.

 expr.cpp |   80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 test.sh  |    5 ++++
 2 files changed, 84 insertions(+), 1 deletion(-)

commit 3dcf23328e430a602938e6022ca2cb789f02b231
web diff http://tartarus.org/~simon-git/gitweb/?p=spigot.git;a=commitdiff;h=3dcf23328e430a602938e6022ca2cb789f02b231;hp=bc86973fc663362249610c9b14bef6c9b5d1995b
Author: Simon Tatham <anakin at pobox.com>
Date:   Fri May 22 14:19:17 2015 +0100

    Implement more 'let' syntax to define functions.
    
    Because spigot cannot support recursion, functions do not come into
    scope until after they're defined, so that if you write 'let f(x) =
    some expression calling f(x)' then you'd better have a previous f in
    scope for the call to refer to.
    
    Also, although you can define a function in a let clause inside the
    body of another function, there's currently no support for the inner
    function referring to the outer one's arguments.

 expr.cpp |  216 +++++++++++++++++++++++++++++++++++++++++++++++++++-----------
 test.sh  |    9 +++
 2 files changed, 188 insertions(+), 37 deletions(-)

commit 616fb681dca7fd02dc14dfa6ee2f640fc318810f
web diff http://tartarus.org/~simon-git/gitweb/?p=spigot.git;a=commitdiff;h=616fb681dca7fd02dc14dfa6ee2f640fc318810f;hp=3dcf23328e430a602938e6022ca2cb789f02b231
Author: Simon Tatham <anakin at pobox.com>
Date:   Fri May 22 14:54:34 2015 +0100

    Merge function and variable scopes.
    
    Having implemented each one separately, I now realise it actually
    makes much more sense to have a single namespace containing both kinds
    of thing. This also allows me to fold the ad-hoc parsing of builtin
    functions and variables into the same framework, so that _every_ name
    lookup just returns a uniform 'Definition *'. A side effect of that is
    that you can now shadow builtin functions and variables with your own
    definitions, which is probably a good thing (land-grabbing 'e' and
    forbidding redefinition was surely excessively intrusive).

 expr.cpp |  247 ++++++++++++++++++++++++++++----------------------------------
 test.sh  |    2 +
 2 files changed, 113 insertions(+), 136 deletions(-)

commit 9505c44b66b132f35db69f62a67b43a12961c2a3
web diff http://tartarus.org/~simon-git/gitweb/?p=spigot.git;a=commitdiff;h=9505c44b66b132f35db69f62a67b43a12961c2a3;hp=616fb681dca7fd02dc14dfa6ee2f640fc318810f
Author: Simon Tatham <anakin at pobox.com>
Date:   Fri May 22 15:32:23 2015 +0100

    Permit nested functions to refer to outer parameters.
    
    A bit of a bodge - I've just arranged for FnArgHolder to be a linked
    list of nested argument scopes, each identified by a unique integer
    'function id' that distinguishes all functions defined in the whole
    expression. But in a world where functions are never passed around as
    first-class objects and also never recurse, it'll do.

 expr.cpp |   72 +++++++++++++++++++++++++++++++++++++++++---------------------
 test.sh  |    2 ++
 2 files changed, 50 insertions(+), 24 deletions(-)

commit d90a3ddc27bfb083ab06ae9ca68e35baf8d613c9
web diff http://tartarus.org/~simon-git/gitweb/?p=spigot.git;a=commitdiff;h=d90a3ddc27bfb083ab06ae9ca68e35baf8d613c9;hp=9505c44b66b132f35db69f62a67b43a12961c2a3
Author: Simon Tatham <anakin at pobox.com>
Date:   Fri May 22 15:34:09 2015 +0100

    Document the new 'let' syntax.
    
    Also remove it from TODO.txt.

 TODO.txt    |   40 ----------------------------------------
 manpage.but |   24 +++++++++++++++++++++++-
 manual.but  |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 41 deletions(-)



More information about the tartarus-commits mailing list