Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem Matching Sets #35

Open
DavePearce opened this issue Jun 20, 2016 · 0 comments
Open

Problem Matching Sets #35

DavePearce opened this issue Jun 20, 2016 · 0 comments

Comments

@DavePearce
Copy link
Member

DavePearce commented Jun 20, 2016

The following WyRL program:

term X
term Y
term Z
define YZ as Y | Z
term C{X,YZ...}

reduce C{X x,Y,YZ... yzs}:
    => C(x++yzs)

Generates the following probe() code:

public final void probe(Automaton automaton, int target, List activations) {
            int r0 = target;
            Automaton.State s0 = automaton.get(r0);
            if(s0.kind == K_C) {
                Automaton.Term t0 = (Automaton.Term) s0;
                int r1 = t0.contents;
                Automaton.State s1 = automaton.get(r1);
                Automaton.Collection c1 = (Automaton.Collection) s1;
                if(c1.size() >= 2) {
                    for(int r3=0;r3!=c1.size();++r3) {
                        int r2 = c1.get(r3);
                        for(int r5=0;r5!=c1.size();++r5) {
                            if(r5 == r3) { continue; }
                            int r4 = c1.get(r5);
                            if(Runtime.accepts(type1,automaton,automaton.get(r4), SCHEMA)) {
                                int[] state = {r0, r1, r2, r3, r4, r5, 0};
                                activations.add(new Reduction.Activation(this,null,state));
                            }
                        }
                    }
                }
            }
        }

If we look very carefully, we can notice that r2 (which represents x) is never tested against the type X. This generates potentially invalid matches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant