Commit Graph

2 Commits

Author SHA1 Message Date
Bob Nystrom
0ea34e00fe feat: implement floating-point number literal parsing and arithmetic operations
Add support for floating-point number literals in the parser by detecting decimal points with trailing digits in `readNumber()`, and switch the compiler's `number()` function from `strtol` to `strtod` for proper double conversion. Update the `num_abs` primitive to use `fabs()` instead of manual negation. Extend test coverage across arithmetic, comparison, equality, modulus, and string conversion tests with floating-point cases, and add a new test for decimal point at end-of-file error detection.
2013-11-10 05:32:57 +00:00
Bob Nystrom
074deebdfd feat: add boolean literals and number comparison operators to compiler and VM
Add TOKEN_TRUE/TOKEN_FALSE parsing with boolean() prefix rule emitting CODE_TRUE/CODE_FALSE bytecodes. Wire comparison operators <, >, <=, >= as infix rules with PREC_COMPARISON precedence. Implement num_lt, num_gt, num_lte, num_gte primitives returning bool values. Register boolClass with toString primitive and move class initialization into registerPrimitives(). Add OBJ_TRUE/OBJ_FALSE object types with makeBool() helper and AS_BOOL macro. Include test files for bool_toString and number_comparison.
2013-11-04 05:38:58 +00:00