add setup-env.sh
[cdsspec-compiler.git] / src / edu / uci / eecs / specCompiler / grammerParser / SpecParser.java
1 /* SpecParser.java */
2 /* Generated By:JavaCC: Do not edit this line. SpecParser.java */
3 package edu.uci.eecs.specCompiler.grammerParser;
4
5         class SpecParser implements SpecParserConstants {
6                 public static void main(String[] argvs)
7                 throws ParseException, TokenMgrError {
8                         SpecParser parser = new SpecParser(System.in);
9                         parser.Start();
10                         System.out.println("Parsing finished!");
11                 }
12
13   final public void Start() throws ParseException {
14     jj_consume_token(HEAD);
15     jj_consume_token(BEGIN);
16     jj_consume_token(END);
17     jj_consume_token(TAIL);
18     jj_consume_token(0);
19   }
20
21   /** Generated Token Manager. */
22   public SpecParserTokenManager token_source;
23   JavaCharStream jj_input_stream;
24   /** Current token. */
25   public Token token;
26   /** Next token. */
27   public Token jj_nt;
28   private int jj_ntk;
29   private int jj_gen;
30   final private int[] jj_la1 = new int[0];
31   static private int[] jj_la1_0;
32   static {
33       jj_la1_init_0();
34    }
35    private static void jj_la1_init_0() {
36       jj_la1_0 = new int[] {};
37    }
38
39   /** Constructor with InputStream. */
40   public SpecParser(java.io.InputStream stream) {
41      this(stream, null);
42   }
43   /** Constructor with InputStream and supplied encoding */
44   public SpecParser(java.io.InputStream stream, String encoding) {
45     try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
46     token_source = new SpecParserTokenManager(jj_input_stream);
47     token = new Token();
48     jj_ntk = -1;
49     jj_gen = 0;
50   }
51
52   /** Reinitialise. */
53   public void ReInit(java.io.InputStream stream) {
54      ReInit(stream, null);
55   }
56   /** Reinitialise. */
57   public void ReInit(java.io.InputStream stream, String encoding) {
58     try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
59     token_source.ReInit(jj_input_stream);
60     token = new Token();
61     jj_ntk = -1;
62     jj_gen = 0;
63     for (int i = 0; i < 0; i++) jj_la1[i] = -1;
64   }
65
66   /** Constructor. */
67   public SpecParser(java.io.Reader stream) {
68     jj_input_stream = new JavaCharStream(stream, 1, 1);
69     token_source = new SpecParserTokenManager(jj_input_stream);
70     token = new Token();
71     jj_ntk = -1;
72     jj_gen = 0;
73   }
74
75   /** Reinitialise. */
76   public void ReInit(java.io.Reader stream) {
77     jj_input_stream.ReInit(stream, 1, 1);
78     token_source.ReInit(jj_input_stream);
79     token = new Token();
80     jj_ntk = -1;
81     jj_gen = 0;
82   }
83
84   /** Constructor with generated Token Manager. */
85   public SpecParser(SpecParserTokenManager tm) {
86     token_source = tm;
87     token = new Token();
88     jj_ntk = -1;
89     jj_gen = 0;
90   }
91
92   /** Reinitialise. */
93   public void ReInit(SpecParserTokenManager tm) {
94     token_source = tm;
95     token = new Token();
96     jj_ntk = -1;
97     jj_gen = 0;
98   }
99
100   private Token jj_consume_token(int kind) throws ParseException {
101     Token oldToken;
102     if ((oldToken = token).next != null) token = token.next;
103     else token = token.next = token_source.getNextToken();
104     jj_ntk = -1;
105     if (token.kind == kind) {
106       jj_gen++;
107       return token;
108     }
109     token = oldToken;
110     jj_kind = kind;
111     throw generateParseException();
112   }
113
114
115 /** Get the next Token. */
116   final public Token getNextToken() {
117     if (token.next != null) token = token.next;
118     else token = token.next = token_source.getNextToken();
119     jj_ntk = -1;
120     jj_gen++;
121     return token;
122   }
123
124 /** Get the specific Token. */
125   final public Token getToken(int index) {
126     Token t = token;
127     for (int i = 0; i < index; i++) {
128       if (t.next != null) t = t.next;
129       else t = t.next = token_source.getNextToken();
130     }
131     return t;
132   }
133
134   private int jj_ntk_f() {
135     if ((jj_nt=token.next) == null)
136       return (jj_ntk = (token.next=token_source.getNextToken()).kind);
137     else
138       return (jj_ntk = jj_nt.kind);
139   }
140
141   private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
142   private int[] jj_expentry;
143   private int jj_kind = -1;
144
145   /** Generate ParseException. */
146   public ParseException generateParseException() {
147     jj_expentries.clear();
148     boolean[] la1tokens = new boolean[21];
149     if (jj_kind >= 0) {
150       la1tokens[jj_kind] = true;
151       jj_kind = -1;
152     }
153     for (int i = 0; i < 0; i++) {
154       if (jj_la1[i] == jj_gen) {
155         for (int j = 0; j < 32; j++) {
156           if ((jj_la1_0[i] & (1<<j)) != 0) {
157             la1tokens[j] = true;
158           }
159         }
160       }
161     }
162     for (int i = 0; i < 21; i++) {
163       if (la1tokens[i]) {
164         jj_expentry = new int[1];
165         jj_expentry[0] = i;
166         jj_expentries.add(jj_expentry);
167       }
168     }
169     int[][] exptokseq = new int[jj_expentries.size()][];
170     for (int i = 0; i < jj_expentries.size(); i++) {
171       exptokseq[i] = jj_expentries.get(i);
172     }
173     return new ParseException(token, exptokseq, tokenImage);
174   }
175
176   /** Enable tracing. */
177   final public void enable_tracing() {
178   }
179
180   /** Disable tracing. */
181   final public void disable_tracing() {
182   }
183
184         }