Exemplo n.º 1
0
    public YSToken IsMatch(YSTokenizer tokenizer)
    {
        if (tokenizer.End())
        {
            return(new YSToken(tokenizer.Location, YSToken.TokenType.EOF, null));
        }

        //YSLexer.Debug ("Current Token: " + tokenizer.Current + " Consume Count " + tokenizer.ConsumeCount);

        var match = IsMatchImpl(tokenizer);

        //YSLexer.Debug (tokenizer.Current + " Consume Count " + tokenizer.ConsumeCount);
        if (match == null)
        {
            YSLexer.Debug("No match for " + Identifier());
        }
        else
        {
            YSLexer.Debug(Identifier() + " matched " + match.Content);
        }

        if (match == null)
        {
            tokenizer.Rollback();
        }
        else
        {
            tokenizer.Commit();
        }

        return(match);
    }
Exemplo n.º 2
0
 public static bool LPIProcess(ref YSStateModule state, string raw)
 {
     bool result = false;
     YSLexer lexer = new YSLexer(raw);
     YSRDParser parser = new YSRDParser (lexer.GetTokenList());
     if(parser.Parse() <= YSInterpreter.ERR_ACCEPT){
         YSInterpreter interpreter = new YSInterpreter (parser.PopLast());
         result = interpreter.Interpret(ref state);
     } else
         Console.WriteLine("Interpreter not started, parsing was aborted");
     return result;
 }
Exemplo n.º 3
0
    public static bool LPIProcess(ref YSStateModule state, string raw)
    {
        bool       result = false;
        YSLexer    lexer  = new YSLexer(raw);
        YSRDParser parser = new YSRDParser(lexer.GetTokenList());

        if (parser.Parse() <= YSInterpreter.ERR_ACCEPT)
        {
            YSInterpreter interpreter = new YSInterpreter(parser.PopLast());
            result = interpreter.Interpret(ref state);
        }
        else
        {
            Console.WriteLine("Interpreter not started, parsing was aborted");
        }
        return(result);
    }