Package org.stringtemplate.v4.test

Examples of org.stringtemplate.v4.test.BaseTest$StreamVacuum


  public Grammar(Tool tool) {
    setTool(tool);
    builtFromString = true;
    composite = new CompositeGrammar(this);
    STGroup lexerGrammarSTG = new STGroupString(lexerGrammarTemplate);
    lexerGrammarST = lexerGrammarSTG.getInstanceOf("grammar");
    target = CodeGenerator.loadLanguageTarget((String)getOption("language"));
  }
View Full Code Here


        // new output dir for each test
        tmpdir = new File(System.getProperty("java.io.tmpdir"),
              "antlr-"+getClass().getName()+"-"+
              System.currentTimeMillis()).getAbsolutePath();
        ErrorManager.resetErrorState();
        STGroup.defaultGroup = new STGroup();
    }
View Full Code Here

    return getBadWords().contains(idNode.getText());
  }

  @Override
  protected STGroup loadTemplates() {
    STGroup result = targetTemplates.get();
    if (result == null) {
      result = super.loadTemplates();
      result.registerRenderer(String.class, new JavaStringRenderer(), true);
      targetTemplates.set(result);
    }

    return result;
  }
View Full Code Here

  }

  public void testActions(String templates, String actionName, String action, String expected) throws org.antlr.runtime.RecognitionException {
    int lp = templates.indexOf('(');
    String name = templates.substring(0, lp);
    STGroup group = new STGroupString(templates);
    ST st = group.getInstanceOf(name);
    st.add(actionName, action);
    String grammar = st.render();
    ErrorQueue equeue = new ErrorQueue();
    Grammar g = new Grammar(grammar, equeue);
    if ( g.ast!=null && !g.ast.hasErrors ) {
View Full Code Here

                Map<String, Map<String, Object>> actions = grammar.getActions();
                actions.put( "all", sharedActionBlocks.get( grammar.name ) );
            }
        }

        STGroup group = generator.getTemplates();
        RubyRenderer renderer = new RubyRenderer();
        try {
            group.registerRenderer( Class.forName( "java.lang.String" ), renderer );
        } catch ( ClassNotFoundException e ) {
            // this shouldn't happen
            System.err.println( "ClassNotFoundException: " + e.getMessage() );
            e.printStackTrace( System.err );
        }
View Full Code Here

  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

   *  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

            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

    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

    }

    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

TOP

Related Classes of org.stringtemplate.v4.test.BaseTest$StreamVacuum

Copyright © 2018 www.massapicom. 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.