summaryrefslogtreecommitdiff
path: root/parser
AgeCommit message (Collapse)Author
38 hoursfix: improve parsing of assign statementsMarc Vertes
Handle assign statements in parseAssign function. Detect multi-assign by the presence of comma in the right hand side tokens. The case of swap is not handled yet.
2 daysfix: correct var order in multi-var declarationMarc Vertes
3 daysfeat: make Next iterator instruction faster and more efficientMarc Vertes
Branching control is delegated directly to the Next instruction, which now takes the location of loop exit as first argument. It avoids the use of JumpFalse, plus the stack storage for the condition.
3 dayschore: use parser.Token.Arg to store generated parametersMarc Vertes
4 dayschore: use token helpersMarc Vertes
4 dayschore: use token helpersMarc Vertes
4 dayschore: refactor token types to avoid mutate scanner tokensMarc Vertes
Mutating scanner tokens or reusing scanner token attributes to store other metadata is a hack. Introduce a new parser token type with arbitrary args. The next step will be to use the arg field instead of scanner token fields.
5 daysfeat: add support for range clause and iteratorsMarc Vertes
- vm: added Pull, Next and Stop instructions, to implement iterators - lang: add Range, Next and Stop tokens - parser: handle range clause. Still naive and incomplete. - comp: generate iterator instructions from range clause. Work in progress. Only initial support for slices. Many more tests and combinations needed, but the main pattern is there now.
10 daysfeat: handle slice expressionsMarc Vertes
13 daysfix: improve literal composite on nested typesMarc Vertes
2026-01-11fix: handle assign statements on map elementsMarc Vertes
A new token MapAssign is added to implement assignements involving a map, slice or array, an index key expression and a value expression.
2026-01-09feat: initial support for mapsMarc Vertes
2026-01-08fix: improve composite literal for slicesMarc Vertes
2026-01-07fix: improve handling of composite literal struct expressionsMarc Vertes
2026-01-07fix: set 'HasInit' token property in language definitionMarc Vertes
2026-01-06Merge branch 'main' of git.vertes.org:git/parscanMarc Vertes
2026-01-06fix: correct and simplify parsing of expressions.Marc Vertes
The expressions were parsed from right to left, and it was incorrect and cumbersome. Now they are processed from left to right, with a simpler and correct handling of precedence rules. The vm function call syntax has been changed to set the function before the input arguments on the stack, as to follow the declaring order in languages.
2025-12-19fix lang: attribute properties to tokens, not stringsMarc Vertes
2025-12-04chore: move symbol types and functions in its own package.Marc Vertes
2025-12-03feat: support literal struct expressions with keyed elementsMarc Vertes
2025-11-28doc: improve comments, pass lintMarc Vertes
Also improve the setup of golangci-lint.
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: mv parser/interpreter.go interpreter/Marc Vertes
2025-11-27chore: move compiler and interpreter in their own packagesMarc Vertes
2025-11-26Chore: improve tracing of code emitsMarc Vertes
2025-11-16fix lintMarc Vertes
2025-11-15chore: update ci lintMarc Vertes
2025-11-14fix: refactor VM instruction typeMarc Vertes
Use custom types for VM instructions. More idiomatic code for tracing.
2025-11-10chore: fix lintMarc 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-21Add extra GoDoc to explain why Dump is on the Compiler.Antonio Navarro Perez
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2024-03-20feat: Add simple Dump creation and recovery.Antonio Navarro Perez
Memory Dump functionality that can restore the previous VM state. It dumps *global* variables, the only ones defining the program state. The dump depends on the program itself, and on the index system, which right now is defined by the variable order. Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2024-03-14feat: improve debug output of tokensMarc Vertes
2024-03-14Merge branch 'main' of github.com:mvertes/parscanMarc 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-13Merge pull request #5 from ajnavarro/fix/small-fixesMarc Vertes
Fix: small README fixes and throw an error if expression not supported.
2024-03-12Fix: small README fixes and throw an error if expression not supported.Antonio Navarro Perez
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
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-11fix callX, update readmeMarc Vertes
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-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