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

com.vectorprint.configuration.generated.parser.HelpParser Maven / Gradle / Ivy

Go to download

A library for settings and parameterization of objects. Key features are support for data types, help for settings and parameters, annotations for ease of use. Settings and parameters both are Clonable and Serializable. More features for settings such as parsing a settingsfile, being observable, readonliness, caching etc. are available. The library contains javacc generated parsers for syntax support for properties, multi valued properties, parameterized objects and multi valued parameters.

The newest version!
/* HelpParser.java */
/* Generated by: ParserGeneratorCC: Do not edit this line. HelpParser.java */
    package com.vectorprint.configuration.generated.parser;

    import java.util.Map;
    import com.vectorprint.configuration.PropertyHelp;
    import com.vectorprint.configuration.PropertyHelpImpl;

    /**
      * A parser for key based help in the form key=type;helptext, helptext can span lines by escaping the end of a line:
      *
      * 

            help=Double;dit is een\
            mooie help tekst\
            !
      * 
      */
    public class HelpParser implements HelpParserConstants {

  final public void parse(Map h) throws ParseException {
    label_1:
    while (true) {
      switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) {
      case KEY:{
        break;
        }
      default:
        jj_la1[0] = jj_gen;
        break label_1;
      }
      help(h);
    }
    jj_consume_token(0);
}

  final public void help(Map h) throws ParseException {Token t = null; StringBuilder v = new StringBuilder(""); String[] kt = null;
    kt = keyAndType();
    t = jj_consume_token(VALUE);
v.append(t.image);
    label_2:
    while (true) {
      switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) {
      case CONTINUATION:{
        break;
        }
      default:
        jj_la1[1] = jj_gen;
        break label_2;
      }
      t = jj_consume_token(CONTINUATION);
v.append(t.image.substring(1));
      switch (jj_ntk == -1 ? jj_ntk_f() : jj_ntk) {
      case VALUE:{
        t = jj_consume_token(VALUE);
v.append(t.image);
        break;
        }
      default:
        jj_la1[2] = jj_gen;
        ;
      }
    }
h.put(kt[0],new PropertyHelpImpl(kt[1],v.toString()));
}

  final public String[] keyAndType() throws ParseException {Token t = null; String k ="";
    t = jj_consume_token(KEY);
k=t.image;
    t = jj_consume_token(TYPE);
{if ("" != null) return new String[] {k,t.image};}
    throw new IllegalStateException ("Missing return statement in function");
}

  /** Generated Token Manager. */
  public HelpParserTokenManager 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[3];
  static private int[] jj_la1_0;
  static {
	   jj_la1_init_0();
	}
	private static void jj_la1_init_0() {
	   jj_la1_0 = new int[] {0x20,0x1000,0x800,};
	}

  /**
   * Constructor with InputStream and supplied encoding
   * @param stream input stream
   * @param encoding charset to be used. May not be null.
   */
  public HelpParser(final java.io.InputStream stream, final String encoding) {
   try {
     jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1);
   } catch(final java.io.UnsupportedEncodingException e) {
     throw new IllegalStateException(e);
   }
	 token_source = new HelpParserTokenManager(jj_input_stream);
	 token = new Token();
	 jj_ntk = -1;
	 jj_gen = 0;
	 for (int i = 0; i < 3; i++) jj_la1[i] = -1;
  }

  /**
   * Reinitialise
   * @param stream input stream
   * @param encoding charset to be used. May not be null.
   */
  public void ReInit(final java.io.InputStream stream, final String encoding) {
	  try {
      jj_input_stream.reInit(stream, encoding, 1, 1);
    } catch(final java.io.UnsupportedEncodingException e) { 
      throw new IllegalStateException(e);
    }
	 token_source.ReInit(jj_input_stream);
	 token = new Token();
	 jj_ntk = -1;
	 jj_gen = 0;
	 for (int i = 0; i < 3; i++) jj_la1[i] = -1;
  }

  /**
   * Constructor with InputStream.
   * @param stream char stream
   */
  public HelpParser(final java.io.Reader stream) {
	 jj_input_stream = new SimpleCharStream(stream, 1, 1);
	 token_source = new HelpParserTokenManager(jj_input_stream);
	 token = new Token();
	 jj_ntk = -1;
	 jj_gen = 0;
   for (int i = 0; i < 3; i++)
     jj_la1[i] = -1;
  }

  /**
   * Reinitialise
   * @param stream char stream
   */
  public void ReInit(final java.io.Reader stream) {
	if (jj_input_stream == null) {
	  jj_input_stream = new SimpleCharStream(stream, 1, 1);
	} else {
	  jj_input_stream.reInit(stream, 1, 1);
  }
	if (token_source == null) {
 token_source = new HelpParserTokenManager(jj_input_stream);
	}

	 token_source.ReInit(jj_input_stream);
	 token = new Token();
	 jj_ntk = -1;
	 jj_gen = 0;
   for (int i = 0; i < 3; i++)
     jj_la1[i] = -1;
  }

  /**
   * Constructor with generated Token Manager.
   * @param tm Token manager to use
   */
  public HelpParser(final HelpParserTokenManager tm) {
	 token_source = tm;
	 token = new Token();
	 jj_ntk = -1;
	 jj_gen = 0;
	 for (int i = 0; i < 3; i++) jj_la1[i] = -1;
  }

  /**
   * Reinitialise
   * @param tm Token manager to use
   */
  public void ReInit(final HelpParserTokenManager tm) {
	 token_source = tm;
	 token = new Token();
	 jj_ntk = -1;
	 jj_gen = 0;
	 for (int i = 0; i < 3; i++) jj_la1[i] = -1;
  }

  private Token jj_consume_token(final int kind) throws ParseException {
    final Token oldToken = token;
    if (token.next != null)
      token = token.next;
    else {
      token.next = token_source.getNextToken();
      token = token.next;
    }
    jj_ntk = -1;
    if (token.kind == kind) {
      jj_gen++;
      return token;
    }
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  }


  /**
   * @return the next Token.
   */
  public final Token getNextToken() {
   if (token.next != null)
     token = token.next;
   else
     token = token.next = token_source.getNextToken();
	 jj_ntk = -1;
	 jj_gen++;
	 return token;
  }

  /**
   * @param index index to be retrieved
   * @return the specific Token.
   */
  public final Token getToken(final int index) {
    Token t = token;
    for (int i = 0; i < index; i++) {
      if (t.next == null)
        t.next = token_source.getNextToken();
      t = t.next;
    }
    return t;
  }

  private int jj_ntk_f() {
    final Token nt = jj_nt = token.next;
    final int ret;
    if (nt == null) {
      token.next = token_source.getNextToken();
      ret = jj_ntk = token.next.kind;
    }
    else
      ret = jj_ntk = nt.kind;
    return ret;
  }

  private java.util.List jj_expentries = new java.util.ArrayList();
  private int[] jj_expentry;
  private int jj_kind = -1;

  /**
   * Generate ParseException.
   * @return new Exception object. Never null
   */
  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 < 3; i++) {
      if (jj_la1[i] == jj_gen) {
        for (int j = 0; j < 32; j++) {
          if ((jj_la1_0[i] & (1<false.
   */
  public final boolean trace_enabled() {
    return false;
  }

  /** Enable tracing. */
  public final void enable_tracing() {}

  /** Disable tracing. */
  public final void disable_tracing() {}

    }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy