All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.cambio.cds.gdl.parser.ExpressionParser Maven / Gradle / Ivy

There is a newer version: 1.3.26
Show newest version
/* Generated By:JavaCC: Do not edit this line. ExpressionParser.java */
package se.cambio.cds.gdl.parser;
import java.io.*;
import java.util.*;
import se.cambio.cds.gdl.model.expression.*;
import org.openehr.rm.datatypes.text.CodePhrase;
import org.openehr.rm.datatypes.quantity.*;
import org.openehr.rm.datatypes.basic.DataValue;

public class ExpressionParser implements ExpressionParserConstants {
  private static final String CHARSET = "UTF-8";

  /* =========================  public interface ======================== */
  /* execute the parsing */
  public List < ExpressionItem > parseBooleanExpressions() throws ParseException
  {
    return expressions();
  }

  public List < ExpressionItem > parseArithmeticExpressions() throws ParseException
  {
    return expressions();
  }

  public ExpressionItem parse() throws ParseException
  {
    return expression_item();
  }

  /* re-initial the parser */
  public void reInit(File file) throws IOException
  {
    ReInit(new FileInputStream(file), CHARSET);
  }

  /* re-initial the parser */
  public void reInit(InputStream input) throws IOException
  {
    ReInit(new BufferedInputStream(input));
  }

  public static void main(String args []) throws ParseException
  {}

  final public List < ExpressionItem > expressions() throws ParseException {
  List < ExpressionItem > items = new ArrayList < ExpressionItem > ();
  ExpressionItem item = null;
    item = expression_item();
    items.add(item);
    label_1:
    while (true) {
      if (jj_2_1(2)) {
        ;
      } else {
        break label_1;
      }
      jj_consume_token(SYM_COMMA);
      item = expression_item();
      items.add(item);
    }
    {if (true) return items;}
    throw new Error("Missing return statement in function");
  }

  final public ExpressionItem expression_item() throws ParseException {
  ExpressionItem item = null;
    if (jj_2_2(4)) {
      item = expression_node();
    } else if (jj_2_3(4)) {
      item = expression_leaf();
    } else {
      jj_consume_token(-1);
      throw new ParseException();
    }
    {if (true) return item;}
    {if (true) return item;}
    throw new Error("Missing return statement in function");
  }

  final public CodePhrase code_phrase() throws ParseException {
  Token t;
  String lang = null;
  String langTerm = null;
  String langCode = null;
    t = jj_consume_token(V_CODE_PHRASE);
    lang = t.image;
    int i = lang.indexOf("::");
    langTerm = lang.substring(1, i);
    langCode = lang.substring(i + 2, lang.length() - 1);
    {if (true) return new CodePhrase(langTerm, langCode);}
    throw new Error("Missing return statement in function");
  }

  final public CodePhrase code_phrase_raw() throws ParseException {
  Token t;
  String lang = null;
  String langTerm = null;
  String langCode = null;
    t = jj_consume_token(V_CODE_PHRASE_RAW);
    lang = t.image;
    int i = lang.indexOf("::");
    langTerm = lang.substring(0, i);
    langCode = lang.substring(i + 2);
    {if (true) return new CodePhrase(langTerm, langCode);}
    throw new Error("Missing return statement in function");
  }

/* ----------------------- expressions ----------------------- */
  final public ExpressionItem expression_node() throws ParseException {
  ExpressionItem ret = null;
  ExpressionItem item = null;
  ExpressionItem item2 = null;
  OperatorKind op = null;
  List assignmentExpressions = null;
  boolean precedenceOverridden = false; // TODO
  Token t = null;
  String attrId = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SYM_EXCLAMATION:
    case SYM_FOR_ALL:
    case SYM_MAX:
    case SYM_MIN:
    case SYM_MATH_FUNCTION:
    case SYM_FIRED:
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SYM_FOR_ALL:
        jj_consume_token(SYM_FOR_ALL);
        item = expression_leaf();
        op = OperatorKind.FOR_ALL;
        break;
      case SYM_MAX:
        jj_consume_token(SYM_MAX);
        item = expression_leaf();
        op = OperatorKind.MAX;
        break;
      case SYM_MIN:
        jj_consume_token(SYM_MIN);
        item = expression_leaf();
        op = OperatorKind.MIN;
        break;
      case SYM_FIRED:
        jj_consume_token(SYM_FIRED);
        item = expression_leaf();
        op = OperatorKind.FIRED;
        break;
      case SYM_MATH_FUNCTION:
        t = jj_consume_token(SYM_MATH_FUNCTION);
        jj_consume_token(SYM_L_PARENTHESIS);
        item = expression_leaf();
        jj_consume_token(SYM_R_PARENTHESIS);
        {if (true) return FunctionalExpression.create(new Function(t.image), item);}
        break;
      default:
        jj_la1[0] = jj_gen;
        if (jj_2_4(2)) {
          jj_consume_token(SYM_EXCLAMATION);
          item = expression_leaf();
        op = OperatorKind.NOT;
        } else if (jj_2_5(2)) {
          jj_consume_token(SYM_EXCLAMATION);
          jj_consume_token(SYM_FIRED);
          item = expression_leaf();
        op = OperatorKind.NOT_FIRED;
        } else {
          jj_consume_token(-1);
          throw new ParseException();
        }
      }
      {if (true) return new UnaryExpression(item, op);}
      break;
    case SYM_L_PARENTHESIS:
    case SYM_DOLLAR:
    case SYM_FALSE:
    case SYM_TRUE:
    case SYM_NULL:
    case SYM_E:
    case V_QUANTITY:
    case V_PROPORTION:
    case V_INTEGER:
    case V_ISO8601_DURATION:
    case V_DATE:
    case V_TIME:
    case V_DATE_TIME_Z:
    case V_DATE_TIME:
    case V_CODE_PHRASE_RAW:
    case V_ORDINAL:
    case V_REAL:
    case V_STRING:
    case V_ABSOLUTE_PATH:
      item = expression_leaf();
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case SYM_EQ:
        jj_consume_token(SYM_EQ);
          op = OperatorKind.EQUALITY;
        break;
      case SYM_NE:
        jj_consume_token(SYM_NE);
          op = OperatorKind.INEQUAL;
        break;
      case SYM_LT:
        jj_consume_token(SYM_LT);
          op = OperatorKind.LESS_THAN;
        break;
      case SYM_GT:
        jj_consume_token(SYM_GT);
          op = OperatorKind.GREATER_THAN;
        break;
      case SYM_LE:
        jj_consume_token(SYM_LE);
          op = OperatorKind.LESS_THAN_OR_EQUAL;
        break;
      case SYM_GE:
        jj_consume_token(SYM_GE);
          op = OperatorKind.GREATER_THAN_OR_EQUAL;
        break;
      case SYM_PLUS:
        jj_consume_token(SYM_PLUS);
          op = OperatorKind.ADDITION;
        break;
      case SYM_MINUS:
        jj_consume_token(SYM_MINUS);
          op = OperatorKind.SUBSTRATION;
        break;
      case SYM_STAR:
        jj_consume_token(SYM_STAR);
          op = OperatorKind.MULTIPLICATION;
        break;
      case SYM_SLASH:
        jj_consume_token(SYM_SLASH);
          op = OperatorKind.DIVISION;
        break;
      case SYM_CARET:
        jj_consume_token(SYM_CARET);
          op = OperatorKind.EXPONENT;
        break;
      case SYM_AND:
        jj_consume_token(SYM_AND);
          op = OperatorKind.AND;
        break;
      case SYM_OR:
        jj_consume_token(SYM_OR);
          op = OperatorKind.OR;
        break;
      case SYM_IS_A:
        jj_consume_token(SYM_IS_A);
          op = OperatorKind.IS_A;
        break;
      case SYM_IS_NOT_A:
        jj_consume_token(SYM_IS_NOT_A);
          op = OperatorKind.IS_NOT_A;
        break;
      default:
        jj_la1[1] = jj_gen;
        if (jj_2_6(4)) {
          jj_consume_token(SYM_ASSIGNMENT);
          op = OperatorKind.ASSIGNMENT;
          item2 = expression_leaf();
          {if (true) return new AssignmentExpression((Variable) item, item2);}
        } else {
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case SYM_L_PARENTHESIS:
            assignmentExpressions = assignmentExpressions();
          {if (true) return new CreateInstanceExpression((Variable) item, assignmentExpressions);}
            break;
          default:
            jj_la1[2] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
          }
        }
      }
      item2 = expression_leaf();
        ret = new BinaryExpression(item, item2, op);
      break;
    default:
      jj_la1[3] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    {if (true) return ret;}
    throw new Error("Missing return statement in function");
  }

  final public ExpressionItem expression_leaf() throws ParseException {
  ExpressionItem item = null;
  Token t = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SYM_L_PARENTHESIS:
      jj_consume_token(SYM_L_PARENTHESIS);
      if (jj_2_7(2147483647)) {
        item = expression_node();
      } else if (jj_2_8(2147483647)) {
        item = variable();
      } else if (jj_2_9(2147483647)) {
        item = constant_expression();
      } else {
        jj_consume_token(-1);
        throw new ParseException();
      }
      jj_consume_token(SYM_R_PARENTHESIS);
      break;
    case SYM_FALSE:
    case SYM_TRUE:
    case SYM_NULL:
    case SYM_E:
    case V_QUANTITY:
    case V_PROPORTION:
    case V_INTEGER:
    case V_ISO8601_DURATION:
    case V_DATE:
    case V_TIME:
    case V_DATE_TIME_Z:
    case V_DATE_TIME:
    case V_CODE_PHRASE_RAW:
    case V_ORDINAL:
    case V_REAL:
    case V_STRING:
      item = constant_expression();
      break;
    case SYM_DOLLAR:
    case V_ABSOLUTE_PATH:
      item = variable();
      break;
    default:
      jj_la1[4] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    {if (true) return item;}
    throw new Error("Missing return statement in function");
  }

  final public AssignmentExpression assignmentExpression() throws ParseException {
    ExpressionItem item = null;
    ExpressionItem item2 = null;
    item = expression_leaf();
    jj_consume_token(SYM_ASSIGNMENT);
    item2 = expression_leaf();
        {if (true) return new AssignmentExpression((Variable) item, item2);}
    throw new Error("Missing return statement in function");
  }

  final public List < AssignmentExpression > assignmentExpressions() throws ParseException {
    List < AssignmentExpression > items = new ArrayList < AssignmentExpression > ();
    AssignmentExpression item = null;
    jj_consume_token(SYM_L_PARENTHESIS);
    item = assignmentExpression();
     items.add(item);
    label_2:
    while (true) {
      if (jj_2_10(2)) {
        ;
      } else {
        break label_2;
      }
      jj_consume_token(SYM_SEMICOLON);
      item = assignmentExpression();
      items.add(item);
    }
    jj_consume_token(SYM_R_PARENTHESIS);
        {if (true) return items;}
    throw new Error("Missing return statement in function");
  }

  final public ConstantExpression constant_expression() throws ParseException {
  Token t = null;
  CodePhrase code = null;
  String text = null;
  String units = null;
  Integer order = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SYM_E:
      jj_consume_token(SYM_E);
      {if (true) return MathConstant.create(Constant.E);}
      break;
    case V_STRING:
      t = jj_consume_token(V_STRING);
      String str = t.image;
      {if (true) return new StringConstant(str.substring(1, str.length() - 1));}
      break;
    case V_ORDINAL:
      t = jj_consume_token(V_ORDINAL);
      String value = "DV_ORDINAL," + t.image;
      DvOrdinal ordinal = (DvOrdinal) DataValue.parseValue(value);
      {if (true) return new OrdinalConstant(ordinal);}
      break;
    case V_REAL:
      t = jj_consume_token(V_REAL);
      break;
    case V_INTEGER:
      t = jj_consume_token(V_INTEGER);
      break;
    case V_PROPORTION:
      t = jj_consume_token(V_PROPORTION);
      break;
    case V_DATE:
      t = jj_consume_token(V_DATE);
      break;
    case V_DATE_TIME_Z:
      t = jj_consume_token(V_DATE_TIME_Z);
      text = t.image;
      text = text.replace("(","");
      text = text.replace(")","");
      {if (true) return new DateTimeConstant(text);}
      break;
    case V_DATE_TIME:
      t = jj_consume_token(V_DATE_TIME);
      text = t.image;
      text = text.replace("(","");
      text = text.replace(")","");
      {if (true) return new DateTimeConstant(text);}
      break;
    case V_TIME:
      t = jj_consume_token(V_TIME);
      break;
    case V_ISO8601_DURATION:
      t = jj_consume_token(V_ISO8601_DURATION);
      break;
    case SYM_NULL:
      t = jj_consume_token(SYM_NULL);
      break;
    case SYM_TRUE:
      t = jj_consume_token(SYM_TRUE);
      break;
    case SYM_FALSE:
      t = jj_consume_token(SYM_FALSE);
      break;
    default:
      jj_la1[6] = jj_gen;
      if (jj_2_11(2)) {
        code = code_phrase_raw();
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case V_LABEL:
          text = label();
          break;
        default:
          jj_la1[5] = jj_gen;
          ;
        }
      if (text != null)
      {
        {if (true) return new CodedTextConstant(text, code);}
      }
      else
      {
        {if (true) return new CodePhraseConstant(code);}
      }
      } else {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case V_QUANTITY:
          t = jj_consume_token(V_QUANTITY);
      text = t.image;
      text = text.replace("(","");
      text = text.replace(")","");
      DvQuantity q = new DvQuantity("m",1,0).parse(text);
      {if (true) return new QuantityConstant(q);}
          break;
        default:
          jj_la1[7] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
      }
    }
    {if (true) return new ConstantExpression(t.image);}
    throw new Error("Missing return statement in function");
  }

  final public Variable variable() throws ParseException {
  Variable v;
  Token t;
  String code = null;
  String path = null;
  String label = null;
  String attribute = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SYM_DOLLAR:
      jj_consume_token(SYM_DOLLAR);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case V_LOCAL_CODE:
        t = jj_consume_token(V_LOCAL_CODE);
        break;
      case SYM_CURRENT_DATETIME:
        t = jj_consume_token(SYM_CURRENT_DATETIME);
        break;
      default:
        jj_la1[8] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      code = t.image;
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case V_LABEL:
        label = label();
        break;
      default:
        jj_la1[9] = jj_gen;
        ;
      }
      break;
    case V_ABSOLUTE_PATH:
      t = jj_consume_token(V_ABSOLUTE_PATH);
      path = t.image;
      break;
    default:
      jj_la1[10] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SYM_DOT:
      jj_consume_token(SYM_DOT);
      t = jj_consume_token(V_ATTRIBUTE_IDENTIFIER);
      attribute = t.image;
      break;
    default:
      jj_la1[11] = jj_gen;
      ;
    }
    {if (true) return new Variable(code, label, path, attribute);}
    throw new Error("Missing return statement in function");
  }

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

  final public double real() throws ParseException {
  Token t;
  String value = null;
    t = jj_consume_token(V_REAL);
    value = t.image;
    {if (true) return Double.parseDouble(value);}
    throw new Error("Missing return statement in function");
  }

  final public int integer() throws ParseException {
  Token t;
  String value = null;
    t = jj_consume_token(V_INTEGER);
    value = t.image;
    {if (true) return Integer.parseInt(value);}
    throw new Error("Missing return statement in function");
  }

  private boolean jj_2_1(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_1(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(0, xla); }
  }

  private boolean jj_2_2(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_2(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(1, xla); }
  }

  private boolean jj_2_3(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_3(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(2, xla); }
  }

  private boolean jj_2_4(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_4(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(3, xla); }
  }

  private boolean jj_2_5(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_5(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(4, xla); }
  }

  private boolean jj_2_6(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_6(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(5, xla); }
  }

  private boolean jj_2_7(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_7(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(6, xla); }
  }

  private boolean jj_2_8(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_8(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(7, xla); }
  }

  private boolean jj_2_9(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_9(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(8, xla); }
  }

  private boolean jj_2_10(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_10(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(9, xla); }
  }

  private boolean jj_2_11(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_11(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(10, xla); }
  }

  private boolean jj_3R_7() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_19()) {
    jj_scanpos = xsp;
    if (jj_3R_20()) {
    jj_scanpos = xsp;
    if (jj_3R_21()) {
    jj_scanpos = xsp;
    if (jj_scan_token(79)) {
    jj_scanpos = xsp;
    if (jj_scan_token(55)) {
    jj_scanpos = xsp;
    if (jj_scan_token(54)) {
    jj_scanpos = xsp;
    if (jj_scan_token(58)) {
    jj_scanpos = xsp;
    if (jj_3R_22()) {
    jj_scanpos = xsp;
    if (jj_3R_23()) {
    jj_scanpos = xsp;
    if (jj_scan_token(64)) {
    jj_scanpos = xsp;
    if (jj_scan_token(56)) {
    jj_scanpos = xsp;
    if (jj_scan_token(36)) {
    jj_scanpos = xsp;
    if (jj_scan_token(35)) {
    jj_scanpos = xsp;
    if (jj_scan_token(34)) {
    jj_scanpos = xsp;
    if (jj_3_11()) {
    jj_scanpos = xsp;
    if (jj_3R_24()) return true;
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    return false;
  }

  private boolean jj_3R_28() {
    if (jj_scan_token(SYM_MIN)) return true;
    if (jj_3R_5()) return true;
    return false;
  }

  private boolean jj_3_1() {
    if (jj_scan_token(SYM_COMMA)) return true;
    if (jj_3R_3()) return true;
    return false;
  }

  private boolean jj_3R_18() {
    if (jj_scan_token(SYM_DOT)) return true;
    if (jj_scan_token(V_ATTRIBUTE_IDENTIFIER)) return true;
    return false;
  }

  private boolean jj_3_6() {
    if (jj_scan_token(SYM_ASSIGNMENT)) return true;
    if (jj_3R_5()) return true;
    return false;
  }

  private boolean jj_3R_27() {
    if (jj_scan_token(SYM_MAX)) return true;
    if (jj_3R_5()) return true;
    return false;
  }

  private boolean jj_3R_50() {
    if (jj_3R_25()) return true;
    return false;
  }

  private boolean jj_3R_45() {
    if (jj_scan_token(SYM_IS_NOT_A)) return true;
    return false;
  }

  private boolean jj_3R_17() {
    if (jj_scan_token(V_ABSOLUTE_PATH)) return true;
    return false;
  }

  private boolean jj_3R_26() {
    if (jj_scan_token(SYM_FOR_ALL)) return true;
    if (jj_3R_5()) return true;
    return false;
  }

  private boolean jj_3R_44() {
    if (jj_scan_token(SYM_IS_A)) return true;
    return false;
  }

  private boolean jj_3R_11() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_26()) {
    jj_scanpos = xsp;
    if (jj_3R_27()) {
    jj_scanpos = xsp;
    if (jj_3R_28()) {
    jj_scanpos = xsp;
    if (jj_3R_29()) {
    jj_scanpos = xsp;
    if (jj_3R_30()) {
    jj_scanpos = xsp;
    if (jj_3_4()) {
    jj_scanpos = xsp;
    if (jj_3_5()) return true;
    }
    }
    }
    }
    }
    }
    return false;
  }

  private boolean jj_3R_43() {
    if (jj_scan_token(SYM_OR)) return true;
    return false;
  }

  private boolean jj_3R_4() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_11()) {
    jj_scanpos = xsp;
    if (jj_3R_12()) return true;
    }
    return false;
  }

  private boolean jj_3R_16() {
    if (jj_scan_token(SYM_DOLLAR)) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_scan_token(52)) {
    jj_scanpos = xsp;
    if (jj_scan_token(45)) return true;
    }
    xsp = jj_scanpos;
    if (jj_3R_50()) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_42() {
    if (jj_scan_token(SYM_AND)) return true;
    return false;
  }

  private boolean jj_3R_6() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_16()) {
    jj_scanpos = xsp;
    if (jj_3R_17()) return true;
    }
    xsp = jj_scanpos;
    if (jj_3R_18()) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3_10() {
    if (jj_scan_token(SYM_SEMICOLON)) return true;
    if (jj_3R_8()) return true;
    return false;
  }

  private boolean jj_3R_41() {
    if (jj_scan_token(SYM_CARET)) return true;
    return false;
  }

  private boolean jj_3R_10() {
    if (jj_3R_25()) return true;
    return false;
  }

  private boolean jj_3R_40() {
    if (jj_scan_token(SYM_SLASH)) return true;
    return false;
  }

  private boolean jj_3R_51() {
    if (jj_scan_token(SYM_L_PARENTHESIS)) return true;
    if (jj_3R_8()) return true;
    Token xsp;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3_10()) { jj_scanpos = xsp; break; }
    }
    if (jj_scan_token(SYM_R_PARENTHESIS)) return true;
    return false;
  }

  private boolean jj_3R_39() {
    if (jj_scan_token(SYM_STAR)) return true;
    return false;
  }

  private boolean jj_3R_38() {
    if (jj_scan_token(SYM_MINUS)) return true;
    return false;
  }

  private boolean jj_3R_37() {
    if (jj_scan_token(SYM_PLUS)) return true;
    return false;
  }

  private boolean jj_3R_9() {
    if (jj_scan_token(V_CODE_PHRASE_RAW)) return true;
    return false;
  }

  private boolean jj_3R_24() {
    if (jj_scan_token(V_QUANTITY)) return true;
    return false;
  }

  private boolean jj_3R_36() {
    if (jj_scan_token(SYM_GE)) return true;
    return false;
  }

  private boolean jj_3R_8() {
    if (jj_3R_5()) return true;
    if (jj_scan_token(SYM_ASSIGNMENT)) return true;
    if (jj_3R_5()) return true;
    return false;
  }

  private boolean jj_3R_35() {
    if (jj_scan_token(SYM_LE)) return true;
    return false;
  }

  private boolean jj_3R_34() {
    if (jj_scan_token(SYM_GT)) return true;
    return false;
  }

  private boolean jj_3_9() {
    if (jj_3R_7()) return true;
    return false;
  }

  private boolean jj_3_8() {
    if (jj_3R_6()) return true;
    return false;
  }

  private boolean jj_3_11() {
    if (jj_3R_9()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_10()) jj_scanpos = xsp;
    return false;
  }

  private boolean jj_3R_33() {
    if (jj_scan_token(SYM_LT)) return true;
    return false;
  }

  private boolean jj_3_7() {
    if (jj_3R_4()) return true;
    return false;
  }

  private boolean jj_3R_32() {
    if (jj_scan_token(SYM_NE)) return true;
    return false;
  }

  private boolean jj_3R_15() {
    if (jj_3R_6()) return true;
    return false;
  }

  private boolean jj_3R_14() {
    if (jj_3R_7()) return true;
    return false;
  }

  private boolean jj_3R_49() {
    if (jj_3R_7()) return true;
    return false;
  }

  private boolean jj_3R_31() {
    if (jj_scan_token(SYM_EQ)) return true;
    return false;
  }

  private boolean jj_3R_48() {
    if (jj_3R_6()) return true;
    return false;
  }

  private boolean jj_3R_47() {
    if (jj_3R_4()) return true;
    return false;
  }

  private boolean jj_3R_23() {
    if (jj_scan_token(V_DATE_TIME)) return true;
    return false;
  }

  private boolean jj_3R_12() {
    if (jj_3R_5()) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_31()) {
    jj_scanpos = xsp;
    if (jj_3R_32()) {
    jj_scanpos = xsp;
    if (jj_3R_33()) {
    jj_scanpos = xsp;
    if (jj_3R_34()) {
    jj_scanpos = xsp;
    if (jj_3R_35()) {
    jj_scanpos = xsp;
    if (jj_3R_36()) {
    jj_scanpos = xsp;
    if (jj_3R_37()) {
    jj_scanpos = xsp;
    if (jj_3R_38()) {
    jj_scanpos = xsp;
    if (jj_3R_39()) {
    jj_scanpos = xsp;
    if (jj_3R_40()) {
    jj_scanpos = xsp;
    if (jj_3R_41()) {
    jj_scanpos = xsp;
    if (jj_3R_42()) {
    jj_scanpos = xsp;
    if (jj_3R_43()) {
    jj_scanpos = xsp;
    if (jj_3R_44()) {
    jj_scanpos = xsp;
    if (jj_3R_45()) {
    jj_scanpos = xsp;
    if (jj_3_6()) {
    jj_scanpos = xsp;
    if (jj_3R_46()) return true;
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    if (jj_3R_5()) return true;
    return false;
  }

  private boolean jj_3R_13() {
    if (jj_scan_token(SYM_L_PARENTHESIS)) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_47()) {
    jj_scanpos = xsp;
    if (jj_3R_48()) {
    jj_scanpos = xsp;
    if (jj_3R_49()) return true;
    }
    }
    if (jj_scan_token(SYM_R_PARENTHESIS)) return true;
    return false;
  }

  private boolean jj_3R_5() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_13()) {
    jj_scanpos = xsp;
    if (jj_3R_14()) {
    jj_scanpos = xsp;
    if (jj_3R_15()) return true;
    }
    }
    return false;
  }

  private boolean jj_3R_22() {
    if (jj_scan_token(V_DATE_TIME_Z)) return true;
    return false;
  }

  private boolean jj_3_3() {
    if (jj_3R_5()) return true;
    return false;
  }

  private boolean jj_3_5() {
    if (jj_scan_token(SYM_EXCLAMATION)) return true;
    if (jj_scan_token(SYM_FIRED)) return true;
    if (jj_3R_5()) return true;
    return false;
  }

  private boolean jj_3_2() {
    if (jj_3R_4()) return true;
    return false;
  }

  private boolean jj_3R_3() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3_2()) {
    jj_scanpos = xsp;
    if (jj_3_3()) return true;
    }
    return false;
  }

  private boolean jj_3R_21() {
    if (jj_scan_token(V_ORDINAL)) return true;
    return false;
  }

  private boolean jj_3R_25() {
    if (jj_scan_token(V_LABEL)) return true;
    return false;
  }

  private boolean jj_3_4() {
    if (jj_scan_token(SYM_EXCLAMATION)) return true;
    if (jj_3R_5()) return true;
    return false;
  }

  private boolean jj_3R_20() {
    if (jj_scan_token(V_STRING)) return true;
    return false;
  }

  private boolean jj_3R_46() {
    if (jj_3R_51()) return true;
    return false;
  }

  private boolean jj_3R_30() {
    if (jj_scan_token(SYM_MATH_FUNCTION)) return true;
    if (jj_scan_token(SYM_L_PARENTHESIS)) return true;
    if (jj_3R_5()) return true;
    if (jj_scan_token(SYM_R_PARENTHESIS)) return true;
    return false;
  }

  private boolean jj_3R_29() {
    if (jj_scan_token(SYM_FIRED)) return true;
    if (jj_3R_5()) return true;
    return false;
  }

  private boolean jj_3R_19() {
    if (jj_scan_token(SYM_E)) return true;
    return false;
  }

  /** Generated Token Manager. */
  public ExpressionParserTokenManager token_source;
  SimpleCharStream jj_input_stream;
  /** Current token. */
  public Token token;
  /** Next token. */
  public Token jj_nt;
  private int jj_ntk;
  private Token jj_scanpos, jj_lastpos;
  private int jj_la;
  private int jj_gen;
  final private int[] jj_la1 = new int[12];
  static private int[] jj_la1_0;
  static private int[] jj_la1_1;
  static private int[] jj_la1_2;
  static {
      jj_la1_init_0();
      jj_la1_init_1();
      jj_la1_init_2();
   }
   private static void jj_la1_init_0() {
      jj_la1_0 = new int[] {0x0,0x7e000f80,0x40000,0x160000,0x140000,0x0,0x0,0x0,0x0,0x0,0x100000,0x1000,};
   }
   private static void jj_la1_init_1() {
      jj_la1_1 = new int[] {0x1780,0x63,0x0,0x5e01f9c,0x5e0081c,0x0,0x5c0081c,0x200000,0x102000,0x0,0x0,0x0,};
   }
   private static void jj_la1_init_2() {
      jj_la1_2 = new int[] {0x0,0x0,0x0,0x401980d,0x401980d,0x4000,0x1900d,0x0,0x0,0x4000,0x4000000,0x0,};
   }
  final private JJCalls[] jj_2_rtns = new JJCalls[11];
  private boolean jj_rescan = false;
  private int jj_gc = 0;

  /** Constructor with InputStream. */
  public ExpressionParser(java.io.InputStream stream) {
     this(stream, null);
  }
  /** Constructor with InputStream and supplied encoding */
  public ExpressionParser(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 ExpressionParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 12; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** 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 < 12; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Constructor. */
  public ExpressionParser(java.io.Reader stream) {
    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new ExpressionParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 12; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** 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 < 12; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Constructor with generated Token Manager. */
  public ExpressionParser(ExpressionParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 12; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  /** Reinitialise. */
  public void ReInit(ExpressionParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 12; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  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++;
      if (++jj_gc > 100) {
        jj_gc = 0;
        for (int i = 0; i < jj_2_rtns.length; i++) {
          JJCalls c = jj_2_rtns[i];
          while (c != null) {
            if (c.gen < jj_gen) c.first = null;
            c = c.next;
          }
        }
      }
      return token;
    }
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  }

  static private final class LookaheadSuccess extends java.lang.Error { }
  final private LookaheadSuccess jj_ls = new LookaheadSuccess();
  private boolean jj_scan_token(int kind) {
    if (jj_scanpos == jj_lastpos) {
      jj_la--;
      if (jj_scanpos.next == null) {
        jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
      } else {
        jj_lastpos = jj_scanpos = jj_scanpos.next;
      }
    } else {
      jj_scanpos = jj_scanpos.next;
    }
    if (jj_rescan) {
      int i = 0; Token tok = token;
      while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
      if (tok != null) jj_add_error_token(kind, i);
    }
    if (jj_scanpos.kind != kind) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
    return false;
  }


/** 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;
  private int[] jj_lasttokens = new int[100];
  private int jj_endpos;

  private void jj_add_error_token(int kind, int pos) {
    if (pos >= 100) return;
    if (pos == jj_endpos + 1) {
      jj_lasttokens[jj_endpos++] = kind;
    } else if (jj_endpos != 0) {
      jj_expentry = new int[jj_endpos];
      for (int i = 0; i < jj_endpos; i++) {
        jj_expentry[i] = jj_lasttokens[i];
      }
      jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) {
        int[] oldentry = (int[])(it.next());
        if (oldentry.length == jj_expentry.length) {
          for (int i = 0; i < jj_expentry.length; i++) {
            if (oldentry[i] != jj_expentry[i]) {
              continue jj_entries_loop;
            }
          }
          jj_expentries.add(jj_expentry);
          break jj_entries_loop;
        }
      }
      if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
    }
  }

  /** Generate ParseException. */
  public ParseException generateParseException() {
    jj_expentries.clear();
    boolean[] la1tokens = new boolean[91];
    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< jj_gen) {
          jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
          switch (i) {
            case 0: jj_3_1(); break;
            case 1: jj_3_2(); break;
            case 2: jj_3_3(); break;
            case 3: jj_3_4(); break;
            case 4: jj_3_5(); break;
            case 5: jj_3_6(); break;
            case 6: jj_3_7(); break;
            case 7: jj_3_8(); break;
            case 8: jj_3_9(); break;
            case 9: jj_3_10(); break;
            case 10: jj_3_11(); break;
          }
        }
        p = p.next;
      } while (p != null);
      } catch(LookaheadSuccess ls) { }
    }
    jj_rescan = false;
  }

  private void jj_save(int index, int xla) {
    JJCalls p = jj_2_rtns[index];
    while (p.gen > jj_gen) {
      if (p.next == null) { p = p.next = new JJCalls(); break; }
      p = p.next;
    }
    p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
  }

  static final class JJCalls {
    int gen;
    Token first;
    int arg;
    JJCalls next;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy