Examples of STGroupFile


Examples of org.stringtemplate.v4.STGroupFile

  public static void setLocale(Locale locale) {
    ErrorManager.locale = locale;
    String language = locale.getLanguage();
    String fileName = "org/antlr/tool/templates/messages/languages/"+language+".stg";
    try {
      messages = new STGroupFile(fileName);
    }
    catch (IllegalArgumentException iae) {
      if ( language.equals(Locale.US.getLanguage()) ) {
        rawError("ANTLR installation corrupted; cannot find English messages file "+fileName);
        panic();
View Full Code Here

Examples of org.stringtemplate.v4.STGroupFile

   *  Otherwise we just use the default "antlr".
   */
  public static void setFormat(String formatName) {
    ErrorManager.formatName = formatName;
    String fileName = "org/antlr/tool/templates/messages/formats/"+formatName+".stg";
    format = new STGroupFile(fileName);
    format.setListener(initSTListener);
    if ( !format.isDefined("message") ) { // pick random msg to load
      if ( formatName.equals("antlr") ) {
        rawError("no such message format file "+fileName+" retrying with default ANTLR format");
        setFormat("antlr"); // recurse on this rule, trying the default message format
View Full Code Here

Examples of org.stringtemplate.v4.STGroupFile

            rawError("no such message format file "+fileName+" retrying with default ANTLR format");
            setFormat("antlr"); // recurse on this rule, trying the default message format
            return;
        }

        format = new STGroupFile(fileName, "UTF-8");
        format.load();

        if ( !initSTListener.errors.isEmpty() ) {
            rawError("ANTLR installation corrupted; can't load messages format file:\n"+
                     initSTListener.toString());
View Full Code Here

Examples of org.stringtemplate.v4.STGroupFile

    loadPrecRuleTemplates();
  }

  public void loadPrecRuleTemplates() {
    String templateGroupFile = "org/antlr/v4/tool/templates/LeftRecursiveRules.stg";
    recRuleTemplates = new STGroupFile(templateGroupFile);
    if ( !recRuleTemplates.isDefined("recRule") ) {
      tool.errMgr.toolError(ErrorType.MISSING_CODE_GEN_TEMPLATES, "LeftRecursiveRules");
    }

    // use codegen to get correct language templates; that's it though
View Full Code Here

Examples of org.stringtemplate.v4.STGroupFile

    }

    public void loadDependencyTemplates() {
        if (templates != null) return;
        String fileName = "org/antlr/v4/tool/templates/depend.stg";
        templates = new STGroupFile(fileName, "UTF-8");
    }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupFile

  public boolean templatesExist() {
    String groupFileName = CodeGenerator.TEMPLATE_ROOT + "/" + getLanguage() + "/" + getLanguage() + STGroup.GROUP_FILE_EXTENSION;
    STGroup result = null;
    try {
      result = new STGroupFile(groupFileName);
    }
    catch (IllegalArgumentException iae) {
      result = null;
    }
    return result!=null;
View Full Code Here

Examples of org.stringtemplate.v4.STGroupFile

  @Nullable
  protected STGroup loadTemplates() {
    String groupFileName = CodeGenerator.TEMPLATE_ROOT + "/" + getLanguage() + "/" + getLanguage() + STGroup.GROUP_FILE_EXTENSION;
    STGroup result = null;
    try {
      result = new STGroupFile(groupFileName);
    }
    catch (IllegalArgumentException iae) {
      gen.tool.errMgr.toolError(ErrorType.MISSING_CODE_GEN_TEMPLATES,
             iae,
             language);
View Full Code Here

Examples of org.stringtemplate.v4.STGroupFile

  public void time2Args(int reps) {
    String templates =
      "t(x,y) ::= \"<x><y>\"\n";
    Misc.writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("t");
    st.add("x", 1);
    st.add("y", 2);

    for (int i = 0; i < reps; i++) {
      st.render();
View Full Code Here

Examples of org.stringtemplate.v4.STGroupFile

  public void timeLotsOfArgs(int reps) {
    String templates =
      "t(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) ::=" +
        " \"<a>,<b>,<c>,<d>,<e>,<f>,<g>,<h>,<i>,<j>,<k>,<l>,<m>,<n>,<o>,<p>,<q>,<r>,<s>,<t>,<u>,<v>,<w>,<x>,<y>,<z>\"\n";
    Misc.writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("t");
    st.add("x", 1);
    st.add("y", 2);

    for (int i = 0; i < reps; i++) {
      st.render();
View Full Code Here

Examples of org.stringtemplate.v4.STGroupFile

  public void timeSimplePropsOfArgs(int reps) {
    String templates =
      "t(x) ::= \"<x.id><x.name><x.id><x.name><x.id><x.name>\"\n";
    Misc.writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("t");
    st.add("x", new User(32,"parrt"));

    for (int i = 0; i < reps; i++) {
      st.render();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.