summaryrefslogtreecommitdiff
path: root/parser
AgeCommit message (Collapse)Author
2023-11-24parser: fix allocation of local variablesMarc Vertes
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.
2023-11-20parser: add pointer support (work in progress)Marc Vertes
This is incomplete because the scalar variables are not addressable right now. To be addressable they must be represented as reflect values, not interfaces.
2023-11-20parser: add support for unary operatorsMarc Vertes
2023-11-20parser: add support for slices and arrays, parse index expressionsMarc Vertes
2023-11-17parser: support selector expression to get / set struct fieldsMarc Vertes
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.
2023-11-15parser: parse struct type declarationsMarc Vertes
Recursive structs and embedded structs are not supported yet.
2023-11-15parser: hande const declarationsMarc Vertes
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.
2023-11-13parser: initial support for type declarations.Marc Vertes
The parsing logic for type declarations is there. Note that no tokens are produced, only symbols. The different type kinds will be added next.
2023-11-10vm: add Grow instruction to increase stackMarc Vertes
2023-11-10parser: implement support for var declarationsMarc Vertes
The full Go syntax is supported, blocks or line, mutiple comma separated variables, assignments. In local and global frame.
2023-11-08parser: fix break in switch statementsMarc Vertes
2023-11-07parser: implement switch statementMarc Vertes
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.
2023-11-04fix: skip parsing empty expressionMarc Vertes
2023-11-04parser: add tests for logical operatatorsMarc Vertes
2023-11-03feat: add support for control flow operators in expressionsMarc Vertes
Logical operators `&&` (and), `||` (or) are now parsed in expressions. The control flow tokens (labels, conditional jumps) are added accordingly.
2023-10-21parser: implement operator precedence rules in expressionsMarc Vertes
2023-10-14parser: implement label, goto and continue statementsMarc Vertes
2023-10-13parser: do not allocate VM data for labelsMarc Vertes
2023-10-13parser: include absolute paths in symbolsMarc Vertes
2023-10-13parser: refactor testsMarc Vertes
2023-10-13parser: implement 'break' statementMarc Vertes
2023-10-12parser: implement 'for' statementMarc Vertes
2023-10-12move to a direct byte code compiler (#8)Marc Vertes
* 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
2023-09-06scanner: add automatic insertion of semi-colon after newlineMarc Vertes
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.
2023-09-06chore: refactor some APIsMarc Vertes
The scanner returns a slice of pointers to tokens instead of a slice of tokens. The parser now pass the initial node context.
2023-09-01parser: skip comment modesMarc Vertes
Refctor node kind names by concatenating category and instance, to allow better sorting. Comments are now parsed and skipped during generation of AST.
2023-08-31codegen: fix interpreter re-entranceMarc Vertes
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
2023-08-29gint: add an interactive REPLMarc Vertes
2023-08-24doc: add diagrams to scanner and parser readmesMarc Vertes
2023-08-24fix: parser must be initialized before useMarc Vertes
2023-08-09codegen: add a bytecode generator (#5)Marc Vertes
* codegen: add a bytecode generator * cleaning scanner, parser and vm1.
2023-07-24parser: define all node kinds to make the parser multi-language (#3)Marc Vertes
* 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.
2023-07-10first commitMarc Vertes