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

org.etlunit.parser.ETLTestParser Maven / Gradle / Ivy

/* Generated By:JavaCC: Do not edit this line. ETLTestParser.java */
package org.etlunit.parser;

import java.io.StringReader;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
import java.io.Reader;

public class ETLTestParser implements ETLTestParserConstants {
        public static void main(String args[]) throws ParseException {
                ETLTestParser parser = new ETLTestParser(System.in);
                parser.loadClasses("");
        }

        public static List load(String s, String _package) throws ParseException
        {
                return load(new StringReader(s), _package);
        }

        public static List load(String s) throws ParseException
        {
                return load(s, "");
        }

        public static ETLTestValueObject loadObject(String s) throws ParseException
        {
                ETLTestParser itp = new ETLTestParser(new StringReader(s));
                return itp.valueObject();
        }

        public static ETLTestValueObject loadBareObject(String s) throws ParseException
        {
                ETLTestParser itp = new ETLTestParser(new StringReader(s));
                return itp.bareMap();
        }

        public static List load(Reader r, String _package) throws ParseException
        {
                ETLTestParser itp = new ETLTestParser(r);
                return itp.loadClasses(_package);
        }

        public static List load(Reader r) throws ParseException
        {
                return load(r, "");
        }

        private String stripChars(String s)
        {
                return s.substring(1, s.length() - 1);
        }

  final public List loadClasses(String _package) throws ParseException {
        List classes = new ArrayList();
    label_1:
    while (true) {
      loadClass(classes, _package);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case CLASS:
      case ANNOTATION:
        ;
        break;
      default:
        jj_la1[0] = jj_gen;
        break label_1;
      }
    }
                {if (true) return classes;}
    throw new Error("Missing return statement in function");
  }

  final public void loadClass(List classes, String _package) throws ParseException {
        ETLTestValueObject val = null;
        Token t;
        ETLTestClassImpl itclass;
        List annotations = new ArrayList();
    label_2:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case ANNOTATION:
        ;
        break;
      default:
        jj_la1[1] = jj_gen;
        break label_2;
      }
      t = jj_consume_token(ANNOTATION);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LPAREN:
        jj_consume_token(LPAREN);
        val = bareMap();
        jj_consume_token(RPAREN);
        break;
      default:
        jj_la1[2] = jj_gen;
        ;
      }
                        if (val == null)
                        {
                                annotations.add(new ETLTestAnnotationImpl(t.image, t));
                        }
                        else
                        {
                                annotations.add(new ETLTestAnnotationImpl(t.image, val, t));
                                val = null;
                        }
    }
    jj_consume_token(CLASS);
    t = jj_consume_token(IDENTIFIER);
                itclass = new ETLTestClassImpl(_package, t);
                itclass.addAnnotations(annotations);
                itclass.setName(t.image);
    jj_consume_token(LBRACE);
    label_3:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case ANNOTATION:
      case VAR:
      case IDENTIFIER:
        ;
        break;
      default:
        jj_la1[3] = jj_gen;
        break label_3;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case ANNOTATION:
      case IDENTIFIER:
        test(itclass);
        break;
      case VAR:
        variable(itclass);
        break;
      default:
        jj_la1[4] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
    jj_consume_token(RBRACE);
                classes.add(itclass);
  }

  final public void test(ETLTestClassImpl itclass) throws ParseException {
        ETLTestValueObject val = null;
        Token t = null;
        ETLTestMethod.method_type tp = null;
        ETLTestMethodImpl method = null;
        List annList = new ArrayList();
    label_4:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case ANNOTATION:
        ;
        break;
      default:
        jj_la1[5] = jj_gen;
        break label_4;
      }
      t = jj_consume_token(ANNOTATION);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LPAREN:
        jj_consume_token(LPAREN);
        val = bareMap();
        jj_consume_token(RPAREN);
        break;
      default:
        jj_la1[6] = jj_gen;
        ;
      }
                        if (val == null)
                        {
                                annList.add(new ETLTestAnnotationImpl(t.image, t));
                        }
                        else
                        {
                                annList.add(new ETLTestAnnotationImpl(t.image, val, t));
                                val = null;
                        }
    }
    t = jj_consume_token(IDENTIFIER);
                method = new ETLTestMethodImpl(t.image, tp, itclass, t);
                method.addAnnotations(annList);
    jj_consume_token(LPAREN);
    jj_consume_token(RPAREN);
    jj_consume_token(LBRACE);
    label_5:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case IDENTIFIER:
        ;
        break;
      default:
        jj_la1[7] = jj_gen;
        break label_5;
      }
      operation(method);
    }
    jj_consume_token(RBRACE);
                if (method != null)
                {
                        itclass.addMethod(method);
                }
  }

  final public void operation(ETLTestMethodImpl itmethod) throws ParseException {
        Token t = null;
        ETLTestOperationImpl opImpl = null;
        StringBuilder quoteBuilder = new StringBuilder();
        ETLTestValueObject val = null;
    t = jj_consume_token(IDENTIFIER);

    jj_consume_token(LPAREN);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case LBRACE:
    case FLOATING_NUMBER:
    case INT_NUMBER:
    case IDENTIFIER:
    case SIMPLE_QUOTE_LITERAL:
    case DOUBLE_QUOTE_LITERAL:
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LBRACE:
        val = map();
        break;
      case FLOATING_NUMBER:
      case INT_NUMBER:
      case IDENTIFIER:
      case SIMPLE_QUOTE_LITERAL:
      case DOUBLE_QUOTE_LITERAL:
        val = nonBlankBareMap();
        break;
      default:
        jj_la1[8] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      break;
    default:
      jj_la1[9] = jj_gen;
      ;
    }
    jj_consume_token(RPAREN);
                opImpl = new ETLTestOperationImpl(itmethod, t.image, itmethod.getOperations().size(), val, t);

                if (itmethod != null)
                {
                        itmethod.addOperation(opImpl);
                }
    jj_consume_token(OPERATION_TERMINATOR);
  }

  final public void variable(ETLTestClassImpl itclass) throws ParseException {
        Token t;
        ETLTestValueObject o;
    jj_consume_token(VAR);
    t = jj_consume_token(IDENTIFIER);
    jj_consume_token(EQUALS);
    o = valueObject();
                itclass.addClassVariable(new ETLTestVariableImpl(t.image, o, t));
    jj_consume_token(OPERATION_TERMINATOR);
  }

  final public ETLTestValueObject valueObject() throws ParseException {
        ETLTestValueObject o;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 34:
      o = array();
      break;
    case LBRACE:
      o = map();
      break;
    case FLOATING_NUMBER:
    case INT_NUMBER:
    case IDENTIFIER:
    case SIMPLE_QUOTE_LITERAL:
    case DOUBLE_QUOTE_LITERAL:
      o = identifier();
      break;
    default:
      jj_la1[10] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
                {if (true) return o;}
    throw new Error("Missing return statement in function");
  }

  final public ETLTestValueObject identifier() throws ParseException {
        Token t;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case FLOATING_NUMBER:
      t = jj_consume_token(FLOATING_NUMBER);
                        {if (true) return new ETLTestValueObjectImpl(t.image, true, t);}
      break;
    case INT_NUMBER:
      t = jj_consume_token(INT_NUMBER);
                        {if (true) return new ETLTestValueObjectImpl(t.image, true, t);}
      break;
    case IDENTIFIER:
      t = jj_consume_token(IDENTIFIER);
                        if (t.image.equals("true"))
                        {
                                {if (true) return new ETLTestValueObjectImpl(true, t);}
                        }
                        else if (t.image.equals("false"))
                        {
                                {if (true) return new ETLTestValueObjectImpl(false, t);}
                        }
                        else if(t.image.equals("null"))
                        {
                                {if (true) return null;}
                        }

                        {if (true) return new ETLTestValueObjectImpl(t.image, true, t);}
      break;
    case SIMPLE_QUOTE_LITERAL:
      t = jj_consume_token(SIMPLE_QUOTE_LITERAL);
                        {if (true) return new ETLTestValueObjectImpl(UnEscapist.dequotify(UnEscapist.unescape(t.image)), t);}
      break;
    case DOUBLE_QUOTE_LITERAL:
      t = jj_consume_token(DOUBLE_QUOTE_LITERAL);
                        {if (true) return new ETLTestValueObjectImpl(UnEscapist.dequotify(UnEscapist.unescape(t.image)), t);}
      break;
    default:
      jj_la1[11] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    throw new Error("Missing return statement in function");
  }

  final public ETLTestValueObject array() throws ParseException {
        List list = new ArrayList();
        ETLTestValueObject o;
    jj_consume_token(34);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case LBRACE:
    case FLOATING_NUMBER:
    case INT_NUMBER:
    case IDENTIFIER:
    case SIMPLE_QUOTE_LITERAL:
    case DOUBLE_QUOTE_LITERAL:
    case 34:
      o = valueObject();
                                  list.add(o);
      label_6:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case OPERAND_DIVIDER:
          ;
          break;
        default:
          jj_la1[12] = jj_gen;
          break label_6;
        }
        jj_consume_token(OPERAND_DIVIDER);
        o = valueObject();
                                                                          list.add(o);
      }
      break;
    default:
      jj_la1[13] = jj_gen;
      ;
    }
    jj_consume_token(35);
                {if (true) return new ETLTestValueObjectImpl(list);}
    throw new Error("Missing return statement in function");
  }

  final public ETLTestValueObject map() throws ParseException {
        ETLTestValueObject map;
    jj_consume_token(LBRACE);
    map = bareMap();
    jj_consume_token(RBRACE);
                {if (true) return map;}
    throw new Error("Missing return statement in function");
  }

  final public ETLTestValueObject bareMap() throws ParseException {
        Map map = new HashMap();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case FLOATING_NUMBER:
    case INT_NUMBER:
    case IDENTIFIER:
    case SIMPLE_QUOTE_LITERAL:
    case DOUBLE_QUOTE_LITERAL:
      keyValue(map);
      label_7:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case OPERAND_DIVIDER:
          ;
          break;
        default:
          jj_la1[14] = jj_gen;
          break label_7;
        }
        jj_consume_token(OPERAND_DIVIDER);
        keyValue(map);
      }
      break;
    default:
      jj_la1[15] = jj_gen;
      ;
    }
                {if (true) return new ETLTestValueObjectImpl(map);}
    throw new Error("Missing return statement in function");
  }

  final public ETLTestValueObject nonBlankBareMap() throws ParseException {
        Map map = new HashMap();
    keyValue(map);
    label_8:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case OPERAND_DIVIDER:
        ;
        break;
      default:
        jj_la1[16] = jj_gen;
        break label_8;
      }
      jj_consume_token(OPERAND_DIVIDER);
      keyValue(map);
    }
                {if (true) return new ETLTestValueObjectImpl(map);}
    throw new Error("Missing return statement in function");
  }

  final public void keyValue(Map map) throws ParseException {
        ETLTestValueObject k;
        ETLTestValueObject v;
    k = identifier();
    jj_consume_token(36);
    v = valueObject();
                if (k == null)
                {
                        {if (true) throw new ParseException("null cannot be used as key in object");}
                }

                map.put(k.getValueAsString(),v);
  }

  /** Generated Token Manager. */
  public ETLTestParserTokenManager 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[17];
  static private int[] jj_la1_0;
  static private int[] jj_la1_1;
  static {
      jj_la1_init_0();
      jj_la1_init_1();
   }
   private static void jj_la1_init_0() {
      jj_la1_0 = new int[] {0x48000,0x40000,0x80000,0x40840000,0x40840000,0x40000,0x80000,0x40000000,0x70010000,0x70010000,0x70010000,0x70000000,0x400000,0x70010000,0x400000,0x70000000,0x400000,};
   }
   private static void jj_la1_init_1() {
      jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x3,0x7,0x3,0x0,0x7,0x0,0x3,0x0,};
   }

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

  /** Constructor. */
  public ETLTestParser(java.io.Reader stream) {
    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new ETLTestParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 17; 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 < 17; i++) jj_la1[i] = -1;
  }

  /** Constructor with generated Token Manager. */
  public ETLTestParser(ETLTestParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 17; i++) jj_la1[i] = -1;
  }

  /** Reinitialise. */
  public void ReInit(ETLTestParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 17; 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[37];
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 17; i++) {
      if (jj_la1[i] == jj_gen) {
        for (int j = 0; j < 32; j++) {
          if ((jj_la1_0[i] & (1<




© 2015 - 2025 Weber Informatics LLC | Privacy Policy