Пример #1
0
 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();
     }
 }
Пример #2
0
        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()));
        }