67 Commits
Author SHA1 Message Date
zeekay 961d4a47d0 fork: keep upstream module path github.com/expr-lang/expr (consumed via replace), rehome to hanzoai/expr 2026-06-30 17:46:21 -07:00
zeekay 1e8be921d2 fork: rename module to github.com/hanzoai/expr 2026-06-30 17:34:46 -07:00
Anton MedvedevandGitHub d5f9c1bf84 Fix parsing of variable declaration nodes combined with sequence node (#773)
Fixes #772
2025-03-18 10:49:13 +01:00
Anton Medvedev ddbaa171c4 Add more tailing comma tests 2025-03-09 10:48:37 +01:00
18e2e03c5a Allow tailing comma in arguments (#623)
* feat: extract code for compiling equal operator

* feat: support last argument append with comma

---------

Co-authored-by: Anton Medvedev <[email protected]>
2025-03-09 10:45:17 +01:00
Anton Medvedev 41da963d55 Remove pointer accessor check in parser 2025-03-08 17:11:49 +01:00
Anton Medvedev 26eebbe70c Better error message for predicate with sequence 2025-03-08 12:14:13 +01:00
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 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
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
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
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 4683fbe2bf Add parsing support for pointer names 2023-08-24 15:27:00 +02:00
Anton Medvedev ed5f9bfbcb Add variables 2023-08-22 22:30:07 +02:00
Anton Medvedev 4ae978d384 Allow to disable builtins 2023-08-19 22:24:42 +02:00
Anton Medvedev bac96c2c29 Add expr.ExperimentalPipes() config 2023-08-15 15:39:59 +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 95f8b7ff17 Add nil coalescing operator 2023-02-03 15:53:43 +01:00
Anton Medvedev 16a6690333 Make closure brackets optional 2023-01-29 22:38:21 +01:00
Anton Medvedev 72a4ce18e9 Add len() builtin 2023-01-29 20:34:15 +01:00
Anton Medvedev 54c29bfda2 Simplify "not in" operators 2022-11-06 13:04:35 +01:00
Anton Medvedev 2c402d27db Fix parser for 0x6E int 2022-11-05 20:40:29 +01:00
Anton Medvedev 371e24c30d Add ^ as exponent operator 2022-11-05 20:21:48 +01:00
Anton Medvedev f11639bf0e Fix exponent operator precedence
Now -2^2 == -4
2022-11-05 20:17:11 +01:00
Anton Medvedev d9bd9e021c Add ternary operator test 2022-10-22 22:07:32 +02:00
Anton Medvedev 873d4eecac wip 2022-10-15 20:31:04 +02:00
Anton Medvedev ab621bec0e Optional chaining 2022-10-15 15:59:39 +02:00
Anton Medvedev e11960b91f wip 2022-10-15 13:37:07 +02:00
Anton Medvedev 360e0c27c3 Add ?. in lexer 2022-10-14 16:23:41 +02:00
Anton Medvedev 6a7630dba1 Remove ast nodes 2022-10-10 20:26:59 +02:00
Anton Medvedev b24419bf76 Remove wrong nil safe implementation 2022-10-09 12:53:30 +02:00
Anton Medvedev 56127510a5 Refactor tests and start refactoring nil safe operator 2022-10-09 12:28:51 +02:00
Vladimir FetisovandGitHub 6adbfc5b37 acceptWord checks the rune after word (#184) 2021-06-15 23:57:54 +03:00
Zach BadgettandGitHub 3eb822d35a Add nil safe operator (#173) 2021-06-07 22:53:12 +03:00
Anton Medvedev f7dd5eed88 Add support for trailing comma in arrays and maps 2020-03-04 09:15:19 +03:00