Beispiel #1
0
 public Parser(
     MarkedString source,
     Dictionary <string, Variable> vars,
     Dictionary <string, MethodOperation.Factory> funcs
     ) :
     base(new VarAssignLexer(source, vars, funcs), vars, funcs)
 {
 }
Beispiel #2
0
 public static IBaseExpression Parse(
     MarkedString expr,
     Dictionary <string, Variable> vars,
     Dictionary <string, MethodOperation.Factory> funcs
     )
 {
     return(new Parser(expr, vars, funcs).Parse());
 }
Beispiel #3
0
 public void RevertToCopy(MarkedString other)
 {
     pos              = other.pos;
     cachedPos        = other.cachedPos;
     Line             = other.Line;
     CachedLine       = other.CachedLine;
     CharInLine       = other.CharInLine;
     CachedCharInLine = other.CachedCharInLine;
 }
Beispiel #4
0
        public int Match(MarkedString source)
        {
            var res = source.MatchOne(regex);

            if (!res.Success)
            {
                LastError = "no match for '" + regex.ToString() + "' regex";
            }
            else
            {
                LastError = "";
            }
            lastMatch = res.Value;
            return(res.Success ? res.Length : -1);
        }
Beispiel #5
0
        public int Match(MarkedString source)
        {
            MarkedString saved = source.ShallowCopy();

            int last = source.AbsoluteAt;

            lastMatch = factory(source);
            if (lastMatch == null)
            {
                source.RevertToCopy(saved);
                LastError = "cannot parse " + name;
                return(-1);
            }
            int res = source.AbsoluteAt - last;

            source.RevertToCopy(saved);
            return(res);
        }
Beispiel #6
0
 public static VarDefStatement Parse(
     MarkedString source,
     Dictionary <string, Variable> vars
     ) =>
 new Parser(source, vars).Parse();
Beispiel #7
0
 public static VarAssignStatement Parse(
     MarkedString source,
     Dictionary <string, Variable> vars,
     Dictionary <string, MethodOperation.Factory> funcs
     ) => new Parser(source, vars, funcs).Parse();
Beispiel #8
0
 public Parser(MarkedString source, Dictionary <string, Variable> vars) :
     base(new VarDefLexer(source), vars)
 {
 }