Update grammar, expand CRC32 function #2
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "grammar"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
This PR introduces several significant updates to the XN grammar and transformation engine, including support for bitwise operations, improved function parameter handling, and enhanced error reporting.
Major Changes
Bitwise Operations: Added support for bitwise XOR (^), AND (&), and OR (|) operators.
Power Operator: Renamed the power operator from ^ to ** to align with common mathematical notation and avoid conflict with bitwise XOR.
Hexadecimal Literals: Added support for hex numbers in expressions (e.g., 0xDEADBEEF).
Stricter Semicolon Grammar: Rules and Bangs now strictly require a semicolon terminator for better parsing reliability and clearer error hints when one is missing.
Multi-Rule Support: The parser now supports multiple root-level rules in a single .xn file.
Parameterized CRC32: The crc() function has been renamed to crc32() and expanded to support custom polynomials, initial values, and bit reflection. It defaults to the MPEG-2 standard.
String Utilities:
Renamed hex() to hexlit(), which now defaults to lowercase output.
Added lower() and upper() functions for string case conversion.
require() Function: Added a new require(message) function that throws a RequireException if a node is missing during transformation, allowing for explicit validation of XML structures.
Default Parameter Support: The function resolution logic now correctly handles C# methods with optional/default parameters.
Enhanced Parse Errors: Added hints to the CLI output when a missing semicolon is likely the cause of a parsing failure.
RequireException: Introduced a specific exception type for failed requirements, which includes source location tracking for precise error reporting in the input files.