Build Antlr4 projects with eclipse java project template.
来源:互联网 发布:wireshark是什么软件 编辑:程序博客网 时间:2024/06/07 19:54
from:https://shijinglu.wordpress.com/2015/01/22/build-antlr4-projects-with-eclipse-java-project-template/
Before taking any action, remember to install antlr4 plugin for eclipse, it can be easily found from “Eclipse Marketplace”.
1.Create an antlr4 project. This will create an simple “Hello” antlr4 project.
2.Add java project facet to the project.
3.Eclipse will automatically rebuild the project, see messages in the Console, pay attention to the default antlr-4.4-complete.jar path.
4.Or you can move the antlr4 jar file to your comfortable directory and add it the eclipse build path from therein.
5.Add destination folder of generated java files to the project as source folder.
6.Add some code to test this project, <>
// // import ANTLR's runtime librariesimport org.antlr.v4.runtime.*;import org.antlr.v4.runtime.tree.*;public class HelloRunner {public static void main( String[] args) throws Exception {// create a CharStream that reads from standard inputANTLRInputStream input = new ANTLRInputStream( System.in);// create a lexer that feeds off of input CharStreamHelloLexer lexer = new HelloLexer(input);// create a buffer of tokens pulled from the lexerCommonTokenStream tokens = new CommonTokenStream(lexer);// create a parser that feeds off the tokens bufferHelloParser parser = new HelloParser(tokens);ParseTree tree = parser.r(); // begin parsing at rule 'r'System.out.println(tree.toStringTree(parser)); // print LISP-style tree}}
7. Runt this HelloRunner.java as java application
阅读全文
0 0
- Build Antlr4 projects with eclipse java project template.
- Maven&Eclipse build java project.
- Automation for the people: Build Java projects with Raven
- Get Started With Continuous Integration For Your .NET (C#) Projects - Build Your Project
- Project build error: 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as p
- Build GUIs with the Eclipse Visual Editor project
- How to Build an Android Project with Eclipse
- Eclipse Project Build Types
- Eclipse Project Build Types
- Eclipse Project Build Automatically、Build Project
- Build Android Project with Gradle
- java.lang.IllegalStateException: Missing project All-Projects
- Practical Ajax Projects with Java Technology
- 【spring】Building Java Projects with Maven
- 【Spring】Building Java Projects with Gradle
- Build with CMake in Eclipse
- Create a Project with Eclipse
- Create a Project with Eclipse
- Liferay7启动报错There is an error in invoking javac.
- MYSQL性能优化之Mysql数据库高可用架构设计之MMM架构设计(上)
- linux shell编程(三) if 和 for
- Android获取当前毫秒值
- Linux安装mysql5.7.12
- Build Antlr4 projects with eclipse java project template.
- linux开机过程
- linux 磁盘管理与文件系统
- Java订单号生成策略(基于消息队列)
- linux 文件存取 软硬联接的区别
- linux 设备文件
- 使用ngrok让微信公众平台通过80端口访问本机
- linux 新建分区 、格式化 并挂载的命令
- 学习Java分为几个阶段,分别是什么?