Build Antlr4 projects with eclipse java project template.
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 libraries
import 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 input
ANTLRInputStream input = new ANTLRInputStream( System.in);
// create a lexer that feeds off of input CharStream
HelloLexer lexer = new HelloLexer(input);
// create a buffer of tokens pulled from the lexer
CommonTokenStream tokens = new CommonTokenStream(lexer);
// create a parser that feeds off the tokens buffer
HelloParser 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
Build Antlr4 projects with eclipse java project template.的更多相关文章
- solr不是标准的java project解决方案
官方默认提供的源码包并不是一个标准的Eclipse Java - Project,需要使用ivy进行构建,通过ivy的构建可以将下载下来的源码包转换成一个标准的java Project,然后我们就能把 ...
- 【eclipse】eclipse报错:the resource is not on the build path of a java project
最近在eclipse中,使用svn导入svn上的一个maven项目,但是导入后类的包并没有以源码包的方式显示,而是以普通文件包的方式显示出来,在对类进行F3等操作时就报错:“the resource ...
- Eclipse Java Build Path详解
Eclipse Java Build Path详解 1.设置"source folder"与"output folder". * source folder:存 ...
- This compilation unit is not on the build path of java project (此编译单元不在java项目的生成路径上)
This compilation unit is not on the build path of a Java project 解决办法 索发现,大致是因为项目文件缺失. 解决办法:找到项目根目录 ...
- myecplise 打开报错 Errors occurred during the build. Errors running builder 'DeploymentBuilder' on project 'myf'. Java.lang.NullPointerException
Errors occurred during the build. Errors running builder 'DeploymentBuilder' on project 'myf'.Java.l ...
- this compilation unit is not on the build path of a java project
在eclipse中新建maven project后,会自动生成main\test目录结构,新建一个测试类,然后编辑类文件时,总是提示错误:this compilation unit is not on ...
- 一个Web Project引用多个Java Project在Eclipse下的配置--转载
项目结构: 项目由一个Web Project和多个Java Project构成,Web Project需要引用其它Java Project的类和Jar包.开发时用Eclipse3.5和Tomcat调试 ...
- 【问题记录系列】the resource is not on the build path of a java project
在eclipse中新建了一个maven项目搭建Spring源码阅读环境,创建一个bean生产getter和setter方法的时候报错“the resource is not on the build ...
- eclipse Java compiler level does not match the version of the installed Java project facet.
eclipse Java compiler level does not match the version of the installed Java project facet. Create ...
随机推荐
- poj 2553 The Bottom of a Graph(强连通、缩点、出入度)
题意:给出一个有向图G,寻找所有的sink点.“sink”的定义为:{v∈V|∀w∈V:(v→w)⇒(w→v)},对于一个点v,所有能到达的所有节点w,都能够回到v,这样的点v称为sink. 分析:由 ...
- Problem A. Dynamic Grid
Problem We have a grid with R rows and C columns in which every entry is either 0 or 1. We are going ...
- android:分享 一个非常强大的LOG开关---Log.isLoggable
1.API亮点: 此API能够实现不更换APK.在出问题的手机上就直接能抓到有效log,能提升不少工作效率. .API介绍 近期在解决短信问题时.看到一个非常强大的LOG开关---Log.isLogg ...
- dede后台title怎么修改的?去掉XXXX-织梦内容管理系统V5.7
dede后台title怎么修改的? 去掉XXXX-织梦内容管理系统V5.7 打开include/common.inc.php的文件. $cfg_version = 'V57_UTF8_SP1';(这是 ...
- Wireshark 与 Tcpdump
[1]Wireshark 与 Tcpdump Wireshark是Windows下非常容易上手的抓包工具.但在Linux下很难找到一个好用的图形界面抓包工具.还好有Tcpdump.我们可以用Tcpdu ...
- 嵌入式驱动开发之sensor---"VIP0 PortA", "VIP0 PortB", "VIP1 PortA", "VIP1 PortB",dvo0(vout1) dvo1(vout0)
(1)vip 简介 (2)vip 电路图 (3)vip 更换采集相机输入 (4)vip 驱动 ---------------------author:pkf --------------------- ...
- resin 4.0 项目的配置
前一篇我们了解了resin中配置数据源,依照不同项目的要求我们进行数据源的配置,如多个项目共享多个数据源,一个项目配置多个数据源,以下我们来看看项目的部署方式: 1.在一个host(虚拟主机)下配置一 ...
- saltstack内置执行模块groupadd
groupadd模块用于命令行管理用户组 salt.modules.groupadd.add(name, gid=None, system=False) 添加一个用户到指定GID 例:salt '*' ...
- 简洁的一键SSH脚本
这里发一个自己图省事搞的一个批量打通SSH的脚本,可能对于好多朋友也是实用的,是expect+python的一个组合实现,原理非常easy, 使用起来也不复杂,在此还是简单贴出来说说. noscp.e ...
- python+pip+adb
最近开始玩python,用它写一些小程序游戏的辅助,现在做下总结 下面进入正文. 本文适用对象为WIN10系统,安卓用户.目的在于让丝毫没有接触过Python的小伙伴都能成功运行,如果你恰好是这样的对 ...