You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ov...@apache.org on 2002/03/17 23:01:23 UTC

cvs commit: xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/flow Translator.java

ovidiu      02/03/17 14:01:23

  Added:       src/scratchpad/schecoon/src/org/apache/cocoon/flow
                        Translator.java
  Log:
  Simple translator.
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/flow/Translator.java
  
  Index: Translator.java
  ===================================================================
  package org.apache.cocoon.flow;
  
  import antlr.CommonAST;
  import antlr.TokenStreamRecognitionException;
  import antlr.collections.AST;
  import java.io.BufferedReader;
  import java.io.FileReader;
  import java.io.Reader;
  
  public class Translator
  {
    static void main(String[] args)
      throws Exception
    {
      Reader input = new BufferedReader(new FileReader(args[0]));
  
      System.out.println("translating " + args[0]);
      Translator t = new Translator();
      t.translate(input, args[0]);
    }
  
    public void translate(Reader input, String identifier)
      throws Exception
    {
      FlowLexer lexer = new FlowLexer(input);
      lexer.setFilename(identifier);
  
      FlowParser parser = new FlowParser(lexer);
      parser.setFilename(identifier);
  
      try {
        parser.program();
      }
      catch (TokenStreamRecognitionException ex) {
        ex.printStackTrace();
        System.out.println(lexer.getFilename() + ":" + lexer.getLine()
                           + ":" + lexer.getColumn() + ": "
                           + ex.getMessage());
        
      }
  
      CommonAST ast = (CommonAST)parser.getAST();
      if (ast != null)
        System.out.println(ast.toStringTree());
      else
        System.out.println("nothing returned");
      
    }
  }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org