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.的更多相关文章

  1. solr不是标准的java project解决方案

    官方默认提供的源码包并不是一个标准的Eclipse Java - Project,需要使用ivy进行构建,通过ivy的构建可以将下载下来的源码包转换成一个标准的java Project,然后我们就能把 ...

  2. 【eclipse】eclipse报错:the resource is not on the build path of a java project

    最近在eclipse中,使用svn导入svn上的一个maven项目,但是导入后类的包并没有以源码包的方式显示,而是以普通文件包的方式显示出来,在对类进行F3等操作时就报错:“the resource ...

  3. Eclipse Java Build Path详解

    Eclipse Java Build Path详解 1.设置"source folder"与"output folder". * source folder:存 ...

  4. 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 解决办法​ 索发现,大致是因为项目文件缺失. 解决办法:找到项目根目录 ...

  5. 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 ...

  6. this compilation unit is not on the build path of a java project

    在eclipse中新建maven project后,会自动生成main\test目录结构,新建一个测试类,然后编辑类文件时,总是提示错误:this compilation unit is not on ...

  7. 一个Web Project引用多个Java Project在Eclipse下的配置--转载

    项目结构: 项目由一个Web Project和多个Java Project构成,Web Project需要引用其它Java Project的类和Jar包.开发时用Eclipse3.5和Tomcat调试 ...

  8. 【问题记录系列】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 ...

  9. 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 ...

随机推荐

  1. js项目第一课:获取节点的方法有三个

    第一种方法: demo.html代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &qu ...

  2. YUV Player

    https://github.com/Yonsm/RawPlayer RawPlayer https://github.com/latelee/YUVPlayer YUVPlayer https:// ...

  3. MySQL_知识点

    1.执行顺序 语句模板: (8)SELECT (9)DISTINCT (11)<Top Num> <select list> (1)FROM [left_table] (3)& ...

  4. csv文件中出现乱码的解决方法

    1.首先用UE打开CSV文件,发现没有乱码了. 2.然后新建一个txt文本,把CSV中的数据复制到txt文本中,保存格式为ANSI/ASCII. 3.复制txt文件,再把副本后缀改为CSV格式,再用E ...

  5. Foundation框架 - NSDictionary类、NSMutableDictionary类

    NSArray.NSSet.NSDictionary /* 集合 1.NSArray\NSMutableArray * 有序 * 高速创建(不可变):@[obj1, obj2, obj3] * 高速訪 ...

  6. rsync客户端命令使用简介

    rsync是linux下很流行的增量备份工具,也支持本地文件(夹)复制至远程,而且支持只传输增量部分,也是一个代码(程序)发布的好工具. 基本用法如下: rsync [一堆选项] 源文件(夹) 目标文 ...

  7. maven 常用的环境插件

    <build> <finalName>yycgproject</finalName> <plugins> <!-- 修改jdk插件 --> ...

  8. Django下实现HelloWorld

    我的实现工具:window10 在window10 下面,实现第一个Django的HelloWorld项目. 1.创建一个项目 确保你的电脑上装了python和Django.我的是在python2.7 ...

  9. GitHub 寻宝指南

    GitHub 寻宝指南 寻找 Demo 技术栈的关键字搜索,并按更新时间进行排序 生命有限 ,如若是每次我们尝试一个新的技术,总得自己编写一个个 Demo.编写多个 Demo,都得花去个半天八小时的时 ...

  10. Python修饰器的函数式编程(转)

    From:http://coolshell.cn/articles/11265.html 作者:陈皓 Python的修饰器的英文名叫Decorator,当你看到这个英文名的时候,你可能会把其跟Desi ...