antlr学习笔记
来源:互联网 发布:想要女生的身体 知乎 编辑:程序博客网 时间:2024/05/19 00:50
Requirements
- Eclipse 4.3 (Kepler及以上版本)
- XText 2.5.x/2.6
Installation
ANTLR 4 IDE必须通过旧的方式安装. 请遵循以下步骤:
- Open Eclipse Kepler (4.3)
- 点击:
Help > Install New Software...
- 需要先安装 XText 2.5.x/2.6
- 复制并粘贴这个URL:http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/ 到 Work with 区域
- 点回车
- 选择 XText. 注意: 不用选Xtend
- 安装完后Eclipse会重启, 复制并粘贴这个URL: http://dl.bintray.com/jknack/antlr4ide 到Work with 区域
- 选择: ANTLR 4 SDK IDE. 注意: 如果你看不到就打开分类
- 一直点Next到Finish
Manual Installation
You can download the plugin and the save it in the dropins
directory of your Eclipse installation.//上面安装成功了就没有使用手动安装
Usage
新的IDE使用非常简单 所有的以*.g4 为拓展明的文件都将用 ANTLR 4 Editor打开
Code Generation
如果语法是有效的代码是自动生成并保存的. 如果你想关闭这个特性 在: Window > Preferences > ANTLR 4 > Tool
下取消"Tool is activated" 选项. 你还可以设置一些别的选项
生成的代码保存在 target/generated-sources/antlr4
(和antlr4-maven-plugin是一个地址)
Manual Code Generation
You can fire a code generation action by selecting a *.g4
文件 from the Package Explorer, 只需要点击:Run As > ANTLR 4
.
A default ANTLR 4 launch configuration will be created. You can modify the generated launch configuration by going to: Run > External Tools > External Tools Configurations...
from there you will see the launch configuration and how to set or override code generation options
Syntax Diagrams
To open the Syntax Diagram view go to: Window > Show View > Other
search and select: Syntax Diagram
Build with Maven 3.x
- Fork and clone the repository from github
- Download and install Maven 3.x(安装过程在下面)
- Open a shell console and type:
cd antlr4ide
- Build the project with:
mvn clean package
- It takes a while to download and configure Eclipse dependencies, so be patient
- Wait for a:
BUILD SUCCESS
message
Windows下安装maven3.x
- 在下载maven.apach.org/download下下载 apache-maven-3.2.3-bin.zip 并解压你要安装的地方 比如我解压到了 (中间那个解压的apache-maven-3.2.3-bin文件不要了)
- 增加一个叫 M2_HOME 的环境变量,类型为用户变量值为 D:\apache-maven-3.2.3 . Be sure to omit any quotation marks around the path even if it contains spaces. 先不要选确定
- 在增加一个叫 M2 的环境变量值为 %M2_HOME%\bin.
- 可选项: 增加 MAVEN_OPTS 环境变量(用户变量)指定 JVM 属性, 例如,值为 -Xms256m -Xmx512m. 这个环境变量可以被用来给Maven提供更多选项.
- 在 Path 增加一个 %M2% to add Maven available in the command line.
- 确保 JAVA_HOME 在环境变量中不管是系统变量还是用户变量,并且值为 JDK的位置,确保 %JAVA_HOME%\bin 在 Path 环境变量中.
- 打开命令行输入 mvn --version 安装成功.
Eclipse setup
- Make sure you built the project first.
- Open Eclipse Kepler (4.3)
- Install Xtext 2.5.3
- Copy and paste this url:http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/ in the Work with text field
- Hit Enter
- Choose XText 2.5.3. NOTE: DON'T confuse with Xtend, you must choose Xtext
- Restart Eclipse after installing Xtext
- Import the project into Eclipse
- Go to:
File > Import...
thenGeneral > Existing Projects into Workspace
- Choose project root
antlr4ide
- Enabled:
Search for nested projects
- Finish
You don't need any extra Eclipse plugin (like m2e or similar). Project metadata is on git so all you need to do is: mvn clean package
and then import the projects into Eclipse.
- Antlr学习笔记1
- antlr学习笔记
- ANTLR v4学习笔记
- Antlr学习笔记
- ANTLR笔记
- ANTLR笔记
- antlr笔记
- antlr学习
- The Definitive Antlr 4 第4章学习笔记
- The Definitive Antlr 4 第4章学习笔记
- The Definitive Antlr 4 第5章学习笔记
- The Definitive Antlr 4 第6章学习笔记
- The Definitive Antlr 4 第7章学习笔记
- The Definitive Antlr 4 第8章学习笔记
- ANTLR笔记2
- ANTLR资料 学习ANTLR http://book.antlr.org.cn
- 语法分析之antlr学习
- ANTLR学习资源汇总
- using thymeleaf之四操作符
- joseph环
- 前端知识体系及修炼攻略
- 一个页面引入另一个页面时,contentType 应保持一致
- SGU 552 Database optimization
- antlr学习笔记
- Android底层开发之音频输入通道的软硬件分析
- 关于Verilog中的赋值问题
- 日志文件3种状态
- 第四章 4.10节练习
- using thymeleaf之五条件表达式
- 个人项目:统计文本中的单词出现频率
- 点击率校准
- set、env、export的区别