Exemplo n.º 1
0
        private ParsecError getSysUnexpected(int i)
        {
            if (i >= sys_unexpected.Length)
            {
                return(eof_unexpected);
            }
            ParsecError r = sys_unexpected[i];

            if (r == null)
            {
                Tok ptok = input[i];
                r = ParsecError.raiseSysUnexpected(ptok.Index,
                                                   show(ptok.Token));
                sys_unexpected[i] = r;
            }
            return(r);
        }
Exemplo n.º 2
0
        internal override bool apply(ParseContext ctxt, ref Tok result, ref AbstractParsecError err)
        {
            int original_step = ctxt.getStep();
            int original_at   = ctxt.getAt();
            S   tmp           = default(S);

            if (!scanner.parse(ctxt, ref tmp, ref err))
            {
                return(false);
            }
            int    cur = ctxt.getAt();
            int    len = cur - original_at;
            object tok = tn(ctxt.getSource(), original_at, len);

            //The java version uses null to indicate a failure. It doesn't not seem to be used though. So we keep it simple.
            result = new Tok(original_at, len, tok);
            ctxt.setStep(original_step + 1);
            return(true);
        }
Exemplo n.º 3
0
 //caller should not change input after it is passed in.
 internal ParserState(Tok[] input,
     int at, string module, PositionMap pmap,
     int end_index,
     string eof_str, ShowToken show)
     : base(at, module, pmap)
 {
     this.input = input;
     this.sys_unexpected = new ParsecError[input.Length];
     this.show = show;
     this.end_index = end_index;
     this.eof_unexpected = ParsecError.raiseSysUnexpected(
         end_index, eof_str);
 }