18 Commits

Author SHA1 Message Date
66c1d531ea feat: docs and guides for quick ref 2026-08-24 16:18:21 +03:00
9a44ee8bb6 Merge pull request #1 from allankoechke/security-hardening-and-language-features
Security hardening and language feature expansion
2026-08-23 22:51:02 +03:00
4570aaaa0d build: enable warnings, scope example linkage, and gate tests
- add /W4 and -Wall -Wextra -Wpedantic
- change the example target link from PUBLIC to PRIVATE
- gate tests and examples behind BUILD_TESTING
2026-08-20 14:00:29 +03:00
46f9947b64 feat: add expression precompilation API and custom function registry
- F14: compile(source) separated from evaluation so an expression can be
  parsed once and evaluated many times
- F15: register user-defined C++ functions callable from expressions,
  replacing the hardcoded method dispatch with a named registry
2026-08-20 14:00:27 +03:00
a8b0431a35 feat: add ternary operator and in operator
- F1: conditional expressions (cond ? a : b)
- F4: 'in' operator for arrays and object keys
2026-08-20 14:00:26 +03:00
20d3c12457 feat: add string methods and object introspection
- F5: contains, startsWith, endsWith, toLowerCase, toUpperCase, trim,
  indexOf, replace, substring, split
- F10: .keys() and .values() for objects
2026-08-20 14:00:24 +03:00
74fbcf80e0 feat: add modulo, negative and string indexing, .type(), and ?? operator
- F2: modulo operator (%)
- F6: negative array indexing (@arr[-1])
- F7: string character indexing ("hello"[0])
- F8: .type() returning string/number/boolean/array/object/null
- F3: null-coalescing operator (??) with short-circuit evaluation
2026-08-20 14:00:22 +03:00
4e42a9e052 refactor: code quality cleanups in lexer, parser, and evaluator
- Q1: remove redundant if-else in the eval_expr Binary case
- Q2: remove duplicate text assignment for the AtIdent token
- Q3: add break after the [[noreturn]] error() call to silence
  fallthrough warnings
- Q9: convert all lexer runtime_error throws to ParseError carrying a
  source location, matching the parser
- Q10: .empty on numbers returns false instead of null
2026-08-20 14:00:20 +03:00
9a30408129 fix: correct scientific notation lexing, &&/|| return type, and Expr::kind init
- B1: malformed scientific notation (1e+, 1e-) no longer silently eats
  the following operator
- B2: && and || now consistently return booleans on every path (C-style
  semantics), instead of leaking the raw operand on the non-short-circuit
  path
- B3: example main.cpp passes the populated context instead of an empty
  object
- B4: give Expr::kind a default initializer to avoid reading an
  uninitialized enum
2026-08-20 14:00:19 +03:00
cda2e9daa7 fix: harden arithmetic, string ops, and lexer error handling
- S4: add isfinite checks after all arithmetic ops (Add, Sub, Mul, Div,
  Pow, Neg) so NaN/Infinity can never enter JSON output
- S5: fix is_integral_number INT64_MAX boundary check to eliminate
  undefined behaviour from double rounding
- S6: cap string concatenation result at MAX_STRING_SIZE (1MB)
- S7: add optional max_source_length parameter to test/eval_val/eval_true
- S8: catch std::out_of_range in lexNumber() and report a descriptive
  ParseError instead of a bare 'stod' message
2026-08-20 14:00:17 +03:00
9d5571b7d2 feat: critical security fixes - string repeat cap, parser/evaluator depth limits
- Cap string repeat to MAX_STRING_SIZE (1MB) to prevent DoS via integer overflow
- Consolidate duplicated string*number/number*string repeat blocks into helper
- Add parser depth counter (limit 512) to prevent stack overflow from nested parens/unary chains
- Add evaluator depth counter (limit 512) to prevent stack overflow during eval
- Add EvalError type for evaluation-time errors
- Add test cases for all security fixes
2026-08-20 01:14:52 +03:00
aab91708de Set script.h import to relative path to avoid include errors downstream 2026-03-20 00:55:59 +03:00
3c21e64045 Updated readme 2026-03-20 00:25:35 +03:00
188b1e8e24 Rename mantis to mbs 2026-03-19 23:53:14 +03:00
e0cd44d929 Minor fixes 2026-03-19 23:34:21 +03:00
eedf714cb3 Added example file 2026-03-19 17:28:13 +03:00
87b131d12f Removed build dir from commit 2026-03-19 17:06:16 +03:00
68e60a3dc8 Initial Commit 2026-03-19 17:05:22 +03:00