Package org.stringtemplate.v4.compiler

Examples of org.stringtemplate.v4.compiler.Bytecode


   'for'=8
   *
   *  This is independent of the target language; used by antlr internally
   */
  ST getTokenVocabOutput() {
    ST vocabFileST = new ST(vocabFilePattern);
    Map<String,Integer> tokens = new LinkedHashMap<String,Integer>();
    // make constants for the token names
    for (String t : g.tokenNameToTypeMap.keySet()) {
      int tokenType = g.tokenNameToTypeMap.get(t);
      if ( tokenType>=Token.MIN_USER_TOKEN_TYPE) {
        tokens.put(t, tokenType);
      }
    }
    vocabFileST.add("tokens", tokens);

    // now dump the strings
    Map<String,Integer> literals = new LinkedHashMap<String,Integer>();
    for (String literal : g.stringLiteralToTypeMap.keySet()) {
      int tokenType = g.stringLiteralToTypeMap.get(literal);
      if ( tokenType>=Token.MIN_USER_TOKEN_TYPE) {
        literals.put(literal, tokenType);
      }
    }
    vocabFileST.add("literals", literals);

    return vocabFileST;
  }
View Full Code Here


  public void writeHeaderFile() {
    String fileName = getHeaderFileName();
    if ( fileName==null ) return;
    if ( getTemplates().isDefined("headerFile") ) {
      ST extST = getTemplates().getInstanceOf("headerFileExtension");
      ST headerFileST = null;
      // TODO:  don't hide this header file generation here!
      getTarget().genRecognizerHeaderFile(g, headerFileST, extST.render(lineWidth));
    }
  }
View Full Code Here

  }

  public void writeVocabFile() {
    // write out the vocab interchange file; used by antlr,
    // does not change per target
    ST tokenVocabSerialization = getTokenVocabOutput();
    String fileName = getVocabFileName();
    if ( fileName!=null ) {
      getTarget().genFile(g, tokenVocabSerialization, fileName);
    }
  }
View Full Code Here

  /** Generate TParser.java and TLexer.java from T.g4 if combined, else
   *  just use T.java as output regardless of type.
   */
  public String getRecognizerFileName() {
    ST extST = getTemplates().getInstanceOf("codeFileExtension");
    String recognizerName = g.getRecognizerName();
    return recognizerName+extST.render();
  }
View Full Code Here

  /** A given grammar T, return the listener name such as
   *  TListener.java, if we're using the Java target.
    */
  public String getListenerFileName() {
    assert g.name != null;
    ST extST = getTemplates().getInstanceOf("codeFileExtension");
    String listenerName = g.name + "Listener";
    return listenerName+extST.render();
  }
View Full Code Here

  /** A given grammar T, return the visitor name such as
   *  TVisitor.java, if we're using the Java target.
    */
  public String getVisitorFileName() {
    assert g.name != null;
    ST extST = getTemplates().getInstanceOf("codeFileExtension");
    String listenerName = g.name + "Visitor";
    return listenerName+extST.render();
  }
View Full Code Here

  /** A given grammar T, return a blank listener implementation
   *  such as TBaseListener.java, if we're using the Java target.
    */
  public String getBaseListenerFileName() {
    assert g.name != null;
    ST extST = getTemplates().getInstanceOf("codeFileExtension");
    String listenerName = g.name + "BaseListener";
    return listenerName+extST.render();
  }
View Full Code Here

  /** A given grammar T, return a blank listener implementation
   *  such as TBaseListener.java, if we're using the Java target.
    */
  public String getBaseVisitorFileName() {
    assert g.name != null;
    ST extST = getTemplates().getInstanceOf("codeFileExtension");
    String listenerName = g.name + "BaseVisitor";
    return listenerName+extST.render();
  }
View Full Code Here

  public String getVocabFileName() {
    return g.name+VOCAB_FILE_EXTENSION;
  }

  public String getHeaderFileName() {
    ST extST = getTemplates().getInstanceOf("headerFileExtension");
    if ( extST==null ) return null;
    String recognizerName = g.getRecognizerName();
    return recognizerName+extST.render();
  }
View Full Code Here

    public void testActions(String location, String[] pairs, String template) {
        for (int i = 0; i < pairs.length; i+=2) {
            String action = pairs[i];
            String expected = pairs[i+1];
            ST st = new ST(template);
            st.add(location, action);
            String grammar = st.render();
            testErrors(new String[] {grammar, expected}, false);
        }
    }
View Full Code Here

TOP

Related Classes of org.stringtemplate.v4.compiler.Bytecode

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.