001    /*
002     * LAPIS lightweight structured text processing system
003     *
004     * Copyright (C) 1998-2002 Carnegie Mellon University,
005     * Copyright (C) 2003 Massachusetts Institute of Technology.
006     * All rights reserved.
007     *
008     * This library is free software; you can redistribute it
009     * and/or modify it under the terms of the GNU General
010     * Public License as published by the Free Software
011     * Foundation, version 2.
012     *
013     * LAPIS homepage: http://graphics.lcs.mit.edu/lapis/
014     */
015    
016    package lapis.tc;
017    
018    public class Cloner implements Visitor {
019        public Object forAnd (TC.And n) {
020            return new TC.And ((TC.Node) n.getArg1 ().accept (this),
021                            (TC.Node) n.getArg2 ().accept (this));
022        }
023        public Object forOr (TC.Or n) {
024            return new TC.Or ((TC.Node) n.getArg1 ().accept (this),
025                           (TC.Node) n.getArg2 ().accept (this));
026        }
027        public Object forButNot (TC.ButNot n) {
028            return new TC.ButNot ((TC.Node) n.getArg1 ().accept (this),
029                               (TC.Node) n.getArg2 ().accept (this));
030        }
031        public Object forOrButNot (TC.OrButNot n){
032            return new TC.OrButNot ((TC.Node) n.getArg1 ().accept (this),
033                                 (TC.Node) n.getArg2 ().accept (this),
034                                 (TC.Node) n.getArg3 ().accept (this));
035        }
036        public Object forEquals (TC.Equals n) {
037            return new TC.Equals ((TC.Node) n.getArg ().accept (this));
038        }
039        public Object forBefore (TC.Before n) {
040            return new TC.Before ((TC.Node) n.getArg ().accept (this));
041        }
042        public Object forAfter (TC.After n) {
043            return new TC.After ((TC.Node) n.getArg ().accept (this));
044        }
045        public Object forJustBefore (TC.JustBefore n) {
046            return new TC.JustBefore ((TC.Node) n.getArg ().accept (this));
047        }
048        public Object forJustAfter (TC.JustAfter n) {
049            return new TC.JustAfter ((TC.Node) n.getArg ().accept (this));
050        }
051        public Object forBeforeDelimited (TC.BeforeDelimited n) {
052            return new TC.BeforeDelimited ((TC.Node) n.getArg ().accept (this));
053        }
054        public Object forAfterDelimited (TC.AfterDelimited n) {
055            return new TC.AfterDelimited ((TC.Node) n.getArg ().accept (this));
056        }
057        public Object forJustBeforeDelimited (TC.JustBeforeDelimited n) {
058            return new TC.JustBeforeDelimited ((TC.Node) n.getArg ().accept (this));
059        }
060        public Object forJustAfterDelimited (TC.JustAfterDelimited n) {
061            return new TC.JustAfterDelimited ((TC.Node) n.getArg ().accept (this));
062        }
063    
064        public Object forIn (TC.In n) {
065            return new TC.In ((TC.Node) n.getArg ().accept (this));
066        }
067        public Object forContains (TC.Contains n) {
068            return new TC.Contains ((TC.Node) n.getArg ().accept (this));
069        }
070    
071        public Object forDescendant (TC.Descendant n) {
072            return new TC.Descendant ((TC.Node) n.getArg ().accept (this));
073        }
074        public Object forAncestor (TC.Ancestor n) {
075            return new TC.Ancestor ((TC.Node) n.getArg ().accept (this));
076        }
077    
078        public Object forStarting (TC.Starting n) {
079            return new TC.Starting ((TC.Node) n.getArg ().accept (this));
080        }
081        public Object forEnding (TC.Ending n) {
082            return new TC.Ending ((TC.Node) n.getArg ().accept (this));
083        }
084        public Object forStartingDelimited (TC.StartingDelimited n) {
085            return new TC.StartingDelimited ((TC.Node) n.getArg ().accept (this));
086        }
087        public Object forEndingDelimited (TC.EndingDelimited n) {
088            return new TC.EndingDelimited ((TC.Node) n.getArg ().accept (this));
089        }
090        public Object forOverlapsStart (TC.OverlapsStart n) {
091            return new TC.OverlapsStart ((TC.Node) n.getArg ().accept (this));
092        }
093        public Object forOverlapsEnd (TC.OverlapsEnd n) {
094            return new TC.OverlapsEnd ((TC.Node) n.getArg ().accept (this));
095        }
096        public Object forOverlaps (TC.Overlaps n) {
097            return new TC.Overlaps ((TC.Node) n.getArg ().accept (this));
098        }
099        public Object forSeparatedBy (TC.SeparatedBy n) {
100            return new TC.SeparatedBy ((TC.Node) n.getArg ().accept (this));
101        }
102        public Object forStartOf (TC.StartOf n) {
103            return new TC.StartOf ((TC.Node) n.getArg ().accept (this));
104        }
105        public Object forEndOf (TC.EndOf n) {
106            return new TC.EndOf ((TC.Node) n.getArg ().accept (this));
107        }
108        public Object forBalancedUnary (TC.BalancedUnary n) {
109            return new TC.BalancedUnary ((TC.Node) n.getArg ().accept (this));
110        }
111        public Object forBalancedBinary (TC.BalancedBinary n){
112            return new TC.BalancedBinary ((TC.Node) n.getArg1 ().accept (this),
113                                       (TC.Node) n.getArg2 ().accept (this));
114        }
115        public Object forFromTo (TC.FromTo n){
116            return new TC.FromTo ((TC.Node) n.getArg1 ().accept (this),
117                                  (TC.Node) n.getArg2 ().accept (this));
118        }
119        public Object forConstant (TC.Constant n) {
120            return n;
121        }
122        public Object forExternalPattern (TC.ExternalPattern n) {
123            return n;
124        }
125        public Object forLiteral (TC.Literal n) {
126            return n;
127        }
128        public Object forRegexp (TC.Regexp n) {
129            return n;
130        }
131        public Object forId (TC.Id n) {
132            return n;
133        }
134        public Object forAny (TC.Any n) {
135            return n;
136        }
137        public Object forNothing (TC.Nothing n) {
138            return n;
139        }
140        public Object forNextTo (TC.NextTo n) {
141            return new TC.NextTo ((TC.Node) n.getArg1 ().accept (this),
142                               (TC.Node) n.getArg2 ().accept (this));
143        }
144        public Object forTrim (TC.Trim n) {
145            return new TC.Trim ((TC.Node) n.getArg1 ().accept (this),
146                             (TC.Node) n.getArg2 ().accept (this));
147        }
148        public Object forInclude (TC.Include n) {
149            return new TC.Include ((TC.Node) n.getArg1 ().accept (this),
150                             (TC.Node) n.getArg2 ().accept (this));
151        }
152        public Object forAssign (TC.Assign n) {
153            return new TC.Assign (n.getString (),
154                                  (TC.Node) n.getArg ().accept (this));
155        }
156        public Object forSeq (TC.Seq n) {
157            return new TC.Seq ((TC.Node) n.getArg1 ().accept (this),
158                            (TC.Node) n.getArg2 ().accept (this));
159        }
160        public Object forIgnoreBinary (TC.IgnoreBinary n) {
161            return new TC.IgnoreBinary ((TC.Node) n.getArg1 ().accept (this),
162                                     (TC.Node) n.getArg2 ().accept (this));
163        }
164        public Object forNth (TC.Nth n){
165            return new TC.Nth (n.getCount (),
166                            (TC.Node) n.getCounter ().accept (this),
167                            (TC.Node) n.getContext ().accept (this));
168        }
169        public Object forFlatten (TC.Flatten n) {
170            return new TC.Flatten ((TC.Node) n.getArg ().accept (this));
171        }
172        public Object forUnbind (TC.Unbind n) {
173            return new TC.Unbind ((TC.Node) n.getArg ().accept (this));
174        }
175        public Object forMelt (TC.Melt n) {
176            return new TC.Melt ((TC.Node) n.getArg ().accept (this));
177        }
178        public Object forCrispen (TC.Crispen n) {
179            return new TC.Crispen ((TC.Node) n.getArg ().accept (this));
180        }
181        public Object forNonempty (TC.Nonempty n) {
182            return new TC.Nonempty ((TC.Node) n.getArg ().accept (this));
183        }
184        public Object forPrefix (TC.Prefix n) {
185            return new TC.Prefix (n.getPrefix (), 
186                                  (TC.Node) n.getArg ().accept (this));
187        }
188        public Object forCaseSensitivity (TC.CaseSensitivity n) {
189            return new TC.CaseSensitivity (n.getCaseSensitive (), 
190                                           (TC.Node) n.getArg ().accept (this));
191        }
192        public Object forView (TC.View n) {
193            return new TC.View (n.getView (), 
194                                (TC.Node) n.getArg ().accept (this));
195        }
196    }