Haibo Huang | b7f974f | 2018-08-28 13:51:54 -0700 | [diff] [blame] | 1 | ANTLR v3.5 |
| 2 | January 4, 2013 |
| 3 | |
| 4 | Terence Parr, parrt at cs usfca edu |
| 5 | ANTLR project lead and supreme dictator for life |
| 6 | University of San Francisco |
| 7 | |
| 8 | INTRODUCTION |
| 9 | |
| 10 | Welcome to ANTLR v3! ANTLR (ANother Tool for Language Recognition) is |
| 11 | a language tool that provides a framework for constructing |
| 12 | recognizers, interpreters, compilers, and translators from grammatical |
| 13 | descriptions containing actions in a variety of target |
| 14 | languages. ANTLR provides excellent support for tree construction, |
| 15 | tree walking, translation, error recovery, and error reporting. I've |
| 16 | been working on parser generators for 25 years and on this particular |
| 17 | version of ANTLR for 9 years. |
| 18 | |
| 19 | You should use v3 in conjunction with ANTLRWorks: |
| 20 | |
| 21 | http://www.antlr.org/works/index.html |
| 22 | |
| 23 | and gUnit (grammar unit testing tool included in distribution): |
| 24 | |
| 25 | http://www.antlr.org/wiki/display/ANTLR3/gUnit+-+Grammar+Unit+Testing |
| 26 | |
| 27 | The book will also help you a great deal (printed May 15, 2007); you |
| 28 | can also buy the PDF: |
| 29 | |
| 30 | http://www.pragmaticprogrammer.com/titles/tpantlr/index.html |
| 31 | |
| 32 | 2nd book, Language Implementation Patterns: |
| 33 | |
| 34 | http://pragprog.com/titles/tpdsl/language-implementation-patterns |
| 35 | |
| 36 | See the getting started document: |
| 37 | |
| 38 | http://www.antlr.org/wiki/display/ANTLR3/FAQ+-+Getting+Started |
| 39 | |
| 40 | You also have the examples plus the source to guide you. |
| 41 | |
| 42 | See the wiki FAQ: |
| 43 | |
| 44 | http://www.antlr.org/wiki/display/ANTLR3/ANTLR+v3+FAQ |
| 45 | |
| 46 | and general doc root: |
| 47 | |
| 48 | http://www.antlr.org/wiki/display/ANTLR3/ANTLR+3+Wiki+Home |
| 49 | |
| 50 | Please help add/update FAQ entries. |
| 51 | |
| 52 | If all else fails, you can buy support or ask the antlr-interest list: |
| 53 | |
| 54 | http://www.antlr.org/support.html |
| 55 | |
| 56 | Per the license in LICENSE.txt, this software is not guaranteed to |
| 57 | work and might even destroy all life on this planet: |
| 58 | |
| 59 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 60 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 61 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 62 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
| 63 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 64 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 65 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 66 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 67 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 68 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 69 | POSSIBILITY OF SUCH DAMAGE. |
| 70 | |
| 71 | ---------------------------------------------------------------------- |
| 72 | |
| 73 | EXAMPLES |
| 74 | |
| 75 | ANTLR v3 sample grammars: |
| 76 | |
| 77 | https://github.com/antlr/examples-v3 |
| 78 | |
| 79 | Examples from Language Implementation Patterns: |
| 80 | |
| 81 | http://www.pragprog.com/titles/tpdsl/source_code |
| 82 | |
| 83 | ---------------------------------------------------------------------- |
| 84 | |
| 85 | What is ANTLR? |
| 86 | |
| 87 | ANTLR stands for (AN)other (T)ool for (L)anguage (R)ecognition |
| 88 | and generates LL(*) recursive-descent parsers. ANTLR is a language tool |
| 89 | that provides a framework for constructing recognizers, compilers, and |
| 90 | translators from grammatical descriptions containing actions. |
| 91 | Target language list: |
| 92 | |
| 93 | http://www.antlr.org/wiki/display/ANTLR3/Code+Generation+Targets |
| 94 | |
| 95 | ---------------------------------------------------------------------- |
| 96 | |
| 97 | How is ANTLR v3 different than ANTLR v2? |
| 98 | |
| 99 | See "What is the difference between ANTLR v2 and v3?" |
| 100 | |
| 101 | http://www.antlr.org/wiki/pages/viewpage.action?pageId=719 |
| 102 | |
| 103 | See migration guide: |
| 104 | |
| 105 | http://www.antlr.org/wiki/display/ANTLR3/Migrating+from+ANTLR+2+to+ANTLR+3 |
| 106 | |
| 107 | ---------------------------------------------------------------------- |
| 108 | |
| 109 | How do I install this damn thing? |
| 110 | |
| 111 | You will have grabbed either of these: |
| 112 | |
| 113 | http://antlr.org/download/antlr-3.5-complete-no-st3.jar |
| 114 | http://antlr.org/download/antlr-3.5-complete.jar |
| 115 | |
| 116 | It has all of the jars you need combined into one. Then you need to |
| 117 | add antlr-3.5-complete.jar to your CLASSPATH or add to arg list; e.g., on unix: |
| 118 | |
| 119 | $ java -cp "/usr/local/lib/antlr-3.5-complete.jar:$CLASSPATH" org.antlr.Tool Test.g |
| 120 | |
| 121 | Source + java binaries: Just untar antlr-3.5.tar.gz and you'll get: |
| 122 | |
| 123 | antlr-3.5/BUILD.txt |
| 124 | antlr-3.5/antlr3-maven-plugin |
| 125 | antlr-3.5/antlrjar.xml |
| 126 | antlr-3.5/antlrsources.xml |
| 127 | antlr-3.5/gunit |
| 128 | antlr-3.5/gunit-maven-plugin |
| 129 | antlr-3.5/pom.xml |
| 130 | antlr-3.5/runtime |
| 131 | antlr-3.5/tool |
| 132 | antlr-3.5/lib |
| 133 | |
| 134 | Please see the FAQ |
| 135 | |
| 136 | http://www.antlr.org/wiki/display/ANTLR3/ANTLR+v3+FAQ |
| 137 | |
| 138 | ------------------------- |
| 139 | |
| 140 | How can I contribute to ANTLR v3? |
| 141 | |
| 142 | http://www.antlr.org/wiki/pages/viewpage.action?pageId=33947666 |