Skip to content

Problem Matching Sets #35

Open
Open
@DavePearce

Description

@DavePearce

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions