コード例 #1
0
ファイル: Lexer.cs プロジェクト: chernokoz/python-lexer
        private static bool ResolveNewLine(LexerContext context)
        {
            var stringSep = Environment.NewLine;

            if (stringSep.Length == 1 && stringSep.Equals(context.GetCurrentCharByString()))
            {
                return(true);
            }
            else if (stringSep.Length == 2 && !context.IsLast() && stringSep.Equals(context.GetCharPair()))
            {
                context.IncIndex();
                return(true);
            }
            return(false);
        }
コード例 #2
0
ファイル: Lexer.cs プロジェクト: chernokoz/python-lexer
        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));
            }
        }