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. java.lang.IllegalArgumentException: Request header is too large的解决方法

    <Connector port="8080" protocol="HTTP/1.1"               connectionTimeout=&q ...

  2. js 抢月饼

    面源码: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" co ...

  3. python学习 04 函数参数

    1.参数可以传递元组,但是要加* 2.参数可以传递字典,但是要加**

  4. ios NavigationViewController跳转以及返回传值

    (一)使用NavigationViewController进行页面跳转时,应该使用pushViewController方法来跳转至下一页面.这种话.下一页面相同在NavigationViewContr ...

  5. js浅度克隆/深度克隆

    首先弄明白几个概念: 一. 具体数据类型分为两种:  1.原始数据类型  2.引用数据类型 原始数据类型存储的是对象的实际地址,包括: number.string.boolean.还有两个特殊的nul ...

  6. Sumdiv(较难数学题)

    Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 20971   Accepted: 5290 Description Cons ...

  7. Collect More Jewels(hdu1044)(BFS+DFS)

    Collect More Jewels Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  8. POJ 2031 Building a Space Station【经典最小生成树】

    链接: http://poj.org/problem?id=2031 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...

  9. iOS系统层次架构

    本文转自:http://blog.csdn.net/lxl_815520/article/details/51172917 一,概述 iOS的系统架构分为四个层次:核心操作系统层(Core OS la ...

  10. Django利用form进行显示

    form的显示部分主要分为2部分:1.统一显示(表单里的所有字段): a.{{form.as_table}} b.{{form.as_p}}2.显示部分字段: {{ field.label_tag } ...