001: //----------------------------------------------------
002: // The following code was generated by CUP v0.10j
003: // Tue Jul 06 21:50:16 EDT 2004
004: //----------------------------------------------------
005:
006: package com.Ostermiller.bte;
007:
008: import java_cup.runtime.*;
009: import java.io.*;
010: import java.util.*;
011:
012: /** CUP v0.10j generated parser.
013: * @version Tue Jul 06 21:50:16 EDT 2004
014: */
015: public class parser extends java_cup.runtime.lr_parser {
016:
017: /** Default constructor. */
018: public parser() {
019: super ();
020: }
021:
022: /** Constructor which sets the default scanner. */
023: public parser(java_cup.runtime.Scanner s) {
024: super (s);
025: }
026:
027: /** Production table. */
028: protected static final short _production_table[][] = unpackFromStrings(new String[] { "\000\024\000\002\003\011\000\002\002\004\000\002\005"
029: + "\004\000\002\005\002\000\002\004\006\000\002\007\004"
030: + "\000\002\007\002\000\002\006\003\000\002\006\003\000"
031: + "\002\006\003\000\002\006\003\000\002\006\003\000\002"
032: + "\015\006\000\002\012\005\000\002\013\005\000\002\013"
033: + "\002\000\002\011\003\000\002\010\005\000\002\014\003"
034: + "\000\002\014\002" });
035:
036: /** Access to production table. */
037: public short[][] production_table() {
038: return _production_table;
039: }
040:
041: /** Parse-action table. */
042: protected static final short[][] _action_table = unpackFromStrings(new String[] { "\000\046\000\006\011\uffee\016\006\001\002\000\004\011"
043: + "\010\001\002\000\004\002\007\001\002\000\016\002\uffef"
044: + "\004\uffef\007\uffef\011\uffef\012\uffef\014\uffef\001\002\000"
045: + "\004\002\000\001\002\000\006\004\uffee\016\006\001\002"
046: + "\000\004\004\013\001\002\000\006\004\013\012\ufffe\001"
047: + "\002\000\016\005\ufffb\006\022\007\017\013\015\015\023"
048: + "\016\016\001\002\000\020\005\ufffb\006\022\007\017\010"
049: + "\ufffb\013\015\015\023\016\016\001\002\000\006\007\uffee"
050: + "\016\006\001\002\000\020\005\ufff8\006\ufff8\007\ufff8\010"
051: + "\ufff8\013\ufff8\015\ufff8\016\ufff8\001\002\000\016\006\022"
052: + "\007\017\010\ufffb\013\015\015\023\016\016\001\002\000"
053: + "\020\005\ufff6\006\ufff6\007\ufff6\010\ufff6\013\ufff6\015\ufff6"
054: + "\016\ufff6\001\002\000\004\005\025\001\002\000\020\005"
055: + "\ufffa\006\ufffa\007\ufffa\010\ufffa\013\ufffa\015\ufffa\016\ufffa"
056: + "\001\002\000\020\005\ufff9\006\ufff9\007\ufff9\010\ufff9\013"
057: + "\ufff9\015\ufff9\016\ufff9\001\002\000\020\005\ufff7\006\ufff7"
058: + "\007\ufff7\010\ufff7\013\ufff7\015\ufff7\016\ufff7\001\002\000"
059: + "\010\004\uffee\012\uffee\016\006\001\002\000\006\004\ufffd"
060: + "\012\ufffd\001\002\000\004\010\030\001\002\000\022\005"
061: + "\ufff0\006\ufff0\007\ufff0\010\ufff0\013\ufff0\014\ufff0\015\ufff0"
062: + "\016\ufff0\001\002\000\004\007\017\001\002\000\004\014"
063: + "\042\001\002\000\010\007\uffee\014\uffee\016\006\001\002"
064: + "\000\010\007\ufff1\014\ufff1\016\ufff1\001\002\000\006\007"
065: + "\017\014\ufff2\001\002\000\010\007\uffee\014\uffee\016\006"
066: + "\001\002\000\004\014\ufff4\001\002\000\006\007\017\014"
067: + "\ufff2\001\002\000\004\014\ufff3\001\002\000\020\005\ufff5"
068: + "\006\ufff5\007\ufff5\010\ufff5\013\ufff5\015\ufff5\016\ufff5\001"
069: + "\002\000\006\005\ufffc\010\ufffc\001\002\000\006\004\013"
070: + "\012\ufffe\001\002\000\004\012\046\001\002\000\006\002"
071: + "\uffee\016\006\001\002\000\004\002\001\001\002\000\004"
072: + "\012\uffff\001\002" });
073:
074: /** Access to parse-action table. */
075: public short[][] action_table() {
076: return _action_table;
077: }
078:
079: /** <code>reduce_goto</code> table. */
080: protected static final short[][] _reduce_table = unpackFromStrings(new String[] { "\000\046\000\006\003\004\014\003\001\001\000\002\001"
081: + "\001\000\002\001\001\000\002\001\001\000\002\001\001"
082: + "\000\004\014\010\001\001\000\004\004\011\001\001\000"
083: + "\006\004\043\005\044\001\001\000\012\006\013\007\020"
084: + "\010\023\015\017\001\001\000\012\006\013\007\042\010"
085: + "\023\015\017\001\001\000\004\014\030\001\001\000\002"
086: + "\001\001\000\012\006\013\007\026\010\023\015\017\001"
087: + "\001\000\002\001\001\000\002\001\001\000\002\001\001"
088: + "\000\002\001\001\000\002\001\001\000\004\014\025\001"
089: + "\001\000\002\001\001\000\002\001\001\000\002\001\001"
090: + "\000\010\010\033\011\032\012\031\001\001\000\002\001"
091: + "\001\000\004\014\034\001\001\000\002\001\001\000\010"
092: + "\010\033\011\035\013\036\001\001\000\004\014\037\001"
093: + "\001\000\002\001\001\000\010\010\033\011\035\013\040"
094: + "\001\001\000\002\001\001\000\002\001\001\000\002\001"
095: + "\001\000\006\004\043\005\047\001\001\000\002\001\001"
096: + "\000\004\014\046\001\001\000\002\001\001\000\002\001"
097: + "\001" });
098:
099: /** Access to <code>reduce_goto</code> table. */
100: public short[][] reduce_table() {
101: return _reduce_table;
102: }
103:
104: /** Instance of action encapsulation class. */
105: protected CUP$parser$actions action_obj;
106:
107: /** Action encapsulation object initializer. */
108: protected void init_actions() {
109: action_obj = new CUP$parser$actions(this );
110: }
111:
112: /** Invoke a user supplied parse action. */
113: public java_cup.runtime.Symbol do_action(int act_num,
114: java_cup.runtime.lr_parser parser, java.util.Stack stack,
115: int top) throws java.lang.Exception {
116: /* call code in generated class */
117: return action_obj.CUP$parser$do_action(act_num, parser, stack,
118: top);
119: }
120:
121: /** Indicates start state. */
122: public int start_state() {
123: return 0;
124: }
125:
126: /** Indicates start production. */
127: public int start_production() {
128: return 1;
129: }
130:
131: /** <code>EOF</code> Symbol index. */
132: public int EOF_sym() {
133: return 0;
134: }
135:
136: /** <code>error</code> Symbol index. */
137: public int error_sym() {
138: return 1;
139: }
140:
141: /** Scan to get the next Symbol. */
142: public java_cup.runtime.Symbol scan() throws java.lang.Exception {
143: return getScanner().next_token();
144: }
145:
146: /**
147: * Parses a file or System.in.
148: * If no arguments are given, System.in will be used for input.
149: * If more arguments are given, the first argument will be used as
150: * the name of the file to use as input
151: *
152: * @param args program arguments, of which the first is a filename
153: */
154: public static void main(String[] args) {
155: InputStream in;
156: try {
157: if (args.length > 0) {
158: File f = new File(args[0]);
159: if (f.exists()) {
160: if (f.canRead()) {
161: in = new FileInputStream(f);
162: } else {
163: throw new IOException("Could not open "
164: + args[0]);
165: }
166: } else {
167: throw new IOException("Could not find " + args[0]);
168: }
169: } else {
170: in = System.in;
171: }
172: BTEFile f = (BTEFile) (((new parser(new Lexer(in))).parse()).value);
173: Writer warningWriter = new OutputStreamWriter(System.err);
174: f.printWarnings(warningWriter, "System.in", "System.in");
175: warningWriter.flush();
176: System.out.println(f);
177: } catch (Exception e) {
178: System.out.println(e.getMessage());
179: e.printStackTrace();
180: }
181: }
182:
183: public void syntax_error(Symbol cur_token) {
184: }
185:
186: public void unrecovered_syntax_error(Symbol cur_token)
187: throws Exception {
188: Token t = ((Token) cur_token.value);
189: String s = t.getContents();
190: if (s.length() > 50) {
191: s = s.substring(0, 50);
192: }
193: int i = s.indexOf("\n");
194: int j = s.indexOf("\r");
195: if (j != -1 && j < i) {
196: i = j;
197: }
198: if (i != -1) {
199: s = s.substring(0, i);
200: }
201: throw new ParseException("Syntax Error on line "
202: + t.getLineNumber() + ": "
203: + ((s.length() > 50) ? (s.substring(0, 50)) : (s)));
204: }
205:
206: }
207:
208: /** Cup generated class to encapsulate user supplied action code.*/
209: class CUP$parser$actions {
210: private final parser parser;
211:
212: /** Constructor */
213: CUP$parser$actions(parser parser) {
214: this .parser = parser;
215: }
216:
217: /** Method with the actual generated action code. */
218: public final java_cup.runtime.Symbol CUP$parser$do_action(
219: int CUP$parser$act_num,
220: java_cup.runtime.lr_parser CUP$parser$parser,
221: java.util.Stack CUP$parser$stack, int CUP$parser$top)
222: throws java.lang.Exception {
223: /* Symbol object for return from actions */
224: java_cup.runtime.Symbol CUP$parser$result;
225:
226: /* select the action based on the action number */
227: switch (CUP$parser$act_num) {
228: /*. . . . . . . . . . . . . . . . . . . .*/
229: case 19: // whitespace_opt ::=
230: {
231: Object RESULT = null;
232:
233: CUP$parser$result = new java_cup.runtime.Symbol(
234: 10/*whitespace_opt*/,
235: ((java_cup.runtime.Symbol) CUP$parser$stack
236: .elementAt(CUP$parser$top - 0)).right,
237: ((java_cup.runtime.Symbol) CUP$parser$stack
238: .elementAt(CUP$parser$top - 0)).right,
239: RESULT);
240: }
241: return CUP$parser$result;
242:
243: /*. . . . . . . . . . . . . . . . . . . .*/
244: case 18: // whitespace_opt ::= WHITESPACE
245: {
246: Object RESULT = null;
247:
248: CUP$parser$result = new java_cup.runtime.Symbol(
249: 10/*whitespace_opt*/,
250: ((java_cup.runtime.Symbol) CUP$parser$stack
251: .elementAt(CUP$parser$top - 0)).left,
252: ((java_cup.runtime.Symbol) CUP$parser$stack
253: .elementAt(CUP$parser$top - 0)).right,
254: RESULT);
255: }
256: return CUP$parser$result;
257:
258: /*. . . . . . . . . . . . . . . . . . . .*/
259: case 17: // group ::= START_GROUP template_elements_opt END_GROUP
260: {
261: Object RESULT = null;
262: int t1left = ((java_cup.runtime.Symbol) CUP$parser$stack
263: .elementAt(CUP$parser$top - 2)).left;
264: int t1right = ((java_cup.runtime.Symbol) CUP$parser$stack
265: .elementAt(CUP$parser$top - 2)).right;
266: Object t1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
267: .elementAt(CUP$parser$top - 2)).value;
268: int e1left = ((java_cup.runtime.Symbol) CUP$parser$stack
269: .elementAt(CUP$parser$top - 1)).left;
270: int e1right = ((java_cup.runtime.Symbol) CUP$parser$stack
271: .elementAt(CUP$parser$top - 1)).right;
272: Object e1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
273: .elementAt(CUP$parser$top - 1)).value;
274:
275: Group g = new Group((Token) t1);
276: g.elements = (Element) e1;
277: RESULT = g;
278:
279: CUP$parser$result = new java_cup.runtime.Symbol(
280: 6/*group*/,
281: ((java_cup.runtime.Symbol) CUP$parser$stack
282: .elementAt(CUP$parser$top - 2)).left,
283: ((java_cup.runtime.Symbol) CUP$parser$stack
284: .elementAt(CUP$parser$top - 0)).right,
285: RESULT);
286: }
287: return CUP$parser$result;
288:
289: /*. . . . . . . . . . . . . . . . . . . .*/
290: case 16: // one_element ::= group
291: {
292: Object RESULT = null;
293: int e1left = ((java_cup.runtime.Symbol) CUP$parser$stack
294: .elementAt(CUP$parser$top - 0)).left;
295: int e1right = ((java_cup.runtime.Symbol) CUP$parser$stack
296: .elementAt(CUP$parser$top - 0)).right;
297: Object e1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
298: .elementAt(CUP$parser$top - 0)).value;
299:
300: RESULT = e1;
301:
302: CUP$parser$result = new java_cup.runtime.Symbol(
303: 7/*one_element*/,
304: ((java_cup.runtime.Symbol) CUP$parser$stack
305: .elementAt(CUP$parser$top - 0)).left,
306: ((java_cup.runtime.Symbol) CUP$parser$stack
307: .elementAt(CUP$parser$top - 0)).right,
308: RESULT);
309: }
310: return CUP$parser$result;
311:
312: /*. . . . . . . . . . . . . . . . . . . .*/
313: case 15: // one_elements_opt ::=
314: {
315: Object RESULT = null;
316:
317: CUP$parser$result = new java_cup.runtime.Symbol(
318: 9/*one_elements_opt*/,
319: ((java_cup.runtime.Symbol) CUP$parser$stack
320: .elementAt(CUP$parser$top - 0)).right,
321: ((java_cup.runtime.Symbol) CUP$parser$stack
322: .elementAt(CUP$parser$top - 0)).right,
323: RESULT);
324: }
325: return CUP$parser$result;
326:
327: /*. . . . . . . . . . . . . . . . . . . .*/
328: case 14: // one_elements_opt ::= one_element whitespace_opt one_elements_opt
329: {
330: Object RESULT = null;
331: int t1left = ((java_cup.runtime.Symbol) CUP$parser$stack
332: .elementAt(CUP$parser$top - 2)).left;
333: int t1right = ((java_cup.runtime.Symbol) CUP$parser$stack
334: .elementAt(CUP$parser$top - 2)).right;
335: Object t1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
336: .elementAt(CUP$parser$top - 2)).value;
337: int t2left = ((java_cup.runtime.Symbol) CUP$parser$stack
338: .elementAt(CUP$parser$top - 0)).left;
339: int t2right = ((java_cup.runtime.Symbol) CUP$parser$stack
340: .elementAt(CUP$parser$top - 0)).right;
341: Object t2 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
342: .elementAt(CUP$parser$top - 0)).value;
343:
344: /* Add the newly discovered element to
345: the head of the linked list */
346: ((Element) t1).next = (Element) t2;
347: RESULT = t1;
348:
349: CUP$parser$result = new java_cup.runtime.Symbol(
350: 9/*one_elements_opt*/,
351: ((java_cup.runtime.Symbol) CUP$parser$stack
352: .elementAt(CUP$parser$top - 2)).left,
353: ((java_cup.runtime.Symbol) CUP$parser$stack
354: .elementAt(CUP$parser$top - 0)).right,
355: RESULT);
356: }
357: return CUP$parser$result;
358:
359: /*. . . . . . . . . . . . . . . . . . . .*/
360: case 13: // one_elements ::= one_element whitespace_opt one_elements_opt
361: {
362: Object RESULT = null;
363: int t1left = ((java_cup.runtime.Symbol) CUP$parser$stack
364: .elementAt(CUP$parser$top - 2)).left;
365: int t1right = ((java_cup.runtime.Symbol) CUP$parser$stack
366: .elementAt(CUP$parser$top - 2)).right;
367: Object t1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
368: .elementAt(CUP$parser$top - 2)).value;
369: int t2left = ((java_cup.runtime.Symbol) CUP$parser$stack
370: .elementAt(CUP$parser$top - 0)).left;
371: int t2right = ((java_cup.runtime.Symbol) CUP$parser$stack
372: .elementAt(CUP$parser$top - 0)).right;
373: Object t2 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
374: .elementAt(CUP$parser$top - 0)).value;
375:
376: /* Add the newly discovered element to
377: the head of the linked list */
378: ((Element) t1).next = (Element) t2;
379: RESULT = t1;
380:
381: CUP$parser$result = new java_cup.runtime.Symbol(
382: 8/*one_elements*/,
383: ((java_cup.runtime.Symbol) CUP$parser$stack
384: .elementAt(CUP$parser$top - 2)).left,
385: ((java_cup.runtime.Symbol) CUP$parser$stack
386: .elementAt(CUP$parser$top - 0)).right,
387: RESULT);
388: }
389: return CUP$parser$result;
390:
391: /*. . . . . . . . . . . . . . . . . . . .*/
392: case 12: // one ::= START_ONE whitespace_opt one_elements END_ONE
393: {
394: Object RESULT = null;
395: int t1left = ((java_cup.runtime.Symbol) CUP$parser$stack
396: .elementAt(CUP$parser$top - 3)).left;
397: int t1right = ((java_cup.runtime.Symbol) CUP$parser$stack
398: .elementAt(CUP$parser$top - 3)).right;
399: Object t1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
400: .elementAt(CUP$parser$top - 3)).value;
401: int e1left = ((java_cup.runtime.Symbol) CUP$parser$stack
402: .elementAt(CUP$parser$top - 1)).left;
403: int e1right = ((java_cup.runtime.Symbol) CUP$parser$stack
404: .elementAt(CUP$parser$top - 1)).right;
405: Object e1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
406: .elementAt(CUP$parser$top - 1)).value;
407:
408: One o = new One((Token) t1);
409: o.elements = (Element) e1;
410: RESULT = o;
411:
412: CUP$parser$result = new java_cup.runtime.Symbol(11/*one*/,
413: ((java_cup.runtime.Symbol) CUP$parser$stack
414: .elementAt(CUP$parser$top - 3)).left,
415: ((java_cup.runtime.Symbol) CUP$parser$stack
416: .elementAt(CUP$parser$top - 0)).right,
417: RESULT);
418: }
419: return CUP$parser$result;
420:
421: /*. . . . . . . . . . . . . . . . . . . .*/
422: case 11: // template_element ::= one
423: {
424: Object RESULT = null;
425: int o1left = ((java_cup.runtime.Symbol) CUP$parser$stack
426: .elementAt(CUP$parser$top - 0)).left;
427: int o1right = ((java_cup.runtime.Symbol) CUP$parser$stack
428: .elementAt(CUP$parser$top - 0)).right;
429: Object o1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
430: .elementAt(CUP$parser$top - 0)).value;
431:
432: RESULT = o1;
433:
434: CUP$parser$result = new java_cup.runtime.Symbol(
435: 4/*template_element*/,
436: ((java_cup.runtime.Symbol) CUP$parser$stack
437: .elementAt(CUP$parser$top - 0)).left,
438: ((java_cup.runtime.Symbol) CUP$parser$stack
439: .elementAt(CUP$parser$top - 0)).right,
440: RESULT);
441: }
442: return CUP$parser$result;
443:
444: /*. . . . . . . . . . . . . . . . . . . .*/
445: case 10: // template_element ::= group
446: {
447: Object RESULT = null;
448: int e1left = ((java_cup.runtime.Symbol) CUP$parser$stack
449: .elementAt(CUP$parser$top - 0)).left;
450: int e1right = ((java_cup.runtime.Symbol) CUP$parser$stack
451: .elementAt(CUP$parser$top - 0)).right;
452: Object e1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
453: .elementAt(CUP$parser$top - 0)).value;
454:
455: RESULT = e1;
456:
457: CUP$parser$result = new java_cup.runtime.Symbol(
458: 4/*template_element*/,
459: ((java_cup.runtime.Symbol) CUP$parser$stack
460: .elementAt(CUP$parser$top - 0)).left,
461: ((java_cup.runtime.Symbol) CUP$parser$stack
462: .elementAt(CUP$parser$top - 0)).right,
463: RESULT);
464: }
465: return CUP$parser$result;
466:
467: /*. . . . . . . . . . . . . . . . . . . .*/
468: case 9: // template_element ::= WHITESPACE
469: {
470: Object RESULT = null;
471: int tleft = ((java_cup.runtime.Symbol) CUP$parser$stack
472: .elementAt(CUP$parser$top - 0)).left;
473: int tright = ((java_cup.runtime.Symbol) CUP$parser$stack
474: .elementAt(CUP$parser$top - 0)).right;
475: Object t = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
476: .elementAt(CUP$parser$top - 0)).value;
477:
478: RESULT = new Element((Token) t);
479:
480: CUP$parser$result = new java_cup.runtime.Symbol(
481: 4/*template_element*/,
482: ((java_cup.runtime.Symbol) CUP$parser$stack
483: .elementAt(CUP$parser$top - 0)).left,
484: ((java_cup.runtime.Symbol) CUP$parser$stack
485: .elementAt(CUP$parser$top - 0)).right,
486: RESULT);
487: }
488: return CUP$parser$result;
489:
490: /*. . . . . . . . . . . . . . . . . . . .*/
491: case 8: // template_element ::= TEXT
492: {
493: Object RESULT = null;
494: int tleft = ((java_cup.runtime.Symbol) CUP$parser$stack
495: .elementAt(CUP$parser$top - 0)).left;
496: int tright = ((java_cup.runtime.Symbol) CUP$parser$stack
497: .elementAt(CUP$parser$top - 0)).right;
498: Object t = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
499: .elementAt(CUP$parser$top - 0)).value;
500:
501: RESULT = new Element((Token) t);
502:
503: CUP$parser$result = new java_cup.runtime.Symbol(
504: 4/*template_element*/,
505: ((java_cup.runtime.Symbol) CUP$parser$stack
506: .elementAt(CUP$parser$top - 0)).left,
507: ((java_cup.runtime.Symbol) CUP$parser$stack
508: .elementAt(CUP$parser$top - 0)).right,
509: RESULT);
510: }
511: return CUP$parser$result;
512:
513: /*. . . . . . . . . . . . . . . . . . . .*/
514: case 7: // template_element ::= START_INCLUDE
515: {
516: Object RESULT = null;
517: int tleft = ((java_cup.runtime.Symbol) CUP$parser$stack
518: .elementAt(CUP$parser$top - 0)).left;
519: int tright = ((java_cup.runtime.Symbol) CUP$parser$stack
520: .elementAt(CUP$parser$top - 0)).right;
521: Object t = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
522: .elementAt(CUP$parser$top - 0)).value;
523:
524: RESULT = new IncludeElement((Token) t);
525:
526: CUP$parser$result = new java_cup.runtime.Symbol(
527: 4/*template_element*/,
528: ((java_cup.runtime.Symbol) CUP$parser$stack
529: .elementAt(CUP$parser$top - 0)).left,
530: ((java_cup.runtime.Symbol) CUP$parser$stack
531: .elementAt(CUP$parser$top - 0)).right,
532: RESULT);
533: }
534: return CUP$parser$result;
535:
536: /*. . . . . . . . . . . . . . . . . . . .*/
537: case 6: // template_elements_opt ::=
538: {
539: Object RESULT = null;
540:
541: CUP$parser$result = new java_cup.runtime.Symbol(
542: 5/*template_elements_opt*/,
543: ((java_cup.runtime.Symbol) CUP$parser$stack
544: .elementAt(CUP$parser$top - 0)).right,
545: ((java_cup.runtime.Symbol) CUP$parser$stack
546: .elementAt(CUP$parser$top - 0)).right,
547: RESULT);
548: }
549: return CUP$parser$result;
550:
551: /*. . . . . . . . . . . . . . . . . . . .*/
552: case 5: // template_elements_opt ::= template_element template_elements_opt
553: {
554: Object RESULT = null;
555: int t1left = ((java_cup.runtime.Symbol) CUP$parser$stack
556: .elementAt(CUP$parser$top - 1)).left;
557: int t1right = ((java_cup.runtime.Symbol) CUP$parser$stack
558: .elementAt(CUP$parser$top - 1)).right;
559: Object t1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
560: .elementAt(CUP$parser$top - 1)).value;
561: int t2left = ((java_cup.runtime.Symbol) CUP$parser$stack
562: .elementAt(CUP$parser$top - 0)).left;
563: int t2right = ((java_cup.runtime.Symbol) CUP$parser$stack
564: .elementAt(CUP$parser$top - 0)).right;
565: Object t2 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
566: .elementAt(CUP$parser$top - 0)).value;
567:
568: /* Add the newly discovered element to
569: the head of the linked list */
570: ((Element) t1).next = (Element) t2;
571: RESULT = t1;
572:
573: CUP$parser$result = new java_cup.runtime.Symbol(
574: 5/*template_elements_opt*/,
575: ((java_cup.runtime.Symbol) CUP$parser$stack
576: .elementAt(CUP$parser$top - 1)).left,
577: ((java_cup.runtime.Symbol) CUP$parser$stack
578: .elementAt(CUP$parser$top - 0)).right,
579: RESULT);
580: }
581: return CUP$parser$result;
582:
583: /*. . . . . . . . . . . . . . . . . . . .*/
584: case 4: // template ::= START_TEMPLATE template_elements_opt END_TEMPLATE whitespace_opt
585: {
586: Object RESULT = null;
587: int t1left = ((java_cup.runtime.Symbol) CUP$parser$stack
588: .elementAt(CUP$parser$top - 3)).left;
589: int t1right = ((java_cup.runtime.Symbol) CUP$parser$stack
590: .elementAt(CUP$parser$top - 3)).right;
591: Object t1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
592: .elementAt(CUP$parser$top - 3)).value;
593: int t2left = ((java_cup.runtime.Symbol) CUP$parser$stack
594: .elementAt(CUP$parser$top - 2)).left;
595: int t2right = ((java_cup.runtime.Symbol) CUP$parser$stack
596: .elementAt(CUP$parser$top - 2)).right;
597: Object t2 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
598: .elementAt(CUP$parser$top - 2)).value;
599:
600: /* Add the linked list of elements to
601: a new template */
602: Template t = new Template((Token) t1);
603: t.elements = (Element) t2;
604: RESULT = t;
605:
606: CUP$parser$result = new java_cup.runtime.Symbol(
607: 2/*template*/,
608: ((java_cup.runtime.Symbol) CUP$parser$stack
609: .elementAt(CUP$parser$top - 3)).left,
610: ((java_cup.runtime.Symbol) CUP$parser$stack
611: .elementAt(CUP$parser$top - 0)).right,
612: RESULT);
613: }
614: return CUP$parser$result;
615:
616: /*. . . . . . . . . . . . . . . . . . . .*/
617: case 3: // templates_opt ::=
618: {
619: Object RESULT = null;
620:
621: CUP$parser$result = new java_cup.runtime.Symbol(
622: 3/*templates_opt*/,
623: ((java_cup.runtime.Symbol) CUP$parser$stack
624: .elementAt(CUP$parser$top - 0)).right,
625: ((java_cup.runtime.Symbol) CUP$parser$stack
626: .elementAt(CUP$parser$top - 0)).right,
627: RESULT);
628: }
629: return CUP$parser$result;
630:
631: /*. . . . . . . . . . . . . . . . . . . .*/
632: case 2: // templates_opt ::= template templates_opt
633: {
634: Object RESULT = null;
635: int t1left = ((java_cup.runtime.Symbol) CUP$parser$stack
636: .elementAt(CUP$parser$top - 1)).left;
637: int t1right = ((java_cup.runtime.Symbol) CUP$parser$stack
638: .elementAt(CUP$parser$top - 1)).right;
639: Object t1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
640: .elementAt(CUP$parser$top - 1)).value;
641: int t2left = ((java_cup.runtime.Symbol) CUP$parser$stack
642: .elementAt(CUP$parser$top - 0)).left;
643: int t2right = ((java_cup.runtime.Symbol) CUP$parser$stack
644: .elementAt(CUP$parser$top - 0)).right;
645: Object t2 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
646: .elementAt(CUP$parser$top - 0)).value;
647:
648: /* Add the newly discovered template to
649: the head of the linked list */
650: ((Template) t1).next = (Template) t2;
651: RESULT = t1;
652:
653: CUP$parser$result = new java_cup.runtime.Symbol(
654: 3/*templates_opt*/,
655: ((java_cup.runtime.Symbol) CUP$parser$stack
656: .elementAt(CUP$parser$top - 1)).left,
657: ((java_cup.runtime.Symbol) CUP$parser$stack
658: .elementAt(CUP$parser$top - 0)).right,
659: RESULT);
660: }
661: return CUP$parser$result;
662:
663: /*. . . . . . . . . . . . . . . . . . . .*/
664: case 1: // $START ::= file EOF
665: {
666: Object RESULT = null;
667: int start_valleft = ((java_cup.runtime.Symbol) CUP$parser$stack
668: .elementAt(CUP$parser$top - 1)).left;
669: int start_valright = ((java_cup.runtime.Symbol) CUP$parser$stack
670: .elementAt(CUP$parser$top - 1)).right;
671: Object start_val = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
672: .elementAt(CUP$parser$top - 1)).value;
673: RESULT = start_val;
674: CUP$parser$result = new java_cup.runtime.Symbol(
675: 0/*$START*/,
676: ((java_cup.runtime.Symbol) CUP$parser$stack
677: .elementAt(CUP$parser$top - 1)).left,
678: ((java_cup.runtime.Symbol) CUP$parser$stack
679: .elementAt(CUP$parser$top - 0)).right,
680: RESULT);
681: }
682: /* ACCEPT */
683: CUP$parser$parser.done_parsing();
684: return CUP$parser$result;
685:
686: /*. . . . . . . . . . . . . . . . . . . .*/
687: case 0: // file ::= whitespace_opt START_DOCUMENT whitespace_opt template templates_opt END_DOCUMENT whitespace_opt
688: {
689: Object RESULT = null;
690: int e1left = ((java_cup.runtime.Symbol) CUP$parser$stack
691: .elementAt(CUP$parser$top - 5)).left;
692: int e1right = ((java_cup.runtime.Symbol) CUP$parser$stack
693: .elementAt(CUP$parser$top - 5)).right;
694: Object e1 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
695: .elementAt(CUP$parser$top - 5)).value;
696: int e2left = ((java_cup.runtime.Symbol) CUP$parser$stack
697: .elementAt(CUP$parser$top - 3)).left;
698: int e2right = ((java_cup.runtime.Symbol) CUP$parser$stack
699: .elementAt(CUP$parser$top - 3)).right;
700: Object e2 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
701: .elementAt(CUP$parser$top - 3)).value;
702: int e3left = ((java_cup.runtime.Symbol) CUP$parser$stack
703: .elementAt(CUP$parser$top - 2)).left;
704: int e3right = ((java_cup.runtime.Symbol) CUP$parser$stack
705: .elementAt(CUP$parser$top - 2)).right;
706: Object e3 = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack
707: .elementAt(CUP$parser$top - 2)).value;
708:
709: BTEFile f = new BTEFile((Token) e1);
710: f.main = (Template) e2;
711: f.defaultList = (Template) e3;
712: if (e1 != null) {
713: /* if there is a super tag, this
714: * template is allowed to be without
715: * a name, otherwise check for it. */
716: f.main.checkNames(false);
717: }
718: if (f.defaultList != null) {
719: /* These templates must be checked */
720: f.defaultList.checkNames(false);
721: /* put the default list into the default
722: * hash table */
723: f.defaultList.hashThyself(f.defaults);
724: }
725: RESULT = f;
726:
727: CUP$parser$result = new java_cup.runtime.Symbol(1/*file*/,
728: ((java_cup.runtime.Symbol) CUP$parser$stack
729: .elementAt(CUP$parser$top - 6)).left,
730: ((java_cup.runtime.Symbol) CUP$parser$stack
731: .elementAt(CUP$parser$top - 0)).right,
732: RESULT);
733: }
734: return CUP$parser$result;
735:
736: /* . . . . . .*/
737: default:
738: throw new Exception(
739: "Invalid action number found in internal parse table");
740:
741: }
742: }
743: }
|