earlgrey
Version:
Programming language compiling to JavaScript, featuring macros, dynamic typing annotations and pattern matching.
86 lines (64 loc) • 2.64 kB
Plain Text
Source code organization
------------------------
location.eg
Defines the Source and Location classes and a bunch of utility
functions for highlighting.
lex.eg
Defines the lexer.
lex.tokenize{Source} ==> list of tokens
parse.eg
Operator precedence parsing.
Note that the following simplifications are applied in this phase:
* "a with b" ==> a{b}
* "foo bar: baz" ==> foo{bar, baz}
parse.parse{tokens} ==> raw AST (unexpanded)
expand.eg
Defines the Scope, Env and Expander classes, which are the basis of
the macro expander. Core behavior like symbol resolution and
expansion of #multi and #data nodes are here.
stdenv.eg
Defines most core macros and control structures.
* if, while, break, class, each, etc.
* Whitelist of global variables.
* Contains the code for a few required shims (e.g. Array.prototype["::check"])
pattern.eg
Most of the code pertaining to pattern matching is here.
translate-js.eg
Defines Translator, which takes an expanded AST and produces
JavaScript code.
earl-grey.eg
Glues all the parts together in a coherent interface, Generator.
run.eg
Defines the command-line interface of the earl utility.
Entry point is the run function.
register.eg
Import to register earl grey as an extension.
util.eg
Miscellaneous utilities.
opt.eg
Defines the hoist function, a minor optimization.
pp.eg
Pretty-printing, to be removed (probably).
Notes
-----
AST nodes are plain arrays, so you won't find a formal definition
anywhere. Essentially:
Core nodes (produced by parse.parse):
#symbol{String?} ==> symbol
Processed nodes (produced during macro expansion in addition to core nodes):
#array{...} ==> create an array
Temporary nodes/expansion control
(macro expansion may happen in multiple contexts)
(useful to implement interpolation in strings)