186 string lexeme =
null;
188 List<Token> tokenStream =
new List<Token>();
338 if (
char.IsLetter(ch) || ch ==
'_')
343 else if (
char.IsDigit(ch))
356 case State.BinaryNot:
391 case State.InlineComment:
397 case State.BlockComment:
599 case State.Identifier:
601 if (
char.IsLetterOrDigit(ch) || ch ==
'_')
609 if (lexeme ==
"null")
611 else if (lexeme ==
"true" || lexeme ==
"false")
613 else if (lexeme ==
"if")
615 else if (lexeme ==
"else")
617 else if (lexeme ==
"while")
619 else if (lexeme ==
"for")
621 else if (lexeme ==
"foreach")
623 else if (lexeme ==
"in")
625 else if (lexeme ==
"switch")
627 else if (lexeme ==
"case")
629 else if (lexeme ==
"default")
631 else if (lexeme ==
"break")
633 else if (lexeme ==
"continue")
635 else if (lexeme ==
"function")
637 else if (lexeme ==
"return")
640 else if (lexeme ==
"shared")
642 else if (lexeme ==
"var")
645 else if (lexeme ==
"include")
647 else if (lexeme ==
"lock")
649 else if (lexeme ==
"run")
651 else if (lexeme ==
"yield")
653 else if (lexeme ==
"notify")
655 else if (lexeme ==
"wait")
665 if (lexeme ==
"true")
673 tokenStream.Add(
new Token(tokenType, lexeme,
line,
column, currentLine));
692 if (lexeme ==
"\\n") c =
'\n';
693 else if (lexeme ==
"\\t") c =
'\t';
694 else if (lexeme ==
"\\b") c =
'\b';
695 else if (lexeme ==
"\\r") c =
'\r';
696 else if (lexeme ==
"\\f") c =
'\f';
697 else if (lexeme ==
"\\\'") c =
'\'';
698 else if (lexeme ==
"\\\"") c =
'\"';
699 else if (lexeme ==
"\\\\") c =
'\\';
700 else c =
char.Parse(lexeme);
718 else if (ch ==
'\r' || ch ==
'\n')
728 case State.EscapeString:
772 case State.MultiLineString:
792 case State.MultiLineStringQuote1:
801 if (ch !=
'\r') lexeme += ch;
806 case State.MultiLineStringQuote2:
817 if (ch !=
'\r') lexeme += ch;
822 case State.EscapeMultiLineString:
824 if (ch ==
'"') { lexeme +=
'\"';
state =
State.MultiLineString; }
825 else if (ch ==
'\\') { lexeme +=
'\\';
state =
State.MultiLineString; }
826 else if (ch ==
'n') { lexeme +=
'\n';
state =
State.MultiLineString; }
827 else if (ch ==
't') { lexeme +=
'\t';
state =
State.MultiLineString; }
828 else if (ch ==
'r') { lexeme +=
'\r';
state =
State.MultiLineString; }
829 else if (ch ==
'b') { lexeme +=
'\b';
state =
State.MultiLineString; }
839 if (
char.IsDigit(ch))
865 int intValue = Convert.ToInt32(lexeme, 2);
872 int intValue = Convert.ToInt32(lexeme, 8);
878 int intValue =
int.Parse(lexeme);
886 if (
char.IsDigit(ch))
890 float floatValue =
float.Parse(lexeme, System.Globalization.CultureInfo.InvariantCulture);
898 if (
char.IsDigit(ch))
902 double doubleValue =
double.Parse(lexeme, System.Globalization.CultureInfo.InvariantCulture);
910 if (
char.IsDigit(ch))
918 decimal decimalValue = decimal.Parse(lexeme, System.Globalization.CultureInfo.InvariantCulture);
926 if (
char.IsDigit(ch) ||
char.IsLetter(ch))
928 if (
char.IsLetter(ch) && !(ch >=
'a' && ch <=
'f') || (ch >=
'A' && ch <=
'F'))
929 throw new LexerException(
"Ein hexadezimaler Wert darf ausser Zahlen nur Buchstaben von 'a' - 'f' bzw. 'A' - 'F' enthalten.",
line,
column, currentLine);
934 int intValue = Convert.ToInt32(lexeme, 16);