public Lexem NextLexem() { _state = _emptyState; while (true) { if (_iterator.MoveToContent()) { char cs = _iterator.CurrentSymbol; if (Char.IsLetter(cs) || cs == '_') { _state = _wordState; } else if (Char.IsDigit(cs)) { _state = _numberState; } else if (cs == SpecialChars.DateQuote) { _state = _dateState; } else if (cs == SpecialChars.StringQuote) { _state = _stringState; } else if (SpecialChars.IsOperatorChar(cs)) { _state = _operatorState; } else if (cs == SpecialChars.EndOperator) { _iterator.MoveNext(); return(new Lexem() { Type = LexemType.EndOperator, Token = Token.Semicolon }); } else if (cs == '?') { _iterator.MoveNext(); return(new Lexem() { Type = LexemType.Identifier, Token = Token.Question }); } else if (cs == SpecialChars.Directive) { _state = _directiveState; } else { var cp = _iterator.GetPositionInfo(_iterator.CurrentLine); throw new ParserException(cp, string.Format("Неизвестный символ {0}", cs)); } var lex = _state.ReadNextLexem(_iterator); if (lex.Type == LexemType.NotALexem) { _state = _emptyState; continue; } return(lex); } else { return(Lexem.EndOfText()); } } }
public ParserException CreateExceptionOnCurrentLine(string message, ParseIterator iterator) { var cp = iterator.GetPositionInfo(iterator.CurrentLine); return new ParserException(cp, message); }
public ParserException CreateExceptionOnCurrentLine(string message, ParseIterator iterator) { var cp = iterator.GetPositionInfo(iterator.CurrentLine); return(new ParserException(cp, message)); }