feat: Major grammar improvements and refactoring

- Refactor statement parsing with proper precedence handling
- Improve block structure parsing with indent/dedent support
- Enhance control flow parsing (conditionals, loops)
- Add print command support
- Improve function declaration parsing
- Update scanner for better string and comment handling
- Add comprehensive test corpus
- Better handling of newlines and statement boundaries
This commit is contained in:
2025-11-26 22:19:38 +01:00
parent b7942e9f79
commit 4d61f91e06
9 changed files with 15323 additions and 18695 deletions

View File

@@ -145,9 +145,9 @@ equipL poison wand
equipR vigor shield *7 +5
------------------
(source_file
(command (identifier))
(command (identifier) (identifier))
(command (identifier) (identifier) (identifier) (number) (number))
(command (identifier) (identifier) (identifier))
(command (identifier) (identifier) (identifier) (star_level (number)) (enchantment_level (number)))
)
==================
@@ -158,9 +158,9 @@ activate R
loadout 1
------------------
(source_file
(command (identifier))
(command (identifier))
(command (number))
(command (identifier) (identifier))
(command (identifier) (identifier))
(command (identifier) (number))
)
==================
@@ -299,17 +299,17 @@ Real Example from Manual
(source_file
(conditional
(binary_expression (identifier) (identifier))
(block (command (identifier)))
(block (command (identifier) (identifier)))
)
(conditional
(binary_expression (identifier) (identifier))
(block
(command (number))
(command (identifier) (number))
(conditional
(binary_expression (identifier) (identifier))
(block
(command (identifier))
(command (identifier) (identifier) (number))
(command (identifier) (identifier))
(command (identifier) (identifier) (star_level (number)))
)
)
)
@@ -317,21 +317,21 @@ Real Example from Manual
(conditional
(binary_expression (identifier) (identifier))
(block
(command (identifier) (identifier))
(command (identifier) (identifier))
(command (identifier) (identifier) (identifier))
(command (identifier) (identifier) (identifier))
(conditional
(binary_expression
(member_expression (identifier) (identifier))
(number)
)
(block
(command (identifier) (identifier) (identifier) (number))
(command (identifier) (identifier) (identifier) (enchantment_level (number)))
)
)
)
)
(conditional
(binary_expression (identifier) (number))
(block (command (identifier)))
(block (command (identifier) (identifier)))
)
)