public override Lexem ReadNextLexem(ParseIterator iterator) { bool isEndOfText = false; Char cs = '\0'; while (true) { if (!isEndOfText) { cs = iterator.CurrentSymbol; } if (SpecialChars.IsDelimiter(cs) || isEndOfText) { var content = iterator.GetContents().content; Lexem lex; if (_booleanOperators.Contains(content)) { lex = new Lexem() { Type = LexemType.Operator, Token = LanguageDef.GetToken(content), Content = content }; } else if (_booleanLiterals.Contains(content)) { lex = new Lexem() { Type = LexemType.BooleanLiteral, Content = content }; } else if (_undefined.Contains(content)) { lex = new Lexem() { Type = LexemType.UndefinedLiteral, Content = content }; } else if (String.Compare(content, "null", true) == 0) { lex = new Lexem() { Type = LexemType.NullLiteral, Content = content }; } else { lex = new Lexem() { Type = LexemType.Identifier, Content = content, Token = LanguageDef.GetToken(content) }; if (LanguageDef.IsBuiltInFunction(lex.Token)) { iterator.SkipSpaces(); if (iterator.CurrentSymbol != '(') { lex.Token = Token.NotAToken; } } } return(lex); } if (!iterator.MoveNext()) { if (isEndOfText) { break; } else { isEndOfText = true; } } } return(Lexem.Empty()); }
public override Lexem ReadNextLexem(ParseIterator iterator) { if (iterator.CurrentSymbol == '<') { if (iterator.MoveNext()) { var next = iterator.CurrentSymbol; if (next != '>' && next != '=') { iterator.MoveBack(); } else { iterator.MoveNext(); return(ExtractOperatorContent(iterator)); } } } else if (iterator.CurrentSymbol == '>') { if (iterator.MoveNext()) { var next = iterator.CurrentSymbol; if (next != '=') { iterator.MoveBack(); } else { iterator.MoveNext(); return(ExtractOperatorContent(iterator)); } } } else if (iterator.CurrentSymbol == '/') { if (iterator.MoveNext()) { if (iterator.CurrentSymbol == '/') { // это комментарий while (iterator.MoveNext()) { if (iterator.CurrentSymbol == '\n') { iterator.GetContents(); return(Lexem.Empty()); } } iterator.GetContents(); return(Lexem.EndOfText()); } else { iterator.MoveBack(); } } } var lex = ExtractOperatorContent(iterator); iterator.MoveNext(); return(lex); }
public override Lexem ReadNextLexem(ParseIterator iterator) { return(Lexem.Empty()); }