| Age | Commit message (Collapse) | Author |
|
|
|
Also detection and automatic execution of main function.
Make sure that all debug is output to stderr.
|
|
Fix: small README fixes and throw an error if expression not supported.
|
|
Co-authored-by: Marc Vertes <mvertes@free.fr>
|
|
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
|
|
fix: force a return at end of function
|
|
|
|
This will avoid infinite loops, and is necessary for functions with
no returned values. This doesn't remove the need to better check the
consistency of return statements in general.
|
|
|
|
feat: add type representation in vm package
|
|
Type and Value types in vm package are now used in place of reflect.Type
and reflect.Value. It allows to remove the dependency on reflect for
parser and compiler packages.
The main purpose of Type is to provide a solution to implement recursive
structs, named types, interfaces and methods, despite the limitations of
Go reflect. The goal is to provide the thinnest layer around reflect.
|
|
Add PIPs prpoposal and state management proposal
|
|
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
|
|
|
|
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
|
|
A 'New' instruction is added in VM to manage initialisation
of typed variables in the stack. The instantiated type symbols
are now added to global data. Accessing and setting values by
address is now working.
|
|
|
|
This is incomplete because the scalar variables are not addressable
right now. To be addressable they must be represented as reflect
values, not interfaces.
|
|
|
|
|
|
The structures are reresented by reflect values. New instructions
`Field` and `Vassign` have been added to the VM to assign reflect
values and access struct fields.
|
|
Recursive structs and embedded structs are not supported yet.
|
|
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.
|
|
The parsing logic for type declarations is there. Note that no
tokens are produced, only symbols. The different type kinds will
be added next.
|
|
|
|
The full Go syntax is supported, blocks or line,
mutiple comma separated variables, assignments.
In local and global frame.
|
|
|
|
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
|
|
|
|
Also isolate repl in a separate function.
Introduce `run` function for executing programs, letting room for
other verbs to be done later: test, debug, ...
Use file path as argument. Standard input redirect is no more mandatory.
|
|
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.
|
|
The scanner returns a slice of pointers to tokens instead of a
slice of tokens. The parser now pass the initial node context.
|
|
Also simplify project structure. The executable is now produced in
the root directory. Work in progress.
|
|
|
|
Refctor node kind names by concatenating category and instance, to
allow better sorting. Comments are now parsed and skipped during
generation of AST.
|
|
So multiple successive incremental Evals function correctly.
Also improve the following:
- Apply the same Eval API to vm0 and vm1
- parser: dot diagram display is now synchronous
- codegen: outsource complex code generation for readability
- vm1: Pop take the number of values to pop as operand
|
|
|
|
|
|
|