4 Commits

Author SHA1 Message Date
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
f3cc5b90c8
chore: Fix naming of wiki source file
Signed-off-by: erick-alcachofa <erick@artichoke.dev>
2025-10-02 00:26:35 -06:00
e024c03134
chore: Removed unnecessary bold in titles
Signed-off-by: erick-alcachofa <erick@artichoke.dev>
2025-10-01 23:39:17 -06:00
d0599d374f
feat: Add language grammar and adjusted tokenizer
Signed-off-by: erick-alcachofa <erick@artichoke.dev>

This commit lays the foundational groundwork for the artichoke language
parser by introducing the formal language grammar specification.

The tokenizer was updated to include new operators and keywords, also
added the posibility to handle comments.

Key Additions:
- Implemented support for C-style block comments (`/* ... */`),
  including error handling for unclosed comments.
- Added all necessary tokens for missing keywords (e.g., `module`,
  `export`, `using`, `match`, `loop`) and operators (e.g., `+=`, `:=`,
  `.#`, `.*`, `.@`).
- The `Token` enum has been expanded to reflect the full language
  feature set.

Documentation:
- Added `docs/grammar.ebnf` which contains the official, well-structured
  EBNF grammar for the language.
- Added `docs/readme.md` providing a detailed technical overview of the
  language's features, syntax, and semantics.

BREAKING CHANGE: The `kwVariant` and `kwMut` tokens have been removed to
align with the updated language design defined in the new grammar.
2025-10-01 18:51:09 -06:00