/* Generated By:JavaCC: Do not edit this line. ProfilingOutputParser.java */
package net.sf.eclipsefp.haskell.profiler.internal.parser;
import net.sf.eclipsefp.haskell.profiler.model.*;
public class ProfilingOutputParser implements ProfilingOutputParserConstants {
final public Job job() throws ParseException {
String name;
String date;
String sampleUnit;
String valueUnit;
Job j;
Sample s;
jj_consume_token(JOB);
name = quotedString();
jj_consume_token(DATE);
date = quotedString();
jj_consume_token(SAMPLE_UNIT);
sampleUnit = quotedString();
jj_consume_token(VALUE_UNIT);
valueUnit = quotedString();
j = new Job(name, date, sampleUnit, valueUnit);
label_1:
while (true) {
s = sample();
j.addSample(s);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case BEGIN_SAMPLE:
break;
default:
jj_la1[0] = jj_gen;
break label_1;
}
}
{if (true) return j;}
throw new Error("Missing return statement in function");
}
final public Sample sample() throws ParseException {
float time;
Sample s;
String ident;
long value;
jj_consume_token(BEGIN_SAMPLE);
time = floatNumber();
s = new Sample(time);
label_2:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case IDENTIFIER:
break;
default:
jj_la1[1] = jj_gen;
break label_2;
}
ident = identifier();
value = integerNumber();
s.addEntry(ident, value);
}
jj_consume_token(END_SAMPLE);
floatNumber();
{if (true) return s;}
throw new Error("Missing return statement in function");
}
final public float floatNumber() throws ParseException {
Token string;
string = jj_consume_token(FLOAT);
{if (true) return Float.valueOf(string.image);}
throw new Error("Missing return statement in function");
}
final public long integerNumber() throws ParseException {
Token string;
string = jj_consume_token(INTEGER);
{if (true) return Long.valueOf(string.image);}
throw new Error("Missing return statement in function");
}
final public String identifier() throws ParseException {
Token string;
string = jj_consume_token(IDENTIFIER);
{if (true) return string.image;}
throw new Error("Missing return statement in function");
}
final public String quotedString() throws ParseException {
Token string;
string = jj_consume_token(QUOTEDSTRING);
{if (true) return string.image.substring(1, string.image.length() - 1);}
throw new Error("Missing return statement in function");
}
/** Generated Token Manager. */
public ProfilingOutputParserTokenManager token_source;
SimpleCharStream 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[2];
static private int[] jj_la1_0;
static {
jj_la1_init_0();
}
private static void jj_la1_init_0() {
jj_la1_0 = new int[] {0x200,0x4000,};
}
/** Constructor with InputStream. */
public ProfilingOutputParser(java.io.InputStream stream) {
this(stream, null);
}
/** Constructor with InputStream and supplied encoding */
public ProfilingOutputParser(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 ProfilingOutputParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 2; 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 < 2; i++) jj_la1[i] = -1;
}
/** Constructor. */
public ProfilingOutputParser(java.io.Reader stream) {
jj_input_stream = new SimpleCharStream(stream, 1, 1);
token_source = new ProfilingOutputParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 2; 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 < 2; i++) jj_la1[i] = -1;
}
/** Constructor with generated Token Manager. */
public ProfilingOutputParser(ProfilingOutputParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 2; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
public void ReInit(ProfilingOutputParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 2; 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<int[]> 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[16];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 2; 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 < 16; 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] = jj_expentries.get(i);
}
return new ParseException(token, exptokseq, tokenImage);
}
/** Enable tracing. */
final public void enable_tracing() {
}
/** Disable tracing. */
final public void disable_tracing() {
}
}