Commit Graph
102 Commits
Author SHA1 Message Date
Anton Medvedev 97e061adca Only allow if on precedence == 0 2025-03-08 12:02:09 +01:00
Anton Medvedev 2cff08a4a5 Refactor TestParse_error tests 2025-03-08 09:49:28 +01:00
Anton Medvedev c146c2fc9b Add SequenceNode
Fixes #717
2025-03-08 09:27:09 +01:00
9dd86858e1 feat: add node budget and memory limits (#762)
* 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]>
2025-03-07 14:09:41 +01:00
5000e417f5 Add if-else conditional (#736)
Co-authored-by: Anton Medvedev <[email protected]>
2025-02-23 14:19:51 +01:00
Anton MedvedevandGitHub c953d0dde1 Refactor types table (#667) 2024-06-04 00:08:01 +02:00
Anton Medvedev c8b0171f3a Return tree on parse errors 2024-05-18 23:41:49 +02:00
Anton MedvedevandGitHub 696844a709 Refactor lexer (#653) 2024-05-17 18:10:26 +02:00
Anton MedvedevandGitHub 68e3148c1f Vendor testify (#642) 2024-05-08 00:24:35 +02:00
Anton Medvedev c5dfe3a811 Make count() predicate optional 2024-04-13 23:38:35 +02:00
Anton MedvedevandGitHub 772eaba1ca Add predicate to sum() builtin (#592)
* Add predicate to sum() builtin

* go mod tidy
2024-04-13 15:37:02 +02:00
Ganesan KaruppasamyandGitHub 650a7f5ac1 Fix -1 not in [] expressions (#590) 2024-03-04 14:40:33 +01:00
SergeyandGitHub 26bfa591a9 Support chzained comparisonc1 < 2 < 3 (#581) 2024-02-27 14:23:49 +01:00
Anton MedvedevandGitHub b1e82de54a Refactor groupBy and sortBy (#562)
* Rearrange opcodes

* Refactor groupBy

* Fix tests

* Super opcodes for GroupBy

* Refactor sortBy builtin

* Fix sortBy bench
2024-02-15 19:53:35 +01:00
SergeyandGitHub 8d2e6b133c Add optional array access like foo?.[42] (#550) 2024-02-08 12:20:20 +01:00
SergeyandGitHub a0e2fe3664 Fix string literal slicing error (#543) 2024-01-31 18:07:26 +01:00
Anton Medvedev d645265cd1 Fix pipeline and call parsing 2024-01-24 23:49:57 +01:00
Anton Medvedev 7d4dd1a708 Improve ast printing for boolean operators 2024-01-17 23:21:11 +01:00
Ganesan KaruppasamyandGitHub 9b73bb722e Remove parents field for optimization (#527) 2024-01-16 12:47:46 +01:00
Anton MedvedevandGitHub e7b1a64b58 Allow to override builtins (#522)
* Allow to override builtins

* Add :: syntax to access builtin in case of override
2024-01-13 15:56:49 +01:00
Anton MedvedevandGitHub 30be4c9f08 Remove redundant fields from CallNode and BinaryNode (#504) 2023-12-29 19:50:08 +01:00
a0db9a6c19 feat: Implement Bitwise and Shift Operator Support (#496)
Co-authored-by: Ganesan Karuppasamy <[email protected]>
2023-12-25 18:25:26 +01:00
Ganesan KaruppasamyandGitHub 57a6bc8f7d Incorporate support for raw string literals (#485) 2023-12-25 18:05:25 +01:00
591e36fc00 Enhance the number parser to include support for parsing hexadecimal, binary, and octal literals. (#483)
* 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]>
2023-12-08 18:33:50 +01:00
Anton Medvedev 551d2a7e0f Use expr-lang/expr 2023-12-03 21:53:01 +01:00
Anton Medvedev 113725207c Fix size check 2023-09-06 09:51:46 +02:00
Anton Medvedev e2c14ca624 Fix if 2023-09-06 09:42:58 +02:00
Anton Medvedev 3c4d579704 Check for an overflow before allocating 2023-09-06 09:42:58 +02:00
Anton Medvedev d78a714f19 Add check for int64->int conversion 2023-09-06 09:42:58 +02:00
Anton Medvedev 6d8d2390cf Remove countBy 2023-08-30 14:55:05 +02:00
Anton Medvedev 5023b3005d Add reduce() 2023-08-30 13:33:16 +02:00
Anton Medvedev 7f85c0551f Add countBy() 2023-08-30 12:07:16 +02:00
Anton Medvedev 32f5fde2eb Replace interface{} with any 2023-08-30 11:25:15 +02:00
Anton Medvedev 3f57b885d4 Add groupBy 2023-08-30 11:14:54 +02:00
Anton Medvedev 2fd03266f6 Add better pointer lexer 2023-08-25 15:50:57 +02:00
Anton Medvedev 4683fbe2bf Add parsing support for pointer names 2023-08-24 15:27:00 +02:00
Anton Medvedev 166d8b8ce9 Add filter()[-1] optimization 2023-08-24 11:15:43 +02:00
Anton Medvedev 2c139ca36a Add find() and findIndex() 2023-08-24 11:15:43 +02:00
Anton Medvedev d237c8ab4e Forbid to redeclare variables, builtins, functions. 2023-08-22 22:30:07 +02:00
Anton Medvedev ed5f9bfbcb Add variables 2023-08-22 22:30:07 +02:00
Anton Medvedev eb023470c8 Refactor lexer_test.go 2023-08-22 14:02:53 +02:00
Anton Medvedev 4ae978d384 Allow to disable builtins 2023-08-19 22:24:42 +02:00
Anton Medvedev c8b485f6a8 Add String() to nodes 2023-08-17 17:23:18 +02:00
Anton Medvedev bac96c2c29 Add expr.ExperimentalPipes() config 2023-08-15 15:39:59 +02:00
Anton Medvedev 59cfb8a834 Fix pipe operator parsing 2023-08-15 14:38:48 +02:00
Anton Medvedev 8177d8bd9f Add OpCallBuiltin opcode to avoid an extra allocation 2023-08-14 11:50:42 +02:00
Anton MedvedevandGitHub 86f7951db2 Add pipe operator (#400) 2023-08-13 01:17:49 +02:00
Anton Medvedev 115af7af88 gofmt 2023-08-11 08:49:26 +02:00
Anton Medvedev 95f8b7ff17 Add nil coalescing operator 2023-02-03 15:53:43 +01:00
Anton Medvedev 5d34457179 Lexer: remove redundant case for ?. 2023-02-03 14:46:15 +01:00