erick-alcachofa f5be339f43
fix(grammar): Simplify and improve EBNF definition
Signed-off-by: erick-alcachofa <erick@artichoke.dev>

The EBNF grammar definition contained several redundancies,
inconsistencies, and minor omissions. This commit refactors the grammar
to make it more concise, readable, and robust for parsing.

Key changes include:

- **Rule Simplification**: Redundant intermediate rules (`fn_params`,
  `statements`, `assign_expression`) have been removed. Rules like
  `code_block` and `import_target` are now more concisely expressed
  using standard EBNF operators (`?`, `*`).

- **EOF Enforcement**: The top-level `program` rule now requires an
  `<eof>` token. This is a crucial fix to ensure the parser consumes the
  entire file and fails on trailing invalid tokens.

- **Optional Generics**: Generic parameters (`<... >`) are now correctly
  marked as optional on `function`, `struct`, and `enum` declarations,
  which was the original intent.

- **Flexible For-Loops**: The update/increment expression (the third
  part) in a C-style `for` loop is now optional, aligning with behavior
  in languages like C and C++.

- **Primary Expressions**: Primary type expressions failed to parse
  correctly namespaced elements and types, now it's fixed and improved.
2025-10-05 14:49:50 -06:00
..
2025-10-02 00:26:35 -06:00