Package org.jostraca.directive

Source Code of org.jostraca.directive.DirectiveAntlrParser

// $ANTLR 2.7.4: "directive.g" -> "DirectiveAntlrParser.java"$
package org.jostraca.directive;

import java.util.Vector;
import java.util.Hashtable;

import org.jostraca.comp.antlr.TokenBuffer;
import org.jostraca.comp.antlr.TokenStreamException;
import org.jostraca.comp.antlr.TokenStreamIOException;
import org.jostraca.comp.antlr.ANTLRException;
import org.jostraca.comp.antlr.LLkParser;
import org.jostraca.comp.antlr.Token;
import org.jostraca.comp.antlr.TokenStream;
import org.jostraca.comp.antlr.RecognitionException;
import org.jostraca.comp.antlr.NoViableAltException;
import org.jostraca.comp.antlr.MismatchedTokenException;
import org.jostraca.comp.antlr.SemanticException;
import org.jostraca.comp.antlr.ParserSharedInputState;
import org.jostraca.comp.antlr.collections.impl.BitSet;

public class DirectiveAntlrParser extends org.jostraca.comp.antlr.LLkParser       implements DirectiveAntlrLexerTokenTypes
{

  private Vector    iUnnamedArgs = new Vector();
  private Hashtable iNamedArgs   = new Hashtable();
  private String    iName        = "";


  public String getName() {
    return iName;
  }

  public Vector getUnnamedArgs() {
    return iUnnamedArgs;
  }

  public Hashtable getNamedArgs() {
    return iNamedArgs;
  }


  public void reportError( RecognitionException re ) {
    throw new RuntimeException( re.getMessage() );
  }
  public void reportError(String s) {
    throw new RuntimeException( s );
  }
  public void reportWarning(String s) {
    throw new RuntimeException( s );
  }

protected DirectiveAntlrParser(TokenBuffer tokenBuf, int k) {
  super(tokenBuf,k);
  tokenNames = _tokenNames;
}

public DirectiveAntlrParser(TokenBuffer tokenBuf) {
  this(tokenBuf,1);
}

protected DirectiveAntlrParser(TokenStream lexer, int k) {
  super(lexer,k);
  tokenNames = _tokenNames;
}

public DirectiveAntlrParser(TokenStream lexer) {
  this(lexer,1);
}

public DirectiveAntlrParser(ParserSharedInputState state) {
  super(state,1);
  tokenNames = _tokenNames;
}

  public final void root() throws RecognitionException, TokenStreamException {
   
   
    try {      // for error handling
      {
      switch ( LA(1)) {
      case DIRECTIVENAME:
      {
        directivename();
        break;
      }
      case EOF:
      case DQSTRING:
      case SQSTRING:
      case ARGNAME:
      case NONSPACE:
      {
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
      }
      {
      _loop38:
      do {
        if ((LA(1)==DQSTRING||LA(1)==SQSTRING||LA(1)==NONSPACE)) {
          unnamedarg();
        }
        else {
          break _loop38;
        }
       
      } while (true);
      }
      {
      _loop40:
      do {
        if ((LA(1)==ARGNAME)) {
          namedarg();
        }
        else {
          break _loop40;
        }
       
      } while (true);
      }
    }
    catch (RecognitionException ex) {
      reportError(ex);
      consume();
      consumeUntil(_tokenSet_0);
    }
  }
 
  public final void directivename() throws RecognitionException, TokenStreamException {
   
    Token  dn = null;
   
    try {      // for error handling
      dn = LT(1);
      match(DIRECTIVENAME);
     
      iName = dn.getText();
     
    }
    catch (RecognitionException ex) {
      reportError(ex);
      consume();
      consumeUntil(_tokenSet_1);
    }
  }
 
  public final void unnamedarg() throws RecognitionException, TokenStreamException {
   
   
    String av;
   
   
    try {      // for error handling
      av=argvalue();
     
      iUnnamedArgs.add( av );     
      /* System.out.println( "p.ua:"+av ); */
     
    }
    catch (RecognitionException ex) {
      reportError(ex);
      consume();
      consumeUntil(_tokenSet_1);
    }
  }
 
  public final void namedarg() throws RecognitionException, TokenStreamException {
   
   
    String an;
    String av;
   
   
    try {      // for error handling
      an=argname();
      av=argvalue();
     
      iNamedArgs.put( an, av );
     
    }
    catch (RecognitionException ex) {
      reportError(ex);
      consume();
      consumeUntil(_tokenSet_2);
    }
  }
 
  public final String  argvalue() throws RecognitionException, TokenStreamException {
    String res;
   
   
    res = "";
   
   
    try {      // for error handling
      switch ( LA(1)) {
      case NONSPACE:
      {
        res=nonspace();
        /* System.out.println( "p.av,ns:"+res ); */
        break;
      }
      case SQSTRING:
      {
        res=sqstring();
        break;
      }
      case DQSTRING:
      {
        res=dqstring();
        break;
      }
      default:
      {
        throw new NoViableAltException(LT(1), getFilename());
      }
      }
    }
    catch (RecognitionException ex) {
      reportError(ex);
      consume();
      consumeUntil(_tokenSet_1);
    }
    return res;
  }
 
  public final String  argname() throws RecognitionException, TokenStreamException {
    String res;
   
    Token  an = null;
   
    res = "";
   
   
    try {      // for error handling
      an = LT(1);
      match(ARGNAME);
     
      res = an.getText();
      /* System.out.println( "p.an:"+an ); */
     
    }
    catch (RecognitionException ex) {
      reportError(ex);
      consume();
      consumeUntil(_tokenSet_3);
    }
    return res;
  }
 
  public final String  nonspace() throws RecognitionException, TokenStreamException {
    String res;
   
    Token  ns = null;
   
    res = "";
   
   
    try {      // for error handling
      ns = LT(1);
      match(NONSPACE);
     
      res = ns.getText();
     
    }
    catch (RecognitionException ex) {
      reportError(ex);
      consume();
      consumeUntil(_tokenSet_1);
    }
    return res;
  }
 
  public final String  sqstring() throws RecognitionException, TokenStreamException {
    String res;
   
    Token  sqs = null;
   
    res = "";
   
   
    try {      // for error handling
      sqs = LT(1);
      match(SQSTRING);
     
      res = sqs.getText();
     
    }
    catch (RecognitionException ex) {
      reportError(ex);
      consume();
      consumeUntil(_tokenSet_1);
    }
    return res;
  }
 
  public final String  dqstring() throws RecognitionException, TokenStreamException {
    String res;
   
    Token  dqs = null;
   
    res = "";
   
   
    try {      // for error handling
      dqs = LT(1);
      match(DQSTRING);
     
      res = dqs.getText();
     
    }
    catch (RecognitionException ex) {
      reportError(ex);
      consume();
      consumeUntil(_tokenSet_1);
    }
    return res;
  }
 
 
  public static final String[] _tokenNames = {
    "<0>",
    "EOF",
    "<2>",
    "NULL_TREE_LOOKAHEAD",
    "DQSTRING",
    "ESCDQ",
    "SQSTRING",
    "ESCSQ",
    "DIRECTIVENAME",
    "ARGNAME",
    "NONSPACE",
    "ID",
    "REFINEDID",
    "WS"
  };
 
  private static final long[] mk_tokenSet_0() {
    long[] data = { 2L, 0L};
    return data;
  }
  public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
  private static final long[] mk_tokenSet_1() {
    long[] data = { 1618L, 0L};
    return data;
  }
  public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
  private static final long[] mk_tokenSet_2() {
    long[] data = { 514L, 0L};
    return data;
  }
  public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
  private static final long[] mk_tokenSet_3() {
    long[] data = { 1104L, 0L};
    return data;
  }
  public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
 
  }
TOP

Related Classes of org.jostraca.directive.DirectiveAntlrParser

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.