Skip to content

Commit

Permalink
Fix negative literal edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ai-kana committed Nov 8, 2024
1 parent af160ba commit cfd13b4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions GDWeave/Script/ScriptTokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static class ScriptTokenizer {
{"|=", TokenType.OpAssignBitOr},
{"^=", TokenType.OpAssignBitXor},

{"+", TokenType.OpAnd},
{"+", TokenType.OpAdd},
{"-", TokenType.OpSub},
{"*", TokenType.OpMul},
{"/", TokenType.OpDiv},
Expand Down Expand Up @@ -252,7 +252,10 @@ public static IEnumerable<Token> Tokenize(string gdScript, uint baseIndent = 0)
var toFlush = new List<Token>(2);
finalTokens.Add(new Token(TokenType.Newline, baseIndent));
var enumerator = tokens.GetEnumerator();
while (enumerator.MoveNext()) {
var reparse = false;
while (reparse ? true : enumerator.MoveNext()) {
reparse = false;

if (enumerator.Current == "\n") {
InsertNewLine(enumerator, baseIndent, toFlush);
endAndFlushId();
Expand All @@ -274,10 +277,9 @@ public static IEnumerable<Token> Tokenize(string gdScript, uint baseIndent = 0)

if (enumerator.Current == "-" || char.IsDigit(enumerator.Current[0])) {
BuildNumber(enumerator, toFlush, out bool foundFull);
reparse = !foundFull;
endAndFlushId();
if (foundFull) {
continue;
}
continue;
}

if (BuiltinFunctions.Contains(enumerator.Current)) {
Expand Down

0 comments on commit cfd13b4

Please sign in to comment.