private static IToken Resolve(LexerContext context) { if (CommentToken.IsCommentBegin(context)) { return(ResolveComment(context)); } else if (NumberToken.IsNumberBegin(context)) { return(ResolveNumber(context)); } else if (StringToken.IsStringBegin(context)) { return(ResolveString(context)); } else if (SpecialSymbolToken.IsSpecial(context)) { return(ResolveSpecial(context)); } else if (IdentifierToken.IsIdentifierBegin(context)) { return(ResolveIdentifier(context)); } else { throw new SyntaxErrorException(); } }
private static SpecialSymbolToken ResolveSpecial(LexerContext context) { var begin = context.GetIndex(); if (!context.IsLast() && SpecialSymbolToken.IsSpecialPair(context)) { var pair = context.GetCharPair(); context.IncIndex(); context.IncIndex(); return(new SpecialSymbolToken(pair, begin)); } else { var ch = context.GetCurrentChar(); context.IncIndex(); return(new SpecialSymbolToken(ch, begin)); } }