/* Generated By:JJTree&JavaCC: Do not edit this line. TagFile.java */
package com.sun.tlddoc.tagfileparser;

import java.io.InputStream;
import java.util.ArrayList;

/**
 * Simple parser for tag files that only actually parses the directives.
 * All other content is left unparsed.
 *
 * @author Mark Roth
 */
public class TagFile/*@bgen(jjtree)*/implements TagFileTreeConstants, TagFileConstants {/*@bgen(jjtree)*/
  protected JJTTagFileState jjtree = new JJTTagFileState();
    /** The set of directives in this tag file */
    public ArrayList directives = new ArrayList();

    public static TagFile parse( InputStream in ) throws ParseException {
        TagFile parser = new TagFile( in );
        parser.Input();
        return parser;
    }

    public static void main(String args[]) throws ParseException {
        TagFile parser = new TagFile(System.in);
        parser.Input();
        ((SimpleNode)parser.jjtree.rootNode()).dump(">");
    }

    /**
     * Returns the list of directives in this tag file.
     */
    public ArrayList getDirectives() {
        return this.directives;
    }

  final public void Input() throws ParseException {
 /*@bgen(jjtree) Input */
  SimpleNode jjtn000 = new SimpleNode(JJTINPUT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      JSPTagDef();
      jj_consume_token(0);
    } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      {if (true) throw (RuntimeException)jjte000;}
    }
    if (jjte000 instanceof ParseException) {
      {if (true) throw (ParseException)jjte000;}
    }
    {if (true) throw (Error)jjte000;}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

  final public void JSPTagDef() throws ParseException {
 /*@bgen(jjtree) JSPTagDef */
  SimpleNode jjtn000 = new SimpleNode(JJTJSPTAGDEF);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      label_1:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case JSP_COMMENT:
        case JSP_DIRECTIVE:
        case XML_DIRECTIVE:
        case OTHER_CONTENT:
          ;
          break;
        default:
          jj_la1[0] = jj_gen;
          break label_1;
        }
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case JSP_COMMENT:
          Comment();
          break;
        case JSP_DIRECTIVE:
          JSPDirective();
          break;
        case XML_DIRECTIVE:
          XMLDirective();
          break;
        case OTHER_CONTENT:
          OtherContent();
          break;
        default:
          jj_la1[1] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
      }
    } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      {if (true) throw (RuntimeException)jjte000;}
    }
    if (jjte000 instanceof ParseException) {
      {if (true) throw (ParseException)jjte000;}
    }
    {if (true) throw (Error)jjte000;}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

  final public void Comment() throws ParseException {
 /*@bgen(jjtree) Comment */
  SimpleNode jjtn000 = new SimpleNode(JJTCOMMENT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      jj_consume_token(JSP_COMMENT);
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

  final public void JSPDirective() throws ParseException {
 /*@bgen(jjtree) JSPDirective */
  SimpleNode jjtn000 = new SimpleNode(JJTJSPDIRECTIVE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);Directive result = new Directive();
  String directiveName;
  String attributeName;
  String attributeValue;
    try {
      jj_consume_token(JSP_DIRECTIVE);
      directiveName = JSPDirectiveName();
    result.setDirectiveName( directiveName );
      label_2:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case JSP_ATTRIBUTE_NAME:
          ;
          break;
        default:
          jj_la1[2] = jj_gen;
          break label_2;
        }
        attributeName = JSPAttributeName();
        jj_consume_token(EQ);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case BEGIN_QUOTE_SINGLE:
          jj_consume_token(BEGIN_QUOTE_SINGLE);
          attributeValue = JSPAttributeValue();
          jj_consume_token(END_QUOTE_SINGLE);
          break;
        case BEGIN_QUOTE_DOUBLE:
          jj_consume_token(BEGIN_QUOTE_DOUBLE);
          attributeValue = JSPAttributeValue();
          jj_consume_token(END_QUOTE_DOUBLE);
          break;
        default:
          jj_la1[3] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
      result.addAttribute( new Attribute( attributeName, attributeValue ) );
      }
      jj_consume_token(END_DIRECTIVE);
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    directives.add( result );
    } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      {if (true) throw (RuntimeException)jjte000;}
    }
    if (jjte000 instanceof ParseException) {
      {if (true) throw (ParseException)jjte000;}
    }
    {if (true) throw (Error)jjte000;}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

  final public String JSPDirectiveName() throws ParseException {
 /*@bgen(jjtree) JSPDirectiveName */
  SimpleNode jjtn000 = new SimpleNode(JJTJSPDIRECTIVENAME);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);Token result;
    try {
      result = jj_consume_token(JSP_DIRECTIVE_NAME);
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    {if (true) return result.toString();}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
    throw new Error("Missing return statement in function");
  }

  final public String JSPAttributeName() throws ParseException {
 /*@bgen(jjtree) JSPAttributeName */
  SimpleNode jjtn000 = new SimpleNode(JJTJSPATTRIBUTENAME);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);Token result;
    try {
      result = jj_consume_token(JSP_ATTRIBUTE_NAME);
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    {if (true) return result.toString();}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
    throw new Error("Missing return statement in function");
  }

  final public String JSPAttributeValue() throws ParseException {
 /*@bgen(jjtree) JSPAttributeValue */
  SimpleNode jjtn000 = new SimpleNode(JJTJSPATTRIBUTEVALUE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);Token result;
    try {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case JSP_ATTRIBUTE_VALUE1:
        result = jj_consume_token(JSP_ATTRIBUTE_VALUE1);
        break;
      case JSP_ATTRIBUTE_VALUE2:
        result = jj_consume_token(JSP_ATTRIBUTE_VALUE2);
        break;
      default:
        jj_la1[4] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    {if (true) return result.toString();}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
    throw new Error("Missing return statement in function");
  }

  final public void XMLDirective() throws ParseException {
 /*@bgen(jjtree) XMLDirective */
  SimpleNode jjtn000 = new SimpleNode(JJTXMLDIRECTIVE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);Directive result = new Directive();
  String directiveName;
  String attributeName;
  String attributeValue;
    try {
      jj_consume_token(XML_DIRECTIVE);
      directiveName = XMLDirectiveName();
    result.setDirectiveName( directiveName );
      label_3:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case XML_ATTRIBUTE_NAME:
          ;
          break;
        default:
          jj_la1[5] = jj_gen;
          break label_3;
        }
        attributeName = XMLAttributeName();
        jj_consume_token(X_EQ);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case X_BEGIN_QUOTE_SINGLE:
          jj_consume_token(X_BEGIN_QUOTE_SINGLE);
          attributeValue = XMLAttributeValue();
          jj_consume_token(X_END_QUOTE_SINGLE);
          break;
        case X_BEGIN_QUOTE_DOUBLE:
          jj_consume_token(X_BEGIN_QUOTE_DOUBLE);
          attributeValue = XMLAttributeValue();
          jj_consume_token(X_END_QUOTE_DOUBLE);
          break;
        default:
          jj_la1[6] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
      result.addAttribute( new Attribute( attributeName, attributeValue ) );
      }
      jj_consume_token(X_END_DIRECTIVE);
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    directives.add( result );
    } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      {if (true) throw (RuntimeException)jjte000;}
    }
    if (jjte000 instanceof ParseException) {
      {if (true) throw (ParseException)jjte000;}
    }
    {if (true) throw (Error)jjte000;}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

  final public String XMLDirectiveName() throws ParseException {
 /*@bgen(jjtree) XMLDirectiveName */
  SimpleNode jjtn000 = new SimpleNode(JJTXMLDIRECTIVENAME);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);Token result;
    try {
      result = jj_consume_token(XML_DIRECTIVE_NAME);
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    {if (true) return result.toString();}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
    throw new Error("Missing return statement in function");
  }

  final public String XMLAttributeName() throws ParseException {
 /*@bgen(jjtree) XMLAttributeName */
  SimpleNode jjtn000 = new SimpleNode(JJTXMLATTRIBUTENAME);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);Token result;
    try {
      result = jj_consume_token(XML_ATTRIBUTE_NAME);
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    {if (true) return result.toString();}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
    throw new Error("Missing return statement in function");
  }

  final public String XMLAttributeValue() throws ParseException {
 /*@bgen(jjtree) XMLAttributeValue */
  SimpleNode jjtn000 = new SimpleNode(JJTXMLATTRIBUTEVALUE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);Token result;
    try {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case XML_ATTRIBUTE_VALUE1:
        result = jj_consume_token(XML_ATTRIBUTE_VALUE1);
        break;
      case XML_ATTRIBUTE_VALUE2:
        result = jj_consume_token(XML_ATTRIBUTE_VALUE2);
        break;
      default:
        jj_la1[7] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
    {if (true) return result.toString();}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
    throw new Error("Missing return statement in function");
  }

  final public void OtherContent() throws ParseException {
 /*@bgen(jjtree) OtherContent */
  SimpleNode jjtn000 = new SimpleNode(JJTOTHERCONTENT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      jj_consume_token(OTHER_CONTENT);
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }

  public TagFileTokenManager token_source;
  SimpleCharStream jj_input_stream;
  public Token token, jj_nt;
  private int jj_ntk;
  private int jj_gen;
  final private int[] jj_la1 = new int[8];
  static private int[] jj_la1_0;
  static private int[] jj_la1_1;
  static {
      jj_la1_0();
      jj_la1_1();
   }
   private static void jj_la1_0() {
      jj_la1_0 = new int[] {0x1e,0x1e,0x4000,0x1800,0x120000,0x10000000,0x6000000,0x80000000,};
   }
   private static void jj_la1_1() {
      jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,};
   }

  public TagFile(java.io.InputStream stream) {
     this(stream, null);
  }
  public TagFile(java.io.InputStream stream, String encoding) {
    try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source = new TagFileTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  public void ReInit(java.io.InputStream stream) {
     ReInit(stream);
  }
  public void ReInit(java.io.InputStream stream, String encoding) {
    try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jjtree.reset();
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  public TagFile(java.io.Reader stream) {
    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new TagFileTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 8; 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;
    jjtree.reset();
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

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

  public void ReInit(TagFileTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jjtree.reset();
    jj_gen = 0;
    for (int i = 0; i < 8; 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;

  public ParseException generateParseException() {
    jj_expentries.removeAllElements();
    boolean[] la1tokens = new boolean[38];
    for (int i = 0; i < 38; i++) {
      la1tokens[i] = false;
    }
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 8; 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 < 38; 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() {
  }

}
