The ThinkPy parser currently fails to properly recognize floating-point numbers in code, throwing a syntax error when encountering numbers like 10.5. This affects basic arithmetic operations and variable assignments using decimal numbers.
Steps to Reproduce
Create a ThinkPy program with floating-point numbers:
task "FloatMath" {
step "Basic arithmetic" {
a = 10.5
b = 3.0
result = a / b
print(result)
}
}
run "FloatMath"
2. Run the program
### Current Behavior
The parser throws a syntax error:
ThinkPy Error: Syntax error at token FLOAT
Line: 5
Column: 15
Context: Near token: '0.5'
### Expected Behavior
The parser should recognize `10.5` and `3.0` as valid floating-point numbers and execute the arithmetic operations successfully.
### Root Cause
The lexer token ordering causes the NUMBER token to consume the "10" portion before the FLOAT token can properly match the entire "10.5" number. The FLOAT token definition needs to be placed before the NUMBER token in the lexer rules to ensure proper pattern matching.
### Environment
- Python Version: 3.13
- ThinkPy Parser Version: 1.0
Description
The ThinkPy parser currently fails to properly recognize floating-point numbers in code, throwing a syntax error when encountering numbers like
10.5
. This affects basic arithmetic operations and variable assignments using decimal numbers.Steps to Reproduce
task "FloatMath" { step "Basic arithmetic" { a = 10.5 b = 3.0 result = a / b print(result) } }
run "FloatMath"
ThinkPy Error: Syntax error at token FLOAT Line: 5 Column: 15 Context: Near token: '0.5'