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 StringToken ResolveString(LexerContext context) { var begin = context.GetIndex(); var builder = new StringBuilder(); while (StringToken.IsStringBegin(context)) { if (context.GetCurrentChar().Equals('\'')) { ResolveQuotedString(context, builder); } else { ResolveControlString(context, builder); } } return(new StringToken(builder.ToString(), begin, context.GetIndex())); }