- public Singleton(Element e, HashSet<Sequence> and, HashSet<Sequence> not) { this(new Element[] { e }, 0, and, not); }
- public Singleton(Element[] e, int idx, HashSet<Sequence> and, HashSet<Sequence> not) { super(e, and, not); this.idx = idx; }
- public <T> Forest<T> postReduce(Token.Location loc, Forest<T>[] args) { return (Forest<T>)Forest.singleton(loc, args[idx], this); }
- }
-
- public static class Unwrap extends Sequence {
- private boolean[] drops;
- public Unwrap(Element[] e, HashSet<Sequence> and, HashSet<Sequence> not) { super(e, and, not); this.drops = null; }
- public Unwrap(Element[] e, boolean[] drops, HashSet<Sequence> and, HashSet<Sequence> not) { super(e, and, not); this.drops = drops; }
- public <T> Forest<T> postReduce(Token.Location loc, Forest<T>[] args) {
- for(int i=0; i<args.length; i++) if (args[i]==null) throw new Error();
- if (drops==null) return Forest.create(loc, null, args, this, true, false);
- int count = 0;
- for(int i=0; i<drops.length; i++) if (!drops[i]) count++;
- Forest<T>[] args2 = new Forest[count];
- int j = 0;
- for(int i=0; i<args.length; i++) if (!drops[i]) args2[j++] = args[i];
- return Forest.create(loc, null, args2, this, true, false);
+ public Singleton(Element e) { this(new Element[] { e }, 0); }
+ public Singleton(Element[] e, int idx) { super(e); this.idx = idx; }
+ public <T> Forest<T> postReduce(Input.Region loc, Forest<T>[] args, Position p) { return args[idx]; }
+ Sequence _clone() { return new Singleton(elements,idx); }
+ Forest epsilonForm(Input.Region loc) {
+ return ((Union)elements[idx]).epsilonForm(loc);