cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ovi...@apache.org
Subject cvs commit: xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/flow Translator.java
Date Sun, 17 Mar 2002 22:01:23 GMT
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


Mime
View raw message