Exemple #1
0
 public Parser(
     MarkedString source,
     Dictionary <string, Variable> vars,
     Dictionary <string, MethodOperation.Factory> funcs
     ) :
     base(new VarAssignLexer(source, vars, funcs), vars, funcs)
 {
 }
 public static IBaseExpression Parse(
     MarkedString expr,
     Dictionary <string, Variable> vars,
     Dictionary <string, MethodOperation.Factory> funcs
     )
 {
     return(new Parser(expr, vars, funcs).Parse());
 }
Exemple #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;
 }
Exemple #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);
        }
Exemple #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);
        }
Exemple #6
0
 public static VarDefStatement Parse(
     MarkedString source,
     Dictionary <string, Variable> vars
     ) =>
 new Parser(source, vars).Parse();
Exemple #7
0
 public static VarAssignStatement Parse(
     MarkedString source,
     Dictionary <string, Variable> vars,
     Dictionary <string, MethodOperation.Factory> funcs
     ) => new Parser(source, vars, funcs).Parse();
Exemple #8
0
 public Parser(MarkedString source, Dictionary <string, Variable> vars) :
     base(new VarDefLexer(source), vars)
 {
 }