forked from jasder/antlr
I have removed all of the installation and getting started stuff from the readme and pointed them to the wiki which is easier to update.
This commit is contained in:
parent
358a1025d2
commit
403e8231c0
106
README.md
106
README.md
|
@ -12,111 +12,7 @@
|
||||||
|
|
||||||
[Release notes](https://github.com/antlr/antlr4/releases)
|
[Release notes](https://github.com/antlr/antlr4/releases)
|
||||||
|
|
||||||
## INTRODUCTION
|
*For installation and other getting started information, see [Getting started with v4](https://theantlrguy.atlassian.net/wiki/display/ANTLR4/Getting+Started+with+ANTLR+v4).*
|
||||||
|
|
||||||
Hi and welcome to the Honey Badger 4.2.1 release (March 25, 2014) of ANTLR!
|
|
||||||
|
|
||||||
## INSTALLATION
|
|
||||||
|
|
||||||
### UNIX
|
|
||||||
|
|
||||||
0. [Install Java](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (version 1.6 or higher)
|
|
||||||
|
|
||||||
1. Download
|
|
||||||
```sh
|
|
||||||
$ cd /usr/local/lib
|
|
||||||
$ curl -O http://www.antlr4.org/download/antlr-4.2.1-complete.jar
|
|
||||||
```
|
|
||||||
Or just [download in browser](http://www.antlr.org/download/antlr-4.2.1-complete.jar) and put it somewhere rational like `/usr/local/lib`.
|
|
||||||
|
|
||||||
2. Add `antlr-4.2.1-complete.jar` to your `CLASSPATH`:
|
|
||||||
```sh
|
|
||||||
$ export CLASSPATH=".:/usr/local/lib/antlr-4.2.1-complete.jar:$CLASSPATH"
|
|
||||||
```
|
|
||||||
Is also a good idea to put this in your .bash_profile or whatever your
|
|
||||||
startup script is.
|
|
||||||
|
|
||||||
3. Create aliases for the ANTLR Tool, and TestRig.
|
|
||||||
```sh
|
|
||||||
$ alias antlr4='java -jar /usr/local/lib/antlr-4.2.1-complete.jar'
|
|
||||||
$ alias grun='java org.antlr.v4.runtime.misc.TestRig'
|
|
||||||
```
|
|
||||||
|
|
||||||
### Windows (Thanks to Graham Wideman)
|
|
||||||
|
|
||||||
0. [Install Java](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (version 1.6 or higher)
|
|
||||||
|
|
||||||
1. Download [antlr-4.2.1-complete.jar](http://www.antlr.org/download/antlr-4.2.1-complete.jar)
|
|
||||||
Save to your directory for 3rd party Java libraries, say `C:\Javalib`
|
|
||||||
|
|
||||||
2. Add `antlr-4.2.1-complete.jar` to `CLASSPATH`, either:
|
|
||||||
|
|
||||||
* Permanently: Using System Properties dialog > Environment variables >
|
|
||||||
Create or append to `CLASSPATH` variable
|
|
||||||
|
|
||||||
* Temporarily, at command line:
|
|
||||||
`SET CLASSPATH=C:\Javalib\antlr-4.2.1-complete.jar;%CLASSPATH%`
|
|
||||||
|
|
||||||
3. Create short convenient commands for the ANTLR Tool, and TestRig,
|
|
||||||
using batch files or doskey commands:
|
|
||||||
|
|
||||||
* Batch files (in directory in system `PATH`)
|
|
||||||
```
|
|
||||||
antlr4.bat: java org.antlr.v4.Tool %*
|
|
||||||
run.bat: java org.antlr.v4.runtime.misc.TestRig %*
|
|
||||||
```
|
|
||||||
|
|
||||||
* Or, use doskey commands:
|
|
||||||
```bat
|
|
||||||
doskey antlr4=java org.antlr.v4.Tool $*
|
|
||||||
doskey grun =java org.antlr.v4.runtime.misc.TestRig $*
|
|
||||||
```
|
|
||||||
|
|
||||||
## Testing installation
|
|
||||||
|
|
||||||
Either launch `org.antlr.v4.Tool` directly:
|
|
||||||
```sh
|
|
||||||
$ java org.antlr.v4.Tool
|
|
||||||
ANTLR Parser Generator Version 4.2.1
|
|
||||||
-o ___ specify output directory where all output is generated
|
|
||||||
-lib ___ specify location of .tokens files
|
|
||||||
...
|
|
||||||
```
|
|
||||||
or use `-jar` option on java:
|
|
||||||
```sh
|
|
||||||
$ java -jar /usr/local/lib/antlr-4.2-complete.jar.1
|
|
||||||
ANTLR Parser Generator Version 4.2.1
|
|
||||||
-o ___ specify output directory where all output is generated
|
|
||||||
-lib ___ specify location of .tokens files
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
In a temporary directory, put the following grammar inside file `Hello.g4`:
|
|
||||||
```g
|
|
||||||
// Define a grammar called Hello
|
|
||||||
// match keyword hello followed by an identifier
|
|
||||||
// match lower-case identifiers
|
|
||||||
grammar Hello;
|
|
||||||
r : 'hello' ID ;
|
|
||||||
ID : [a-z]+ ;
|
|
||||||
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
|
|
||||||
```
|
|
||||||
Then run ANTLR the tool on it:
|
|
||||||
```sh
|
|
||||||
$ cd /tmp
|
|
||||||
$ antlr4 Hello.g4
|
|
||||||
$ javac Hello*.java
|
|
||||||
```
|
|
||||||
Now test it:
|
|
||||||
```sh
|
|
||||||
$ grun Hello r -tree
|
|
||||||
hello parrt
|
|
||||||
^D
|
|
||||||
(r hello parrt)
|
|
||||||
```
|
|
||||||
(That `^D` means `EOF` on unix; it's `^Z` in Windows.) The `-tree` option prints the parse tree in LISP notation.
|
|
||||||
|
|
||||||
## The Definitive ANTLR 4 Reference
|
## The Definitive ANTLR 4 Reference
|
||||||
You can buy a book [The Definitive ANTLR 4 Reference](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference)
|
You can buy a book [The Definitive ANTLR 4 Reference](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference)
|
||||||
|
|
Loading…
Reference in New Issue