/src/ca/usask/cs/giraffe/compiler/parser/CParser.java
Java | 8719 lines | 7345 code | 414 blank | 960 comment | 1334 complexity | f899d290bfbbc62a00ba072a61ed263c MD5 | raw file
Possible License(s): GPL-2.0
Large files files are truncated, but you can click here to view the full file
- /* Generated by: FreeCC 0.9.3. CParser.java */
- package ca.usask.cs.giraffe.compiler.parser;
- import ca.usask.cs.giraffe.core.GiraffeLogger;
- import java.util.*;
- @SuppressWarnings("unused")
- public class CParser implements CConstants {
- // Hastable for storing typedef types
- private static Set types=new HashSet();
- // Stack for determining when the parser
- // is parsing a typdef definition.
- private static Stack typedefParsingStack=new Stack();
- // Returns true if the given string is
- // a typedef type.
- private static boolean isType(String type) {
- return types.contains(type);
- }
- // Add a typedef type to those already defined
- private static void addType(String type) {
- types.add(type);
- }
- // Prints out all the types used in parsing the c source
- private static void printTypes() {
- for(Iterator i=types.iterator();
- i.hasNext();
- ) {
- GiraffeLogger.debug(""+i.next());
- }
- }
- private boolean buildTree=true;
- private boolean tokensAreNodes=true;
- private boolean specialTokensAreNodes=true;
- private java.util.ArrayList<Node>nodes=new java.util.ArrayList<Node>();
- private java.util.ArrayList<java.lang.Integer>marks=new java.util.ArrayList<java.lang.Integer>();
- private int mark;
- // current mark
- private boolean node_created;
- /**
- * Determines whether the current node was actually closed and
- * pushed. This should only be called in the final user action of a
- * node scope.
- */
- public boolean nodeCreated() {
- return node_created;
- }
- /**
- * Returns the root node of the AST. It only makes sense to call
- * this after a successful parse.
- */
- public Node rootNode() {
- return nodes.get(0);
- }
- /**
- * push a node onto the top of the node stack
- */
- public void pushNode(Node n) {
- nodes.add(n);
- }
- /**
- * Returns the node on the top of the stack, and remove it from the
- * stack.
- */
- public Node popNode() {
- return nodes.remove(nodes.size()-1);
- }
- /**
- * Returns the node currently on the top of the stack.
- */
- public Node peekNode() {
- return nodes.get(nodes.size()-1);
- }
- /**
- * Puts the node on the top of the stack. However, unlike pushNode()
- * it replaces the node that is currently on the top of the stack.
- * This is effectively equivalent to popNode() followed by pushNode(n)
- */
- public void pokeNode(Node n) {
- pokeNode(n,false);
- }
- /**
- * Puts the node on the top of the stack. If clearNodeScope is true,
- * it removes all the nodes in the current node scope and pushes
- * n onto the top. Otherwise, it simply replaces the node at the
- * top of the stack with n.
- */
- public void pokeNode(Node n,boolean clearNodeScope) {
- if (clearNodeScope) {
- clearNodeScope();
- nodes.add(n);
- }
- else {
- nodes.set(nodes.size()-1,n);
- }
- }
- /** Returns the number of children on the stack in the current node
- * scope.
- */
- public int nodeArity() {
- return nodes.size()-mark;
- }
- public void clearNodeScope() {
- while (nodes.size()>mark) {
- popNode();
- }
- }
- public void openNodeScope(Node n) {
- marks.add(mark);
- mark=nodes.size();
- n.open();
- }
- /* A definite node is constructed from a specified number of
- * children. That number of nodes are popped from the stack and
- * made the children of the definite node. Then the definite node
- * is pushed on to the stack. */
- public void closeNodeScope(Node n,int num) {
- mark=marks.remove(marks.size()-1);
- java.util.ArrayList<Node>nodes=new java.util.ArrayList<Node>();
- for(int i=0;
- i<num;
- i++) {
- nodes.add(popNode());
- }
- java.util.Collections.reverse(nodes);
- for(Node child : nodes) {
- if (specialTokensAreNodes&&(child instanceof Token)) {
- Token token=(Token) child;
- Token specialToken=token;
- while (specialToken!=null) {
- specialToken=specialToken.specialToken;
- }
- while (specialToken!=null&&specialToken!=token) {
- n.addChild(specialToken);
- specialToken=specialToken.next;
- }
- }
- n.addChild(child);
- }
- n.close();
- pushNode(n);
- node_created=true;
- }
- /**
- * A conditional node is constructed if its condition is true. All
- * the nodes that have been pushed since the node was opened are
- * made children of the conditional node, which is then pushed
- * on to the stack. If the condition is false the node is not
- * constructed and they are left on the stack.
- */
- public void closeNodeScope(Node n,boolean condition) {
- if (condition) {
- int a=nodeArity();
- mark=marks.remove(marks.size()-1);
- java.util.ArrayList<Node>nodes=new java.util.ArrayList<Node>();
- while (a-->0) {
- nodes.add(popNode());
- }
- java.util.Collections.reverse(nodes);
- for(Node child : nodes) {
- if (specialTokensAreNodes&&(child instanceof Token)) {
- Token token=(Token) child;
- Token specialToken=token;
- while (specialToken.specialToken!=null) {
- specialToken=specialToken.specialToken;
- }
- while (specialToken!=null&&specialToken!=token) {
- n.addChild(specialToken);
- specialToken=specialToken.next;
- }
- }
- n.addChild(child);
- }
- n.close();
- pushNode(n);
- node_created=true;
- }
- else {
- mark=marks.remove(marks.size()-1);
- node_created=false;
- }
- }
- public boolean getBuildTree() {
- return buildTree;
- }
- public void setBuildTree(boolean buildTree) {
- this.buildTree=buildTree;
- }
- private boolean isSpecialToken(Node n) {
- if (n instanceof Token) {
- Token t=(Token) n;
- return t.next!=null&&t.next.specialToken==t;
- }
- return false;
- }
- /**
- * @deprecated
- * Kludge so that existing jjtree-based code that uses
- * parser.jjtree.foo can work without change.
- */
- CParser jjtree=this;
- /** Generated Lexer. */
- public CLexer token_source;
- SimpleCharStream jj_input_stream;
- public void setInputSource(String inputSource) {
- token_source.setInputSource(inputSource);
- }
- String getInputSource() {
- return token_source.getInputSource();
- }
- Token current_token;
- /** Next token. */
- private Token jj_nt;
- private int jj_ntk;
- private Token jj_scanpos,jj_lastpos;
- private int jj_la;
- /** Whether we are looking ahead. */
- private boolean jj_lookingAhead=false;
- private boolean jj_semLA;
- private int jj_gen;
- final private int[] jj_la1=new int[79];
- static private int[] jj_la1_0;
- static private int[] jj_la1_1;
- static private int[] jj_la1_2;
- static private int[] jj_la1_3;
- static {
- jj_la1_init_0();
- jj_la1_init_1();
- jj_la1_init_2();
- jj_la1_init_3();
- }
- private static void jj_la1_init_0() {
- jj_la1_0=new int[]{0x0,0xa0a00000,0x100000,0xa0a00000,0x42400000,0x100000,0x0,0x0,0x40000000,0x0,0x0,0x100000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4068c00,0x0,0x0,0x0,0x100000,0x0,0x100000,0x0,0x0,0x0,0x0,0x4068c00,0x0,0x0,0x0,0x4068c00,0x0,0x0,0x4068c00,0x0,0x8000000,0x10080000,0x1000000,0x4068c00,0x8000000,0x0,0x0,0x4068c00,0x4068c00,0x10080000,0x4068c00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4068c00,0x4000000,0x0,0x0,0x0,0x0,0x68c00,0x68c00,0x0,0x68c00};
- }
- private static void jj_la1_init_1() {
- jj_la1_1=new int[]{0x80400000,0x800,0x10,0x800,0x93669,0x10,0x400000,0x400000,0x8,0x10000000,0x20000000,0x10,0x10000000,0x80400000,0xc0400000,0x400000,0x400000,0x10000000,0x20000000,0x0,0x80400000,0x80000000,0x80400000,0x400000,0x0,0x80000000,0x10,0x0,0x10,0x10000000,0x80000000,0x10000000,0x10000000,0x84400000,0x80000000,0x0,0x80000000,0x80400000,0x80000000,0x80000000,0x80400000,0x80000000,0x4068002,0x4004,0x4100,0x80400000,0x20000,0x48002,0x2000000,0x80400000,0x80400000,0x4004,0x80400000,0x10000000,0x20000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x80000000,0x80000000,0x80000000,0x80400000,0x400000,0x10000000,0x0};
- }
- private static void jj_la1_init_2() {
- jj_la1_2=new int[]{0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8,0x8,0x0,0x0,0x0,0x0,0x8,0x0,0x2,0x60400008,0x0,0x2,0x0,0x0,0x8,0x0,0x0,0xa,0x0,0x0,0x60400008,0xa,0x8,0xa,0x60400008,0x2,0x2,0x60400008,0x2,0x0,0x0,0x0,0x60400008,0x0,0x0,0x0,0x60400008,0x60400008,0x0,0x60400008,0x0,0x1ff80,0x20000,0x40000,0x80000,0x100000,0x200000,0x400000,0x1800000,0x1800000,0x1e000000,0x1e000000,0x60000000,0x60000000,0x80000008,0x80000008,0x60400008,0x60400008,0x60400008,0x0,0x2,0x2,0x0,0x0,0x0,0x0};
- }
- private static void jj_la1_init_3() {
- jj_la1_3=new int[]{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e,0x0,0x0,0x0,0x1e,0x0,0x0,0x1e,0x0,0x0,0x0,0x0,0x1e,0x0,0x0,0x0,0x1e,0x1e,0x0,0x1e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x1e,0x1e,0x18,0x0,0x66,0x66,0x0,0x0,0x0,0x0};
- }
- final private JJCalls[] jj_2_rtns=new JJCalls[43];
- private boolean jj_rescan=false;
- private int jj_gc=0;
- public CParser(java.io.Reader stream) {
- jj_input_stream=new SimpleCharStream(stream,1,1);
- token_source=new CLexer(this,jj_input_stream);
- current_token=new Token();
- jj_ntk=-1;
- for(int i=0;
- i<79;
- i++) jj_la1[i]=-1;
- for(int i=0;
- i<jj_2_rtns.length;
- i++) jj_2_rtns[i]=new JJCalls();
- }
- /** Constructor with generated Token Manager. */
- public CParser(CLexer tm) {
- token_source=tm;
- current_token=new Token();
- jj_ntk=-1;
- for(int i=0;
- i<79;
- i++) jj_la1[i]=-1;
- for(int i=0;
- i<jj_2_rtns.length;
- i++) jj_2_rtns[i]=new JJCalls();
- }
- private Token jj_consume_token(int kind) throws ParseException {
- Token oldToken=current_token;
- if (current_token.next!=null) current_token=current_token.next;
- else current_token=current_token.next=token_source.getNextToken();
- jj_ntk=-1;
- if (current_token.kind==kind) {
- jj_gen++;
- if (++jj_gc>100) {
- jj_gc=0;
- for(int i=0;
- i<jj_2_rtns.length;
- i++) {
- JJCalls c=jj_2_rtns[i];
- while (c!=null) {
- if (c.gen<jj_gen) c.first=null;
- c=c.next;
- }
- }
- }
- if (buildTree&&tokensAreNodes) {
- pushNode(current_token);
- }
- return current_token;
- }
- current_token=oldToken;
- jj_kind=kind;
- throw generateParseException();
- }
- @SuppressWarnings("serial")
- static private final class LookaheadSuccess extends java.lang.Error {
- }
- final private LookaheadSuccess jj_ls=new LookaheadSuccess();
- private boolean jj_scan_token(int kind) {
- if (jj_scanpos==jj_lastpos) {
- jj_la--;
- if (jj_scanpos.next==null) {
- jj_lastpos=jj_scanpos=jj_scanpos.next=token_source.getNextToken();
- }
- else {
- jj_lastpos=jj_scanpos=jj_scanpos.next;
- }
- }
- else {
- jj_scanpos=jj_scanpos.next;
- }
- if (jj_rescan) {
- int i=0;
- Token tok=current_token;
- while (tok!=null&&tok!=jj_scanpos) {
- i++;
- tok=tok.next;
- }
- if (tok!=null) jj_add_error_token(kind,i);
- }
- if (jj_scanpos.kind!=kind) return true;
- if (jj_la==0&&jj_scanpos==jj_lastpos) throw jj_ls;
- return false;
- }
- /** Get the next Token. */
- final public Token getNextToken() {
- if (current_token.next!=null) current_token=current_token.next;
- else current_token=current_token.next=token_source.getNextToken();
- jj_ntk=-1;
- jj_gen++;
- return current_token;
- }
- /** Get the specific Token. */
- final public Token getToken(int index) {
- Token t=current_token;
- for(int i=0;
- i<index;
- i++) {
- if (t.next!=null) t=t.next;
- else t=t.next=token_source.getNextToken();
- }
- return t;
- }
- private int jj_ntk() {
- if ((jj_nt=current_token.next)==null) return(jj_ntk=(current_token.next=token_source.getNextToken()).kind);
- else return(jj_ntk=jj_nt.kind);
- }
- private java.util.ArrayList<int[]>jj_expentries=new java.util.ArrayList<int[]>();
- private int[] jj_expentry;
- private int jj_kind=-1;
- private int[] jj_lasttokens=new int[100];
- private int jj_endpos;
- private void jj_add_error_token(int kind,int pos) {
- if (pos>=100) return;
- if (pos==jj_endpos+1) {
- jj_lasttokens[jj_endpos++]=kind;
- }
- else if (jj_endpos!=0) {
- jj_expentry=new int[jj_endpos];
- for(int i=0;
- i<jj_endpos;
- i++) {
- jj_expentry[i]=jj_lasttokens[i];
- }
- jj_entries_loop:
- for(java.util.Iterator<int[]>it=jj_expentries.iterator();
- it.hasNext();
- ) {
- int[] oldentry=(int[])(it.next());
- if (oldentry.length==jj_expentry.length) {
- for(int i=0;
- i<jj_expentry.length;
- i++) {
- if (oldentry[i]!=jj_expentry[i]) {
- continue jj_entries_loop;
- }
- }
- jj_expentries.add(jj_expentry);
- break jj_entries_loop;
- }
- }
- if (pos!=0) jj_lasttokens[(jj_endpos=pos)-1]=kind;
- }
- }
- public ParseException generateParseException() {
- jj_expentries.clear();
- boolean[] la1tokens=new boolean[103];
- if (jj_kind>=0) {
- la1tokens[jj_kind]=true;
- jj_kind=-1;
- }
- for(int i=0;
- i<79;
- i++) {
- if (jj_la1[i]==jj_gen) {
- for(int j=0;
- j<32;
- j++) {
- if ((jj_la1_0[i]&(1<<j))!=0) {
- la1tokens[0+j]=true;
- }
- if ((jj_la1_1[i]&(1<<j))!=0) {
- la1tokens[32+j]=true;
- }
- if ((jj_la1_2[i]&(1<<j))!=0) {
- la1tokens[64+j]=true;
- }
- if ((jj_la1_3[i]&(1<<j))!=0) {
- la1tokens[96+j]=true;
- }
- }
- }
- }
- for(int i=0;
- i<103;
- i++) {
- if (la1tokens[i]) {
- jj_expentry=new int[1];
- jj_expentry[0]=i;
- jj_expentries.add(jj_expentry);
- }
- }
- jj_endpos=0;
- jj_rescan_token();
- jj_add_error_token(0,0);
- int[][] exptokseq=new int[jj_expentries.size()][];
- for(int i=0;
- i<jj_expentries.size();
- i++) {
- exptokseq[i]=(int[]) jj_expentries.get(i);
- }
- return new ParseException(current_token,exptokseq,tokenImage);
- }
- /** Enable tracing. */
- final public void enable_tracing() {
- }
- /** Disable tracing. */
- final public void disable_tracing() {
- }
- private void jj_rescan_token() {
- jj_rescan=true;
- for(int i=0;
- i<43;
- i++) {
- try {
- JJCalls p=jj_2_rtns[i];
- do {
- if (p.gen>jj_gen) {
- jj_la=p.arg;
- jj_lastpos=jj_scanpos=p.first;
- switch(i) {
- case 0:
- jj_3_1();
- break;
- case 1:
- jj_3_2();
- break;
- case 2:
- jj_3_3();
- break;
- case 3:
- jj_3_4();
- break;
- case 4:
- jj_3_5();
- break;
- case 5:
- jj_3_6();
- break;
- case 6:
- jj_3_7();
- break;
- case 7:
- jj_3_8();
- break;
- case 8:
- jj_3_9();
- break;
- case 9:
- jj_3_10();
- break;
- case 10:
- jj_3_11();
- break;
- case 11:
- jj_3_12();
- break;
- case 12:
- jj_3_13();
- break;
- case 13:
- jj_3_14();
- break;
- case 14:
- jj_3_15();
- break;
- case 15:
- jj_3_16();
- break;
- case 16:
- jj_3_17();
- break;
- case 17:
- jj_3_18();
- break;
- case 18:
- jj_3_19();
- break;
- case 19:
- jj_3_20();
- break;
- case 20:
- jj_3_21();
- break;
- case 21:
- jj_3_22();
- break;
- case 22:
- jj_3_23();
- break;
- case 23:
- jj_3_24();
- break;
- case 24:
- jj_3_25();
- break;
- case 25:
- jj_3_26();
- break;
- case 26:
- jj_3_27();
- break;
- case 27:
- jj_3_28();
- break;
- case 28:
- jj_3_29();
- break;
- case 29:
- jj_3_30();
- break;
- case 30:
- jj_3_31();
- break;
- case 31:
- jj_3_32();
- break;
- case 32:
- jj_3_33();
- break;
- case 33:
- jj_3_34();
- break;
- case 34:
- jj_3_35();
- break;
- case 35:
- jj_3_36();
- break;
- case 36:
- jj_3_37();
- break;
- case 37:
- jj_3_38();
- break;
- case 38:
- jj_3_39();
- break;
- case 39:
- jj_3_40();
- break;
- case 40:
- jj_3_41();
- break;
- case 41:
- jj_3_42();
- break;
- case 42:
- jj_3_43();
- break;
- }
- }
- p=p.next;
- }
- while (p!=null);
- }
- catch(LookaheadSuccess ls) {
- }
- }
- jj_rescan=false;
- }
- private void jj_save(int index,int xla) {
- JJCalls p=jj_2_rtns[index];
- while (p.gen>jj_gen) {
- if (p.next==null) {
- p=p.next=new JJCalls();
- break;
- }
- p=p.next;
- }
- p.gen=jj_gen+xla-jj_la;
- p.first=current_token;
- p.arg=xla;
- }
- static final class JJCalls {
- int gen;
- Token first;
- int arg;
- JJCalls next;
- }
- // C.jj, line 235
- final public void TranslationUnit() throws ParseException {
- // C.jj, line 237
- TranslationUnit node1=null;
- if (buildTree) {
- node1=new TranslationUnit();
- Token jjtStartToken=getToken(1);
- node1.setBeginLine(jjtStartToken.beginLine);
- node1.setBeginColumn(jjtStartToken.beginColumn);
- node1.setInputSource(this.getInputSource());
- openNodeScope(node1);
- }
- boolean hitException1=false;
- try {
- // C.jj, line 237
- label_1:
- while (true) {
- // C.jj, line 237
- // C.jj, line 237
- ExternalDeclaration();
- if (!(jj_2_1(1))) {
- break label_1;
- }
- }
- // C.jj, line 238
- printTypes();
- }
- catch(Exception e1) {
- hitException1=false;
- if (e1 instanceof ParseException) throw(ParseException) e1;
- if (e1 instanceof RuntimeException) throw(RuntimeException) e1;
- throw new RuntimeException(e1);
- }
- finally {
- if (buildTree) {
- if (!hitException1) {
- closeNodeScope(node1,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node1.setEndLine(jjtEndToken.endLine);
- node1.setEndColumn(jjtEndToken.endColumn);
- }
- else {
- clearNodeScope();
- mark=marks.remove(marks.size()-1);
- }
- }
- }
- }
- // C.jj, line 241
- final public void ExternalDeclaration() throws ParseException {
- // C.jj, line 243
- ExternalDeclaration node2=null;
- if (buildTree) {
- node2=new ExternalDeclaration();
- Token jjtStartToken=getToken(1);
- node2.setBeginLine(jjtStartToken.beginLine);
- node2.setBeginColumn(jjtStartToken.beginColumn);
- node2.setInputSource(this.getInputSource());
- openNodeScope(node2);
- }
- boolean hitException2=false;
- try {
- // C.jj, line 243
- if (jj_2_2(2147483647)) {
- // C.jj, line 243
- // C.jj, line 243
- FunctionDefinition();
- }
- else if (jj_2_3(1)) {
- // C.jj, line 243
- // C.jj, line 243
- Declaration();
- }
- else {
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- catch(Exception e2) {
- hitException2=false;
- if (e2 instanceof ParseException) throw(ParseException) e2;
- if (e2 instanceof RuntimeException) throw(RuntimeException) e2;
- throw new RuntimeException(e2);
- }
- finally {
- if (buildTree) {
- if (!hitException2) {
- closeNodeScope(node2,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node2.setEndLine(jjtEndToken.endLine);
- node2.setEndColumn(jjtEndToken.endColumn);
- }
- else {
- clearNodeScope();
- mark=marks.remove(marks.size()-1);
- }
- }
- }
- }
- //Removed Declaration list
- //Since declarations are statements now
- // C.jj, line 248
- final public void FunctionDefinition() throws ParseException {
- // C.jj, line 250
- FunctionDefinition node3=null;
- if (buildTree) {
- node3=new FunctionDefinition();
- Token jjtStartToken=getToken(1);
- node3.setBeginLine(jjtStartToken.beginLine);
- node3.setBeginColumn(jjtStartToken.beginColumn);
- node3.setInputSource(this.getInputSource());
- openNodeScope(node3);
- }
- boolean hitException3=false;
- try {
- // C.jj, line 250
- if (jj_2_4(2147483647)) {
- // C.jj, line 250
- // C.jj, line 250
- DeclarationSpecifiers();
- }
- // C.jj, line 250
- Declarator();
- // C.jj, line 252
- CompoundStatement();
- }
- catch(Exception e3) {
- hitException3=false;
- if (e3 instanceof ParseException) throw(ParseException) e3;
- if (e3 instanceof RuntimeException) throw(RuntimeException) e3;
- throw new RuntimeException(e3);
- }
- finally {
- if (buildTree) {
- if (!hitException3) {
- closeNodeScope(node3,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node3.setEndLine(jjtEndToken.endLine);
- node3.setEndColumn(jjtEndToken.endColumn);
- }
- else {
- clearNodeScope();
- mark=marks.remove(marks.size()-1);
- }
- }
- }
- }
- // C.jj, line 255
- final public void Declaration() throws ParseException {
- // C.jj, line 257
- Declaration node4=null;
- if (buildTree) {
- node4=new Declaration();
- Token jjtStartToken=getToken(1);
- node4.setBeginLine(jjtStartToken.beginLine);
- node4.setBeginColumn(jjtStartToken.beginColumn);
- node4.setInputSource(this.getInputSource());
- openNodeScope(node4);
- }
- boolean hitException4=false;
- try {
- // C.jj, line 257
- DeclarationSpecifiers();
- // C.jj, line 257
- int int1=(jj_ntk==-1)?jj_ntk():
- jj_ntk;
- if (int1==IDENTIFIER||int1==63||int1==67) {
- // C.jj, line 257
- // C.jj, line 257
- InitDeclaratorList();
- }
- else {
- jj_la1[0]=jj_gen;
- }
- // C.jj, line 257
- jj_consume_token(57);
- }
- catch(Exception e4) {
- hitException4=false;
- if (e4 instanceof ParseException) throw(ParseException) e4;
- if (e4 instanceof RuntimeException) throw(RuntimeException) e4;
- throw new RuntimeException(e4);
- }
- finally {
- if (buildTree) {
- if (!hitException4) {
- closeNodeScope(node4,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node4.setEndLine(jjtEndToken.endLine);
- node4.setEndColumn(jjtEndToken.endColumn);
- }
- else {
- clearNodeScope();
- mark=marks.remove(marks.size()-1);
- }
- }
- }
- }
- //Changed to allow mid-function declarations
- //Removed, but added declaration as type of Statement
- // C.jj, line 263
- final public void DeclarationList() throws ParseException {
- // C.jj, line 265
- DeclarationList node5=null;
- if (buildTree) {
- node5=new DeclarationList();
- Token jjtStartToken=getToken(1);
- node5.setBeginLine(jjtStartToken.beginLine);
- node5.setBeginColumn(jjtStartToken.beginColumn);
- node5.setInputSource(this.getInputSource());
- openNodeScope(node5);
- }
- boolean hitException5=false;
- try {
- // C.jj, line 265
- label_2:
- while (true) {
- // C.jj, line 265
- // C.jj, line 265
- Declaration();
- if (!(jj_2_5(2147483647))) {
- break label_2;
- }
- }
- }
- catch(Exception e5) {
- hitException5=false;
- if (e5 instanceof ParseException) throw(ParseException) e5;
- if (e5 instanceof RuntimeException) throw(RuntimeException) e5;
- throw new RuntimeException(e5);
- }
- finally {
- if (buildTree) {
- if (!hitException5) {
- closeNodeScope(node5,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node5.setEndLine(jjtEndToken.endLine);
- node5.setEndColumn(jjtEndToken.endColumn);
- }
- else {
- clearNodeScope();
- mark=marks.remove(marks.size()-1);
- }
- }
- }
- }
- // C.jj, line 268
- final public void DeclarationSpecifiers() throws ParseException {
- // C.jj, line 270
- DeclarationSpecifiers node6=null;
- if (buildTree) {
- node6=new DeclarationSpecifiers();
- Token jjtStartToken=getToken(1);
- node6.setBeginLine(jjtStartToken.beginLine);
- node6.setBeginColumn(jjtStartToken.beginColumn);
- node6.setInputSource(this.getInputSource());
- openNodeScope(node6);
- }
- boolean hitException6=false;
- try {
- switch((jj_ntk==-1)?jj_ntk():
- jj_ntk) {
- case REGISTER:
- case TYPEDEF:
- case EXTERN:
- case STATIC:
- case AUTO:
- // C.jj, line 270
- // C.jj, line 270
- StorageClassSpecifier();
- // C.jj, line 270
- if (jj_2_6(2147483647)) {
- // C.jj, line 270
- // C.jj, line 271
- DeclarationSpecifiers();
- }
- break;
- default:
- jj_la1[1]=jj_gen;
- if (jj_2_9(1)) {
- // C.jj, line 272
- // C.jj, line 272
- TypeSpecifier();
- // C.jj, line 272
- if (jj_2_7(2147483647)) {
- // C.jj, line 272
- // C.jj, line 273
- DeclarationSpecifiers();
- }
- }
- else {
- switch((jj_ntk==-1)?jj_ntk():
- jj_ntk) {
- case VOLATILE:
- case CONST:
- // C.jj, line 274
- // C.jj, line 274
- TypeQualifier();
- // C.jj, line 274
- if (jj_2_8(2147483647)) {
- // C.jj, line 274
- // C.jj, line 275
- DeclarationSpecifiers();
- }
- break;
- default:
- jj_la1[2]=jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- }
- }
- catch(Exception e6) {
- hitException6=false;
- if (e6 instanceof ParseException) throw(ParseException) e6;
- if (e6 instanceof RuntimeException) throw(RuntimeException) e6;
- throw new RuntimeException(e6);
- }
- finally {
- if (buildTree) {
- if (!hitException6) {
- closeNodeScope(node6,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node6.setEndLine(jjtEndToken.endLine);
- node6.setEndColumn(jjtEndToken.endColumn);
- }
- else {
- clearNodeScope();
- mark=marks.remove(marks.size()-1);
- }
- }
- }
- }
- // C.jj, line 278
- final public void StorageClassSpecifier() throws ParseException {
- // C.jj, line 280
- StorageClassSpecifier node7=null;
- if (buildTree) {
- node7=new StorageClassSpecifier();
- Token jjtStartToken=getToken(1);
- node7.setBeginLine(jjtStartToken.beginLine);
- node7.setBeginColumn(jjtStartToken.beginColumn);
- node7.setInputSource(this.getInputSource());
- openNodeScope(node7);
- }
- boolean hitException7=false;
- try {
- // C.jj, line 280
- switch((jj_ntk==-1)?jj_ntk():
- jj_ntk) {
- case AUTO:
- // C.jj, line 280
- // C.jj, line 280
- jj_consume_token(AUTO);
- break;
- case REGISTER:
- // C.jj, line 280
- // C.jj, line 280
- jj_consume_token(REGISTER);
- break;
- case STATIC:
- // C.jj, line 280
- // C.jj, line 280
- jj_consume_token(STATIC);
- break;
- case EXTERN:
- // C.jj, line 280
- // C.jj, line 280
- jj_consume_token(EXTERN);
- break;
- case TYPEDEF:
- // C.jj, line 280
- // C.jj, line 280
- jj_consume_token(TYPEDEF);
- // C.jj, line 281
- typedefParsingStack.push(Boolean.TRUE);
- break;
- default:
- jj_la1[3]=jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- catch(Exception e7) {
- hitException7=false;
- if (e7 instanceof ParseException) throw(ParseException) e7;
- if (e7 instanceof RuntimeException) throw(RuntimeException) e7;
- throw new RuntimeException(e7);
- }
- finally {
- if (buildTree) {
- if (!hitException7) {
- closeNodeScope(node7,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node7.setEndLine(jjtEndToken.endLine);
- node7.setEndColumn(jjtEndToken.endColumn);
- }
- else {
- clearNodeScope();
- mark=marks.remove(marks.size()-1);
- }
- }
- }
- }
- // C.jj, line 286
- final public void TypeSpecifier() throws ParseException {
- // C.jj, line 288
- TypeSpecifier node8=null;
- if (buildTree) {
- node8=new TypeSpecifier();
- Token jjtStartToken=getToken(1);
- node8.setBeginLine(jjtStartToken.beginLine);
- node8.setBeginColumn(jjtStartToken.beginColumn);
- node8.setInputSource(this.getInputSource());
- openNodeScope(node8);
- }
- boolean hitException8=false;
- try {
- // C.jj, line 288
- switch((jj_ntk==-1)?jj_ntk():
- jj_ntk) {
- case VOID:
- // C.jj, line 288
- // C.jj, line 288
- jj_consume_token(VOID);
- break;
- case CHAR:
- // C.jj, line 288
- // C.jj, line 288
- jj_consume_token(CHAR);
- break;
- case SHORT:
- // C.jj, line 288
- // C.jj, line 288
- jj_consume_token(SHORT);
- break;
- case INT:
- // C.jj, line 288
- // C.jj, line 288
- jj_consume_token(INT);
- break;
- case LONG:
- // C.jj, line 288
- // C.jj, line 288
- jj_consume_token(LONG);
- break;
- case FLOAT:
- // C.jj, line 288
- // C.jj, line 288
- jj_consume_token(FLOAT);
- break;
- case DOUBLE:
- // C.jj, line 288
- // C.jj, line 288
- jj_consume_token(DOUBLE);
- break;
- case SIGNED:
- // C.jj, line 288
- // C.jj, line 288
- jj_consume_token(SIGNED);
- break;
- case BOOL:
- // C.jj, line 288
- // C.jj, line 288
- jj_consume_token(BOOL);
- break;
- case UNSIGNED:
- // C.jj, line 289
- // C.jj, line 289
- jj_consume_token(UNSIGNED);
- break;
- case STRUCT:
- case UNION:
- // C.jj, line 289
- // C.jj, line 289
- StructOrUnionSpecifier();
- break;
- case ENUM:
- // C.jj, line 289
- // C.jj, line 289
- EnumSpecifier();
- break;
- default:
- jj_la1[4]=jj_gen;
- if (isType(getToken(1).image)) {
- // C.jj, line 289
- // C.jj, line 289
- TypedefName();
- }
- else {
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- }
- catch(Exception e8) {
- hitException8=false;
- if (e8 instanceof ParseException) throw(ParseException) e8;
- if (e8 instanceof RuntimeException) throw(RuntimeException) e8;
- throw new RuntimeException(e8);
- }
- finally {
- if (buildTree) {
- if (!hitException8) {
- closeNodeScope(node8,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node8.setEndLine(jjtEndToken.endLine);
- node8.setEndColumn(jjtEndToken.endColumn);
- }
- else {
- clearNodeScope();
- mark=marks.remove(marks.size()-1);
- }
- }
- }
- }
- // C.jj, line 292
- final public void TypeQualifier() throws ParseException {
- // C.jj, line 294
- TypeQualifier node9=null;
- if (buildTree) {
- node9=new TypeQualifier();
- Token jjtStartToken=getToken(1);
- node9.setBeginLine(jjtStartToken.beginLine);
- node9.setBeginColumn(jjtStartToken.beginColumn);
- node9.setInputSource(this.getInputSource());
- openNodeScope(node9);
- }
- boolean hitException9=false;
- try {
- // C.jj, line 294
- switch((jj_ntk==-1)?jj_ntk():
- jj_ntk) {
- case CONST:
- // C.jj, line 294
- // C.jj, line 294
- jj_consume_token(CONST);
- break;
- case VOLATILE:
- // C.jj, line 294
- // C.jj, line 294
- jj_consume_token(VOLATILE);
- break;
- default:
- jj_la1[5]=jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- catch(Exception e9) {
- hitException9=false;
- if (e9 instanceof ParseException) throw(ParseException) e9;
- if (e9 instanceof RuntimeException) throw(RuntimeException) e9;
- throw new RuntimeException(e9);
- }
- finally {
- if (buildTree) {
- if (!hitException9) {
- closeNodeScope(node9,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node9.setEndLine(jjtEndToken.endLine);
- node9.setEndColumn(jjtEndToken.endColumn);
- }
- else {
- clearNodeScope();
- mark=marks.remove(marks.size()-1);
- }
- }
- }
- }
- // C.jj, line 297
- final public void StructOrUnionSpecifier() throws ParseException {
- // C.jj, line 299
- StructOrUnionSpecifier node10=null;
- if (buildTree) {
- node10=new StructOrUnionSpecifier();
- Token jjtStartToken=getToken(1);
- node10.setBeginLine(jjtStartToken.beginLine);
- node10.setBeginColumn(jjtStartToken.beginColumn);
- node10.setInputSource(this.getInputSource());
- openNodeScope(node10);
- }
- boolean hitException10=false;
- try {
- // C.jj, line 299
- typedefParsingStack.push(Boolean.FALSE);
- // C.jj, line 303
- StructOrUnion();
- // C.jj, line 303
- if (jj_2_10(3)) {
- // C.jj, line 303
- // C.jj, line 303
- int int2=(jj_ntk==-1)?jj_ntk():
- jj_ntk;
- if (int2==IDENTIFIER) {
- // C.jj, line 303
- // C.jj, line 303
- jj_consume_token(IDENTIFIER);
- }
- else {
- jj_la1[6]=jj_gen;
- }
- // C.jj, line 303
- jj_consume_token(58);
- // C.jj, line 303
- StructDeclarationList();
- // C.jj, line 303
- jj_consume_token(59);
- }
- else {
- switch((jj_ntk==-1)?jj_ntk():
- jj_ntk) {
- case IDENTIFIER:
- // C.jj, line 303
- // C.jj, line 303
- jj_consume_token(IDENTIFIER);
- break;
- default:
- jj_la1[7]=jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- // C.jj, line 305
- typedefParsingStack.pop();
- }
- catch(Exception e10) {
- hitException10=false;
- if (e10 instanceof ParseException) throw(ParseException) e10;
- if (e10 instanceof RuntimeException) throw(RuntimeException) e10;
- throw new RuntimeException(e10);
- }
- finally {
- if (buildTree) {
- if (!hitException10) {
- closeNodeScope(node10,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node10.setEndLine(jjtEndToken.endLine);
- node10.setEndColumn(jjtEndToken.endColumn);
- }
- else {
- clearNodeScope();
- mark=marks.remove(marks.size()-1);
- }
- }
- }
- }
- // C.jj, line 310
- final public void StructOrUnion() throws ParseException {
- // C.jj, line 312
- StructOrUnion node11=null;
- if (buildTree) {
- node11=new StructOrUnion();
- Token jjtStartToken=getToken(1);
- node11.setBeginLine(jjtStartToken.beginLine);
- node11.setBeginColumn(jjtStartToken.beginColumn);
- node11.setInputSource(this.getInputSource());
- openNodeScope(node11);
- }
- boolean hitException11=false;
- try {
- // C.jj, line 312
- switch((jj_ntk==-1)?jj_ntk():
- jj_ntk) {
- case STRUCT:
- // C.jj, line 312
- // C.jj, line 312
- jj_consume_token(STRUCT);
- break;
- case UNION:
- // C.jj, line 312
- // C.jj, line 312
- jj_consume_token(UNION);
- break;
- default:
- jj_la1[8]=jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- catch(Exception e11) {
- hitException11=false;
- if (e11 instanceof ParseException) throw(ParseException) e11;
- if (e11 instanceof RuntimeException) throw(RuntimeException) e11;
- throw new RuntimeException(e11);
- }
- finally {
- if (buildTree) {
- if (!hitException11) {
- closeNodeScope(node11,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node11.setEndLine(jjtEndToken.endLine);
- node11.setEndColumn(jjtEndToken.endColumn);
- }
- else {
- clearNodeScope();
- mark=marks.remove(marks.size()-1);
- }
- }
- }
- }
- // C.jj, line 317
- final public void StructDeclarationList() throws ParseException {
- // C.jj, line 319
- StructDeclarationList node12=null;
- if (buildTree) {
- node12=new StructDeclarationList();
- Token jjtStartToken=getToken(1);
- node12.setBeginLine(jjtStartToken.beginLine);
- node12.setBeginColumn(jjtStartToken.beginColumn);
- node12.setInputSource(this.getInputSource());
- openNodeScope(node12);
- }
- boolean hitException12=false;
- try {
- // C.jj, line 319
- label_3:
- while (true) {
- // C.jj, line 319
- // C.jj, line 319
- StructDeclaration();
- if (!(jj_2_11(1))) {
- break label_3;
- }
- }
- }
- catch(Exception e12) {
- hitException12=false;
- if (e12 instanceof ParseException) throw(ParseException) e12;
- if (e12 instanceof RuntimeException) throw(RuntimeException) e12;
- throw new RuntimeException(e12);
- }
- finally {
- if (buildTree) {
- if (!hitException12) {
- closeNodeScope(node12,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node12.setEndLine(jjtEndToken.endLine);
- node12.setEndColumn(jjtEndToken.endColumn);
- }
- else {
- clearNodeScope();
- mark=marks.remove(marks.size()-1);
- }
- }
- }
- }
- // C.jj, line 322
- final public void InitDeclaratorList() throws ParseException {
- // C.jj, line 324
- InitDeclaratorList node13=null;
- if (buildTree) {
- node13=new InitDeclaratorList();
- Token jjtStartToken=getToken(1);
- node13.setBeginLine(jjtStartToken.beginLine);
- node13.setBeginColumn(jjtStartToken.beginColumn);
- node13.setInputSource(this.getInputSource());
- openNodeScope(node13);
- }
- boolean hitException13=false;
- try {
- // C.jj, line 324
- InitDeclarator();
- // C.jj, line 324
- label_4:
- while (true) {
- int int3=(jj_ntk==-1)?jj_ntk():
- jj_ntk;
- if (!(int3==60)) {
- jj_la1[9]=jj_gen;
- break label_4;
- }
- // C.jj, line 324
- // C.jj, line 324
- jj_consume_token(60);
- // C.jj, line 324
- InitDeclarator();
- }
- // C.jj, line 325
- // Finished with a typedefDeclaration??
- if (!(typedefParsingStack.empty())&&((Boolean) typedefParsingStack.peek()).booleanValue()) {
- typedefParsingStack.pop();
- }
- }
- catch(Exception e13) {
- hitException13=false;
- if (e13 instanceof ParseException) throw(ParseException) e13;
- if (e13 instanceof RuntimeException) throw(RuntimeException) e13;
- throw new RuntimeException(e13);
- }
- finally {
- if (buildTree) {
- if (!hitException13) {
- closeNodeScope(node13,nodeArity()>1);
- Token jjtEndToken=getToken(0);
- node13.setEndLine(jjtEndToken.endLine);
- node13.setEndColumn(jjtEndToken.e…
Large files files are truncated, but you can click here to view the full file