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 ...
随机推荐
- 出现windows启动服务失败(无法从命令行或调试器启动,需要安装InstallUtil.exe)的解决办法
两种方法1 从命令行安装2 选择项目-视图-自定义操作 然后将 安装,提交,回滚,卸载分别加入自定义操作,注意InstallClass属性为true
- 4Sum_leetCode
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = tar ...
- Gradle 的配置和引用
我们的Android studio工程有时会存在很多共同的构建包 这里我会新建一个gradle 文件 config.gradle ext{ android = [ applicationId : &q ...
- windows svchost.exe 引起的出现的莫名其妙的窗口失去焦点
我不知道你们遇到没,反正我是遇到了,现在我就把解决方法给你们,当然都是从网上整理下来的 这个失去焦点可以分为两种,一种是病毒,一种是系统自带的问题 首先你得知道自己的窗口被什么给挤掉了焦点 先看看这篇 ...
- dynamic与var
dynamic与var示例 var是一种语法省略写法,编译器会根据上下文推断出正确的类型. , , , , , , , }; foreach (var item in scores) { Consol ...
- Linux下apache安装php
php 1.下载解压 cd /usr/local/src wget http://mirrors.sohu.com/php/php-5.6.9.tar.gz tar zxvf php-5.6.9.ta ...
- Python的Django框架中的Context使用
Python的Django框架中的Context使用 近期整理些Python方面的知识,一旦你创建一个 Template 对象,你能够用 context 来传递数据给它. 一个context是一系列变 ...
- NSNotificationCenter详解
本文转载至 http://blog.csdn.net/chengyingzhilian/article/details/7874408 作用:NSNotificationCenter是专门供程序中不同 ...
- poj2891(线性同余方程组)
一个exgcd解决一个线性同余问题,多个exgcd解决线性同余方程组. Strange Way to Express Integers Time Limit: 1000MS Memory Limi ...
- poj2421
Constructing Roads Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 22048 Accepted: 93 ...