Commit Graph

3 Commits

Author SHA1 Message Date
Bob Nystrom
7eabd40181 feat: add unary operators and variable assignment with precedence handling
Implement unary negation for numbers and logical not for booleans, introduce PREC_ASSIGNMENT and PREC_UNARY precedence levels, refactor parse functions to accept allowAssignment parameter, add assignment tests for global/local/chained/error cases, and update if-syntax to support statement branches and assignment in conditions.
2013-11-13 15:10:52 +00:00
Bob Nystrom
8353c26596 feat: add == and != operators for bool, number, and string types with type-checking
Implement equality and inequality operators across three primitive types in the compiler and runtime. Add `bool_eqeq`/`bool_bangeq`, `num_eqeq`/`num_bangeq`, and `string_eqeq`/`string_bangeq` primitives that return false/true respectively when comparing against incompatible types. Update the parse rule table with `INFIX_OPERATOR` macros for `TOKEN_EQEQ` and `TOKEN_BANGEQ` at `PREC_COMPARISON` precedence. Include test files `bool_equality.wren`, `number_equality.wren`, and `string_equality.wren` covering cross-type comparisons and edge cases.
2013-11-05 17:57:57 +00:00
Bob Nystrom
d3cffd521d feat: add parentheses grouping support in expression parser
Implement parenthesized expression parsing in the primary() function by matching TOKEN_LEFT_PAREN, recursively calling expression(), and consuming TOKEN_RIGHT_PAREN. Add grammar test cases in test/grammar.wren verifying correct operator precedence with parentheses, including nested grouping expressions.
2013-11-01 04:49:15 +00:00