-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
complexity: padawanIntermediate issues requiring some experienceIntermediate issues requiring some experienceenhancementNew feature or requestNew feature or requestparseruser-experience
Description
Issue Description
Currently, when a user forgets to add a required colon after a block declaration (e.g., step "Calculate"
), the error message is cryptic and points to the wrong location:
DEBUG: Syntax error at token type: IDENTIFIER
DEBUG: Token value: int_result
DEBUG: Position: 59
ThinkPy Error: Syntax error at token IDENTIFIER
Line: 4
Column: 9
Context: Near token: 'int_result'
Source code:
2: task "Math":
3: step "Calculate"
--> 4: int_result = 42 + -17
5: print(int_result)
6:
The error indicates an issue with the following identifier rather than the actual missing colon, making it difficult for users to identify and fix the problem.
Current Behavior
Given code like:
objective "Test"
task "Math":
step "Calculate" # Missing colon here
int_result = 42 + -17
print(int_result)
run "Math"
The parser reports an error at int_result
instead of indicating the missing colon after "Calculate"
.
Expected Behavior
The parser should detect missing colons and provide a clear error message:
ThinkPy Error: Missing colon ':' after 'Calculate'
Line: 3
Column: 19
Context: Near token: 'Calculate'
Implementation Plan
- Modify the parser's error handler to check if:
- The previous token was a STRING
- No colon follows the STRING token
- The context suggests a block declaration
- Enhance error reporting to show the exact position where the colon should be
- Update error messages to be more user-friendly and educational
Additional Context
This improvement will help users learn the ThinkPy syntax more easily and reduce confusion when writing programs.
Metadata
Metadata
Assignees
Labels
complexity: padawanIntermediate issues requiring some experienceIntermediate issues requiring some experienceenhancementNew feature or requestNew feature or requestparseruser-experience