Skip to content

Commit

Permalink
Fixed lexer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Uralstech committed Dec 24, 2024
1 parent c2d09d5 commit b97e4fb
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions src/Syntax/Lexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void Advance()
private void ReverseTo(int index)
{
_currentChar = _script[index];
_position.ReverseTo(index, _currentChar == '\n' ? 1 : 0);
_position = _position.ReverseTo(index, _currentChar == '\n' ? 1 : 0);
}

/// <summary>
Expand Down Expand Up @@ -584,66 +584,66 @@ private Token CompileIdentifier(out EzrSyntaxError? error)
? new Token(TokenType.Identifier, TokenTypeGroup.Special, original, startPosition, _position)
: original.ToLower() switch
{
"private" => new Token(TokenType.KeywordPrivate, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"constant" => new Token(TokenType.KeywordConstant, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"readonly" => new Token(TokenType.KeywordReadonly, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"item" => new Token(TokenType.KeywordItem, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"and" => new Token(TokenType.KeywordAnd, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"or" => new Token(TokenType.KeywordOr, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"invert" => new Token(TokenType.KeywordInvert, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"if" => new Token(TokenType.KeywordIf, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"else" => new Token(TokenType.KeywordElse, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"do" => new Token(TokenType.KeywordDo, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"count" => new Token(TokenType.KeywordCount, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"for" => new Token(TokenType.KeywordFor, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"each" => new Token(TokenType.KeywordEach, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"from" => new Token(TokenType.KeywordFrom, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"as" => new Token(TokenType.KeywordAs, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"to" => new Token(TokenType.KeywordTo, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"step" => new Token(TokenType.KeywordStep, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"while" => new Token(TokenType.KeywordWhile, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"function" => new Token(TokenType.KeywordFunction, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"private" => new Token(TokenType.KeywordPrivate, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"constant" => new Token(TokenType.KeywordConstant, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"readonly" => new Token(TokenType.KeywordReadonly, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"item" => new Token(TokenType.KeywordItem, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"and" => new Token(TokenType.KeywordAnd, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"or" => new Token(TokenType.KeywordOr, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"invert" => new Token(TokenType.KeywordInvert, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"if" => new Token(TokenType.KeywordIf, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"else" => new Token(TokenType.KeywordElse, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"do" => new Token(TokenType.KeywordDo, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"count" => new Token(TokenType.KeywordCount, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"for" => new Token(TokenType.KeywordFor, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"each" => new Token(TokenType.KeywordEach, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"from" => new Token(TokenType.KeywordFrom, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"as" => new Token(TokenType.KeywordAs, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"to" => new Token(TokenType.KeywordTo, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"step" => new Token(TokenType.KeywordStep, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"while" => new Token(TokenType.KeywordWhile, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"function" => new Token(TokenType.KeywordFunction, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),

#pragma warning disable CS0618
"special" => new Token(TokenType.KeywordSpecial, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"special" => new Token(TokenType.KeywordSpecial, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
#pragma warning restore CS0618

"with" => new Token(TokenType.KeywordWith, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"more" => new Token(TokenType.KeywordMore, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"named" => new Token(TokenType.KeywordNamed, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"end" => new Token(TokenType.KeywordEnd, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"return" => new Token(TokenType.KeywordReturn, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"last" => new Token(TokenType.KeywordLast, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"skip" => new Token(TokenType.KeywordSkip, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"stop" => new Token(TokenType.KeywordStop, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"try" => new Token(TokenType.KeywordTry, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"catch" => new Token(TokenType.KeywordCatch, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"not" => new Token(TokenType.KeywordNot, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"in" => new Token(TokenType.KeywordIn, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"object" => new Token(TokenType.KeywordObject, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"global" => new Token(TokenType.KeywordGlobal, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"include" => new Token(TokenType.KeywordInclude, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"all" => new Token(TokenType.KeywordAll, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"static" => new Token(TokenType.KeywordStatic, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"define" => new Token(TokenType.KeywordDefine, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"f" => new Token(TokenType.QeywordF, TokenTypeGroup.Qeyword, original, startPosition, _position),
"l" => new Token(TokenType.QeywordL, TokenTypeGroup.Qeyword, original, startPosition, _position),
"e" => new Token(TokenType.QeywordE, TokenTypeGroup.Qeyword, original, startPosition, _position),
"c" => new Token(TokenType.QeywordC, TokenTypeGroup.Qeyword, original, startPosition, _position),
"p" => new Token(TokenType.QeywordP, TokenTypeGroup.Qeyword, original, startPosition, _position),
"t" => new Token(TokenType.QeywordT, TokenTypeGroup.Qeyword, original, startPosition, _position),
"n" => new Token(TokenType.QeywordN, TokenTypeGroup.Qeyword, original, startPosition, _position),
"w" => new Token(TokenType.QeywordW, TokenTypeGroup.Qeyword, original, startPosition, _position),
"fd" => new Token(TokenType.QeywordFd, TokenTypeGroup.Qeyword, original, startPosition, _position),
"sd" => new Token(TokenType.QeywordSd, TokenTypeGroup.Qeyword, original, startPosition, _position),
"sb" => new Token(TokenType.QeywordSb, TokenTypeGroup.Qeyword, original, startPosition, _position),
"od" => new Token(TokenType.QeywordOd, TokenTypeGroup.Qeyword, original, startPosition, _position),
"i" => new Token(TokenType.QeywordI, TokenTypeGroup.Qeyword, original, startPosition, _position),
"s" => new Token(TokenType.QeywordS, TokenTypeGroup.Qeyword, original, startPosition, _position),
"d" => new Token(TokenType.QeywordD, TokenTypeGroup.Qeyword, original, startPosition, _position),
"g" => new Token(TokenType.QeywordG, TokenTypeGroup.Qeyword, original, startPosition, _position),
"v" => new Token(TokenType.QeywordV, TokenTypeGroup.Qeyword, original, startPosition, _position),
_ => new Token(TokenType.Identifier, TokenTypeGroup.Special, original, startPosition, _position),
"with" => new Token(TokenType.KeywordWith, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"more" => new Token(TokenType.KeywordMore, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"named" => new Token(TokenType.KeywordNamed, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"end" => new Token(TokenType.KeywordEnd, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"return" => new Token(TokenType.KeywordReturn, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"last" => new Token(TokenType.KeywordLast, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"skip" => new Token(TokenType.KeywordSkip, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"stop" => new Token(TokenType.KeywordStop, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"try" => new Token(TokenType.KeywordTry, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"catch" => new Token(TokenType.KeywordCatch, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"not" => new Token(TokenType.KeywordNot, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"in" => new Token(TokenType.KeywordIn, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"object" => new Token(TokenType.KeywordObject, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"global" => new Token(TokenType.KeywordGlobal, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"include" => new Token(TokenType.KeywordInclude, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"all" => new Token(TokenType.KeywordAll, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"static" => new Token(TokenType.KeywordStatic, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"define" => new Token(TokenType.KeywordDefine, TokenTypeGroup.Keyword, string.Empty, startPosition, _position),
"f" => new Token(TokenType.QeywordF, TokenTypeGroup.Qeyword, original, startPosition, _position),
"l" => new Token(TokenType.QeywordL, TokenTypeGroup.Qeyword, original, startPosition, _position),
"e" => new Token(TokenType.QeywordE, TokenTypeGroup.Qeyword, original, startPosition, _position),
"c" => new Token(TokenType.QeywordC, TokenTypeGroup.Qeyword, original, startPosition, _position),
"p" => new Token(TokenType.QeywordP, TokenTypeGroup.Qeyword, original, startPosition, _position),
"t" => new Token(TokenType.QeywordT, TokenTypeGroup.Qeyword, original, startPosition, _position),
"n" => new Token(TokenType.QeywordN, TokenTypeGroup.Qeyword, original, startPosition, _position),
"w" => new Token(TokenType.QeywordW, TokenTypeGroup.Qeyword, original, startPosition, _position),
"fd" => new Token(TokenType.QeywordFd, TokenTypeGroup.Qeyword, original, startPosition, _position),
"sd" => new Token(TokenType.QeywordSd, TokenTypeGroup.Qeyword, original, startPosition, _position),
"sb" => new Token(TokenType.QeywordSb, TokenTypeGroup.Qeyword, original, startPosition, _position),
"od" => new Token(TokenType.QeywordOd, TokenTypeGroup.Qeyword, original, startPosition, _position),
"i" => new Token(TokenType.QeywordI, TokenTypeGroup.Qeyword, original, startPosition, _position),
"s" => new Token(TokenType.QeywordS, TokenTypeGroup.Qeyword, original, startPosition, _position),
"d" => new Token(TokenType.QeywordD, TokenTypeGroup.Qeyword, original, startPosition, _position),
"g" => new Token(TokenType.QeywordG, TokenTypeGroup.Qeyword, original, startPosition, _position),
"v" => new Token(TokenType.QeywordV, TokenTypeGroup.Qeyword, original, startPosition, _position),
_ => new Token(TokenType.Identifier, TokenTypeGroup.Special, original, startPosition, _position),
};
}
}

0 comments on commit b97e4fb

Please sign in to comment.