Skip to content

Commit

Permalink
Implemented underscore syntax in numbers (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandone authored Dec 24, 2024
1 parent 9bf4d35 commit ae202e9
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 123 deletions.
2 changes: 1 addition & 1 deletion Numscript.g4
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ PERCENTAGE_PORTION_LITERAL: [0-9]+ ('.' [0-9]+)? '%';
STRING: '"' ('\\"' | ~[\r\n"])* '"';
IDENTIFIER: [a-z]+ [a-z_]*;
NUMBER: MINUS? [0-9]+;
NUMBER: MINUS? [0-9]+ ('_' [0-9]+)*;
VARIABLE_NAME: '$' [a-z_]+ [a-z0-9_]*;
ACCOUNT: '@' [a-zA-Z0-9_-]+ (':' [a-zA-Z0-9_-]+)*;
ASSET: [A-Z/0-9]+;
Expand Down
37 changes: 37 additions & 0 deletions internal/parser/__snapshots__/parser_test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2264,3 +2264,40 @@ parser.Program{
},
}
---

[TestNumberSyntaxUnderscore - 1]
parser.Program{
Vars: nil,
Statements: {
&parser.FnCall{
Range: parser.Range{
Start: parser.Position{Character:0, Line:1},
End: parser.Position{Character:29, Line:1},
},
Caller: &parser.FnCallIdentifier{
Range: parser.Range{
Start: parser.Position{Character:0, Line:1},
End: parser.Position{Character:11, Line:1},
},
Name: "set_tx_meta",
},
Args: {
&parser.StringLiteral{
Range: parser.Range{
Start: parser.Position{Character:12, Line:1},
End: parser.Position{Character:16, Line:1},
},
String: "k1",
},
&parser.NumberLiteral{
Range: parser.Range{
Start: parser.Position{Character:18, Line:1},
End: parser.Position{Character:28, Line:1},
},
Number: 1234567,
},
},
},
},
}
---
2 changes: 1 addition & 1 deletion internal/parser/antlr/NumscriptLexer.interp

Large diffs are not rendered by default.

Loading

0 comments on commit ae202e9

Please sign in to comment.