Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enriches the Quill language with variable declarations, assignments, conditional logic, and enhanced interpolation, alongside a demonstration script.
- Expanded AST with
LetStatement,AssignStatement,IfStatement, Boolean/Integer literals, infix/prefix expressions, and updatedString()methods to guard againstnil. - Updated tokenizer and scanner to recognize new operators (
+=,>=,&&, etc.) and keywords (LET,IF,ELSE,TRUE,FALSE). - Enhanced interpreter to store variables, execute new statements, evaluate complex expressions, and report detailed errors; added
examples/shop.qto showcase features.
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/token/types.go | Added new operator tokens and variable keywords; updated comments |
| internal/scanner/scanner.go | Extended scanning logic for multi-character operators |
| internal/interpreter/interpreter.go | Introduced variable storage and execution for let/assign/if; expression evaluator updates |
| internal/ast/statements.go | Added AST nodes and String() guards for new statements |
| internal/ast/node.go | Added nil check in Program.String() |
| internal/ast/expressions.go | Added AST nodes and guards for new literals/expressions |
| examples/shop.q | New example script demonstrating variables and logic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant enhancements to the
quilllanguage and its interpreter, including support for variable declarations, assignments, conditional statements, and more robust expression handling. Additionally, it introduces a new example script showcasing these features. The changes span across the Abstract Syntax Tree (AST), interpreter logic, and the example script.Language Features and Syntax Enhancements:
Expanded AST Support:
BooleanLiteral,IntegerLiteral,InfixExpression,PrefixExpression,InterpolatedString) and statement types (LetStatement,AssignStatement,IfStatement) to support variable declarations, assignments, and conditional logic. ([[1]](https://github.com/ThePat02/quill/pull/1/files#diff-21a96fe9ac8432a6a8ab1a6270893e2f84419b176e4889bd8696b1720329b82aR50-R155),[[2]](https://github.com/ThePat02/quill/pull/1/files#diff-435c5aebaadc51c284cea54190e5ffa0de06a65190c20f0cf71db8f9077d672aL100-R249))DialogStatementto support expressions for text, enabling interpolation and dynamic content. ([internal/ast/statements.goL31-R74](https://github.com/ThePat02/quill/pull/1/files#diff-435c5aebaadc51c284cea54190e5ffa0de06a65190c20f0cf71db8f9077d672aL31-R74))Interpreter Updates:
LetStatement,AssignStatement,IfStatement) and expanded expression evaluation to handle interpolation, infix, and prefix operations. ([[1]](https://github.com/ThePat02/quill/pull/1/files#diff-584e5570407b02964ad571ea8ac4603bc6fdabbbcec9bb12734a3dac2909e748R97-L119),[[2]](https://github.com/ThePat02/quill/pull/1/files#diff-584e5570407b02964ad571ea8ac4603bc6fdabbbcec9bb12734a3dac2909e748R134-R232),[[3]](https://github.com/ThePat02/quill/pull/1/files#diff-584e5570407b02964ad571ea8ac4603bc6fdabbbcec9bb12734a3dac2909e748R530-R737))variablesmap) to track declared variables and their values during execution. ([[1]](https://github.com/ThePat02/quill/pull/1/files#diff-584e5570407b02964ad571ea8ac4603bc6fdabbbcec9bb12734a3dac2909e748R58),[[2]](https://github.com/ThePat02/quill/pull/1/files#diff-584e5570407b02964ad571ea8ac4603bc6fdabbbcec9bb12734a3dac2909e748R80))Example Script:
examples/shop.q):[examples/shop.qR1-R54](https://github.com/ThePat02/quill/pull/1/files#diff-599f96a6d1ef22cc0874f9fdd977700f047a90f04bcce49489db87acaa93d1c6R1-R54))Code Robustness:
Improved String Representations:
String()methods across AST nodes to handlenilcases gracefully, ensuring robust debugging and error handling. ([[1]](https://github.com/ThePat02/quill/pull/1/files#diff-21a96fe9ac8432a6a8ab1a6270893e2f84419b176e4889bd8696b1720329b82aR12-R14),[[2]](https://github.com/ThePat02/quill/pull/1/files#diff-21a96fe9ac8432a6a8ab1a6270893e2f84419b176e4889bd8696b1720329b82aR25-R27),[[3]](https://github.com/ThePat02/quill/pull/1/files#diff-21a96fe9ac8432a6a8ab1a6270893e2f84419b176e4889bd8696b1720329b82aR38-R40),[[4]](https://github.com/ThePat02/quill/pull/1/files#diff-644fc1ed5ebae9c40e2542a3450a224634d7e413997e9ebad135a02aad1c0fd6R22-R30),[[5]](https://github.com/ThePat02/quill/pull/1/files#diff-435c5aebaadc51c284cea54190e5ffa0de06a65190c20f0cf71db8f9077d672aL12-R19),[[6]](https://github.com/ThePat02/quill/pull/1/files#diff-435c5aebaadc51c284cea54190e5ffa0de06a65190c20f0cf71db8f9077d672aL22-R36),[[7]](https://github.com/ThePat02/quill/pull/1/files#diff-435c5aebaadc51c284cea54190e5ffa0de06a65190c20f0cf71db8f9077d672aL58-R117))Error Handling:
[[1]](https://github.com/ThePat02/quill/pull/1/files#diff-584e5570407b02964ad571ea8ac4603bc6fdabbbcec9bb12734a3dac2909e748R134-R232),[[2]](https://github.com/ThePat02/quill/pull/1/files#diff-584e5570407b02964ad571ea8ac4603bc6fdabbbcec9bb12734a3dac2909e748R530-R737))These changes collectively enhance the language's capabilities, making it more expressive and suitable for complex interactive narratives. The example script serves as a practical demonstration of these new features.