/* Generated By:JavaCC: Do not edit this line. PigFileParser.java */
package org.apache.pig.tools.parameters;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Hashtable;
public class PigFileParser implements PigFileParserConstants {
private PreprocessorContext pc;
public void setContext(PreprocessorContext pc) {
this.pc = pc;
}
private static String unquote(String s)
{
if (s.charAt(0) == '\u005c'' && s.charAt(s.length()-1) == '\u005c'')
return s.substring(1, s.length()-1);
else if (s.charAt(0) == '"' && s.charAt(s.length()-1) == '"')
return s.substring(1, s.length()-1);
else
return s;
}
final public void Parse() throws ParseException, IOException {
Token id, val;
Boolean overwrite;
String s;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case DECLARE:
jj_consume_token(DECLARE);
overwrite=true;
id = jj_consume_token(IDENTIFIER);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case OTHER:
val = jj_consume_token(OTHER);
pc.processOrdLine(id.image , val.image);
break;
case IDENTIFIER:
val = jj_consume_token(IDENTIFIER);
s = val.image;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case OTHER:
val = jj_consume_token(OTHER);
s += val.image;
break;
default:
jj_la1[0] = jj_gen;
;
}
pc.processOrdLine(id.image , s, overwrite);
break;
case SHELLCMD:
val = jj_consume_token(SHELLCMD);
pc.processShellCmd(id.image , val.image, overwrite);
break;
case LITERAL:
val = jj_consume_token(LITERAL);
s = unquote(val.image); pc.processOrdLine(id.image, s, overwrite);
break;
default:
jj_la1[1] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
case PIGDEFAULT:
jj_consume_token(PIGDEFAULT);
overwrite=false;
id = jj_consume_token(IDENTIFIER);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case OTHER:
val = jj_consume_token(OTHER);
pc.processOrdLine(id.image , val.image);
break;
case IDENTIFIER:
val = jj_consume_token(IDENTIFIER);
s = val.image;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case OTHER:
val = jj_consume_token(OTHER);
s += val.image;
break;
default:
jj_la1[2] = jj_gen;
;
}
pc.processOrdLine(id.image , s, overwrite);
break;
case SHELLCMD:
val = jj_consume_token(SHELLCMD);
pc.processShellCmd(id.image , val.image , overwrite);
break;
case LITERAL:
val = jj_consume_token(LITERAL);
s = unquote(val.image); pc.processOrdLine(id.image , s, overwrite);
break;
default:
jj_la1[3] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
jj_la1[4] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
/** Generated Token Manager. */
public PigFileParserTokenManager token_source;
JavaCharStream jj_input_stream;
/** Current token. */
public Token token;
/** Next token. */
public Token jj_nt;
private int jj_ntk;
private int jj_gen;
final private int[] jj_la1 = new int[5];
static private int[] jj_la1_0;
static {
jj_la1_init_0();
}
private static void jj_la1_init_0() {
jj_la1_0 = new int[] {0x2000,0x3c00,0x2000,0x3c00,0x300,};
}
/** Constructor with InputStream. */
public PigFileParser(java.io.InputStream stream) {
this(stream, null);
}
/** Constructor with InputStream and supplied encoding */
public PigFileParser(java.io.InputStream stream, String encoding) {
try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source = new PigFileParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 5; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
public void ReInit(java.io.InputStream stream) {
ReInit(stream, null);
}
/** Reinitialise. */
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;
jj_gen = 0;
for (int i = 0; i < 5; i++) jj_la1[i] = -1;
}
/** Constructor. */
public PigFileParser(java.io.Reader stream) {
jj_input_stream = new JavaCharStream(stream, 1, 1);
token_source = new PigFileParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 5; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
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 < 5; i++) jj_la1[i] = -1;
}
/** Constructor with generated Token Manager. */
public PigFileParser(PigFileParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 5; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
public void ReInit(PigFileParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 5; i++) jj_la1[i] = -1;
}
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();
}
/** Get the next Token. */
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;
}
/** Get the specific 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;
}
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.List jj_expentries = new java.util.ArrayList();
private int[] jj_expentry;
private int jj_kind = -1;
/** Generate ParseException. */
public ParseException generateParseException() {
jj_expentries.clear();
boolean[] la1tokens = new boolean[14];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 5; 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;
}
}
}
}
for (int i = 0; i < 14; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
jj_expentries.add(jj_expentry);
}
}
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(token, exptokseq, tokenImage);
}
/** Enable tracing. */
final public void enable_tracing() {
}
/** Disable tracing. */
final public void disable_tracing() {
}
}