Пример #1
0
            internal override bool apply(ParseContext ctxt, ref D_ result, ref AbstractParsecError err)
            {
                int from = ctxt.getAt();

                if (!outer_scanner.parse(ctxt, ref result, ref err))
                {
                    return(false);
                }
                ScannerState inner_ctxt = new ScannerState(ctxt.getSource(), from, module, ctxt.getPositionMap(),
                                                           ctxt.getAt() - from);

                return(ParserChores.cont(ctxt, inner_ctxt, nested, ref result, ref err));
            }
Пример #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);
        }
Пример #3
0
 internal override bool apply(ParseContext ctxt, ref D_ result, ref AbstractParsecError err)
 {
     int at = ctxt.getAt();
     string src = ctxt.getSource();
     int mlen = pp.Match(src, at, src.Length);
     if (mlen < 0)
     {
         return Scanners.setErrorExpecting(out err, expected_name, ctxt);
     }
     ctxt.next(mlen);
     return true;
 }
Пример #4
0
            internal override bool apply(ParseContext ctxt, ref D_ result, ref AbstractParsecError err)
            {
                int    at   = ctxt.getAt();
                string src  = ctxt.getSource();
                int    mlen = pp.Match(src, at, src.Length);

                if (mlen < 0)
                {
                    return(Scanners.setErrorExpecting(out err, expected_name, ctxt));
                }
                ctxt.next(mlen);
                return(true);
            }
Пример #5
0
 internal override bool apply(ParseContext ctxt, ref D_ result, ref AbstractParsecError err)
 {
     if (!open.parse(ctxt, ref result, ref err))
     {
         return(false);
     }
     for (int level = 1; level > 0;)
     {
         int at = ctxt.getAt();
         if (close.parse(ctxt, ref result, ref err))
         {
             if (at == ctxt.getAt())
             {
                 throw new IllegalParserStateException("closing comment scanner not consuming input.");
             }
             level--;
             continue;
         }
         if (at != ctxt.getAt())
         {
             return(false);
         }
         if (open.parse(ctxt, ref result, ref err))
         {
             if (at == ctxt.getAt())
             {
                 throw new IllegalParserStateException("opening comment scanner not consuming input.");
             }
             level++;
             continue;
         }
         if (at != ctxt.getAt())
         {
             return(false);
         }
         if (commented.parse(ctxt, ref result, ref err))
         {
             if (at == ctxt.getAt())
             {
                 throw new IllegalParserStateException("commented scanner not consuming input.");
             }
             continue;
         }
         return(false);
     }
     return(true);
 }
Пример #6
0
 internal override bool apply(ParseContext ctxt, ref D_ result, ref AbstractParsecError err)
 {
     if (!open.parse(ctxt, ref result, ref err))
     {
         return false;
     }
     for (int level = 1; level > 0; )
     {
         int at = ctxt.getAt();
         if (close.parse(ctxt, ref result, ref err))
         {
             if (at == ctxt.getAt())
             {
                 throw new IllegalParserStateException("closing comment scanner not consuming input.");
             }
             level--;
             continue;
         }
         if (at != ctxt.getAt())
         {
             return false;
         }
         if (open.parse(ctxt, ref result, ref err))
         {
             if (at == ctxt.getAt())
                 throw new IllegalParserStateException("opening comment scanner not consuming input.");
             level++;
             continue;
         }
         if (at != ctxt.getAt())
         {
             return false;
         }
         if (commented.parse(ctxt, ref result, ref err))
         {
             if (at == ctxt.getAt())
                 throw new IllegalParserStateException("commented scanner not consuming input.");
             continue;
         }
         return false;
     }
     return true;
 }
Пример #7
0
 internal override bool apply(ParseContext ctxt, ref D_ result, ref AbstractParsecError err)
 {
     int from = ctxt.getAt();
     if (!outer_scanner.parse(ctxt, ref result, ref err))
         return false;
     ScannerState inner_ctxt = new ScannerState(ctxt.getSource(), from, module, ctxt.getPositionMap(),
       ctxt.getAt() - from);
     return ParserChores.cont(ctxt, inner_ctxt, nested, ref result, ref err);
 }