summaryrefslogtreecommitdiff
path: root/parser/parse.go
AgeCommit message (Collapse)Author
2025-11-27fix: improve parser, compiler and interpreter APIsMarc Vertes
Pass a language spec as an argument when create a new parser, compiler or interpreter. Also move the REPL code in interpreter package.
2025-11-27chore: move compiler and interpreter in their own packagesMarc Vertes
2025-03-03chore: fix lintMarc Vertes
2025-03-03fix: improve structparscan-structMarc Vertes
Use 'unsafe' to modify private struct fields, allowing to keep unmodified field names: before they were prefixed with a capital. Parse package statement. Provide a also a default package name for REPL and tests. The support of packages is still incomplete.
2024-07-18fix (parser): don't panic if assign of define untyped value (#10)Marc Vertes
* fix (parser): don't panic if assign of define untyped value In case of defining or assigning to untyped value, the type has to be taken from the source value instead of the target value. The vm test coverage has also been slightly improved. * fix and simplify Token.Name() * improve parser errors
2024-04-23feat: initial and partial support of composite expressions (#9)Marc Vertes
A new `Composite` token is created. Literal composite expressions are recognized and partially handled by the parser but not yet by the code generator. Other cosmetic changes are present.
2024-04-02chore: add linters and some lint fixes (#8)Marc Vertes
* chore: add linters and some lint fixes Configure some golangci-lint linters to get the code quality right. Apply the first fixes. Next step will be to add github actions to run lint and tests in github CI. * chore: more lint, fixed comments and variable names. no semantic change. * chore: add Makefile This makefile is intended to be used as a local substitute to github actions.
2024-03-22feat: add initial support for import, provide minimal fmt (#6)Marc Vertes
The `import` statement is now parsed. It only provides minimal support for the `fmt` package (only `Println` symbol is defined). This should be sufficient to pass a few tests. Full support of package namespaces, source and binary imports will be supported later, based on this work.
2024-03-14feat: improve debug output of tokensMarc Vertes
2024-03-14feat: initial support of closuresMarc Vertes
Also detection and automatic execution of main function. Make sure that all debug is output to stderr.
2024-03-12fixupMarc Vertes
2024-03-12fix: force adding a return at end of functionMarc Vertes
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.
2024-03-08feat: add type representation in vm packageMarc Vertes
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.
2024-01-15chore: import from gnolangMarc Vertes
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-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-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: include absolute paths in symbolsMarc 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-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-09codegen: add a bytecode generator (#5)Marc Vertes
* codegen: add a bytecode generator * cleaning scanner, parser and vm1.
2023-07-10first commitMarc Vertes