* convert source to a struct and fix minor issue displaying error
* lexer: add byte and char pos
* improve parser to use string instead of []rune
* add lexer benchmarks
* make lexer work as an iterator
* make parser use the new iterator API in lexer
* allow reusing the parser
* cleanup code
* add parser benchmarks
* feat: extract code for compiling equal operator
* feat: support last argument append with comma
---------
Co-authored-by: Anton Medvedev <[email protected]>
* feat: add node budget and memory limits
Implement compile-time and runtime safeguards against deeply nested expressions:
- Add MaxNodes limit to track and limit AST node count during parsing
- Move MemoryBudget from VM to Config for better configurability
- Add node creation tracking in parser to enforce node budget
- Refactor node creation to check limits before allocation
- Add RunWithConfig to VM for passing memory budget settings
- Set reasonable defaults in Config (10000 nodes, 1M memory)
- Add comprehensive tests for both node and memory limits
This prevents stack overflows from malicious or poorly written expressions
by failing fast with clear error messages during compilation or runtime.
Signed-off-by: Ville Vesilehto <[email protected]>
* Update parser.go
Signed-off-by: Anton Medvedev <[email protected]>
---------
Signed-off-by: Ville Vesilehto <[email protected]>
Signed-off-by: Anton Medvedev <[email protected]>
Co-authored-by: Anton Medvedev <[email protected]>
* Enhance the number parser to include support for parsing hexadecimal, binary, and octal literals.
* added invalid literal test cases
* Refactoring code as per comment
---------
Co-authored-by: Ganesan Karuppasamy <[email protected]>