Ejemplo n.º 1
0
    public override LAD Reify(NFA pad)
    {
        if (Lexer.LtmTrace)
            Console.WriteLine("+ Processing subrule {0}", name);
        if (name == "ws")
            return new LADImp();
        pad.used_methods.Add(name);

        if (pad.method_stack.Contains(name)) {
            // NFAs cannot be recursive, so treat this as the end of the
            // declarative prefix.
            if (Lexer.LtmTrace)
                Console.WriteLine("+ Pruning to avoid recursion");
            return new LADImp();
        }

        Frame outer;
        LAD sub = pad.ResolveMethod(name, out outer);

        pad.method_stack.Add(name);
        pad.outer_stack.Add(outer);

        LAD ret;
        if (sub == null) {
            ret = new LADImp();
        } else {
            ret = sub.Reify(pad);
        }

        pad.method_stack.Remove(name);
        pad.outer_stack.RemoveAt(pad.outer_stack.Count - 1);

        return ret;
    }