ANTLR

来自开放百科 - 灰狐
(版本间的差异)
跳转到: 导航, 搜索
(Links)
(语言)
 
(未显示1个用户的8个中间版本)
第1行: 第1行:
[[Image:antlr-editor.jpg|right|thumb|Editor]]
+
{{SeeWikipedia}}
 +
 
 
ANTLR, ANother Tool for Language Recognition, is a language tool that provides a framework for constructing recognizers, interpreters, compilers, and translators from grammatical descriptions containing actions in a variety of target languages. ANTLR provides excellent support for tree construction, tree walking, translation, error recovery, and error reporting.
 
ANTLR, ANother Tool for Language Recognition, is a language tool that provides a framework for constructing recognizers, interpreters, compilers, and translators from grammatical descriptions containing actions in a variety of target languages. ANTLR provides excellent support for tree construction, tree walking, translation, error recovery, and error reporting.
  
==Links==
+
==简介==
 +
 
 +
==功能==
 +
 
 +
==指南==
 +
===mac OS===
 +
$ cd /usr/local/lib
 +
$ sudo curl -O https://www.antlr.org/download/antlr-4.7.1-complete.jar
 +
$ export CLASSPATH=".:/usr/local/lib/antlr-4.7.1-complete.jar:$CLASSPATH"
 +
$ alias antlr4='java -jar /usr/local/lib/antlr-4.7.1-complete.jar'
 +
$ alias grun='java org.antlr.v4.gui.TestRig'
 +
touch Expr.g4
 +
grammar Expr;
 +
prog: (expr NEWLINE)* ;
 +
expr: expr ('*'|'/') expr
 +
    | expr ('+'|'-') expr
 +
    | INT
 +
    | '(' expr ')'
 +
    ;
 +
NEWLINE : [\r\n]+ ;
 +
INT    : [0-9]+ ;
 +
编译运行
 +
$ antlr4 Expr.g4
 +
$ javac Expr*.java
 +
$ grun Expr prog -gui
 +
100+2*34
 +
^D
 +
 
 +
==语言==
 +
*[https://github.com/apache/groovy/tree/master/src/antlr Groovy]词法分析、语法分析  [[Groovy]] [https://github.com/apache/groovy/blob/master/src/main/antlr2/org/codehaus/groovy/antlr/groovy.g Main程序]
 +
 
 +
==项目==
 +
 
 +
==图集==
 +
<gallery>
 +
image:antlr-editor.jpg|Editor
 +
image:antlr-parse-tree-insepector.png|语法分析树
 +
</gallery>
 +
 
 +
==链接==
 
*[http://www.antlr.org/ ANTLR主页]
 
*[http://www.antlr.org/ ANTLR主页]
*[http://docs.huihoo.com/antlr/ ANTLR开源文档]
+
*[http://docs.huihoo.com/antlr/ ANTLR文档]
*[http://download.huihoo.com/antlr/ ANTLR灰狐下载]
+
*[http://download.huihoo.com/antlr/ ANTLR下载]
  
[[Category:Programming Language]]
+
[[category:programming language]]

2018年5月4日 (五) 07:00的最后版本

Wikipedia-35x35.png 您可以在Wikipedia上了解到此条目的英文信息 ANTLR Thanks, Wikipedia.

ANTLR, ANother Tool for Language Recognition, is a language tool that provides a framework for constructing recognizers, interpreters, compilers, and translators from grammatical descriptions containing actions in a variety of target languages. ANTLR provides excellent support for tree construction, tree walking, translation, error recovery, and error reporting.

目录

[编辑] 简介

[编辑] 功能

[编辑] 指南

[编辑] mac OS

$ cd /usr/local/lib
$ sudo curl -O https://www.antlr.org/download/antlr-4.7.1-complete.jar
$ export CLASSPATH=".:/usr/local/lib/antlr-4.7.1-complete.jar:$CLASSPATH"
$ alias antlr4='java -jar /usr/local/lib/antlr-4.7.1-complete.jar'
$ alias grun='java org.antlr.v4.gui.TestRig'

touch Expr.g4

grammar Expr;		
prog:	(expr NEWLINE)* ;
expr:	expr ('*'|'/') expr
    |	expr ('+'|'-') expr
    |	INT
    |	'(' expr ')'
    ;
NEWLINE : [\r\n]+ ;
INT     : [0-9]+ ;

编译运行

$ antlr4 Expr.g4
$ javac Expr*.java
$ grun Expr prog -gui
100+2*34
^D

[编辑] 语言

[编辑] 项目

[编辑] 图集

[编辑] 链接

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱