|
@@ -68,6 +68,16 @@ namespace NTERA.Interpreter
|
|
|
["TIMES"] = Token.Times,
|
|
|
};
|
|
|
|
|
|
+ private readonly Dictionary<string, Token> TokenLineDictionary = new Dictionary<string, Token>(StringComparer.InvariantCultureIgnoreCase)
|
|
|
+ {
|
|
|
+ ["PRINT"] = Token.Print,
|
|
|
+ ["PRINTL"] = Token.PrintL,
|
|
|
+ ["DRAWLINEFORM"] = Token.DrawLineForm,
|
|
|
+ ["PRINTFORML"] = Token.PrintFormL,
|
|
|
+ ["PRINT_IMG"] = Token.PrintImg,
|
|
|
+ ["PRINTBUTTON"] = Token.PrintButton,
|
|
|
+ };
|
|
|
+
|
|
|
public IEnumerable<Token> GetTokens()
|
|
|
{
|
|
|
while (true)
|
|
@@ -85,29 +95,21 @@ namespace NTERA.Interpreter
|
|
|
while (char.IsLetterOrDigit(GetChar()) || lastChar == '_')
|
|
|
Identifer += lastChar;
|
|
|
|
|
|
- if (TokenDictionary.ContainsKey(Identifer))
|
|
|
+ if (TokenDictionary.TryGetValue(Identifer, out Token token))
|
|
|
{
|
|
|
- yield return TokenDictionary[Identifer];
|
|
|
+ yield return token;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- switch (Identifer.ToUpper())
|
|
|
+ if (TokenLineDictionary.TryGetValue(Identifer, out token))
|
|
|
{
|
|
|
- case "DRAWLINEFORM":
|
|
|
- foreach (Token t in ReturnAsLine(Token.DrawLineForm))
|
|
|
- yield return t;
|
|
|
- continue;
|
|
|
-
|
|
|
- case "PRINTFORML":
|
|
|
- foreach (Token t in ReturnAsLine(Token.PrintFormL))
|
|
|
- yield return t;
|
|
|
- continue;
|
|
|
-
|
|
|
- case "PRINT":
|
|
|
- foreach (Token t in ReturnAsLine(Token.Print))
|
|
|
- yield return t;
|
|
|
- continue;
|
|
|
+ foreach (Token t in ReturnAsLine(token))
|
|
|
+ yield return t;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
+ switch (Identifer.ToUpper())
|
|
|
+ {
|
|
|
case "REM":
|
|
|
while (lastChar != '\n')
|
|
|
GetChar();
|
|
@@ -224,7 +226,7 @@ namespace NTERA.Interpreter
|
|
|
|
|
|
yield return token;
|
|
|
|
|
|
- Value = new Value(bodyBuilder.ToString());
|
|
|
+ Value = new Value(bodyBuilder.ToString().TrimEnd());
|
|
|
yield return Token.Value;
|
|
|
|
|
|
yield return Token.NewLine;
|