/* Generated By:JavaCC: Do not edit this line. Parser.java */
import edu.neu.ccs.demeter.dj.*;
import java.lang.reflect.*;
import edu.neu.ccs.demeter.*;
public class Parser implements ParserConstants {
  // oit is uugly.  Why isn't there a Character.valueOf(String)? 
  static char unescapifyChar(String s) {
    char c = s.charAt(0);
    if (c == '\\') {
      switch (s.charAt(1)) {
      case 'n': c = '\n'; break;
      case 't': c = '\t'; break;
      case 'b': c = '\b'; break;
      case 'r': c = '\r'; break;
      case 'f': c = '\f'; break;
      case '\\': c = '\\'; break;
      case '\'': c = '\''; break;
      case '\"': c = '\"'; break;
      default:
       c = (char) Integer.parseInt(s.substring(1, s.length()), 8);
       break;
      }
    }
    return c;
  }
  // Even uglier... 
  static String unescapify(String s) {
    char str[] = new char[s.length()];
    int i = 0, o = 0;
    while (i < s.length()) {
      char c = s.charAt(i++);
      if (c == '\\') {
       int j = i + 1;
       while (j < s.length() &&
              Character.digit(s.charAt(j), 8) != -1) {
         j++;
       }
       c = unescapifyChar(s.substring(i-1, j));
       i = j;
      }
      str[o++] = c;
    }
    return String.valueOf(str, 0, o);
  }

  final public FileSystem _FileSystem() throws ParseException {
  FileSystem it = null;
  CompoundFile _root;
    it=new FileSystem();
    _root = _CompoundFile();
                          it.set_root(_root);
    jj_consume_token(0);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public File _File() throws ParseException {
  File it = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 1:
      it = _SimpleFile();
      break;
    case 2:
      it = _CompoundFile();
      break;
    default:
      jj_la1[0] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public void common_File(File it) throws ParseException {
  FileName _f;
    _f = _FileName();
                   it.set_f(_f);

  }

  final public SimpleFile _SimpleFile() throws ParseException {
  SimpleFile it = null;
    it=new SimpleFile();
    jj_consume_token(1);
    common_File(it);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public CompoundFile _CompoundFile() throws ParseException {
  CompoundFile it = null;
  File_PList _contents;
  CompoundFile _parent;
    it=new CompoundFile();
    jj_consume_token(2);
    _contents = _File_PList();
                                        it.set_contents(_contents);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 2:
      _parent = _CompoundFile();
                               it.set_parent(_parent);
      break;
    default:
      jj_la1[1] = jj_gen;
      ;
    }
    common_File(it);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public Commands _Commands() throws ParseException {
  Commands it = null;
  Command_List _command_list;
    it=new Commands();
    _command_list = _Command_List();
                                  it.set_command_list(_command_list);
    jj_consume_token(0);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public Command _Command() throws ParseException {
  Command it = null;
    it = _Simple();
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public void common_Command(Command it) throws ParseException {

  }

  final public Simple _Simple() throws ParseException {
  Simple it = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 3:
      it = _MakeDirectory();
      break;
    case 4:
      it = _ChangeDirectoryUp();
      break;
    case 5:
      it = _ChangeDirectoryDown();
      break;
    case 6:
      it = _CreateEmptyFile();
      break;
    case 7:
      it = _RemoveFile();
      break;
    case 8:
      it = _CopyFile();
      break;
    default:
      jj_la1[2] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public void common_Simple(Simple it) throws ParseException {
    common_Command(it);

  }

  final public MakeDirectory _MakeDirectory() throws ParseException {
  MakeDirectory it = null;
  DirectoryName _directoryname;
    it=new MakeDirectory();
    jj_consume_token(3);
    _directoryname = _DirectoryName();
                                             it.set_directoryname(_directoryname);
    common_Simple(it);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public ChangeDirectoryUp _ChangeDirectoryUp() throws ParseException {
  ChangeDirectoryUp it = null;
    it=new ChangeDirectoryUp();
    jj_consume_token(4);
    common_Simple(it);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public ChangeDirectoryDown _ChangeDirectoryDown() throws ParseException {
  ChangeDirectoryDown it = null;
  DirectoryName _directoryname;
    it=new ChangeDirectoryDown();
    jj_consume_token(5);
    _directoryname = _DirectoryName();
                                          it.set_directoryname(_directoryname);
    common_Simple(it);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public CreateEmptyFile _CreateEmptyFile() throws ParseException {
  CreateEmptyFile it = null;
  FileName _filename;
    it=new CreateEmptyFile();
    jj_consume_token(6);
    _filename = _FileName();
                                   it.set_filename(_filename);
    common_Simple(it);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public RemoveFile _RemoveFile() throws ParseException {
  RemoveFile it = null;
  FileName _filename;
    it=new RemoveFile();
    jj_consume_token(7);
    _filename = _FileName();
                                it.set_filename(_filename);
    common_Simple(it);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public CopyFile _CopyFile() throws ParseException {
  CopyFile it = null;
  FileName _from;
  FileName _to;
    it=new CopyFile();
    jj_consume_token(8);
    _from = _FileName();
                            it.set_from(_from);
    _to = _FileName();
                    it.set_to(_to);
    common_Simple(it);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public Step _Step() throws ParseException {
  Step it = null;
  Ident _v;
    it=new Step();
    _v = _Ident();
                it.set_v(_v);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public FileName _FileName() throws ParseException {
  FileName it = null;
  Step_Path _path;
    it=new FileName();
    _path = _Step_Path();
                       it.set_path(_path);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public DirectoryName _DirectoryName() throws ParseException {
  DirectoryName it = null;
  Ident _ident;
    it=new DirectoryName();
    _ident = _Ident();
                    it.set_ident(_ident);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public Message _Message() throws ParseException {
  Message it = null;
  String _string;
    it=new Message();
    _string = _String();
                      it.set_string(_string);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public Main _Main() throws ParseException {
  Main it = null;
    it=new Main();
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public CommandVisitor _CommandVisitor() throws ParseException {
  CommandVisitor it = null;
    it=new CommandVisitor();
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public FileNameVisitor _FileNameVisitor() throws ParseException {
  FileNameVisitor it = null;
    it=new FileNameVisitor();
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public File_PList _File_PList() throws ParseException {
  File_PList it = null;
  Nonempty_File_PList _first;
    it=new File_PList();
    jj_consume_token(9);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 1:
    case 2:
      _first = _Nonempty_File_PList();
                                          it.set_first(_first);
      break;
    default:
      jj_la1[3] = jj_gen;
      ;
    }
    jj_consume_token(10);
         {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public Command_List _Command_List() throws ParseException {
  Command_List it = null;
  Nonempty_Command_List _first;
    it=new Command_List();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
      _first = _Nonempty_Command_List();
                                       it.set_first(_first);
      break;
    default:
      jj_la1[4] = jj_gen;
      ;
    }
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public Step_Path _Step_Path() throws ParseException {
  Step_Path it = null;
  Nonempty_Step_Path _first;
    it=new Step_Path();
    _first = _Nonempty_Step_Path();
                                 it.set_first(_first);
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public Nonempty_File_PList _Nonempty_File_PList() throws ParseException {
  Nonempty_File_PList it = null;
  File _it;
  Nonempty_File_PList _next;
    it=new Nonempty_File_PList();
    _it = _File();
                it.set_it(_it);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 1:
    case 2:
      _next = _Nonempty_File_PList();
                                    it.set_next(_next);
      break;
    default:
      jj_la1[5] = jj_gen;
      ;
    }
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public Nonempty_Command_List _Nonempty_Command_List() throws ParseException {
  Nonempty_Command_List it = null;
  Command _it;
  Nonempty_Command_List _next;
    it=new Nonempty_Command_List();
    _it = _Command();
                   it.set_it(_it);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
      _next = _Nonempty_Command_List();
                                      it.set_next(_next);
      break;
    default:
      jj_la1[6] = jj_gen;
      ;
    }
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public Nonempty_Step_Path _Nonempty_Step_Path() throws ParseException {
  Nonempty_Step_Path it = null;
  Step _it;
  Nonempty_Step_Path _next;
    it=new Nonempty_Step_Path();
    _it = _Step();
                it.set_it(_it);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 11:
      jj_consume_token(11);
      _next = _Nonempty_Step_Path();
                                        it.set_next(_next);
      break;
    default:
      jj_la1[7] = jj_gen;
      ;
    }
    {if (true) return it;}
    throw new Error("Missing return statement in function");
  }

  final public boolean _boolean() throws ParseException {
                       Token t;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case TRUE:
      t = jj_consume_token(TRUE);
               {if (true) return true;}
      break;
    case FALSE:
      t = jj_consume_token(FALSE);
                {if (true) return false;}
      break;
    default:
      jj_la1[8] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    throw new Error("Missing return statement in function");
  }

  final public char _char() throws ParseException {
                 Token t;
    t = jj_consume_token(CHARACTER_LITERAL);
       String s = t.image;
       {if (true) return unescapifyChar(s.substring(1, s.length()-1));}
    throw new Error("Missing return statement in function");
  }

  final public byte _byte() throws ParseException {
                 int i;
    i = _int();
             {if (true) return (byte) i;}
    throw new Error("Missing return statement in function");
  }

  final public short _short() throws ParseException {
                   int i;
    i = _int();
             {if (true) return (short) i;}
    throw new Error("Missing return statement in function");
  }

  final public int _int() throws ParseException {
               Number num;
    num = _Number();
                  {if (true) return num.intValue();}
    throw new Error("Missing return statement in function");
  }

  final public long _long() throws ParseException {
                 Number num;
    num = _Number();
                  {if (true) return num.longValue();}
    throw new Error("Missing return statement in function");
  }

  final public float _float() throws ParseException {
                   Number num;
    num = _Number();
                  {if (true) return num.floatValue();}
    throw new Error("Missing return statement in function");
  }

  final public double _double() throws ParseException {
                     Number num;
    num = _Number();
                  {if (true) return num.doubleValue();}
    throw new Error("Missing return statement in function");
  }

  final public Boolean _Boolean() throws ParseException {
                       Token t;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case TRUE:
      t = jj_consume_token(TRUE);
               {if (true) return Boolean.TRUE;}
      break;
    case FALSE:
      t = jj_consume_token(FALSE);
                {if (true) return Boolean.FALSE;}
      break;
    default:
      jj_la1[9] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    throw new Error("Missing return statement in function");
  }

  final public Character _Character() throws ParseException {
                           char c;
    c = _char();
              {if (true) return new Character(c);}
    throw new Error("Missing return statement in function");
  }

  final public Integer _Integer() throws ParseException {
                       int i;
    i = _int();
               {if (true) return new Integer(i);}
    throw new Error("Missing return statement in function");
  }

  final public Long _Long() throws ParseException {
                 long l;
    l = _long();
              {if (true) return new Long(l);}
    throw new Error("Missing return statement in function");
  }

  final public Float _Float() throws ParseException {
                   float f;
    f = _float();
               {if (true) return new Float(f);}
    throw new Error("Missing return statement in function");
  }

  final public Double _Double() throws ParseException {
                     double d;
    d = _double();
                {if (true) return new Double(d);}
    throw new Error("Missing return statement in function");
  }

  final public Number _Number() throws ParseException {
    Token t;
    String s = null;
    int radix = 0;
    Number num = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case DECIMAL_LITERAL:
    case HEX_LITERAL:
    case OCTAL_LITERAL:
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case DECIMAL_LITERAL:
        t = jj_consume_token(DECIMAL_LITERAL);
       s = t.image;
       radix = 10;
        break;
      case HEX_LITERAL:
        t = jj_consume_token(HEX_LITERAL);
       // Strip off the "0x". 
       s = t.image.substring(2, t.image.length());
       radix = 16;
        break;
      case OCTAL_LITERAL:
        t = jj_consume_token(OCTAL_LITERAL);
       s = t.image;
       radix = 8;
        break;
      default:
        jj_la1[10] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
       switch (s.charAt(s.length()-1)) {
       case 'l': case 'L':
         s = s.substring(0, s.length()-1);
         num = new Long(new java.math.BigInteger(s, radix).longValue());
         break;
       default:
         num = new Integer(new java.math.BigInteger(s, radix).intValue());
         break;
       }
      break;
    case FLOATING_POINT_LITERAL:
      t = jj_consume_token(FLOATING_POINT_LITERAL);
       s = t.image;
       switch (s.charAt(s.length()-1)) {
       case 'd': case 'D':
           num = Double.valueOf(s.substring(0, s.length()-1));
           break;
       case 'f': case 'F':
           num = Float.valueOf(s.substring(0, s.length()-1));
           break;
       default:
           num = Float.valueOf(s);
           break;
       }
      break;
    default:
      jj_la1[11] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
      {if (true) return num;}
    throw new Error("Missing return statement in function");
  }

  final public String _String() throws ParseException {
                     Token t;
    t = jj_consume_token(STRING_LITERAL);
       String s = t.image;
       {if (true) return unescapify(s.substring(1, s.length()-1));}
    throw new Error("Missing return statement in function");
  }

  final public StringBuffer _StringBuffer() throws ParseException {
                                 String s;
    s = _String();
                {if (true) return new StringBuffer(s);}
    throw new Error("Missing return statement in function");
  }

  final public Ident _Ident() throws ParseException {
                   Token t;
    t = jj_consume_token(IDENTIFIER);
       {if (true) return new Ident(t.image);}
    throw new Error("Missing return statement in function");
  }

  final public Text _Text() throws ParseException {
                 Token t;
    t = jj_consume_token(TEXT_LITERAL);
       String s = t.image;
       {if (true) return new Text(s.substring(2, s.length()-2));}
    throw new Error("Missing return statement in function");
  }

  final public Line _Line() throws ParseException {
                 Token t;
      token_source.SwitchTo(1);
    t = jj_consume_token(LINE);
       {if (true) return new Line(t.image);}
    throw new Error("Missing return statement in function");
  }

  final public Word _Word() throws ParseException {
                 Token t;
      token_source.SwitchTo(2);
    t = jj_consume_token(WORD);
       {if (true) return new Word(t.image);}
    throw new Error("Missing return statement in function");
  }

  public ParserTokenManager token_source;
  ASCII_UCodeESC_CharStream jj_input_stream;
  public Token token, jj_nt;
  private int jj_ntk;
  private int jj_gen;
  final private int[] jj_la1 = new int[12];
  final private int[] jj_la1_0 = {0x6,0x4,0x1f8,0x6,0x1f8,0x6,0x1f8,0x800,0xc000000,0xc000000,0x1c0000,0x3c0000,};
  final private int[] jj_la1_1 = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};

  public Parser(java.io.InputStream stream) {
    jj_input_stream = new ASCII_UCodeESC_CharStream(stream, 1, 1);
    token_source = new ParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 12; i++) jj_la1[i] = -1;
  }

  public void ReInit(java.io.InputStream stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 12; i++) jj_la1[i] = -1;
  }

  public Parser(java.io.Reader stream) {
    jj_input_stream = new ASCII_UCodeESC_CharStream(stream, 1, 1);
    token_source = new ParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 12; i++) jj_la1[i] = -1;
  }

  public void ReInit(java.io.Reader stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 12; i++) jj_la1[i] = -1;
  }

  public Parser(ParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 12; i++) jj_la1[i] = -1;
  }

  public void ReInit(ParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 12; i++) jj_la1[i] = -1;
  }

  final private Token jj_consume_token(int kind) throws ParseException {
    Token oldToken;
    if ((oldToken = token).next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    if (token.kind == kind) {
      jj_gen++;
      return token;
    }
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  }

  final public Token getNextToken() {
    if (token.next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    jj_gen++;
    return token;
  }

  final public Token getToken(int index) {
    Token t = token;
    for (int i = 0; i < index; i++) {
      if (t.next != null) t = t.next;
      else t = t.next = token_source.getNextToken();
    }
    return t;
  }

  final private int jj_ntk() {
    if ((jj_nt=token.next) == null)
      return (jj_ntk = (token.next=token_source.getNextToken()).kind);
    else
      return (jj_ntk = jj_nt.kind);
  }

  private java.util.Vector jj_expentries = new java.util.Vector();
  private int[] jj_expentry;
  private int jj_kind = -1;

  final public ParseException generateParseException() {
    jj_expentries.removeAllElements();
    boolean[] la1tokens = new boolean[37];
    for (int i = 0; i < 37; i++) {
      la1tokens[i] = false;
    }
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 12; i++) {
      if (jj_la1[i] == jj_gen) {
        for (int j = 0; j < 32; j++) {
          if ((jj_la1_0[i] & (1<<j)) != 0) {
            la1tokens[j] = true;
          }
          if ((jj_la1_1[i] & (1<<j)) != 0) {
            la1tokens[32+j] = true;
          }
        }
      }
    }
    for (int i = 0; i < 37; i++) {
      if (la1tokens[i]) {
        jj_expentry = new int[1];
        jj_expentry[0] = i;
        jj_expentries.addElement(jj_expentry);
      }
    }
    int[][] exptokseq = new int[jj_expentries.size()][];
    for (int i = 0; i < jj_expentries.size(); i++) {
      exptokseq[i] = (int[])jj_expentries.elementAt(i);
    }
    return new ParseException(token, exptokseq, tokenImage);
  }

  final public void enable_tracing() {
  }

  final public void disable_tracing() {
  }

}