| Age | Commit message (Collapse) | Author |
|
Only symbols are produced, no bytecode is emitted. The constant
expressions are evaluated at compile time using the stdlib package
go/constant. The parser handles implicit repetition of the last
non-empty expression list. The iota symbol is reset to 0 and
incremented for each line of a const block.
To be done in a next commit: type conversions.
|
|
|
|
A VM instruction `EqualSet` has been added to preserve the left
operand on the stack in case of failure, to allow efficient
multiple tests on the same value.
Both the pattern 'if/else if' and the classical case clauses have
been implemented.
|
|
Logical operators `&&` (and), `||` (or) are now parsed in expressions.
The control flow tokens (labels, conditional jumps) are added
accordingly.
|
|
|
|
|
|
|
|
* chore: refactor to keep only the new parser and bytecode vm
* scanner: remove Token.value field
* scanner: remove scanner.kind field
* chore: move language specification in lang package
This avoid a cyclic dependency in scanner_test which can now use
the golang/GoSpec language specification for Go.
* clean code
* scanner: export scanner fields
Also parser now generate function calls, including externals.
* chore: fix lint issues
* parser: handle strings
* wip
* parser: implement support for 'if, else, else if' statements
Resolving labels in the compiler still in progress.
* parser: support if statements, improve compiler
* improve handling of functions
* improve support of local variables
* scanner: trim leading and trailing spaces
* fixes to make fibonacci work
* parser: improve README, fix function parameters parsing
|
|
As specified in the Go specification, adapted to the following:
- the scanner recognise blocks as tokens
- the scanner is multi-language: define keywords in scanner spec
- as a result, we define how to skip semi-colon insertion rather
than how to add it.
|
|
Refctor node kind names by concatenating category and instance, to
allow better sorting. Comments are now parsed and skipped during
generation of AST.
|
|
|
|
|
|
* codegen: add a bytecode generator
* cleaning scanner, parser and vm1.
|
|
* parser: define all node kinds to make the parser multi-language
Defining all AST node kinds in the parser is necessary to make the
parser really multi-language. If a language requires a node kind not
already present in parser/kind.go, it will be necessary to add it first
here.
Note that as long as a node kind subtree is structurally identical
between languages, even if there are lexical and/or syntaxic
differences, it can (and must) be shared amongst multiple language
definitions.
For example, an "if" statememt in shell script or in C code should give
the same `IfStmt` at AST level.
In order to let the parser deal with the various language syntaxes,
and produce the right node kind and subtree, parser flags will be set
in language definitions (see `Flags` field in `NodeSpec` struct).
* lang/golang: use parser node kinds
* vm0: remode dependency on language definition.
|
|
|