Main.java
Upload User: afrynkmhm
Upload Date: 2007-01-06
Package Size: 1262k
Code Size: 1k
Development Platform:

Others

  1. import java.io.*;
  2. import ExprLexer;
  3. import ExprParser;
  4. import antlr.collections.AST;
  5. class Main {
  6. public static void main(String[] args) {
  7. try {
  8. ExprLexer lexer = new ExprLexer(new DataInputStream(System.in));
  9. ExprParser parser = new ExprParser(lexer);
  10. // set the type of tree node to create; this is default action
  11. // so it is unnecessary to do it here, but demos capability.
  12. parser.setASTNodeType("antlr.CommonAST");
  13. parser.expr();
  14. antlr.CommonAST ast = (antlr.CommonAST)parser.getAST();
  15. if (ast != null) {
  16. System.out.println(ast.toStringList());
  17. } else {
  18. System.out.println("null AST");
  19. }
  20. } catch(Exception e) {
  21. System.err.println("exception: "+e);
  22. }
  23. }
  24. }