├── .gitignore ├── .travis.yml ├── ANSI-C ├── C.g ├── examples │ ├── BinaryDigit.c │ ├── add.c │ ├── bt.c │ ├── dialog.c │ ├── helloworld.c │ ├── integrate.c │ └── ll.c ├── pom.xml └── readme.txt ├── Antlrv3 ├── ANTLRv3.g ├── examples │ └── csv.g ├── pom.xml └── readme.txt ├── C-preprocessor ├── CharArrayUtils.java ├── Cpp.g ├── CppTree.g ├── FunctionMacro.java ├── Main.java ├── Makefile ├── ObjectMacro.java ├── pom.xml └── readme.txt ├── CSV ├── csv.g ├── examples │ └── example1.csv ├── pom.xml └── readme.txt ├── CUDAPTX ├── Ptx.g ├── pom.xml └── readme.txt ├── ECMAScript ├── JavaScript.g ├── examples │ └── helloworld.txt ├── pom.xml └── readme.txt ├── FirstOrderLogic ├── FOL.g ├── pom.xml └── readme.txt ├── FreeMPS ├── FreeMPS.g ├── pom.xml └── readme.txt ├── Java1.6 ├── Java.g ├── examples │ └── helloworld.java ├── pom.xml └── readme.txt ├── KUKA ├── krl.g ├── pom.xml └── readme.txt ├── OracleNetServices ├── OracleNetServicesV3.g ├── pom.xml └── readme.txt ├── PLSQL ├── PLSQL.g ├── pom.xml └── readme.txt ├── Pascal ├── pascal.g ├── pom.xml ├── readme.txt └── symtab.g ├── PowerBuilder ├── PBM.g ├── pom.xml └── readme.txt ├── README.md ├── ValueChangeDump ├── ValueChangeDump.g ├── pom.xml └── readme.txt ├── asm ├── ASM.g ├── pom.xml └── readme.txt ├── asn ├── ASN.g ├── examples │ └── example1.asn ├── pom.xml └── readme.txt ├── cpp ├── CPP_grammar_.g ├── pom.xml └── readme.txt ├── csharp ├── CSharpParser.g ├── pom.xml └── readme.txt ├── css21 ├── css21.g ├── pom.xml └── readme.txt ├── css3 ├── csst3.g ├── pom.xml └── readme.txt ├── dcm ├── DCM_2_0_grammar.g ├── pom.xml └── readme.txt ├── fortran77 ├── f77-antlr2.g ├── pom.xml └── readme.txt ├── idl ├── Idl.g ├── pom.xml └── readme.txt ├── informix ├── fgl.g ├── pom.xml └── readme.txt ├── java6separated ├── Java6Lex.g ├── Java6Parse.g ├── pom.xml └── readme.txt ├── javastacktrace ├── StackTraceText.g ├── pom.xml └── readme.txt ├── jpa ├── JPA.g ├── pom.xml └── readme.txt ├── json └── readme.txt ├── lua ├── Lua.g ├── examples │ ├── factorial.lua │ └── helloworld.lua ├── pom.xml └── readme.txt ├── mdx ├── mdx.g ├── pom.xml └── readme.txt ├── memcached ├── memcached_protocol.g ├── pom.xml └── readme.txt ├── modula2pim4 ├── m2pim4_LL1.g ├── pom.xml └── readme.txt ├── mumath ├── mumath.g ├── pom.xml └── readme.txt ├── mysql ├── MySQL.g ├── pom.xml └── readme.tt ├── objc ├── ObjectiveC2ansi.g ├── pom.xml └── readme.txt ├── oraclejdbcurl ├── jdbc-url.g ├── pom.xml └── readme.txt ├── pddl ├── Pddl.g ├── pom.xml └── readme.txt ├── pom.xml ├── python ├── Python.g ├── pom.xml └── readme.txt ├── rcs ├── jrcs.g ├── pom.xml └── readme.txt ├── ruby ├── pom.xml ├── readme.txt └── rubyParserLexerSPGrammar.g ├── sexpression ├── Sexpr.g ├── pom.xml └── readme.txt ├── support ├── .gitignore ├── antlr3test-maven-plugin │ ├── AntlrMojo-pom.xml │ ├── README.md │ ├── generate-sources.sh │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── antlr │ │ │ └── mojo │ │ │ └── antlr3test │ │ │ ├── FileUtil.java │ │ │ └── GrammarTestMojo.java │ │ └── test │ │ ├── java │ │ └── test │ │ │ └── org │ │ │ └── antlr │ │ │ └── mojo │ │ │ └── antlr3test │ │ │ └── TestGrammarTestMojo.java │ │ └── resources │ │ ├── GrammarTestMojo-pom.xml │ │ └── csv.g └── pom.xml ├── unicode ├── AntlrUnicode.g ├── pom.xml └── readme.txt ├── verilog ├── Verilog3.g ├── pom.xml └── readme.txt ├── vhdl ├── examples │ ├── arith.vhd │ ├── misc.vhd │ ├── numeric_bit-body.vhd │ ├── numeric_bit.vhd │ ├── numeric_std-body.vhd │ ├── numeric_std.vhd │ ├── signed.vhd │ ├── standard.vhd │ ├── std_logic_1164.vhd │ ├── std_logic_1164_body.vhd │ ├── std_logic_textio.vhd │ ├── textio.vhd │ └── unsigned.vhd ├── pom.xml ├── readme.txt └── vhdl.g ├── wavefront ├── WavefrontOBJ.g ├── examples │ ├── example1.txt │ └── example2.txt ├── pom.xml └── readme.txt ├── xpath ├── XPath1.g ├── examples │ └── example1.txt ├── pom.xml └── readme.txt └── xpath2 ├── XPath2.g ├── pom.xml └── readme.txt /.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | /**/.project 3 | /**/.classpath 4 | /**/.settings/ 5 | /**/target 6 | 7 | .fetch_time_cache 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk7 4 | - oraclejdk8 5 | - openjdk7 6 | sudo: false 7 | install: mvn clean package install -f support/antlr3test-maven-plugin/ 8 | script: mvn clean package 9 | 10 | -------------------------------------------------------------------------------- /ANSI-C/examples/BinaryDigit.c: -------------------------------------------------------------------------------- 1 | int i = 0b0011; 2 | int j = 0B1010; 3 | -------------------------------------------------------------------------------- /ANSI-C/examples/add.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | int i, sum = 0; 4 | 5 | for ( i = 1; i <= LAST; i++ ) { 6 | sum += i; 7 | } /*-for-*/ 8 | printf("sum = %d\n", sum); 9 | 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /ANSI-C/examples/bt.c: -------------------------------------------------------------------------------- 1 | struct tree_el { 2 | int val; 3 | struct tree_el * right, * left; 4 | }; 5 | 6 | typedef struct tree_el node; 7 | 8 | void insert(node ** tree, node * item) { 9 | if(!(*tree)) { 10 | *tree = item; 11 | return; 12 | } 13 | if(item->val<(*tree)->val) 14 | insert(&(*tree)->left, item); 15 | else if(item->val>(*tree)->val) 16 | insert(&(*tree)->right, item); 17 | } 18 | 19 | void printout(node * tree) { 20 | if(tree->left) printout(tree->left); 21 | printf("%d\n",tree->val); 22 | if(tree->right) printout(tree->right); 23 | } 24 | 25 | void main() { 26 | node * curr, * root; 27 | int i; 28 | 29 | root = NULL; 30 | 31 | for(i=1;i<=10;i++) { 32 | curr = (node *)malloc(sizeof(node)); 33 | curr->left = curr->right = NULL; 34 | curr->val = rand(); 35 | insert(&root, curr); 36 | } 37 | 38 | printout(root); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /ANSI-C/examples/dialog.c: -------------------------------------------------------------------------------- 1 | main() 2 | { 3 | /* Define default values: */ 4 | 5 | int n = 0; 6 | float x = 0.0; 7 | 8 | /* Define contents of dialog window */ 9 | 10 | create_int_dialog_entry("n", &n); 11 | create_float_dialog_entry("x", &x); 12 | 13 | /* Create window with name "Setup" and top-left corner at (0,0) */ 14 | 15 | set_up_dialog("Setup", 0, 0); 16 | 17 | /* Display the window and read the results */ 18 | 19 | read_dialog_window(); 20 | 21 | /* Print out the new values */ 22 | 23 | printf("n = %d, x = %f\n", n, x); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /ANSI-C/examples/helloworld.c: -------------------------------------------------------------------------------- 1 | 2 | /* Hello World program */ 3 | 4 | main() 5 | { 6 | printf("Hello World"); 7 | 8 | } 9 | 10 | -------------------------------------------------------------------------------- /ANSI-C/examples/integrate.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | float f(float x) 5 | { 6 | return(1/(1+pow(x,2))); 7 | } 8 | void main() 9 | { 10 | int i,n; 11 | float x0,xn,h,y[20],so,se,ans,x[20]; 12 | printf("\n Enter values of x0,xn,h:\n"); 13 | scanf("%f%f%f",&x0,&xn,&h); 14 | n=(xn-x0)/h; 15 | if(n%2==1) 16 | { 17 | n=n+1; 18 | } 19 | h=(xn-x0)/n; 20 | printf("\nrefined value of n and h are:%d %f\n",n,h); 21 | printf("\n Y values \n"); 22 | for(i=0; i<=n; i++) 23 | { 24 | x[i]=x0+i*h; 25 | y[i]=f(x[i]); 26 | printf("\n%f\n",y[i]); 27 | } 28 | so=0; 29 | se=0; 30 | for(i=1; ival = i; 18 | curr->next = head; 19 | head = curr; 20 | } 21 | 22 | curr = head; 23 | 24 | while(curr) { 25 | printf("%d\n", curr->val); 26 | curr = curr->next ; 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /ANSI-C/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | ansic 5 | jar 6 | ANTLR ANSI-C grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | C.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | true 38 | false 39 | translation_unit 40 | C 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /ANSI-C/readme.txt: -------------------------------------------------------------------------------- 1 | Terence Parr Wed Jul 19, 2006 18:18 2 | Haven't tested a bunch, but it's a good start. :) -------------------------------------------------------------------------------- /Antlrv3/examples/csv.g: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright 2011 by Nathaniel Harward 4 | 5 | ANTLRv3 grammar for CSV files. 6 | 7 | * No trimming of spaces (disallowed in RFC4180) 8 | * No trimming of double-quotes, either to define/end a quoted field or 9 | when embedded inside one 10 | * Handles all/mixed newline formats (MSDOS/Windows; Unix; Mac OS) 11 | 12 | If you find any issues please email me so I can correct it. 13 | 14 | */ 15 | 16 | grammar csv; 17 | 18 | file 19 | : record (NEWLINE record)* EOF 20 | ; 21 | 22 | record 23 | : (quoted_field | unquoted_field) (COMMA (quoted_field | unquoted_field))* 24 | ; 25 | 26 | quoted_field 27 | : DQUOTE 28 | ( CHAR 29 | | COMMA 30 | | DQUOTE DQUOTE 31 | | NEWLINE 32 | )* DQUOTE 33 | ; 34 | 35 | unquoted_field 36 | : CHAR* 37 | ; 38 | 39 | CHAR 40 | : '\u0000' .. '\u0009' 41 | | '\u000b' .. '\u000c' 42 | | '\u000e' .. '\u0021' 43 | | '\u0023' .. '\u002b' 44 | | '\u002d' .. '\uffff' 45 | ; 46 | 47 | COMMA 48 | : '\u002c' 49 | ; 50 | 51 | DQUOTE 52 | : '\u0022' 53 | ; 54 | 55 | NEWLINE 56 | : '\u000d'? '\u000a' // DOS/Windows(\r\n) + Unix(\n) 57 | | '\u000d' // Mac OS 9 and earlier(\r) 58 | ; 59 | -------------------------------------------------------------------------------- /Antlrv3/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | antlrv3 5 | jar 6 | ANTLR ANTLR3 grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | ANTLRv3.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | true 38 | false 39 | grammarDef 40 | ANTLRv3 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Antlrv3/readme.txt: -------------------------------------------------------------------------------- 1 | Terence Parr Fri Jul 13, 2007 17:32 2 | ANTLR v3 written in its own words. Builds ASTs used by ANTLR tool itself.... -------------------------------------------------------------------------------- /C-preprocessor/CharArrayUtils.java: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @author dschaefe 4 | * 5 | * TODO To change the template for this generated type comment go to 6 | * Window - Preferences - Java - Code Style - Code Templates 7 | */ 8 | public class CharArrayUtils { 9 | 10 | public static final int hash(char[] str, int start, int length) { 11 | int h = 0; 12 | int end = start + length; 13 | 14 | for (int curr = start; curr < end; ++curr) 15 | h += (h << 3) + str[curr]; 16 | 17 | return h; 18 | } 19 | 20 | public static final int hash(char[] str) { 21 | return hash(str, 0, str.length); 22 | } 23 | 24 | public static final boolean equals(char[] str1, char[] str2) { 25 | if (str1 == str2) 26 | return true; 27 | 28 | if (str1.length != str2.length) 29 | return false; 30 | 31 | for (int i = 0; i < str1.length; ++i) 32 | if (str1[i] != str2[i]) 33 | return false; 34 | 35 | return true; 36 | } 37 | 38 | public static final boolean equals(char[] str1, int start1, int length1, char[] str2) { 39 | if (length1 != str2.length || str1.length < length1 ) 40 | return false; 41 | if( str1 == str2 && start1 == 0 ) 42 | return true; 43 | for (int i = 0; i < length1; ++i) 44 | if (str1[start1++] != str2[i]) 45 | return false; 46 | 47 | return true; 48 | } 49 | 50 | public static final boolean equals(char[] str1, int start1, int length1, char[] str2, boolean ignoreCase ) { 51 | if( !ignoreCase ) 52 | return equals( str1, start1, length1, str2 ); 53 | 54 | if (length1 != str2.length || str1.length < length1 ) 55 | return false; 56 | 57 | for (int i = 0; i < length1; ++i) 58 | if( Character.toLowerCase(str1[start1++]) != Character.toLowerCase( str2[i] ) ) 59 | return false; 60 | 61 | return true; 62 | } 63 | 64 | public static final char[] extract(char[] str, int start, int length) { 65 | if (start == 0 && length == str.length) 66 | return str; 67 | 68 | char[] copy = new char[length]; 69 | System.arraycopy(str, start, copy, 0, length); 70 | return copy; 71 | } 72 | 73 | public static final char[] concat(char[] first, char[] second) { 74 | if (first == null) 75 | return second; 76 | if (second == null) 77 | return first; 78 | 79 | int length1 = first.length; 80 | int length2 = second.length; 81 | char[] result = new char[length1 + length2]; 82 | System.arraycopy(first, 0, result, 0, length1); 83 | System.arraycopy(second, 0, result, length1, length2); 84 | return result; 85 | } 86 | 87 | public static final char[] replace( 88 | char[] array, 89 | char[] toBeReplaced, 90 | char[] replacementChars) { 91 | 92 | int max = array.length; 93 | int replacedLength = toBeReplaced.length; 94 | int replacementLength = replacementChars.length; 95 | 96 | int[] starts = new int[5]; 97 | int occurrenceCount = 0; 98 | 99 | if (!equals(toBeReplaced, replacementChars)) { 100 | 101 | next : for (int i = 0; i < max; i++) { 102 | int j = 0; 103 | while (j < replacedLength) { 104 | if (i + j == max) 105 | continue next; 106 | if (array[i + j] != toBeReplaced[j++]) 107 | continue next; 108 | } 109 | if (occurrenceCount == starts.length) { 110 | System.arraycopy( 111 | starts, 112 | 0, 113 | starts = new int[occurrenceCount * 2], 114 | 0, 115 | occurrenceCount); 116 | } 117 | starts[occurrenceCount++] = i; 118 | } 119 | } 120 | if (occurrenceCount == 0) 121 | return array; 122 | char[] result = 123 | new char[max 124 | + occurrenceCount * (replacementLength - replacedLength)]; 125 | int inStart = 0, outStart = 0; 126 | for (int i = 0; i < occurrenceCount; i++) { 127 | int offset = starts[i] - inStart; 128 | System.arraycopy(array, inStart, result, outStart, offset); 129 | inStart += offset; 130 | outStart += offset; 131 | System.arraycopy( 132 | replacementChars, 133 | 0, 134 | result, 135 | outStart, 136 | replacementLength); 137 | inStart += replacedLength; 138 | outStart += replacementLength; 139 | } 140 | System.arraycopy(array, inStart, result, outStart, max - inStart); 141 | return result; 142 | } 143 | 144 | public static final char[][] subarray(char[][] array, int start, int end) { 145 | if (end == -1) 146 | end = array.length; 147 | if (start > end) 148 | return null; 149 | if (start < 0) 150 | return null; 151 | if (end > array.length) 152 | return null; 153 | 154 | char[][] result = new char[end - start][]; 155 | System.arraycopy(array, start, result, 0, end - start); 156 | return result; 157 | } 158 | 159 | public static final char[] subarray(char[] array, int start, int end) { 160 | if (end == -1) 161 | end = array.length; 162 | if (start > end) 163 | return null; 164 | if (start < 0) 165 | return null; 166 | if (end > array.length) 167 | return null; 168 | 169 | char[] result = new char[end - start]; 170 | System.arraycopy(array, start, result, 0, end - start); 171 | return result; 172 | } 173 | 174 | public static final int indexOf(char toBeFound, char[] array) { 175 | for (int i = 0; i < array.length; i++) 176 | if (toBeFound == array[i]) 177 | return i; 178 | return -1; 179 | } 180 | 181 | public static int indexOf( char toBeFound, char[] buffer, int start, int len ) { 182 | if( start < 0 || start > buffer.length || start + len > buffer.length ) 183 | return -1; 184 | 185 | for (int i = start; i < len; i++) 186 | if (toBeFound == buffer[i]) 187 | return i; 188 | return -1; 189 | } 190 | public static final int indexOf( char[] toBeFound, char[] array ){ 191 | if( toBeFound.length > array.length ) 192 | return -1; 193 | 194 | int j = 0; 195 | for( int i = 0; i < array.length; i++ ){ 196 | if( toBeFound[j] == array[i] ){ 197 | if( ++j == toBeFound.length ) 198 | return i - j + 1; 199 | } 200 | else j = 0; 201 | } 202 | return -1; 203 | } 204 | 205 | public static final int lastIndexOf(char[] toBeFound, char[] array) { 206 | int j = toBeFound.length - 1; 207 | for (int i = array.length; --i >= 0;){ 208 | if (toBeFound[j] == array[i]){ 209 | if( --j == -1 ) 210 | return i; 211 | } else j = toBeFound.length - 1; 212 | } 213 | return -1; 214 | } 215 | 216 | final static public char[] trim(char[] chars) { 217 | 218 | if (chars == null) 219 | return null; 220 | 221 | int start = 0, length = chars.length, end = length - 1; 222 | while (start < length && chars[start] == ' ') { 223 | start++; 224 | } 225 | while (end > start && chars[end] == ' ') { 226 | end--; 227 | } 228 | if (start != 0 || end != length - 1) { 229 | return subarray(chars, start, end + 1); 230 | } 231 | return chars; 232 | } 233 | 234 | 235 | final static public char[] lastSegment(char[] array, char[] separator) { 236 | int pos = lastIndexOf(separator, array); 237 | if (pos < 0) 238 | return array; 239 | return subarray(array, pos + separator.length, array.length); 240 | } 241 | 242 | /** 243 | * @param buff 244 | * @param i 245 | * @param charImage 246 | */ 247 | public static void overWrite( char[] buff, int i, char[] charImage ) { 248 | if( buff.length < i + charImage.length ) 249 | return; 250 | for( int j = 0; j < charImage.length; j++ ){ 251 | buff[ i + j ] = charImage[j]; 252 | } 253 | } 254 | 255 | 256 | } 257 | -------------------------------------------------------------------------------- /C-preprocessor/FunctionMacro.java: -------------------------------------------------------------------------------- 1 | import org.antlr.runtime.*; 2 | import org.antlr.runtime.tree.* 3 | ;import java.util.Stack; 4 | import java.util.List; 5 | import java.util.ArrayList; 6 | import java.util.Map; 7 | import java.util.HashMap; 8 | 9 | public class FunctionMacro 10 | { 11 | public String name; 12 | protected String expansion; 13 | 14 | protected boolean haveArgs; 15 | protected boolean shouldExpand; 16 | protected List macArgs; 17 | 18 | protected CppTreeTreeParser cppAST; 19 | 20 | protected static final String ONE = "1"; 21 | 22 | public FunctionMacro(String name, String expansion) 23 | { 24 | this.name = name; 25 | this.expansion = expansion; 26 | this.haveArgs = false; 27 | this.shouldExpand = false; 28 | 29 | if(expansion.equals(" ")||expansion.equals("")) 30 | { 31 | shouldExpand = false; 32 | } 33 | else if(expansion == null) 34 | { 35 | shouldExpand = false; 36 | expansion = " "; 37 | } 38 | else 39 | { 40 | shouldExpand = true; 41 | } 42 | } 43 | 44 | public FunctionMacro(String name, List args, String expansion) 45 | { 46 | this.name = name; 47 | this.expansion = expansion; 48 | this.macArgs = args; 49 | this.haveArgs = true; 50 | 51 | if(expansion.equals(" ")||expansion.equals("")) 52 | { 53 | shouldExpand = false; 54 | } 55 | else if(expansion == null) 56 | { 57 | shouldExpand = false; 58 | expansion = " "; 59 | } 60 | else 61 | { 62 | shouldExpand = true; 63 | } 64 | } 65 | 66 | public List getArgList() 67 | { 68 | return macArgs; 69 | } 70 | 71 | public String getSignature() 72 | { 73 | return name; 74 | } 75 | 76 | public String getName() 77 | { 78 | return name; 79 | } 80 | 81 | public String toString() 82 | { 83 | return new String( name ); 84 | } 85 | 86 | public boolean haveArgs() 87 | { 88 | return haveArgs; 89 | } 90 | 91 | public String getExpansion() 92 | { 93 | String retStr = expansion; 94 | if(shouldExpand) 95 | { 96 | // System.out.println("Func expansion : [" + expansion+"]"); 97 | try 98 | { 99 | CppLexer mLexer = new CppLexer(new ANTLRStringStream(expansion +"\n")); 100 | TokenRewriteStream mtokens = new TokenRewriteStream(mLexer); 101 | mtokens.LT(1); 102 | 103 | CppParser mParser = new CppParser(mtokens); 104 | CppParser.text_line_return mret = mParser.text_line(); 105 | 106 | CommonTreeNodeStream mnodes = new CommonTreeNodeStream((Tree)mret.tree); 107 | // System.out.println("MACRO tree: "+((Tree)mret.tree).toStringTree()); 108 | cppAST = new CppTreeTreeParser(mnodes); 109 | retStr = new String(cppAST.text_line(true,false)); 110 | 111 | } 112 | catch (Exception ex) 113 | { 114 | System.out.println("getExpansion : " + expansion + ":" + ex); 115 | } 116 | } 117 | return retStr; 118 | } 119 | 120 | public int getExpandedValue() 121 | { 122 | int ret=0; 123 | if(shouldExpand) 124 | { 125 | // System.out.println("expansion : " + expansion); 126 | try 127 | { 128 | CppLexer mLexer = new CppLexer(new ANTLRStringStream("#exec_macro_expression " + expansion )); 129 | TokenRewriteStream mtokens = new TokenRewriteStream(mLexer); 130 | mtokens.LT(1); 131 | 132 | CppParser mParser = new CppParser(mtokens); 133 | CppParser.macroExecution_return mret = mParser.macroExecution(); 134 | 135 | // System.out.println("MACRO tree: "+((Tree)mret.tree).toStringTree()); 136 | 137 | CommonTreeNodeStream mnodes = new CommonTreeNodeStream((Tree)mret.tree); 138 | cppAST = new CppTreeTreeParser(mnodes); 139 | ret = cppAST.macroExecution(); 140 | // System.out.println("EXEC MACRO RESULT : " + ret); 141 | 142 | } 143 | catch (Exception ex) 144 | { 145 | System.out.println(" getExpandedValue :"+ expansion + ":" + ex); 146 | } 147 | } 148 | else 149 | { 150 | return 1; 151 | } 152 | return ret; 153 | } 154 | 155 | } 156 | -------------------------------------------------------------------------------- /C-preprocessor/Main.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import org.antlr.runtime.*; 3 | import org.antlr.runtime.tree.*; 4 | 5 | /** Parse a java file or directory of java files using the generated parser 6 | * ANTLR builds from java.g 7 | */ 8 | class Main { 9 | 10 | //static CommonTokenStream tokens = new CommonTokenStream(); 11 | // static TokenRewriteStream tokens = new TokenRewriteStream();; 12 | 13 | public static void main(String[] args) { 14 | try { 15 | if (args.length > 0 ) { 16 | // for each directory/file specified on the command line 17 | for(int i=0; i< args.length;i++) { 18 | doFile(new File(args[i])); // parse it 19 | } 20 | } 21 | else { 22 | System.err.println("Usage: java Main "); 23 | } 24 | } 25 | catch(Exception e) { 26 | System.err.println("exception: "+e); 27 | e.printStackTrace(System.err); // so we can get stack trace 28 | } 29 | } 30 | 31 | // This method decides what action to take based on the type of 32 | // file we are looking at 33 | public static void doFile(File f) 34 | throws Exception { 35 | // If this is a directory, walk each file/dir in that directory 36 | if (f.isDirectory()) { 37 | String files[] = f.list(); 38 | for(int i=0; i < files.length; i++) 39 | doFile(new File(f, files[i])); 40 | } 41 | 42 | // otherwise, if this is a java file, parse it! 43 | else if ( ((f.getName().length()>2) && 44 | f.getName().substring(f.getName().length()-2).equals(".c")) 45 | || f.getName().substring(f.getName().length()-2).equals(".h") 46 | || f.getName().equals("input") ) 47 | { 48 | // System.err.println(" "+f.getAbsolutePath()); 49 | parseFile(f.getAbsolutePath()); 50 | } 51 | } 52 | 53 | // Here's where we do the real work... 54 | public static void parseFile(String f) throws Exception 55 | { 56 | try { 57 | // Create a scanner that reads from the input stream passed to us 58 | System.out.println("file :"+f); 59 | CppLexer lexer = new CppLexer(new ANTLRFileStream(f,"iso8859-1")); 60 | //tokens.setTokenSource(lexer); 61 | TokenRewriteStream tokens = new TokenRewriteStream(lexer); 62 | tokens.LT(1); 63 | //System.out.println("tokens : " + tokens); 64 | /* 65 | System.out.println("size: "+tokens.size()); 66 | for(int i=0; i 3 | 4.0.0 4 | c-cpp 5 | jar 6 | ANTLR C Preprocessor grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | Cpp.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /C-preprocessor/readme.txt: -------------------------------------------------------------------------------- 1 | Youngki KU Wed Dec 20, 2006 17:38 2 | C preprocessor grammar and tree. 3 | -------------------------------------------------------------------------------- /CSV/csv.g: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright 2011 by Nathaniel Harward 4 | 5 | ANTLRv3 grammar for CSV files. 6 | 7 | * No trimming of spaces (disallowed in RFC4180) 8 | * No trimming of double-quotes, either to define/end a quoted field or 9 | when embedded inside one 10 | * Handles all/mixed newline formats (MSDOS/Windows; Unix; Mac OS) 11 | 12 | If you find any issues please email me so I can correct it. 13 | 14 | */ 15 | 16 | grammar csv; 17 | 18 | file 19 | : record (NEWLINE record)* EOF 20 | ; 21 | 22 | record 23 | : (quoted_field | unquoted_field) (COMMA (quoted_field | unquoted_field))* 24 | ; 25 | 26 | quoted_field 27 | : DQUOTE 28 | ( CHAR 29 | | COMMA 30 | | DQUOTE DQUOTE 31 | | NEWLINE 32 | )* DQUOTE 33 | ; 34 | 35 | unquoted_field 36 | : CHAR* 37 | ; 38 | 39 | CHAR 40 | : '\u0000' .. '\u0009' 41 | | '\u000b' .. '\u000c' 42 | | '\u000e' .. '\u0021' 43 | | '\u0023' .. '\u002b' 44 | | '\u002d' .. '\uffff' 45 | ; 46 | 47 | COMMA 48 | : '\u002c' 49 | ; 50 | 51 | DQUOTE 52 | : '\u0022' 53 | ; 54 | 55 | NEWLINE 56 | : '\u000d'? '\u000a' // DOS/Windows(\r\n) + Unix(\n) 57 | | '\u000d' // Mac OS 9 and earlier(\r) 58 | ; 59 | -------------------------------------------------------------------------------- /CSV/examples/example1.csv: -------------------------------------------------------------------------------- 1 | "REVIEW_DATE","AUTHOR","ISBN","DISCOUNTED_PRICE" 2 | "1985/01/21","Douglas Adams",0345391802,5.95 3 | "1990/01/12","Douglas Hofstadter",0465026567,9.95 4 | "1998/07/15","Timothy ""The Parser"" Campbell",0968411304,18.99 5 | "1999/12/03","Richard Friedman",0060630353,5.95 6 | "2001/09/19","Karen Armstrong",0345384563,9.95 7 | "2002/06/23","David Jones",0198504691,9.95 8 | "2002/06/23","Julian Jaynes",0618057072,12.50 9 | "2003/09/30","Scott Adams",0740721909,4.95 10 | "2004/10/04","Benjamin Radcliff",0804818088,4.95 11 | "2004/10/04","Randel Helms",0879755725,4.50 12 | -------------------------------------------------------------------------------- /CSV/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | csv 5 | jar 6 | ANTLR CSV grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | csv.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | true 38 | false 39 | file 40 | csv 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /CSV/readme.txt: -------------------------------------------------------------------------------- 1 | Nathaniel Harward Fri May 13, 2011 10:08 2 | While looking for a simple CSV grammar I saw the one in the ANTLR wiki but wanted a cleaner version, plus one that didn't eat white space (not allowed per RFC4180). 3 | -------------------------------------------------------------------------------- /CUDAPTX/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | cudaptx 5 | jar 6 | ANTLR CUDAPTX grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | Ptx.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /CUDAPTX/readme.txt: -------------------------------------------------------------------------------- 1 | Ken Domino Thu Aug 26, 2010 14:55 2 | This Antlr v3 grammar recognizes the Nvidia CUDA PTX (parallel thread execution) assembly language v2.1, and creates a tree. This grammar is used in an emulator for CUDA programs. 3 | -------------------------------------------------------------------------------- /ECMAScript/examples/helloworld.txt: -------------------------------------------------------------------------------- 1 | function factorial(n) 2 | { if (n == 0) 3 | return 1; 4 | else 5 | return n * factorial(n-1); 6 | } 7 | var i; 8 | document.clear(); 9 | for (i = 0; i <= 16; i++) 10 | document.write(i + "! = " + factorial(i) + "
"); 11 | -------------------------------------------------------------------------------- /ECMAScript/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | ECMAScript 5 | jar 6 | ANTLR ECMAScript grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | JavaScript.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | true 38 | false 39 | program 40 | JavaScript 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /ECMAScript/readme.txt: -------------------------------------------------------------------------------- 1 | Chris Lambrou Fri Mar 28, 2008 13:38 2 | I couldn't get the ECMAScript by Greg Clemenson on the Grammar List page... 3 | -------------------------------------------------------------------------------- /FirstOrderLogic/FOL.g: -------------------------------------------------------------------------------- 1 | grammar FOL; 2 | 3 | options{ 4 | language=Java; 5 | output=AST; 6 | ASTLabelType = CommonTree; 7 | } 8 | 9 | tokens{ 10 | PREDICATE; 11 | FUNCTION; 12 | } 13 | 14 | /*------------------------------------------------------------------ 15 | * PARSER RULES 16 | *------------------------------------------------------------------*/ 17 | 18 | condition: formula EOF! ; 19 | 20 | formula 21 | : ((FORALL^ | EXISTS^) VARIABLE)? disjunction ; 22 | 23 | disjunction 24 | : conjunction (OR^ conjunction)* ; 25 | 26 | conjunction 27 | : negation (AND^ negation)* ; 28 | 29 | negation 30 | : NOT^? (predicate | LPAREN! formula RPAREN!) ; 31 | 32 | predicate 33 | : PREPOSITION predicateTuple -> ^(PREDICATE PREPOSITION predicateTuple) 34 | | PREPOSITION ; 35 | 36 | predicateTuple 37 | : LPAREN! term (','! term)* RPAREN! ; 38 | 39 | term : function | VARIABLE ; 40 | 41 | function: CONSTANT functionTuple -> ^(FUNCTION CONSTANT functionTuple) 42 | | CONSTANT; 43 | 44 | functionTuple 45 | : LPAREN! (CONSTANT | VARIABLE) (','! (CONSTANT | VARIABLE) )* RPAREN!; 46 | 47 | /*------------------------------------------------------------------ 48 | * LEXER RULES 49 | *------------------------------------------------------------------*/ 50 | 51 | LPAREN : '(' ; 52 | RPAREN : ')' ; 53 | AND : '&' ; 54 | OR : '|' ; 55 | NOT : '!' ; 56 | FORALL : 'Forall' ; 57 | EXISTS : 'Exists' ; 58 | 59 | VARIABLE: '?' (('a'..'z') | ('0'..'9')) CHARACTER* ; 60 | 61 | CONSTANT: (('a'..'z') | ('0'..'9')) CHARACTER* ; 62 | 63 | PREPOSITION: ('A'..'Z') CHARACTER* ; 64 | 65 | fragment CHARACTER: ('0'..'9' | 'a'..'z' | 'A'..'Z' | '_') ; 66 | 67 | WS : (' ' | '\t' | '\r' | '\n')+ {$channel = HIDDEN ;} ; 68 | -------------------------------------------------------------------------------- /FirstOrderLogic/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | fol 5 | jar 6 | ANTLR First Order Logic grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | FOL.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | false 38 | false 39 | condition 40 | FOL 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /FirstOrderLogic/readme.txt: -------------------------------------------------------------------------------- 1 | Stephan Opfer Fri May 4, 2012 11:32 2 | A simple grammar for first order logic formulas. 3 | -------------------------------------------------------------------------------- /FreeMPS/FreeMPS.g: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/grammars-v3/3a51146f4b35616f9c9dbaec5cdad4a42ff582e2/FreeMPS/FreeMPS.g -------------------------------------------------------------------------------- /FreeMPS/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | freemps 5 | jar 6 | ANTLR FreeMPS grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | FreeMPS.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /FreeMPS/readme.txt: -------------------------------------------------------------------------------- 1 | Tue Nov 16, 2010 05:58 2 | The grammar defines the structure of the mps format. 3 | -------------------------------------------------------------------------------- /Java1.6/examples/helloworld.java: -------------------------------------------------------------------------------- 1 | public class HelloWorld { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, World"); 4 | } 5 | } 6 | 7 | -------------------------------------------------------------------------------- /Java1.6/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | java1.6 5 | jar 6 | ANTLR Java 1.6 grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | Java.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | true 38 | false 39 | compilationUnit 40 | Java 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Java1.6/readme.txt: -------------------------------------------------------------------------------- 1 | Yang Jiang Fri Jan 16, 2009 12:01 2 | ANTLR-based Java grammar from openjdk project to develop an experimental... -------------------------------------------------------------------------------- /KUKA/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | kuka 5 | jar 6 | ANTLR KUKA grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | krl.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /KUKA/readme.txt: -------------------------------------------------------------------------------- 1 | Jan Schl��in Mon Oct 3, 2011 03:31 2 | The grammar of the industrial robots of KUKA. This grammar has been reverse engineered based on a set of KRL programs. 3 | -------------------------------------------------------------------------------- /OracleNetServices/OracleNetServicesV3.g: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright 2007 by Nathaniel Harward 4 | 5 | ANTLRv3 grammar for Oracle Network Services configuration files 6 | 7 | This grammar can parse entries in an Oracle Network Services configuration 8 | file (tnsnames.ora, listener.ora, sqlnet.ora, cman.ora, ldap.ora...), based 9 | on the Oracle 10g document: 10 | 11 | http://download-west.oracle.com/docs/cd/B19306_01/network.102/b14213/syntax.htm 12 | 13 | This grammar does not strictly conform to the document. In paricular it does 14 | not enforce that parameters start at column 0, and that continuation lines do 15 | not start in column 0 -- whitespace is ignored (as are comments). All other 16 | rules should be observed. 17 | 18 | The Oracle "spec" above is a little vague as a standalone language/syntax 19 | definition: I don't see how "NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES)" is 20 | valid since ',' is not listed as a delimiter. Of course I might have just 21 | misunderstood the document :) At any rate, if you come across valid syntax 22 | that this grammar does not allow please let me know so I can post a fix. 23 | 24 | */ 25 | 26 | grammar OracleNetServicesV3; 27 | 28 | configuration_file 29 | : ( parameter )* 30 | ; 31 | 32 | parameter 33 | : keyword EQUALS ( value 34 | | LEFT_PAREN value_list RIGHT_PAREN 35 | | ( LEFT_PAREN parameter RIGHT_PAREN )+ 36 | ) 37 | ; 38 | 39 | keyword 40 | : WORD 41 | ; 42 | 43 | value 44 | : WORD 45 | | QUOTED_STRING 46 | ; 47 | 48 | value_list 49 | : value ( COMMA value )* 50 | ; 51 | 52 | QUOTED_STRING 53 | : SINGLE_QUOTE ( ~( SINGLE_QUOTE ) )* SINGLE_QUOTE 54 | | DOUBLE_QUOTE ( ~( DOUBLE_QUOTE ) )* DOUBLE_QUOTE 55 | ; 56 | 57 | WORD 58 | : ( 'A' .. 'Z' 59 | | 'a' .. 'z' 60 | | '0' .. '9' 61 | | '<' 62 | | '>' 63 | | '/' 64 | | '.' 65 | | ':' 66 | | ';' 67 | | '-' 68 | | '_' 69 | | '$' 70 | | '+' 71 | | '*' 72 | | '&' 73 | | '!' 74 | | '%' 75 | | '?' 76 | | '@' 77 | | '\\' . 78 | )+ 79 | ; 80 | 81 | LEFT_PAREN 82 | : '(' 83 | ; 84 | 85 | RIGHT_PAREN 86 | : ')' 87 | ; 88 | 89 | EQUALS 90 | : '=' 91 | ; 92 | 93 | COMMA 94 | : ',' 95 | ; 96 | 97 | SINGLE_QUOTE 98 | : '\'' 99 | ; 100 | 101 | DOUBLE_QUOTE 102 | : '"' 103 | ; 104 | 105 | COMMENT 106 | : '#' ( ~( '\n' ) )* {skip();} 107 | ; 108 | 109 | WHITESPACE 110 | : ( '\t' 111 | | ' ' 112 | ) {skip();} 113 | ; 114 | 115 | NEWLINE 116 | : ( '\r' )? '\n' {skip();} 117 | ; 118 | 119 | -------------------------------------------------------------------------------- /OracleNetServices/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | oraclenetservices 5 | jar 6 | ANTLR Oracle Net Services grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | OracleNetServicesV3.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /OracleNetServices/readme.txt: -------------------------------------------------------------------------------- 1 | Nathaniel Harward Mon Jun 18, 2007 10:51 2 | A grammar for Oracle Net Services configuration files, like tnsnames.ora, sqlnet.ora, listener.ora, etc. Based on the syntax for Oracle 10g. 3 | -------------------------------------------------------------------------------- /PLSQL/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | plsql 5 | jar 6 | ANTLR PLSQL grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | PLSQL.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /PLSQL/readme.txt: -------------------------------------------------------------------------------- 1 | Patrick Higgins Fri Jul 16, 2010 15:20 2 | Parser for Oracle PL/SQL. Works with 11g. More details can be found in the header of the grammar. 3 | -------------------------------------------------------------------------------- /Pascal/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | pascal 5 | jar 6 | ANTLR Pascal grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | pascal.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | false 38 | false 39 | program 40 | pascal 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Pascal/readme.txt: -------------------------------------------------------------------------------- 1 | Marton Papp Thu Jul 15, 2010 11:04 2 | It contains a Pascal grammar file in ANTLR 3 format. It was made by exising ANTLR 2 grammar file that can be downloaded at ANTLR site. There is Eclipse project that can be opened in Eclipse and run. 3 | -------------------------------------------------------------------------------- /PowerBuilder/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | powerbuilder 5 | jar 6 | ANTLR PowerBuilder grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | PBM.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /PowerBuilder/readme.txt: -------------------------------------------------------------------------------- 1 | Ivan Brezina Wed Dec 21, 2011 08:30 2 | Sybase PowerBuilder grammar 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # grammars-v3 2 | 3 | A collection of [Antlr3](http://www.antlr3.org/) grammars, from [http://www.antlr3.org/grammar/list.html](http://www.antlr3.org/grammar/list.html) 4 | 5 | Expectation that the grammars are free of actions but it's not a hard and fast rule. There is no common license! 6 | 7 | Beware of the licenses on the individual grammars. **THERE IS NO COMMON 8 | LICENSE!** When in doubt or you don't know what you're doing, please use 9 | the BSD or MIT license. 10 | 11 | Warning 12 | ------------ 13 | 14 | These are legacy Antlr3 grammars. Many have not been updated for the latest version of Antlr3, and may fail to parse using the latest Antlr3. The grammars that parse properly are those that are not commented out in the root `pom.xml` 15 | 16 | Testing the Grammars 17 | ------------ 18 | 19 | The directory /support/antlr3test-maven-plugin contains a maven plugin which compiles the grammars and then runs them against examples in the /examples subdirectory to verify that the grammars compile and produce a clean parse for each example. 20 | 21 | To use the plugin, you will have to compile and install it. 22 | 23 |
24 | cd support/
25 | mvn clean package install
26 | 
27 | 28 | You can then test all grammars: 29 | 30 |
31 | mvn clean test
32 | 
33 | 34 | Travis Status 35 | --------- 36 | 37 | 38 | -------------------------------------------------------------------------------- /ValueChangeDump/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | valuechangedump 5 | jar 6 | ANTLR ValueChangeDump grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | ValueChangeDump.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /ValueChangeDump/readme.txt: -------------------------------------------------------------------------------- 1 | Eric W. Anderson Thu Nov 24, 2011 08:43 2 | Parses VCD (Value Change Dump) files generated by Verilog and VHDL simulators and some logic analyzers. Accompanying code to interpret the AST is available at https://github.com/ewa/ad9510spi . 3 | -------------------------------------------------------------------------------- /asm/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | asm 5 | jar 6 | ANTLR ASM grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | ASM.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | false 38 | false 39 | compilationUnit 40 | ASM 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /asm/readme.txt: -------------------------------------------------------------------------------- 1 | Los olvidados Tue Jan 1, 2008 19:26 2 | This is a very simple grammar of a pentium asm. You will find the lexical and parser specifications in the file and obviously it still lacks many rules. It is intended to be used only for educational purposes. It was written by my teamwork (Hugo Garza and Joaqu?n Moreno) and me (Miguel Ugalde), for a computational theory class project. We all attend Monterrey Tech in Cuernavaca. We will appreciate so much your feedback at A00378918@itesm.mx 3 | -------------------------------------------------------------------------------- /asn/examples/example1.asn: -------------------------------------------------------------------------------- 1 | MyModule DEFINITIONS ::= 2 | BEGIN 3 | 4 | MyTypes ::= SEQUENCE { 5 | myObjectId OBJECT IDENTIFIER, 6 | mySeqOf SEQUENCE OF MyInt, 7 | myBitString BIT STRING { 8 | muxToken(0), 9 | modemToken(1) 10 | } 11 | } 12 | 13 | MyInt ::= INTEGER (0..65535) 14 | 15 | END 16 | -------------------------------------------------------------------------------- /asn/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | asn 5 | jar 6 | ANTLR ASN grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | ASN.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | true 38 | false 39 | moduleDefinition 40 | ASN 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /asn/readme.txt: -------------------------------------------------------------------------------- 1 | Stefan Taranu Thu Jan 8, 2009 08:49 2 | An ASN.1 grammar compiled with antlr3.1.1. 3 | -------------------------------------------------------------------------------- /cpp/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | cpp 5 | jar 6 | ANTLR CPP grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | CPP_grammar_.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | false 38 | false 39 | translation_unit 40 | CPP_grammar_ 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /cpp/readme.txt: -------------------------------------------------------------------------------- 1 | Ramin Zaghi Thu Aug 26, 2010 03:46 2 | Version 4.0.1 August 2010. Compatible with ANTLR 3.2. Please note that this is the first public release for ANTLR 3.2; This does not comiple with any older versions of ANTLR. This may also have some missing features compared to the 2007 update by David Wigg. I am publishing this work only to make this first ANTLR 3.2 update available to the community however if you are interested in a more complete work please take a look at David's 2007 update. Feedbacks are welcome. You may send your comments to Ramin Zaghi antlr3_cpp_parser-at-taggedprogramming-dot-com. 3 | -------------------------------------------------------------------------------- /csharp/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | csharp 5 | jar 6 | ANTLR C# grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | CSharpParser.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /csharp/readme.txt: -------------------------------------------------------------------------------- 1 | Kunle Odutola Fri Feb 10, 2006 02:31 2 | This updated grammar file includes a fix for parsing nested #region and #if preprocessor directive blocks. Thanks to Paul Foster for reporting the issue (and supplying test cases). 3 | -------------------------------------------------------------------------------- /css21/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | css21 5 | jar 6 | ANTLR CSS21 grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | css21.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | false 38 | false 39 | styleSheet 40 | css21 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /css21/readme.txt: -------------------------------------------------------------------------------- 1 | Jim Idle Tue Apr 28, 2009 10:53 2 | Written for a customer who cancelled, this is a commercial level parser, which I am now donating for ANTLR users. It follows the spec for CSS 2.1 exactly, but has not had extensive testing. It should easily adapt to CSS3 as it was intended to do so. Please report any bugs so that all may benefit. 3 | -------------------------------------------------------------------------------- /css3/csst3.g: -------------------------------------------------------------------------------- 1 | grammar csst3; 2 | options { 3 | output=AST; 4 | ASTLabelType=CommonTree; 5 | language=CSharp; 6 | k=4;} 7 | 8 | tokens { 9 | IMPORT; 10 | NESTED; 11 | NEST; 12 | RULE; 13 | ATTRIB; 14 | PARENTOF; 15 | PRECEDEDS; 16 | ATTRIBEQUAL; 17 | HASVALUE; 18 | BEGINSWITH; 19 | PSEUDO; 20 | PROPERTY; 21 | FUNCTION; 22 | TAG; 23 | ID; 24 | CLASS; 25 | } 26 | 27 | stylesheet 28 | : importRule* (nested | ruleset)+ 29 | ; 30 | 31 | importRule 32 | : ('@import' | '@include') STRING -> ^( IMPORT STRING ) 33 | ; 34 | 35 | nested 36 | : '@' nest '{' properties? nested* '}' -> ^( NESTED nest properties* nested* ) 37 | ; 38 | 39 | nest 40 | : IDENT IDENT* pseudo* -> ^( NEST IDENT IDENT* pseudo* ) 41 | ; 42 | 43 | ruleset 44 | : selectors '{' properties? '}' -> ^( RULE selectors properties* ) 45 | ; 46 | 47 | selectors 48 | : selector (',' selector)* 49 | ; 50 | 51 | selector 52 | : elem selectorOperation* attrib* pseudo? -> elem selectorOperation* attrib* pseudo* 53 | ; 54 | 55 | selectorOperation 56 | : selectop? elem -> selectop* elem 57 | ; 58 | 59 | selectop 60 | : '>' -> PARENTOF 61 | | '+' -> PRECEDEDS 62 | ; 63 | 64 | properties 65 | : declaration (';' declaration?)* -> declaration+ 66 | ; 67 | 68 | elem 69 | : IDENT -> ^( TAG IDENT ) 70 | | '#' IDENT -> ^( ID IDENT ) 71 | | '.' IDENT -> ^( CLASS IDENT ) 72 | ; 73 | 74 | pseudo 75 | : (':'|'::') IDENT -> ^( PSEUDO IDENT ) 76 | | (':'|'::') function -> ^( PSEUDO function ) 77 | ; 78 | 79 | attrib 80 | : '[' IDENT (attribRelate (STRING | IDENT))? ']' -> ^( ATTRIB IDENT (attribRelate STRING* IDENT*)? ) 81 | ; 82 | 83 | attribRelate 84 | : '=' -> ATTRIBEQUAL 85 | | '~=' -> HASVALUE 86 | | '|=' -> BEGINSWITH 87 | ; 88 | 89 | declaration 90 | : IDENT ':' args -> ^( PROPERTY IDENT args ) 91 | ; 92 | 93 | args 94 | : expr (','? expr)* -> expr* 95 | ; 96 | 97 | expr 98 | : (NUM unit?) 99 | | IDENT 100 | | COLOR 101 | | STRING 102 | | function 103 | ; 104 | 105 | unit 106 | : ('%'|'px'|'cm'|'mm'|'in'|'pt'|'pc'|'em'|'ex'|'deg'|'rad'|'grad'|'ms'|'s'|'hz'|'khz') 107 | ; 108 | 109 | function 110 | : IDENT '(' args? ')' -> IDENT '(' args* ')' 111 | ; 112 | 113 | IDENT 114 | : ('_' | 'a'..'z'| 'A'..'Z' | '\u0100'..'\ufffe' ) 115 | ('_' | '-' | 'a'..'z'| 'A'..'Z' | '\u0100'..'\ufffe' | '0'..'9')* 116 | | '-' ('_' | 'a'..'z'| 'A'..'Z' | '\u0100'..'\ufffe' ) 117 | ('_' | '-' | 'a'..'z'| 'A'..'Z' | '\u0100'..'\ufffe' | '0'..'9')* 118 | ; 119 | 120 | // string literals 121 | STRING 122 | : '"'! (~('"'|'\n'|'\r'))* '"'! 123 | | '\''! (~('\''|'\n'|'\r'))* '\''! 124 | ; 125 | 126 | NUM 127 | : '-' (('0'..'9')* '.')? ('0'..'9')+ 128 | | (('0'..'9')* '.')? ('0'..'9')+ 129 | ; 130 | 131 | COLOR 132 | : '#' ('0'..'9'|'a'..'f'|'A'..'F')+ 133 | ; 134 | 135 | // Single-line comments 136 | SL_COMMENT 137 | : '//' 138 | (~('\n'|'\r'))* ('\n'|'\r'('\n')?) 139 | {$channel=HIDDEN;} 140 | ; 141 | 142 | // multiple-line comments 143 | COMMENT 144 | : '/*' .* '*/' { $channel = HIDDEN; } 145 | ; 146 | 147 | // Whitespace -- ignored 148 | WS : ( ' ' | '\t' | '\r' | '\n' | '\f' )+ { $channel = HIDDEN; } 149 | ; 150 | 151 | -------------------------------------------------------------------------------- /css3/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | csst3 5 | jar 6 | ANTLR CSSt3 grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | csst3.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /css3/readme.txt: -------------------------------------------------------------------------------- 1 | trihus Tue Jul 1, 2008 13:43 2 | This CSS parser handles valid CSS syntax. It will also accept property values not defined by CSS without giving an error. It has been debugged with ANTLRWorks and tested on a number of CSS files. (You must comment out language=CSharp for it to work with ANTLRWorks). I don't think it handles the full syntax of @import or @include. 3 | -------------------------------------------------------------------------------- /dcm/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | dcm 5 | jar 6 | ANTLR DCM grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | DCM_2_0_grammar.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | false 38 | false 39 | konservierung 40 | DCM_2_0_grammar 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /dcm/readme.txt: -------------------------------------------------------------------------------- 1 | Donn Shull Tue Feb 19, 2008 10:31 2 | antlr 3.0 grammar for DCM 2.0 calibration data files 3 | -------------------------------------------------------------------------------- /fortran77/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | fortran77 5 | jar 6 | ANTLR FORTRAN77 grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | f77-antlr2.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /fortran77/readme.txt: -------------------------------------------------------------------------------- 1 | Olivier Dragon Thu Jun 28, 2007 17:32 2 | A Fortran 77 grammar for ANTLR v2 3 | -------------------------------------------------------------------------------- /idl/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | idl 5 | jar 6 | ANTLR IDL grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | Idl.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | true 38 | false 39 | specification 40 | Idl 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.antlr 57 | stringtemplate 58 | 3.2.1 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /idl/readme.txt: -------------------------------------------------------------------------------- 1 | Dong Nguyen Fri Feb 22, 2008 05:52 2 | Translated from OMG IDL spec at http://www.omg.org/docs/formal/02-06-07.pdf. 3 | -------------------------------------------------------------------------------- /informix/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | informix 5 | jar 6 | ANTLR Informix grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | fgl.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /informix/readme.txt: -------------------------------------------------------------------------------- 1 | Gregorio Momm Mon Jan 5, 2004 18:17 2 | A 1st attempt of a Infomix 4GL Grammar, works with all the files i tried, but needs some improvements. 3 | -------------------------------------------------------------------------------- /java6separated/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | java6separated 5 | jar 6 | ANTLR Java 6 Separated grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | Java6Parse.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | true 38 | false 39 | compilationUnit 40 | Java6Parse 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /java6separated/readme.txt: -------------------------------------------------------------------------------- 1 | George S. Cowan Sun Jul 22, 2012 08:26 2 | The Java 6 grammar separated into a lexer grammar and a parser grammar, complete with an ant build file for generating and testing. 3 | -------------------------------------------------------------------------------- /javastacktrace/StackTraceText.g: -------------------------------------------------------------------------------- 1 | /** A Java stacktrace text grammar for ANTLR v3 2 | * see http://java.sun.com/javase/6/docs/api/java/lang/Throwable.html 3 | * 4 | * Version 1.0 -- initial release March 9, 2008 (requires 3.0 or higher) 5 | * 6 | * Primary authors: Luca Dall'Olio, Christian Cassano, Gabriele Contini 7 | */ 8 | grammar StackTraceText; 9 | 10 | options{ 11 | output=AST; 12 | } 13 | 14 | tokens { 15 | DOT='.'; 16 | AT='at'; 17 | CAUSED_BY='Caused by:'; 18 | MORE='more'; 19 | ELLIPSIS='...'; 20 | COLON=':'; 21 | NATIVE_METHOD='Native Method'; 22 | UNKNOWN_SOURCE='Unknown Source'; 23 | INIT=''; 24 | } 25 | 26 | @rulecatch { } /** Message will catch anything */ 27 | 28 | startRule 29 | : stackTrace EOF; 30 | 31 | 32 | stackTrace 33 | : messageLine+ stackTraceLine* causedByLine? 34 | ; 35 | 36 | stackTraceLine 37 | : (atLine|ellipsisLine) 38 | ; 39 | 40 | atLine 41 | : AT qualifiedMethod '(' classFile (COLON Number)? ')' 42 | ; 43 | 44 | causedByLine 45 | : CAUSED_BY stackTrace 46 | ; 47 | 48 | ellipsisLine : ELLIPSIS Number MORE 49 | ; 50 | 51 | messageLine 52 | : (qualifiedClass message?) 53 | ; 54 | 55 | qualifiedClass: packagePath? className innerClassName*; 56 | 57 | innerClassName 58 | : ('$' className) 59 | ; 60 | 61 | classFile 62 | : (identifier '.java' | NATIVE_METHOD | UNKNOWN_SOURCE) 63 | ; 64 | 65 | /** method name may be missing, I think in ctors */ 66 | qualifiedMethod 67 | : qualifiedClass DOT (methodName|constructor)?; 68 | 69 | constructor 70 | : INIT 71 | ; 72 | 73 | methodName 74 | : identifier 75 | ; 76 | 77 | packagePath : (identifier DOT)+; 78 | 79 | className : JavaWord; 80 | 81 | identifier : JavaWord; 82 | 83 | message : COLON (options {greedy=false;}: .)*; 84 | 85 | Number : Digit+ 86 | ; 87 | 88 | JavaWord : (JavaCharacter)+; 89 | 90 | fragment 91 | JavaCharacter 92 | : (CapitalLetter 93 | | NonCapitalLetter | Symbol 94 | | Digit) 95 | ; 96 | 97 | fragment NonCapitalLetter : 'a'..'z'; 98 | 99 | fragment CapitalLetter 100 | : 'A'..'Z' 101 | ; 102 | 103 | fragment Symbol : '_' 104 | ; 105 | 106 | fragment Digit : '0'..'9'; 107 | 108 | WS : (' '|'\r'|'\t'|'\u000C'|'\n') {$channel=HIDDEN;} 109 | ; 110 | -------------------------------------------------------------------------------- /javastacktrace/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | javastacktrace 5 | jar 6 | ANTLR Java Stack Trace grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | javastacktrace.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /javastacktrace/readme.txt: -------------------------------------------------------------------------------- 1 | Luca Dall'Olio Sun Mar 9, 2008 09:07 2 | This grammar was written to parse serialized Java Stack Trace Text 3 | -------------------------------------------------------------------------------- /jpa/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | jpa 5 | jar 6 | ANTLR JPA grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | JPA.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /jpa/readme.txt: -------------------------------------------------------------------------------- 1 | Alexander Kunkel Wed May 6, 2009 12:58 2 | -------------------------------------------------------------------------------- /json/readme.txt: -------------------------------------------------------------------------------- 1 | Taro L. Saito Mon Jan 26, 2009 17:42 2 | JSON (http://json.org/ ) format grammar, used in Xerial Project (http://www.xerial.org ) 3 | -------------------------------------------------------------------------------- /lua/Lua.g: -------------------------------------------------------------------------------- 1 | /* 2 | * Lua 5.1 grammar 3 | * 4 | * Nicolai Mainiero 5 | * May 2007 6 | * 7 | * This is a Lua (http://www.lua.org) grammar for the version 5.1 for ANTLR 3. 8 | * I tested it with basic and extended examples and it worked fine. It is also used 9 | * for LunarEclipse (http://lunareclipse.sf.net) a Lua editor based on Eclipse. 10 | * 11 | * Thanks to Johannes Luber and Gavin Lambert who helped me with some mutually left recursion. 12 | * 13 | */ 14 | 15 | grammar Lua; 16 | 17 | options { 18 | backtrack=true; 19 | } 20 | 21 | chunk : (stat (';')?)* (laststat (';')?)?; 22 | 23 | block : chunk; 24 | 25 | stat : varlist1 '=' explist1 | 26 | functioncall | 27 | 'do' block 'end' | 28 | 'while' exp 'do' block 'end' | 29 | 'repeat' block 'until' exp | 30 | 'if' exp 'then' block ('elseif' exp 'then' block)* ('else' block)? 'end' | 31 | 'for' NAME '=' exp ',' exp (',' exp)? 'do' block 'end' | 32 | 'for' namelist 'in' explist1 'do' block 'end' | 33 | 'function' funcname funcbody | 34 | 'local' 'function' NAME funcbody | 35 | 'local' namelist ('=' explist1)? ; 36 | 37 | laststat : 'return' (explist1)? | 'break'; 38 | 39 | funcname : NAME ('.' NAME)* (':' NAME)? ; 40 | 41 | varlist1 : var (',' var)*; 42 | 43 | 44 | namelist : NAME (',' NAME)*; 45 | 46 | explist1 : (exp ',')* exp; 47 | 48 | exp : ('nil' | 'false' | 'true' | number | string | '...' | function | prefixexp | tableconstructor | unop exp) (binop exp)* ; 49 | 50 | var: (NAME | '(' exp ')' varSuffix) varSuffix*; 51 | 52 | prefixexp: varOrExp nameAndArgs*; 53 | 54 | functioncall: varOrExp nameAndArgs+; 55 | 56 | /* 57 | var : NAME | prefixexp '[' exp ']' | prefixexp '.' NAME; 58 | 59 | prefixexp : var | functioncall | '(' exp ')'; 60 | 61 | functioncall : prefixexp args | prefixexp ':' NAME args ; 62 | */ 63 | 64 | varOrExp: var | '(' exp ')'; 65 | 66 | nameAndArgs: (':' NAME)? args; 67 | 68 | varSuffix: nameAndArgs* ('[' exp ']' | '.' NAME); 69 | 70 | args : '(' (explist1)? ')' | tableconstructor | string ; 71 | 72 | function : 'function' funcbody; 73 | 74 | funcbody : '(' (parlist1)? ')' block 'end'; 75 | 76 | parlist1 : namelist (',' '...')? | '...'; 77 | 78 | tableconstructor : '{' (fieldlist)? '}'; 79 | 80 | fieldlist : field (fieldsep field)* (fieldsep)?; 81 | 82 | field : '[' exp ']' '=' exp | NAME '=' exp | exp; 83 | 84 | fieldsep : ',' | ';'; 85 | 86 | binop : '+' | '-' | '*' | '/' | '^' | '%' | '..' | 87 | '<' | '<=' | '>' | '>=' | '==' | '~=' | 88 | 'and' | 'or'; 89 | 90 | unop : '-' | 'not' | '#'; 91 | 92 | number : INT | FLOAT | EXP | HEX; 93 | 94 | string : NORMALSTRING | CHARSTRING | LONGSTRING; 95 | 96 | 97 | // LEXER 98 | 99 | NAME :('a'..'z'|'A'..'Z'|'_')(options{greedy=true;}: 'a'..'z'|'A'..'Z'|'_'|'0'..'9')* 100 | ; 101 | 102 | INT : ('0'..'9')+; 103 | 104 | FLOAT :INT '.' INT ; 105 | 106 | EXP : (INT| FLOAT) ('E'|'e') ('-')? INT; 107 | 108 | HEX :'0x' ('0'..'9'| 'a'..'f')+ ; 109 | 110 | 111 | 112 | NORMALSTRING 113 | : '"' ( EscapeSequence | ~('\\'|'"') )* '"' 114 | ; 115 | 116 | CHARSTRING 117 | : '\'' ( EscapeSequence | ~('\''|'\\') )* '\'' 118 | ; 119 | 120 | LONGSTRING 121 | : '['('=')*'[' ( EscapeSequence | ~('\\'|']') )* ']'('=')*']' 122 | ; 123 | 124 | fragment 125 | EscapeSequence 126 | : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\') 127 | | UnicodeEscape 128 | | OctalEscape 129 | ; 130 | 131 | fragment 132 | OctalEscape 133 | : '\\' ('0'..'3') ('0'..'7') ('0'..'7') 134 | | '\\' ('0'..'7') ('0'..'7') 135 | | '\\' ('0'..'7') 136 | ; 137 | 138 | fragment 139 | UnicodeEscape 140 | : '\\' 'u' HexDigit HexDigit HexDigit HexDigit 141 | ; 142 | 143 | fragment 144 | HexDigit : ('0'..'9'|'a'..'f'|'A'..'F') ; 145 | 146 | 147 | COMMENT 148 | : '--[[' ( options {greedy=false;} : . )* ']]' {skip();} 149 | ; 150 | 151 | LINE_COMMENT 152 | : '--' ~('\n'|'\r')* '\r'? '\n' {skip();} 153 | ; 154 | 155 | 156 | WS : (' '|'\t'|'\u000C') {skip();} 157 | ; 158 | 159 | NEWLINE : ('\r')? '\n' {skip();} 160 | ; 161 | -------------------------------------------------------------------------------- /lua/examples/factorial.lua: -------------------------------------------------------------------------------- 1 | -- defines a factorial function 2 | function fact (n) 3 | if n == 0 then 4 | return 1 5 | else 6 | return n * fact(n-1) 7 | end 8 | end 9 | 10 | print("enter a number:") 11 | a = io.read("*number") -- read a number 12 | print(fact(a)) 13 | 14 | -------------------------------------------------------------------------------- /lua/examples/helloworld.lua: -------------------------------------------------------------------------------- 1 | print("Hello World") 2 | 3 | -------------------------------------------------------------------------------- /lua/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | lua 5 | jar 6 | ANTLR LUA grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | Lua.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | true 38 | false 39 | chunk 40 | Lua 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /lua/readme.txt: -------------------------------------------------------------------------------- 1 | Nicolai Mainiero Tue May 8, 2007 00:20 2 | A grammar for the Lua programming language version 5.1 for ANTLR 3 3 | -------------------------------------------------------------------------------- /mdx/mdx.g: -------------------------------------------------------------------------------- 1 | grammar mdx; 2 | 3 | options { 4 | //k = 2; // two token lookahead 5 | //exportVocab=Java; // Call its vocabulary "Java" 6 | output = AST; 7 | //testLiterals=false; 8 | //charVocabulary='\u0001';'\uFFFF'; 9 | //codeGenBitsetTestThreshold=20; 10 | //caseSensitiveLiterals=false; // uses CommonAST by default 11 | } 12 | 13 | 14 | 15 | tokens { 16 | // Keywords 17 | AND = 'AND'; 18 | AS = 'AS'; 19 | CASE = 'CASE'; 20 | CELL = 'CELL'; 21 | CELL_ORDINAL = 'CELL_ORDINAL'; 22 | CREATE = 'CREATE'; 23 | DIMENSION = 'DIMENSION'; 24 | ELSE = 'ELSE'; 25 | EMPTY = 'EMPTY'; 26 | END = 'END'; 27 | FORMATTED_VALUE = 'FORMATTED_VALUE'; 28 | FROM = 'FROM'; 29 | GLOBAL = 'GLOBAL'; 30 | MEMBER = 'MEMBER'; 31 | NON = 'NON'; 32 | NOT = 'NOT'; 33 | ON = 'ON'; 34 | OR = 'OR'; 35 | PROPERTIES = 'PROPERTIES'; 36 | SELECT = 'SELECT'; 37 | SESSION = 'SESSION'; 38 | SET = 'SET'; 39 | THEN = 'THEN'; 40 | VALUE = 'VALUE'; 41 | WHEN = 'WHEN'; 42 | WHERE = 'WHERE'; 43 | XOR = 'XOR'; 44 | WITH = 'WITH'; 45 | 46 | // Symbols 47 | QUOTE = '\''; 48 | ASTERISK = '*'; 49 | COLON = ':'; 50 | SEMICOLON = ';'; 51 | COMMA = ','; 52 | CONCAT = '||'; 53 | DOT = '.'; 54 | EQ = '='; 55 | GE = '>='; 56 | GT = '>'; 57 | LBRACE = '{'; 58 | LE = '<='; 59 | LPAREN = '('; 60 | LT = '<'; 61 | MINUS = '-'; 62 | NE = '<>'; 63 | PLUS = '+'; 64 | RBRACE = '}'; 65 | RPAREN = ')'; 66 | SOLIDUS = '/'; 67 | 68 | } 69 | 70 | 71 | 72 | 73 | 74 | mdx_statement : (select_statement 75 | ) EOF 76 | // This part of MDX language is used rarely: 77 | // | drop_formula_statement) EOF 78 | ; 79 | 80 | 81 | select_statement : (WITH formula_specification)? 82 | SELECT axis_specification_list? 83 | FROM cube_specification 84 | (WHERE slicer_specification)? 85 | cell_props? 86 | ; 87 | 88 | 89 | 90 | formula_specification : 91 | single_formula_specification+ 92 | ; 93 | 94 | single_formula_specification : 95 | member_specification 96 | | set_specification 97 | ; 98 | 99 | set_specification : SET set_name AS 100 | ( QUOTE expression QUOTE | expression ) 101 | ; 102 | 103 | member_specification : 104 | MEMBER member_name AS 105 | ( 106 | ( QUOTE value_expression QUOTE | value_expression) 107 | COMMA member_property_def_list? 108 | ) 109 | ; 110 | 111 | 112 | axis_specification_list : axis_specification (COMMA axis_specification)* 113 | ; 114 | 115 | 116 | member_property_def_list : 117 | member_property_definition (COMMA member_property_definition)* 118 | ; 119 | 120 | 121 | member_name : compound_id 122 | ; 123 | 124 | member_property_definition : identifier EQ value_expression 125 | ; 126 | 127 | set_name : compound_id 128 | ; 129 | 130 | compound_id : (identifier)=>(identifier (DOT identifier)*) 131 | | 132 | ; 133 | 134 | axis_specification : (NON EMPTY)? expression dim_props? ON axis_name 135 | ; 136 | 137 | axis_name : identifier 138 | ; 139 | 140 | dim_props : DIMENSION? PROPERTIES property_list 141 | ; 142 | 143 | property_list: property (COMMA property)* 144 | ; 145 | 146 | 147 | property : compound_id 148 | ; 149 | 150 | cube_specification: cube_name 151 | ; 152 | 153 | cube_name : compound_id 154 | ; 155 | 156 | slicer_specification: expression 157 | ; 158 | 159 | cell_props : CELL? PROPERTIES cell_property_list 160 | ; 161 | 162 | cell_property_list: cell_property COMMA cell_property* 163 | ; 164 | 165 | 166 | cell_property: mandatory_cell_property 167 | | provider_specific_cell_property 168 | ; 169 | 170 | 171 | 172 | mandatory_cell_property: CELL_ORDINAL 173 | | VALUE 174 | | FORMATTED_VALUE 175 | ; 176 | 177 | provider_specific_cell_property : identifier 178 | ; 179 | 180 | expression : value_expression (COLON value_expression)* 181 | ; 182 | 183 | 184 | value_expression: term5 185 | (value_xor_expression | value_or_expression)* 186 | ; 187 | 188 | value_xor_expression: XOR term5 189 | ; 190 | 191 | value_or_expression : OR term5 192 | ; 193 | 194 | term5 : term4 195 | (AND term4)* 196 | ; 197 | 198 | term4 : NOT term4 199 | | term3 200 | ; 201 | 202 | term3 : term2 (comp_op term2)* 203 | ; 204 | 205 | term2 : term ((CONCAT | PLUS | MINUS) term)* 206 | ; 207 | 208 | term : factor ((SOLIDUS | ASTERISK) factor)* 209 | ; 210 | 211 | factor : MINUS value_expression_primary 212 | | PLUS value_expression_primary 213 | | value_expression_primary 214 | ; 215 | 216 | function : identifier LPAREN (exp_list)? RPAREN 217 | ; 218 | 219 | value_expression_primary: value_expression_primary0 220 | ( DOT 221 | ( unquoted_identifier 222 | | quoted_identifier 223 | | amp_quoted_identifier 224 | | function 225 | ) 226 | )* 227 | ; 228 | 229 | value_expression_primary0: function 230 | | (LPAREN exp_list RPAREN) 231 | | (LBRACE (exp_list)? RBRACE) 232 | | case_expression 233 | | STRING 234 | | NUMBER 235 | | identifier 236 | ; 237 | 238 | exp_list : expression (COMMA expression)* 239 | ; 240 | 241 | 242 | case_expression: CASE (value_expression)? 243 | (when_list)? 244 | (ELSE value_expression)? 245 | END 246 | ; 247 | 248 | when_list : when_clause (when_clause)* 249 | ; 250 | 251 | when_clause : WHEN value_expression THEN value_expression 252 | ; 253 | 254 | comp_op : EQ 255 | | NE 256 | | LT 257 | | GT 258 | | LE 259 | | GE 260 | ; 261 | 262 | identifier : (unquoted_identifier 263 | | quoted_identifier) 264 | ; 265 | 266 | unquoted_identifier : keyword 267 | | ID 268 | ; 269 | 270 | amp_quoted_identifier: AMP_QUOTED_ID 271 | ; 272 | 273 | quoted_identifier: QUOTED_ID 274 | ; 275 | 276 | keyword : DIMENSION 277 | | PROPERTIES 278 | ; 279 | 280 | // MDX Lexical Rules 281 | 282 | F : '0'..'9'+ '.' '0'..'9'* ; 283 | 284 | 285 | 286 | // Typed 287 | QUOTE : '\''; 288 | ASTERISK : '*'; 289 | COLON : ':'; 290 | SEMICOLON : ';'; 291 | COMMA : ','; 292 | CONCAT : '||'; 293 | DOT : '.'; 294 | EQ : '='; 295 | GE : '>='; 296 | GT : '>'; 297 | LBRACE : '{'; 298 | LE : '<='; 299 | LPAREN : '('; 300 | LT : '<'; 301 | MINUS : '-'; 302 | NE : '<>'; 303 | PLUS : '+'; 304 | RBRACE : '}'; 305 | RPAREN : ')'; 306 | SOLIDUS : '/'; 307 | 308 | 309 | NUMBER : ('0'..'9')+ 310 | ; 311 | ID : ('a'..'z'|'A'..'Z'|'_'|'$') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'$')* 312 | ; 313 | AMP_QUOTED_ID: '[&' (ID ((' ' | '\t')+ ID)* | NUMBER) ']' 314 | ; 315 | QUOTED_ID: ('[' (ID ((' ' | '\t')+ ID)* | NUMBER) ']') 316 | ; 317 | 318 | STRING : '"' (~'"')* '"' 319 | | '\'' (~'\'')* '\'' 320 | ; 321 | 322 | WS : ( ' ' 323 | | '\t' 324 | | '\r' 325 | | '\f' 326 | | '\n' 327 | )+ 328 | { $channel=HIDDEN; } 329 | ; 330 | -------------------------------------------------------------------------------- /mdx/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | mdx 5 | jar 6 | ANTLR MDX grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | mdx.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /mdx/readme.txt: -------------------------------------------------------------------------------- 1 | Mayur B.M Wed Apr 15, 2009 04:28 2 | updated MDX grammer for V 3.XX from V 2.XXX.please add your custom actions and help in making it better... 3 | -------------------------------------------------------------------------------- /memcached/memcached_protocol.g: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright 2008 by Nathaniel Harward 4 | 5 | ANTLRv3 grammar for the memcached protocol, as described by the document 6 | http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt 7 | 8 | Please email with any corrections/errors you might find. 9 | 10 | */ 11 | grammar memcached_protocol; 12 | 13 | command_line 14 | : (storage_command 15 | | retrieval_command 16 | | delete_command 17 | | increment_command 18 | | decrement_command 19 | | statistics_command 20 | | flush_command 21 | | version_command 22 | | verbosity_command 23 | | quit_command 24 | ) 25 | ; 26 | 27 | storage_command 28 | : ((storage_command_name key flags exptime bytes) 29 | | ('cas' key flags exptime bytes cas_unique)) 30 | noreply? 31 | ; 32 | 33 | storage_command_name 34 | : 'set' 35 | | 'add' 36 | | 'replace' 37 | | 'append' 38 | | 'prepend'; 39 | 40 | retrieval_command 41 | : ('get' | 'gets') key+; 42 | 43 | delete_command 44 | : 'delete' key time? noreply?; 45 | 46 | increment_command 47 | : 'incr' key value noreply?; 48 | 49 | decrement_command 50 | : 'decr' key value noreply?; 51 | 52 | statistics_command 53 | : 'stats' statistics_option?; 54 | 55 | statistics_option 56 | : 'items' 57 | | 'slabs' 58 | | 'sizes' 59 | ; 60 | 61 | flush_command 62 | : 'flush_all' delay? noreply?; 63 | 64 | version_command 65 | : 'version'; 66 | 67 | verbosity_command 68 | : 'verbosity' verbosity_level; 69 | 70 | quit_command 71 | : 'quit'; 72 | 73 | storage_response 74 | : error_response 75 | | 'STORED' 76 | | 'NOT_STORED' 77 | | 'EXISTS' 78 | | 'NOT_FOUND' 79 | ; 80 | 81 | retrieval_response 82 | : error_response 83 | | ('VALUE' key flags bytes cas_unique?) 84 | | end 85 | ; 86 | 87 | deletion_response 88 | : error_response 89 | | 'DELETED' 90 | | 'NOT_FOUND' 91 | ; 92 | 93 | incr_or_decr_response 94 | : error_response 95 | | 'NOT_FOUND' 96 | | INTEGER 97 | ; 98 | 99 | statistics_response 100 | : error_response 101 | | general_statistic 102 | | size_statistic 103 | | end 104 | ; 105 | 106 | 107 | error_response 108 | : general_error 109 | | client_error_message 110 | | server_error_message 111 | ; 112 | 113 | general_statistic 114 | : 'STAT' statistic_name statistic_value; 115 | 116 | size_statistic 117 | : size count; 118 | 119 | general_error 120 | : 'ERROR'; 121 | 122 | client_error_message 123 | : 'CLIENT_ERROR' .+; 124 | 125 | server_error_message 126 | : 'SERVER_ERROR' .+; 127 | 128 | end : 'END'; 129 | 130 | noreply : 'noreply'; 131 | 132 | key : .; 133 | 134 | flags : INTEGER; 135 | 136 | exptime : INTEGER; 137 | 138 | bytes : INTEGER; 139 | 140 | cas_unique 141 | : INTEGER; 142 | 143 | value : INTEGER; 144 | 145 | time : INTEGER; 146 | 147 | delay : INTEGER; 148 | 149 | verbosity_level 150 | : INTEGER; 151 | 152 | statistic_name 153 | : WORD; 154 | 155 | statistic_value 156 | : .; 157 | 158 | size : INTEGER; 159 | 160 | count : INTEGER; 161 | 162 | INTEGER : DIGIT+; 163 | 164 | WORD : PRINTABLE_CHAR+; 165 | 166 | fragment DIGIT 167 | : '0'..'9'; 168 | 169 | fragment PRINTABLE_CHAR 170 | : '!'..'~'; 171 | 172 | WHITESPACE 173 | : (' ' | '\t' | '\r' | '\n' | '\u000C')+ {$channel = HIDDEN;} 174 | ; 175 | -------------------------------------------------------------------------------- /memcached/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | memcached 5 | jar 6 | ANTLR MemcacheD grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | memcached_protocol.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /memcached/readme.txt: -------------------------------------------------------------------------------- 1 | Nathaniel Harward Fri Mar 21, 2008 17:53 2 | A basic grammar for the memcached network protocol as described at http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt. Please email me (address is inside the grammar itself) if you find any problems with it. 3 | -------------------------------------------------------------------------------- /modula2pim4/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | modula2pim4 5 | jar 6 | ANTLR Modula2PIM4 grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | m2pim4_LL1.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /modula2pim4/readme.txt: -------------------------------------------------------------------------------- 1 | Benjamin Kowarsch Fri Jul 10, 2009 01:12 2 | ANTLR v3 grammar for Modula-2 adapted from the syntax given in the fourth edition of "Programming in Modula-2" by N. Wirth, refactored to satisfy LL(1) constraints. 3 | -------------------------------------------------------------------------------- /mumath/mumath.g: -------------------------------------------------------------------------------- 1 | 2 | class mumathParser extends Parser; 3 | options { 4 | k=2; 5 | } 6 | { 7 | String mungID(Token tok) 8 | { 9 | int i; 10 | String t = tok.getText(); 11 | String o = ""; 12 | if(t.equals("@")){ o = "last";} 13 | else if(t.equals("#E")){o = "%E";} 14 | else if(t.charAt(t.length()-1) == '#') 15 | { o = "lie_"+t.substring(0,t.length()-1).toLowerCase(); } 16 | else if((i = t.indexOf('#')) >= 0) 17 | { 18 | o = "lie_"+(new StringBuffer(t)).deleteCharAt(i).toString().toLowerCase(); 19 | } 20 | else o = t.toLowerCase(); 21 | return(o); 22 | } 23 | void p(String s){ System.out.print(s); } 24 | void p(char s){ System.out.print(s); } 25 | } 26 | program : ((functionDefinition|assignment|functionDesignator) 27 | (SEMI|DOLLAR) { System.out.println('$'); } )* EOF ; 28 | 29 | // empty : /* empty */ ; 30 | assignment : (i:ID COLON { p(mungID(i)+':'); } )+ expression ; 31 | 32 | list : LPAREN { p('('); } 33 | (RPAREN { p(')'); } 34 | |i:ID { p(mungID(i)); } 35 | (COMMA j:ID{p(','+mungID(j)); } )* 36 | RPAREN { p(')'); } ) ; 37 | 38 | functionDefinition : FUNCTION i:ID { p(mungID(i)); } list COMMA 39 | { System.out.println(":=block([last]"); } statments (COMMA)? ENDFUN { p(")"); } ; 40 | 41 | actualParameter : expression|assignment ; 42 | 43 | statments : (loop|when|block|assignment|expression|functionDesignator) 44 | (COMMA { System.out.println(','); } statments)* ; 45 | 46 | block : BLOCK {p("block(");} statments COMMA ENDBLOCK {p(')');} ; 47 | loop : LOOP {System.out.println("do(");} 48 | statments (COMMA)? ENDLOOP { System.out.println(")"); }; 49 | when {boolean comma = false; } : WHEN {p("if "); } 50 | expression {p(" then "); } 51 | ((COMMA)? EXIT { p("return(last)"); } 52 | | { p('('); } COMMA statments (COMMA {comma = true;} )? 53 | EXIT { if(!comma)p(','); p("return(last))"); } ) ; 54 | expression : simpleExpression ( relationalOperator simpleExpression)* ; 55 | 56 | relationalOperator 57 | : equal | NOT_EQUAL {p('#');} | LT {p('<');} | LE {p("<=");} | 58 | GE {p(">=");} | GT {p('>');} | EQUATION {p('=');} 59 | ; 60 | 61 | simpleExpression 62 | : (MINUS {p('-');} )? 63 | term ( addingOperator term )* 64 | ; 65 | 66 | addingOperator 67 | : PLUS {p('+');} | MINUS {p('-');} | OR {p(" OR "); } 68 | ; 69 | 70 | term 71 | : factor ( multiplyingOperator factor )* 72 | ; 73 | 74 | multiplyingOperator 75 | : STAR{p('*');} | SLASH{p('/');} | MOD {p(" mod ");} | AND {p(" AND ");} | 76 | POWER {p('^');} 77 | ; 78 | 79 | factor 80 | : i:ID {p(mungID(i));} 81 | | constant 82 | | LPAREN {p('(');} expression RPAREN {p(')');} 83 | | functionDesignator 84 | | NOT {p(" NOT ");} factor 85 | ; 86 | 87 | constant 88 | : n:NUMBER {p(n.getText());} 89 | | s:STRING {p(s.getText());} 90 | | QUOTE i:ID {p('\''+mungID(i));} 91 | | QUOTE qs:STRING {p('\''+qs.getText());} 92 | ; 93 | 94 | functionDesignator 95 | : i:ID LPAREN { p(mungID(i)+'('); } 96 | ((actualParameter ( COMMA { p(','); } actualParameter) *) 97 | |) 98 | RPAREN { p(')'); } ; 99 | 100 | equal : (EQF|EQC) { p('='); }; 101 | 102 | class mumathLexer extends Lexer; 103 | 104 | options { 105 | k=2; 106 | charVocabulary = '\3'..'\377'; 107 | } 108 | 109 | tokens { 110 | BLOCK = "BLOCK" ; 111 | ENDBLOCK = "ENDBLOCK" ; 112 | FUNCTION = "FUNCTION" ; 113 | ENDFUN = "ENDFUN" ; 114 | EQF = "EQ" ; 115 | LOOP = "LOOP" ; 116 | ENDLOOP = "ENDLOOP" ; 117 | WHEN = "WHEN" ; 118 | EXIT = "EXIT" ; 119 | OR = "OR" ; 120 | } 121 | 122 | WS : (' ' | '\t' | '\n' {newline();} | '\r') { _ttype = Token.SKIP; } ; 123 | COMMENT : '%' ('\n' {newline();} | ~('%'|'\n'))* '%' 124 | { System.out.println("/* "+ getText() +" */"); $setType(Token.SKIP);}; 125 | 126 | 127 | EQUATION : "==" ; 128 | QUOTE : '\'' ; 129 | PLUS : '+' ; 130 | MINUS : '-' ; 131 | STAR : '*' ; 132 | SLASH : '/' ; 133 | COMMA : ',' ; 134 | SEMI : ';' ; 135 | DOLLAR : '$' ; 136 | COLON : ':' ; 137 | EQC : '=' ; 138 | NOT_EQUAL : "<>" ; 139 | LT : '<' ; 140 | LE : "<=" ; 141 | GE : ">=" ; 142 | GT : '>' ; 143 | LPAREN : '(' ; 144 | RPAREN : ')' ; 145 | POWER : '^' ; 146 | 147 | ID options {testLiterals=true;} : 148 | ('A'..'Z' | '@' | '{' | '#') ('A'..'Z'|'0'..'9'|'#'|'}')* (ARR)? ; 149 | ARR: '[' NUMBER ']' ; 150 | STRING : '"' (~'"')* '"'; 151 | NUMBER : ('0'..'9')+; 152 | -------------------------------------------------------------------------------- /mumath/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | mumath 5 | jar 6 | ANTLR MuMath grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | mumath.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /mumath/readme.txt: -------------------------------------------------------------------------------- 1 | Dan Stanger Wed Mar 10, 2004 16:49 2 | This is a crude parser for muMath, a almost extinct language which has evolved into Derive. It can be used under the same license as Antlr. 3 | -------------------------------------------------------------------------------- /mysql/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | mysql 5 | jar 6 | ANTLR MYSQL grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | MySQL.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | false 38 | false 39 | file 40 | MySQL 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /mysql/readme.tt: -------------------------------------------------------------------------------- 1 | wangmin Thu Sep 13, 2012 02:27 2 | parse mysql, should has some errors in the grammer parser, if any pazzle, please reffrence http://dev.mysql.com/doc/refman/5.6/en/index.html 3 | -------------------------------------------------------------------------------- /objc/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | objc 5 | jar 6 | ANTLR ObjectiveC grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | ObjectiveC2ansi.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | false 38 | false 39 | translation_unit 40 | ObjectiveC2ansi 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /objc/readme.txt: -------------------------------------------------------------------------------- 1 | Cedric Cuche Thu Jun 5, 2008 14:06 2 | Antlr3 Grammar for ObjectiveC (based on grammar found in the Appendix of "The Objective-C 2.0 Programming Language"). 3 | -------------------------------------------------------------------------------- /oraclejdbcurl/jdbc-url.g: -------------------------------------------------------------------------------- 1 | // 2 | // Oracle JDBC URL (with integrated TNSNAMES.ORA) parser 3 | // 4 | // Author: Nathaniel Harward 5 | // 6 | // A simple parser for Oracle JDBC URLs, also includes a simple parser 7 | // for a TNSNAMES.ORA stream. 8 | // 9 | // I am not an Oracle expert and did not consult the Oracle documentation 10 | // for the format of the TNSNAMES.ORA file -- so in some cases it may need 11 | // to be extended. But for the examples I encountered it worked without 12 | // any problems. Use/extend as you see fit. 13 | // 14 | 15 | 16 | // 17 | // JDBC URL (with integrated TNSNAMES.ORA) parser 18 | // 19 | 20 | class OracleJdbcUrlParser extends Parser; 21 | 22 | options { 23 | k = 2; 24 | buildAST = true; 25 | } 26 | 27 | tokens { 28 | JDBC_DRIVER_TYPE; 29 | JDBC_DB_DEFINITION; 30 | KEY_VALUE_LIST; 31 | KEY; 32 | VALUE; 33 | TNSNAMES_ENTRY; 34 | TNSENTRY_SID; 35 | } 36 | 37 | // 38 | // TNSNAMES.ORA productions, they define the oracle_sid and key_value_list productions 39 | // that are [potentially] used in an Oracle JDBC URL 40 | // 41 | 42 | tnsnames_stream: (tnsnames_entry)*; 43 | 44 | tnsnames_entry: tnsentry_sid EQUALS_SIGN key_value_list 45 | { #tnsnames_entry = #([TNSNAMES_ENTRY, "tnsnames_entry"], #tnsnames_entry); } 46 | ; 47 | 48 | tnsentry_sid: oracle_sid 49 | { #tnsentry_sid = #([TNSENTRY_SID, "tnsentry_sid"], #tnsentry_sid); } 50 | ; 51 | 52 | key_value_list: 53 | OPEN_PAREN key EQUALS_SIGN ( ( key_value_list )+ | value ) CLOSE_PAREN 54 | { 55 | #key_value_list = #([KEY_VALUE_LIST, "key_value_list"], #key_value_list); 56 | } 57 | ; 58 | 59 | key: 60 | ( ~( OPEN_PAREN | CLOSE_PAREN | EQUALS_SIGN ) )+ 61 | { #key = #([KEY, "key"], #key); } 62 | ; 63 | 64 | value: 65 | ( ~( OPEN_PAREN | CLOSE_PAREN | EQUALS_SIGN ) )+ 66 | { #value = #([VALUE, "value"], #value); } 67 | ; 68 | 69 | oracle_sid: WORD ( WORD | NUMBER | UNDERSCORE )* 70 | ; 71 | 72 | hostname: ( NUMBER | WORD ) ( NUMBER | WORD | HYPHEN | UNDERSCORE )* ( DOT ( ( NUMBER | WORD ) ( NUMBER | WORD | HYPHEN | UNDERSCORE )* ) )* 73 | ; 74 | 75 | // 76 | // Oracle JDBC URL productions 77 | // 78 | 79 | oracle_jdbc_url: jdbc_literal_string COLON oracle_literal_string COLON ( oracle_oci_sub_url | oracle_thin_sub_url ) 80 | ; 81 | 82 | oracle_oci_sub_url: 83 | oracle_oci_driver (COLON username_and_password)? COLON AT_SIGN oracle_oci_database_definition 84 | ; 85 | 86 | oracle_thin_sub_url: 87 | oracle_thin_driver (COLON username_and_password)? COLON AT_SIGN oracle_thin_database_definition 88 | ; 89 | 90 | username_and_password: ( ~( SLASH | AT_SIGN ) )+ SLASH ( ~COLON )* 91 | ; 92 | 93 | oracle_oci_driver: oci_literal_string 94 | { #oracle_oci_driver = #([JDBC_DRIVER_TYPE, "driver_type"], #oracle_oci_driver); } 95 | ; 96 | 97 | oracle_thin_driver: thin_literal_string 98 | { #oracle_thin_driver = #([JDBC_DRIVER_TYPE, "driver_type"], #oracle_thin_driver); } 99 | ; 100 | 101 | oracle_oci_database_definition: oracle_sid | key_value_list 102 | { #oracle_oci_database_definition = #([JDBC_DB_DEFINITION, "database_definition"], #oracle_oci_database_definition); } 103 | ; 104 | 105 | oracle_thin_database_definition: ( hostname COLON port COLON oracle_sid ) | key_value_list 106 | { #oracle_thin_database_definition = #([JDBC_DB_DEFINITION, "database_definition"], #oracle_thin_database_definition); } 107 | ; 108 | 109 | port: NUMBER 110 | ; 111 | 112 | jdbc_literal_string: "jdbc" 113 | ; 114 | 115 | oracle_literal_string: "oracle" 116 | ; 117 | 118 | oci_literal_string: "oci" 119 | ; 120 | 121 | thin_literal_string: "thin" 122 | ; 123 | 124 | // 125 | // SQL*Net lexer 126 | // 127 | 128 | class OracleJdbcUrlLexer extends Lexer; 129 | 130 | options { 131 | charVocabulary = '\3' .. '\177'; 132 | k = 2; 133 | } 134 | 135 | EQUALS_SIGN : '='; 136 | 137 | OPEN_PAREN : '('; 138 | 139 | CLOSE_PAREN : ')'; 140 | 141 | COLON: ':'; 142 | 143 | DOLLAR_SIGN: '$'; 144 | 145 | POUND_SIGN: '#'; 146 | 147 | AT_SIGN: '@'; 148 | 149 | SLASH: '/'; 150 | 151 | HYPHEN: '-'; 152 | 153 | UNDERSCORE: '_'; 154 | 155 | DOT: '.'; 156 | 157 | protected 158 | DIGIT: '0' .. '9'; 159 | 160 | protected 161 | LETTER: 'a' .. 'z' | 'A' .. 'Z'; 162 | 163 | NUMBER: 164 | DIGIT ( DIGIT )+ 165 | | DIGIT { $setType(DIGIT); } 166 | ; 167 | 168 | WORD: 169 | LETTER ( LETTER )+ 170 | | LETTER { $setType(LETTER); } 171 | ; 172 | 173 | WS : ( ' ' 174 | | '\t' 175 | | '\r' ( '\n' )? { newline(); } 176 | | '\n' ( '\r' )? { newline(); } 177 | ) 178 | { $setType(Token.SKIP); } 179 | ; 180 | -------------------------------------------------------------------------------- /oraclejdbcurl/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | oraclejdbcurl 5 | jar 6 | ANTLR Oracle JDBC URL grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | jdbc-url.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /oraclejdbcurl/readme.txt: -------------------------------------------------------------------------------- 1 | Nathaniel Harward ( at gmail dot com) Fri Jul 2, 2004 15:52 2 | A very simple parser for Oracle JDBC URLs, includes production rules for parsing a TNSNAMES.ORA stream as well since TNS entries and JDBC URLs can potentially share the same format, so I figured why not include that as well. 3 | -------------------------------------------------------------------------------- /pddl/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | pddl 5 | jar 6 | ANTLR PDDL grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | Pddl.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /pddl/readme.txt: -------------------------------------------------------------------------------- 1 | Grammar for parsing PDDL 3.0. Not quite complete, as it doesn't cope with preference preconditions or goals. Also doesn't yet create friendly named nodes in the AST for all of the rules. (Now fixed so works with ANTLR 3.1.1) 2 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | com.antlr.grammarsv3 4 | grammarsv3 5 | pom 6 | 1.0-SNAPSHOT 7 | ANTLR3 grammars 8 | 9 | ANSI-C 10 | Antlrv3 11 | CSV 12 | asm 13 | asn 14 | 15 | 16 | css21 17 | 18 | 19 | 20 | dcm 21 | ECMAScript 22 | FirstOrderLogic 23 | 24 | 25 | idl 26 | 27 | Java1.6 28 | java6separated 29 | javastacktrace 30 | 31 | KUKA 32 | lua 33 | mdx 34 | 35 | 36 | 37 | mysql 38 | objc 39 | 40 | OracleNetServices 41 | 42 | pddl 43 | PLSQL 44 | 45 | 46 | 47 | 48 | sexpression 49 | 50 | 51 | verilog 52 | 53 | wavefront 54 | xpath 55 | xpath2 56 | 57 | 58 | UTF-8 59 | 1.6 60 | 3.5.2 61 | 62 | 63 | 64 | org.testng 65 | testng 66 | 6.9.9 67 | 68 | 69 | org.antlr 70 | antlr 71 | ${antlr.version} 72 | 73 | 74 | 75 | 76 | 77 | org.apache.maven.plugins 78 | maven-compiler-plugin 79 | 3.0 80 | 81 | ${target.jvm} 82 | ${target.jvm} 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /python/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | python 5 | jar 6 | ANTLR Python grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | Python.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /python/readme.txt: -------------------------------------------------------------------------------- 1 | Frank Wierzbicki Fri Jan 18, 2008 20:09 2 | This grammar is an update to the Python 2.3 grammar in the antlr examples. It adds the new features from Python 2.5, and also supports more lexing corner cases (for example """foo\""""). This grammar recognizes all but eight .py files in the Lib directory of release25-maint branch of Python. The .py files that it cannot match are either deliberately bad files for testing or .py files that use 'as' as an identifier (this will not be allowed in Python 2.5 so I didn't worry about it for now) 3 | -------------------------------------------------------------------------------- /rcs/jrcs.g: -------------------------------------------------------------------------------- 1 | header { 2 | package org.jviewcvs.jrcs; 3 | /* 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Copyright (c) 2000-2003 Lucas Bruand. All rights 7 | * reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in 18 | * the documentation and/or other materials provided with the 19 | * distribution. 20 | * 21 | * 3. The end-user documentation included with the redistribution, if 22 | * any, must include the following acknowlegement: 23 | * "This product includes software developed by the 24 | * Apache Software Foundation (http://www.apache.org/)." 25 | * Alternately, this acknowlegement may appear in the software itself, 26 | * if and wherever such third-party acknowlegements normally appear. 27 | * 28 | * 4. The names "jviewcvs" and "Apache Software 29 | * Foundation" must not be used to endorse or promote products derived 30 | * from this software without prior written permission. For written 31 | * permission, please contact apache@apache.org. 32 | * 33 | * 5. Products derived from this software may not be called "Apache" 34 | * nor may "Apache" appear in their names without prior written 35 | * permission of the Apache Group. 36 | * 37 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 38 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 39 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 40 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 41 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 42 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 43 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 44 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 45 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 47 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 48 | * SUCH DAMAGE. 49 | * ==================================================================== 50 | * 51 | * This software consists of voluntary contributions made by many 52 | * individuals on behalf of the Apache Software Foundation. For more 53 | * information on the Apache Software Foundation, please see 54 | * . 55 | */ 56 | 57 | /* 58 | * Original description of rcsfile can be found: http://www.daemon-systems.org/man/rcsfile.5.html 59 | */ 60 | } 61 | 62 | //---------------------------------------------------------------------------- 63 | // The JRCS parser 64 | //---------------------------------------------------------------------------- 65 | 66 | class JRCSParser extends Parser; 67 | options { 68 | k = 2; // two token lookahead 69 | buildAST = true; // uses CommonAST by default 70 | } 71 | tokens { 72 | IDENT; REVISION;STRING;COMMA;BRANCH; LOGS; ADMIN; DELTAS; 73 | LITERAL_HEAD="head";LITERAL_BRANCH="branch"; 74 | LITERAL_ACCESS="access";LITERAL_SYMBOLS="symbols"; 75 | LITERAL_LOCKS="locks";LITERAL_STRICT="strict"; 76 | LITERAL_COMMENT="comment";LITERAL_EXPAND="expand"; 77 | LITERAL_DATE="date";LITERAL_AUTHOR="author"; 78 | LITERAL_STATE="state";LITERAL_BRANCHES="branches"; 79 | LITERAL_NEXT="next";LITERAL_DESC="desc"; 80 | LITERAL_LOG="log";LITERAL_TEXT="text"; 81 | } 82 | rcstext: 83 | admin 84 | deltalist 85 | desc 86 | deltatextlist 87 | EOF! 88 | ; 89 | rcsheader: 90 | admin 91 | ; 92 | rcsrevisions: 93 | admin 94 | deltalist 95 | ; 96 | 97 | admin: 98 | head 99 | (branch)? 100 | access 101 | symbols 102 | (locks)? 103 | (strict)? 104 | (comment)? 105 | (expand)? 106 | (newphrase)* 107 | { #admin = #( #[ADMIN, "ADMIN"], admin); } 108 | ; 109 | 110 | head: LITERAL_HEAD^ REVISION SEMI!; 111 | branch: LITERAL_BRANCH^ BRANCH SEMI! ; 112 | access: LITERAL_ACCESS^ (IDENT)* SEMI! ; 113 | symbols:LITERAL_SYMBOLS^ (tags)* SEMI!; 114 | tags: IDENT^ COLON! REVISION; 115 | locks: LITERAL_LOCKS^ (IDENT)* SEMI!; 116 | strict: LITERAL_STRICT^ SEMI!; 117 | comment:LITERAL_COMMENT^ (STRING)? SEMI!; 118 | expand: LITERAL_EXPAND^ (STRING)? SEMI!; 119 | 120 | deltalist: 121 | (delta)* 122 | { #deltalist = #( #[LOGS, "LOGS"], deltalist); } 123 | ; 124 | 125 | delta: 126 | REVISION^ 127 | delta_date 128 | delta_author 129 | delta_state 130 | delta_branches 131 | delta_next 132 | (newphrase)* 133 | ; 134 | delta_date: LITERAL_DATE^ REVISION SEMI!; 135 | delta_author: LITERAL_AUTHOR^ IDENT SEMI!; 136 | delta_state: LITERAL_STATE^ IDENT SEMI!; 137 | delta_branches: LITERAL_BRANCHES^ (REVISION)* SEMI!; 138 | delta_next: LITERAL_NEXT^ (REVISION)? SEMI!; 139 | 140 | desc: LITERAL_DESC^ STRING; 141 | 142 | deltatextlist: 143 | (deltatext)* 144 | { #deltatextlist = #( #[DELTAS, "DELTAS"], deltatextlist); } 145 | ; 146 | 147 | deltatext: 148 | REVISION^ 149 | deltatext_log 150 | (newphrase)* 151 | deltatext_text 152 | ; 153 | deltatext_log: LITERAL_LOG^ STRING; 154 | deltatext_text: LITERAL_TEXT^ STRING; 155 | 156 | 157 | 158 | 159 | newphrase: 160 | (IDENT)+ SEMI 161 | ; 162 | 163 | //---------------------------------------------------------------------------- 164 | // The JRCS scanner 165 | //---------------------------------------------------------------------------- 166 | class JRCSLexer extends Lexer; 167 | options { 168 | k=2; 169 | charVocabulary = '\3'..'\377'; // Latin ISO 1 character set. 170 | } 171 | 172 | // an identifier. Note that testLiterals is set to true! This means 173 | // that after we match the rule, we look in the literals table to see 174 | // if it's a literal or really an identifer 175 | IDENT 176 | options {testLiterals=true;} 177 | : (~('$' | ',' | '.' | ':' | ';' | '@' | ' ' | '\t' | '\n' | '\r' | '\f'))+ 178 | ; 179 | 180 | protected 181 | INT: 182 | ('0'..'9')+; 183 | 184 | REVISION: 185 | INT "." INT ("." INT "." INT)*; 186 | 187 | // string literals 188 | STRING 189 | : '@'! 190 | ( /* '\r' '\n' can be matched in one alternative or by matching 191 | '\r' in one iteration and '\n' in another. I am trying to 192 | handle any flavor of newline that comes in, but the language 193 | that allows both "\r\n" and "\r" and "\n" to all be valid 194 | newline is ambiguous. Consequently, the resulting grammar 195 | must be ambiguous. I'm shutting this warning off. 196 | */ 197 | /* options { 198 | generateAmbigWarnings=false; 199 | } 200 | :*/ 201 | //{ LA(2)!='@' }? 202 | '@' '@'! 203 | | ( options {generateAmbigWarnings=false;} 204 | : "\r\n" // Evil DOS 205 | | '\r' // Macintosh 206 | | '\n' // Unix (the right way) 207 | ) 208 | { newline(); } 209 | | ~('@'|'\n'|'\r') 210 | )* 211 | '@'! 212 | ; 213 | SEMI: ";" ; 214 | COLON: ":" ; 215 | 216 | // Whitespace -- ignored 217 | WS : ( ' ' 218 | | '\t' 219 | | '\f' 220 | // handle newlines 221 | | ( options {generateAmbigWarnings=false;} 222 | : "\r\n" // Evil DOS 223 | | '\r' // Macintosh 224 | | '\n' // Unix (the right way) 225 | ) 226 | { newline(); } 227 | )+ 228 | { _ttype = Token.SKIP; } 229 | ; -------------------------------------------------------------------------------- /rcs/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | jrcs 5 | jar 6 | ANTLR JRCS grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | jrcs.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /rcs/readme.txt: -------------------------------------------------------------------------------- 1 | Lucas Bruand Wed Dec 3, 2003 06:21 2 | RCS files grammar in Java. I created this as an exercise to learn ANTLR but I might use it to create yet an other WebCVS. 3 | -------------------------------------------------------------------------------- /ruby/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | ruby 5 | jar 6 | ANTLR Ruby grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | rubyParserLexerSPGrammar.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /ruby/readme.txt: -------------------------------------------------------------------------------- 1 | Sara di Gregorio and Pasquale De Medio Sat Oct 14, 2006 03:03 2 | This grammar is a simplified Ruby grammar. 3 | -------------------------------------------------------------------------------- /sexpression/Sexpr.g: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2008 Robert Stehwien 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | 24 | */ 25 | 26 | grammar Sexpr; 27 | 28 | options { 29 | language=ActionScript; 30 | output=AST; 31 | ASTLabelType=CommonTree; 32 | } 33 | 34 | tokens { 35 | LPAREN='('; 36 | RPAREN=')'; 37 | DOT; 38 | } 39 | 40 | @package {com.arcanearcade.antlr} 41 | @lexer::package {com.arcanearcade.antlr} 42 | 43 | 44 | sexpr 45 | : item* EOF 46 | ; 47 | item 48 | : atom 49 | | (list)=> list 50 | | LPAREN item DOT item RPAREN 51 | ; 52 | list 53 | : LPAREN item* RPAREN 54 | ; 55 | atom 56 | : STRING | SYMBOL | NUMBER | DOT 57 | ; 58 | 59 | STRING 60 | :'"' ( '\\' . | ~('\\'|'"') )* '"' 61 | ; 62 | WHITESPACE 63 | : (' ' | '\n' | '\t' | '\r')+ 64 | {skip();} 65 | ; 66 | NUMBER 67 | : ('+' | '-')? (DIGIT)+ ('.' (DIGIT)+)? 68 | ; 69 | SYMBOL 70 | : SYMBOL_START (SYMBOL_START | DIGIT)* {if ($text == '.') $type = DOT;} 71 | ; 72 | 73 | fragment 74 | SYMBOL_START 75 | : ('a'..'z') | ('A'..'Z') 76 | | '+' | '-' | '*' | '/' 77 | | '.' 78 | ; 79 | fragment 80 | DIGIT 81 | : ('0'..'9') 82 | ; 83 | -------------------------------------------------------------------------------- /sexpression/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | sexpression 5 | jar 6 | ANTLR SExpression grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | Sexpr.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /sexpression/readme.txt: -------------------------------------------------------------------------------- 1 | Robert Stehwien Thu Sep 25, 2008 13:10 2 | A Lisp s-expression parser that is part of a lisp interpreter I'm working on. Dot notation isn't yet working (A . B) but other expressions should work. Updates will be posted or made available as time permits. Feel free to use under the MIT/X license. 3 | -------------------------------------------------------------------------------- /support/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /support/antlr3test-maven-plugin/AntlrMojo-pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | org.apache.maven.plugin.my.unit 5 | project-to-test 6 | 1.0-SNAPSHOT 7 | jar 8 | Test MyMojo 9 | 10 | 3.5.2 11 | 12 | 13 | 14 | 15 | org.antlr 16 | antlr3-maven-plugin 17 | ${antlr.version} 18 | 19 | src/test/resources/ 20 | csv.g 21 | 22 | 23 | 24 | 25 | antlr 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /support/antlr3test-maven-plugin/README.md: -------------------------------------------------------------------------------- 1 | grammartestmojo 2 | =============== 3 | 4 | Maven Mojo for testing Antlr Grammars 5 | 6 | Example usage 7 | --------- 8 | 9 | ```xml 10 | 11 | com.khubla.antlr 12 | grammartest-maven-plugin 13 | 14 | true 15 | equation 16 | src/test/resources/examples/ 17 | src/test/resources/grammars/ 18 | 19 | 20 | ``` 21 | -------------------------------------------------------------------------------- /support/antlr3test-maven-plugin/generate-sources.sh: -------------------------------------------------------------------------------- 1 | # run this script to generate the sources in order to be able to run the tests 2 | mvn -f AntlrMojo-pom.xml clean antlr4:antlr4 3 | 4 | -------------------------------------------------------------------------------- /support/antlr3test-maven-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | org.antlr 5 | antlr3test-maven-plugin 6 | maven-plugin 7 | 1.0-SNAPSHOT 8 | khubla.com Antlr3 test mojo 9 | 10 | 3.8.1 11 | 3.5.2 12 | 13 | 14 | 15 | org.sonatype.plexus 16 | plexus-build-api 17 | 0.0.7 18 | 19 | 20 | org.antlr 21 | antlr 22 | ${antlr.version} 23 | 24 | 25 | org.apache.maven 26 | maven-plugin-api 27 | ${maven.version} 28 | provided 29 | 30 | 31 | org.apache.maven.plugin-testing 32 | maven-plugin-testing-harness 33 | 3.3.0 34 | test 35 | 36 | 37 | org.apache.maven 38 | maven-core 39 | ${maven.version} 40 | provided 41 | 42 | 43 | org.apache.maven 44 | maven-compat 45 | ${maven.version} 46 | test 47 | 48 | 49 | org.apache.maven.plugin-tools 50 | maven-plugin-annotations 51 | 3.4 52 | provided 53 | 54 | 55 | commons-io 56 | commons-io 57 | 2.7 58 | 59 | 60 | 61 | 62 | 63 | maven-compiler-plugin 64 | 3.1 65 | 66 | 1.6 67 | 1.6 68 | 69 | 70 | 71 | org.apache.maven.plugins 72 | maven-plugin-plugin 73 | 3.3 74 | 75 | antlr3test 76 | 77 | 78 | 79 | default-descriptor 80 | 81 | descriptor 82 | 83 | process-classes 84 | 85 | 86 | help-descriptor 87 | 88 | helpmojo 89 | 90 | process-classes 91 | 92 | 93 | 94 | 95 | ${project.artifactId}-${project.version} 96 | 97 | 98 | -------------------------------------------------------------------------------- /support/antlr3test-maven-plugin/src/main/java/org/antlr/mojo/antlr3test/FileUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | [The "BSD license"] 3 | Copyright (c) 2014 Tom Everett 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. The name of the author may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.antlr.mojo.antlr3test; 29 | 30 | import java.io.File; 31 | import java.util.ArrayList; 32 | import java.util.List; 33 | 34 | /** 35 | * @author Tom Everett 36 | */ 37 | public class FileUtil { 38 | /** 39 | * find files 40 | */ 41 | public static List getAllFiles(String dir) throws Exception { 42 | return getAllFiles(dir, null); 43 | } 44 | 45 | /** 46 | * find files 47 | */ 48 | public static List getAllFiles(String dir, String extension) { 49 | final List ret = new ArrayList(); 50 | final File file = new File(dir); 51 | if (file.exists()) { 52 | final String[] list = file.list(); 53 | for (int i = 0; i < list.length; i++) { 54 | final String fileName = dir + "/" + list[i]; 55 | final File f2 = new File(fileName); 56 | if (false == f2.isHidden()) { 57 | if (f2.isDirectory()) { 58 | ret.addAll(getAllFiles(fileName, extension)); 59 | } else { 60 | if (null != extension) { 61 | if (f2.getName().endsWith(extension)) { 62 | ret.add(f2); 63 | } 64 | } else { 65 | ret.add(f2); 66 | } 67 | } 68 | } 69 | } 70 | return ret; 71 | } else { 72 | return null; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /support/antlr3test-maven-plugin/src/main/java/org/antlr/mojo/antlr3test/GrammarTestMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | [The "BSD license"] 3 | Copyright (c) 2014 Tom Everett 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. The name of the author may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package org.antlr.mojo.antlr3test; 29 | 30 | import java.io.File; 31 | import java.lang.reflect.Constructor; 32 | import java.lang.reflect.Method; 33 | import java.net.MalformedURLException; 34 | import java.net.URL; 35 | import java.net.URLClassLoader; 36 | import java.util.List; 37 | 38 | import org.antlr.runtime.ANTLRFileStream; 39 | import org.antlr.runtime.CharStream; 40 | import org.antlr.runtime.CommonTokenStream; 41 | import org.antlr.runtime.Lexer; 42 | import org.antlr.runtime.Parser; 43 | import org.antlr.runtime.TokenStream; 44 | import org.apache.maven.plugin.AbstractMojo; 45 | import org.apache.maven.plugin.MojoExecutionException; 46 | import org.apache.maven.plugin.MojoFailureException; 47 | import org.apache.maven.plugins.annotations.LifecyclePhase; 48 | import org.apache.maven.plugins.annotations.Mojo; 49 | import org.apache.maven.plugins.annotations.Parameter; 50 | 51 | /** 52 | * @author Tom Everett 53 | */ 54 | @Mojo(name = "test", defaultPhase = LifecyclePhase.TEST, requiresProject = true, threadSafe = false) 55 | public class GrammarTestMojo extends AbstractMojo { 56 | /** 57 | * grammar Name 58 | */ 59 | @Parameter 60 | private String grammarName; 61 | /** 62 | * entry point method on the parser 63 | */ 64 | @Parameter 65 | private String entryPoint; 66 | /** 67 | * verbose 68 | */ 69 | @Parameter 70 | private boolean enabled = true; 71 | /** 72 | * verbose 73 | */ 74 | @Parameter 75 | private boolean verbose = false; 76 | /** 77 | * show LISP tree 78 | */ 79 | @Parameter 80 | private boolean showTree = true; 81 | /** 82 | * example files 83 | */ 84 | @Parameter(defaultValue = "/src/test/resources/examples") 85 | private String exampleFiles; 86 | /** 87 | * packageName 88 | */ 89 | @Parameter 90 | private String packageName; 91 | /** 92 | * basedir dir 93 | */ 94 | @Parameter(defaultValue = "${basedir}") 95 | private File baseDir; 96 | 97 | /** 98 | * ctor 99 | */ 100 | public GrammarTestMojo() throws MalformedURLException { 101 | } 102 | 103 | @Override 104 | public void execute() throws MojoExecutionException, MojoFailureException { 105 | try { 106 | /* 107 | * drop message 108 | */ 109 | if (verbose) { 110 | System.out.println("baseDir: " + baseDir); 111 | System.out.println("exampleFiles: " + exampleFiles); 112 | } 113 | /* 114 | * test grammars 115 | */ 116 | if (enabled) { 117 | testGrammars(); 118 | } 119 | } catch (final Exception e) { 120 | e.printStackTrace(); 121 | throw new MojoExecutionException("Unable execute mojo", e); 122 | } 123 | } 124 | 125 | public File getBaseDir() { 126 | return baseDir; 127 | } 128 | 129 | /** 130 | * get a classloader that can find the files we need 131 | */ 132 | private ClassLoader getClassLoader() throws MalformedURLException, ClassNotFoundException { 133 | final URL antlrGeneratedURL = new File(baseDir + "/target/classes").toURI().toURL(); 134 | final URL[] urls = new URL[] { antlrGeneratedURL }; 135 | return new URLClassLoader(urls, Thread.currentThread().getContextClassLoader()); 136 | } 137 | 138 | public String getEntryPoint() { 139 | return entryPoint; 140 | } 141 | 142 | public String getExampleFiles() { 143 | return exampleFiles; 144 | } 145 | 146 | public String getGrammarName() { 147 | return grammarName; 148 | } 149 | 150 | public String getPackageName() { 151 | return packageName; 152 | } 153 | 154 | public boolean isEnabled() { 155 | return enabled; 156 | } 157 | 158 | public boolean isShowTree() { 159 | return showTree; 160 | } 161 | 162 | public boolean isVerbose() { 163 | return verbose; 164 | } 165 | 166 | public void setBaseDir(File baseDir) { 167 | this.baseDir = baseDir; 168 | } 169 | 170 | public void setEnabled(boolean enabled) { 171 | this.enabled = enabled; 172 | } 173 | 174 | public void setEntryPoint(String entryPoint) { 175 | this.entryPoint = entryPoint; 176 | } 177 | 178 | public void setExampleFiles(String exampleFiles) { 179 | this.exampleFiles = exampleFiles; 180 | } 181 | 182 | public void setGrammarName(String grammarName) { 183 | this.grammarName = grammarName; 184 | } 185 | 186 | public void setPackageName(String packageName) { 187 | this.packageName = packageName; 188 | } 189 | 190 | public void setShowTree(boolean showTree) { 191 | this.showTree = showTree; 192 | } 193 | 194 | public void setVerbose(boolean verbose) { 195 | this.verbose = verbose; 196 | } 197 | 198 | /** 199 | * test a single grammar 200 | */ 201 | private void testGrammar(File grammarFile) throws Exception { 202 | /* 203 | * figure out class names 204 | */ 205 | String nn = grammarName; 206 | if (null != packageName) { 207 | nn = packageName + "." + grammarName; 208 | } 209 | final String lexerClassName = nn + "Lexer"; 210 | final String parserClassName = nn + "Parser"; 211 | if (verbose) { 212 | System.out.println("Lexer classname is: " + lexerClassName); 213 | System.out.println("Parser classname is: " + parserClassName); 214 | } 215 | /* 216 | * classloader 217 | */ 218 | final ClassLoader classLoader = getClassLoader(); 219 | /* 220 | * get the classes we need 221 | */ 222 | final Class lexerClass = classLoader.loadClass(lexerClassName).asSubclass(Lexer.class); 223 | final Class parserClass = classLoader.loadClass(parserClassName).asSubclass(Parser.class); 224 | /* 225 | * get ctors 226 | */ 227 | final Constructor lexerConstructor = lexerClass.getConstructor(CharStream.class); 228 | final Constructor parserConstructor = parserClass.getConstructor(TokenStream.class); 229 | System.out.println("Parsing :" + grammarFile.getAbsolutePath()); 230 | ANTLRFileStream antlrFileStream = new ANTLRFileStream(grammarFile.getAbsolutePath(), "UTF-8"); 231 | Lexer lexer = (Lexer) lexerConstructor.newInstance(antlrFileStream); 232 | final CommonTokenStream tokens = new CommonTokenStream(lexer); 233 | if (verbose) { 234 | tokens.fill(); 235 | for (final Object tok : tokens.getTokens()) { 236 | System.out.println(tok); 237 | } 238 | } 239 | /* 240 | * get parser 241 | */ 242 | Parser parser = (Parser) parserConstructor.newInstance(tokens); 243 | final Method method = parserClass.getMethod(entryPoint); 244 | method.invoke(parser); 245 | /* 246 | * show the tree 247 | */ 248 | if (showTree) { 249 | // final String lispTree = Trees.toStringTree(parserRuleContext, parser); 250 | // System.out.println(lispTree); 251 | } 252 | /* 253 | * yup 254 | */ 255 | parser = null; 256 | lexer = null; 257 | // parserRuleContext = null; 258 | antlrFileStream = null; 259 | } 260 | 261 | private void testGrammars() throws Exception { 262 | /* 263 | * iterate examples 264 | */ 265 | final List exampleFiles = FileUtil.getAllFiles(baseDir + "/" + this.exampleFiles); 266 | if (null != exampleFiles) { 267 | for (final File file : exampleFiles) { 268 | /* 269 | * test grammar 270 | */ 271 | testGrammar(file); 272 | /* 273 | * gc 274 | */ 275 | System.gc(); 276 | } 277 | } 278 | } 279 | } -------------------------------------------------------------------------------- /support/antlr3test-maven-plugin/src/test/java/test/org/antlr/mojo/antlr3test/TestGrammarTestMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | [The "BSD license"] 3 | Copyright (c) 2014 Tom Everett 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. The name of the author may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package test.org.antlr.mojo.antlr3test; 29 | 30 | import java.io.File; 31 | 32 | import org.antlr.mojo.antlr3test.GrammarTestMojo; 33 | import org.apache.maven.plugin.testing.AbstractMojoTestCase; 34 | 35 | /** 36 | * @author Tom Everett 37 | */ 38 | public class TestGrammarTestMojo extends AbstractMojoTestCase { 39 | /** 40 | * file 41 | */ 42 | private static final String POMFILE = "src/test/resources/GrammarTestMojo-pom.xml"; 43 | /** 44 | * goal 45 | */ 46 | private static final String GOAL = "test"; 47 | 48 | @Override 49 | protected void setUp() throws Exception { 50 | // required 51 | super.setUp(); 52 | } 53 | 54 | @Override 55 | protected void tearDown() throws Exception { 56 | // required 57 | super.tearDown(); 58 | } 59 | 60 | /** 61 | * Basic test of execution 62 | */ 63 | public void testExecution() throws Exception { 64 | try { 65 | final File pom = getTestFile(POMFILE); 66 | assertNotNull(pom); 67 | assertTrue(pom.exists()); 68 | final GrammarTestMojo grammarTestMojo = (GrammarTestMojo) lookupMojo(GOAL, pom); 69 | assertNotNull(grammarTestMojo); 70 | // grammarTestMojo.execute(); 71 | } catch (final Exception e) { 72 | e.printStackTrace(); 73 | } 74 | } 75 | 76 | /** 77 | * Basic test of instantiation 78 | */ 79 | public void testInstatiation() throws Exception { 80 | try { 81 | final File pom = getTestFile(POMFILE); 82 | assertNotNull(pom); 83 | assertTrue(pom.exists()); 84 | final GrammarTestMojo grammarTestMojo = (GrammarTestMojo) lookupMojo(GOAL, pom); 85 | assertNotNull(grammarTestMojo); 86 | assertTrue(grammarTestMojo.isVerbose() == true); 87 | assertTrue(grammarTestMojo.getExampleFiles().compareTo("src/test/resources/examples/") == 0); 88 | assertTrue(grammarTestMojo.getEntryPoint().compareTo("file") == 0); 89 | } catch (final Exception e) { 90 | e.printStackTrace(); 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /support/antlr3test-maven-plugin/src/test/resources/GrammarTestMojo-pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | org.apache.maven.plugin.my.unit 4 | project-to-test 5 | 1.0-SNAPSHOT 6 | jar 7 | Test MyMojo 8 | 9 | 3.5.2 10 | 11 | 12 | 13 | 14 | org.antlr 15 | antlr3-maven-plugin 16 | ${antlr.version} 17 | 18 | csv.g 19 | 20 | 21 | 22 | 23 | antlr 24 | 25 | 26 | 27 | 28 | 29 | org.antlr 30 | antlr3test-maven-plugin 31 | 32 | true 33 | 34 | file 35 | csv 36 | 37 | src/test/resources/examples/ 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /support/antlr3test-maven-plugin/src/test/resources/csv.g: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright 2011 by Nathaniel Harward 4 | 5 | ANTLRv3 grammar for CSV files. 6 | 7 | * No trimming of spaces (disallowed in RFC4180) 8 | * No trimming of double-quotes, either to define/end a quoted field or 9 | when embedded inside one 10 | * Handles all/mixed newline formats (MSDOS/Windows; Unix; Mac OS) 11 | 12 | If you find any issues please email me so I can correct it. 13 | 14 | */ 15 | 16 | grammar csv; 17 | 18 | file 19 | : record (NEWLINE record)* EOF 20 | ; 21 | 22 | record 23 | : (quoted_field | unquoted_field) (COMMA (quoted_field | unquoted_field))* 24 | ; 25 | 26 | quoted_field 27 | : DQUOTE 28 | ( CHAR 29 | | COMMA 30 | | DQUOTE DQUOTE 31 | | NEWLINE 32 | )* DQUOTE 33 | ; 34 | 35 | unquoted_field 36 | : CHAR* 37 | ; 38 | 39 | CHAR 40 | : '\u0000' .. '\u0009' 41 | | '\u000b' .. '\u000c' 42 | | '\u000e' .. '\u0021' 43 | | '\u0023' .. '\u002b' 44 | | '\u002d' .. '\uffff' 45 | ; 46 | 47 | COMMA 48 | : '\u002c' 49 | ; 50 | 51 | DQUOTE 52 | : '\u0022' 53 | ; 54 | 55 | NEWLINE 56 | : '\u000d'? '\u000a' // DOS/Windows(\r\n) + Unix(\n) 57 | | '\u000d' // Mac OS 9 and earlier(\r) 58 | ; 59 | -------------------------------------------------------------------------------- /support/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | support 4 | pom 5 | ANTLR3 grammars support 6 | 7 | com.antlr.grammarsv3 8 | grammarsv3 9 | 1.0-SNAPSHOT 10 | ../pom.xml 11 | 12 | 13 | antlr3test-maven-plugin 14 | 15 | -------------------------------------------------------------------------------- /unicode/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | unicode 5 | jar 6 | ANTLR Unicode grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | Unicode.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /unicode/readme.txt: -------------------------------------------------------------------------------- 1 | Roger Jack Thu Aug 16, 2012 12:16 2 | This file contains lexer fragments to support 16-bit Unicode Character Classes. 3 | -------------------------------------------------------------------------------- /verilog/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | verilog 5 | jar 6 | ANTLR Verilog grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | Verilog3.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /verilog/readme.txt: -------------------------------------------------------------------------------- 1 | Arik Ter-Galstyan Wed Nov 26, 2008 22:19 2 | Verilog grammar for ANTLR v3 converted from ANTLR v2 verilog grammar written by Steve Eckmann. 3 | -------------------------------------------------------------------------------- /vhdl/examples/standard.vhd: -------------------------------------------------------------------------------- 1 | -- This is Package STANDARD as defined in the VHDL 1992 Language Reference Manual. 2 | 3 | package standard is 4 | type boolean is (false,true); 5 | type bit is ('0', '1'); 6 | type character is ( 7 | nul, soh, stx, etx, eot, enq, ack, bel, 8 | bs, ht, lf, vt, ff, cr, so, si, 9 | dle, dc1, dc2, dc3, dc4, nak, syn, etb, 10 | can, em, sub, esc, fsp, gsp, rsp, usp, 11 | 12 | ' ', '!', '"', '#', '$', '%', '&', ''', 13 | '(', ')', '*', '+', ',', '-', '.', '/', 14 | '0', '1', '2', '3', '4', '5', '6', '7', 15 | '8', '9', ':', ';', '<', '=', '>', '?', 16 | 17 | '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 18 | 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 19 | 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 20 | 'X', 'Y', 'Z', '[', '\', ']', '^', '_', 21 | 22 | '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 23 | 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 24 | 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 25 | 'x', 'y', 'z', '{', '|', '}', '~', del, 26 | 27 | c128, c129, c130, c131, c132, c133, c134, c135, 28 | c136, c137, c138, c139, c140, c141, c142, c143, 29 | c144, c145, c146, c147, c148, c149, c150, c151, 30 | c152, c153, c154, c155, c156, c157, c158, c159 31 | 32 | -- the character code for 160 is there (NBSP), 33 | -- but prints as no char 34 | ); 35 | 36 | type severity_level is (note, warning, error, failure); 37 | type integer is range -2147483647 to 2147483647; 38 | type real is range -1.0E308 to 1.0E308; 39 | type time is range -2147483647 to 2147483647 40 | units 41 | fs; 42 | ps = 1000 fs; 43 | ns = 1000 ps; 44 | us = 1000 ns; 45 | ms = 1000 us; 46 | sec = 1000 ms; 47 | min = 60 sec; 48 | hr = 60 min; 49 | end units; 50 | subtype delay_length is time range 0 fs to time'high; 51 | impure function now return delay_length; 52 | subtype natural is integer range 0 to integer'high; 53 | subtype positive is integer range 1 to integer'high; 54 | type string is array (positive range <>) of character; 55 | type bit_vector is array (natural range <>) of bit; 56 | type file_open_kind is ( 57 | read_mode, 58 | write_mode, 59 | append_mode); 60 | type file_open_status is ( 61 | open_ok, 62 | status_error, 63 | name_error, 64 | mode_error); 65 | attribute foreign : string; 66 | end standard; 67 | -------------------------------------------------------------------------------- /vhdl/examples/textio.vhd: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------- 2 | -- Package TEXTIO as defined in Chapter 14 of the IEEE Standard VHDL 3 | -- Language Reference Manual (IEEE Std. 1076-1987), as modified 4 | -- by the Issues Screening and Analysis Committee (ISAC), a subcommittee 5 | -- of the VHDL Analysis and Standardization Group (VASG) on 6 | -- 10 November, 1988. See "The Sense of the VASG", October, 1989. 7 | --------------------------------------------------------------------------- 8 | -- Version information: %W% %G% 9 | --------------------------------------------------------------------------- 10 | 11 | package TEXTIO is 12 | type LINE is access string; 13 | type TEXT is file of string; 14 | type SIDE is (right, left); 15 | subtype WIDTH is natural; 16 | 17 | -- changed for vhdl92 syntax: 18 | file input : TEXT open read_mode is "STD_INPUT"; 19 | file output : TEXT open write_mode is "STD_OUTPUT"; 20 | 21 | -- changed for vhdl92 syntax (and now a built-in): 22 | procedure READLINE(file f: TEXT; L: out LINE); 23 | 24 | procedure READ(L:inout LINE; VALUE: out bit; GOOD : out BOOLEAN); 25 | procedure READ(L:inout LINE; VALUE: out bit); 26 | 27 | procedure READ(L:inout LINE; VALUE: out bit_vector; GOOD : out BOOLEAN); 28 | procedure READ(L:inout LINE; VALUE: out bit_vector); 29 | 30 | procedure READ(L:inout LINE; VALUE: out BOOLEAN; GOOD : out BOOLEAN); 31 | procedure READ(L:inout LINE; VALUE: out BOOLEAN); 32 | 33 | procedure READ(L:inout LINE; VALUE: out character; GOOD : out BOOLEAN); 34 | procedure READ(L:inout LINE; VALUE: out character); 35 | 36 | procedure READ(L:inout LINE; VALUE: out integer; GOOD : out BOOLEAN); 37 | procedure READ(L:inout LINE; VALUE: out integer); 38 | 39 | procedure READ(L:inout LINE; VALUE: out real; GOOD : out BOOLEAN); 40 | procedure READ(L:inout LINE; VALUE: out real); 41 | 42 | procedure READ(L:inout LINE; VALUE: out string; GOOD : out BOOLEAN); 43 | procedure READ(L:inout LINE; VALUE: out string); 44 | 45 | procedure READ(L:inout LINE; VALUE: out time; GOOD : out BOOLEAN); 46 | procedure READ(L:inout LINE; VALUE: out time); 47 | 48 | -- changed for vhdl92 syntax (and now a built-in): 49 | procedure WRITELINE(file f : TEXT; L : inout LINE); 50 | 51 | procedure WRITE(L : inout LINE; VALUE : in bit; 52 | JUSTIFIED: in SIDE := right; 53 | FIELD: in WIDTH := 0); 54 | 55 | procedure WRITE(L : inout LINE; VALUE : in bit_vector; 56 | JUSTIFIED: in SIDE := right; 57 | FIELD: in WIDTH := 0); 58 | 59 | procedure WRITE(L : inout LINE; VALUE : in BOOLEAN; 60 | JUSTIFIED: in SIDE := right; 61 | FIELD: in WIDTH := 0); 62 | 63 | procedure WRITE(L : inout LINE; VALUE : in character; 64 | JUSTIFIED: in SIDE := right; 65 | FIELD: in WIDTH := 0); 66 | 67 | procedure WRITE(L : inout LINE; VALUE : in integer; 68 | JUSTIFIED: in SIDE := right; 69 | FIELD: in WIDTH := 0); 70 | 71 | procedure WRITE(L : inout LINE; VALUE : in real; 72 | JUSTIFIED: in SIDE := right; 73 | FIELD: in WIDTH := 0; 74 | DIGITS: in NATURAL := 0); 75 | 76 | procedure WRITE(L : inout LINE; VALUE : in string; 77 | JUSTIFIED: in SIDE := right; 78 | FIELD: in WIDTH := 0); 79 | 80 | procedure WRITE(L : inout LINE; VALUE : in time; 81 | JUSTIFIED: in SIDE := right; 82 | FIELD: in WIDTH := 0; 83 | UNIT: in TIME := ns); 84 | 85 | -- is implicit built-in: 86 | -- function ENDFILE(file F : TEXT) return boolean; 87 | 88 | -- function ENDLINE(variable L : in LINE) return BOOLEAN; 89 | -- 90 | -- Function ENDLINE as declared cannot be legal VHDL, and 91 | -- the entire function was deleted from the definition 92 | -- by the Issues Screening and Analysis Committee (ISAC), 93 | -- a subcommittee of the VHDL Analysis and Standardization 94 | -- Group (VASG) on 10 November, 1988. See "The Sense of 95 | -- the VASG", October, 1989, VHDL Issue Number 0032. 96 | end; 97 | 98 | -------------------------------------------------------------------------------- /vhdl/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | vhdl 5 | jar 6 | ANTLR VHDL grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | vhdl.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | true 38 | false 39 | design_file 40 | vhdl 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /vhdl/readme.txt: -------------------------------------------------------------------------------- 1 | Mike Lodder Mon Feb 11, 2008 09:26 2 | This is a modified version of the VHDL AMS grammar file to work in C# 3 | -------------------------------------------------------------------------------- /vhdl/vhdl.g: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlr/grammars-v3/3a51146f4b35616f9c9dbaec5cdad4a42ff582e2/vhdl/vhdl.g -------------------------------------------------------------------------------- /wavefront/WavefrontOBJ.g: -------------------------------------------------------------------------------- 1 | /* Wavefront's Advanced Visualizer ASCII .OBJ file format grammer. 2 | */ 3 | 4 | grammar WavefrontOBJ; 5 | 6 | start : line+ 7 | ; 8 | 9 | line : (comment | vertex | face | mtllib | object | use_material | group) ('\r')? '\n' 10 | ; 11 | 12 | comment : COMMENT 13 | ; 14 | 15 | face : FACE (INTEGER)+ 16 | ; 17 | 18 | vertex : GEOMETRIC_VERTEX x=DECIMAL y=DECIMAL z=DECIMAL 19 | ; 20 | 21 | mtllib : MATERIAL_LIBRARY a=NAME '.mtl' 22 | { 23 | System.out.println($a.text); 24 | System.out.println($NAME.text); 25 | } 26 | ; 27 | 28 | object : OBJECT_NAME a=NAME 29 | ; 30 | 31 | use_material 32 | : MATERIAL_NAME a=NAME 33 | ; 34 | 35 | group : SMOOTHING_GROUP ('on' | 'off' ) 36 | ; 37 | 38 | // Vertex data 39 | GEOMETRIC_VERTEX 40 | : 'v' 41 | ; 42 | 43 | TEXTURE_VERTEX 44 | : 'vt' 45 | ; 46 | 47 | VERTEX_NORMAL 48 | : 'vn' 49 | ; 50 | 51 | PARAMETER_SPACE_VERTEX 52 | : 'vp' 53 | ; 54 | 55 | // Free-form curve/surface attributes 56 | DEGREE : 'deg'; 57 | 58 | BASIS_MATRIX 59 | : 'bmat' 60 | ; 61 | 62 | STEP_SIZE 63 | : 'step' 64 | ; 65 | 66 | CURVE_SURF_TYPE 67 | : 'cstype' 68 | ; 69 | 70 | // Elements 71 | POINT : 'p'; 72 | 73 | LINE : 'l'; 74 | 75 | FACE : 'f'; 76 | 77 | CURVE : 'curv'; 78 | 79 | CURVE2D : 'curv2'; 80 | 81 | SURF : 'surf'; 82 | 83 | // Free-form curve/surface body statements 84 | PARAM : 'parm'; 85 | 86 | OUTER_TRIMMING_HOLE 87 | : 'trim' 88 | ; 89 | 90 | INNER_TRIMMING_HOLE 91 | : 'hole' 92 | ; 93 | 94 | SPECIAL_CURVE 95 | : 'scrv' 96 | ; 97 | 98 | SPECIAL_POINT 99 | : 'sp' 100 | ; 101 | 102 | END : 'end'; 103 | 104 | // Connectivity between free-form surfaces 105 | CONNECT : 'con'; 106 | 107 | // Grouping 108 | GROUP_NAME 109 | : 'g' 110 | ; 111 | 112 | SMOOTHING_GROUP 113 | : 's' 114 | ; 115 | 116 | MERGING_GROUP 117 | : 'mg' 118 | ; 119 | 120 | OBJECT_NAME 121 | : 'o' 122 | ; 123 | 124 | // Display/render attributes 125 | BEVEL_INTERPOLATION 126 | : 'bevel' 127 | ; 128 | 129 | COLOR_INTERPOLATION 130 | : 'c_interp' 131 | ; 132 | 133 | DISSOLVE_INTERPOLATION 134 | : 'd_interp' 135 | ; 136 | 137 | LEVEL_OF_DETAIL 138 | : 'lod' 139 | ; 140 | 141 | MATERIAL_NAME 142 | : 'usemtl' 143 | ; 144 | 145 | MATERIAL_LIBRARY 146 | : 'mtllib' 147 | ; 148 | 149 | SHADOW_CASTING 150 | : 'shadow_obj' 151 | ; 152 | 153 | RAY_TRACING 154 | : 'trace_obj' 155 | ; 156 | 157 | CURVE_APPROX 158 | : 'ctech' 159 | ; 160 | 161 | SURF_APPROX 162 | : 'stech' 163 | ; 164 | 165 | fragment 166 | DIGIT: '0'..'9'; 167 | 168 | INTEGER : '-'? (DIGIT)+; 169 | 170 | DECIMAL: INTEGER ('.' DIGIT*)?; 171 | 172 | COMMENT : '#' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;} 173 | ; 174 | 175 | NAME : ( 'A'..'Z' | 'a'..'z' | '0'..'9' | '-' | '_' | '~'| '(' | ')' )+ 176 | ; 177 | 178 | WS: (' ' | '\t')+ {$channel = HIDDEN;} 179 | ; 180 | -------------------------------------------------------------------------------- /wavefront/examples/example1.txt: -------------------------------------------------------------------------------- 1 | v -5.000000 5.000000 0.000000 2 | v -5.000000 -5.000000 0.000000 3 | v 5.000000 -5.000000 0.000000 4 | v 5.000000 5.000000 0.000000 5 | vt -5.000000 5.000000 0.000000 6 | vt -5.000000 -5.000000 0.000000 7 | vt 5.000000 -5.000000 0.000000 8 | vt 5.000000 5.000000 0.000000 9 | vn 0.000000 0.000000 1.000000 10 | vn 0.000000 0.000000 1.000000 11 | vn 0.000000 0.000000 1.000000 12 | vn 0.000000 0.000000 1.000000 13 | vp 0.210000 3.590000 14 | vp 0.000000 0.000000 15 | vp 1.000000 0.000000 16 | vp 0.500000 0.500000 17 | -------------------------------------------------------------------------------- /wavefront/examples/example2.txt: -------------------------------------------------------------------------------- 1 | v -2.300000 1.950000 0.000000 2 | v -2.200000 0.790000 0.000000 3 | v -2.340000 -1.510000 0.000000 4 | v -1.530000 -1.490000 0.000000 5 | v -0.720000 -1.470000 0.000000 6 | v -0.780000 0.230000 0.000000 7 | v 0.070000 0.250000 0.000000 8 | v 0.920000 0.270000 0.000000 9 | v 0.800000 -1.610000 0.000000 10 | v 1.620000 -1.590000 0.000000 11 | v 2.440000 -1.570000 0.000000 12 | v 2.690000 0.670000 0.000000 13 | v 2.600000 1.980000 0.000000 14 | -------------------------------------------------------------------------------- /wavefront/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | wavefront 5 | jar 6 | ANTLR WaveFront grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | WavefrontOBJ.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | true 38 | false 39 | start 40 | WavefrontOBJ 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /wavefront/readme.txt: -------------------------------------------------------------------------------- 1 | Edward Ames Thu Jun 14, 2007 20:38 2 | Recognizes Wavefront .obj files. These are ASCII files for exchanging 3D graphical information. Blender can import/export these type of files as well. 3 | -------------------------------------------------------------------------------- /xpath/XPath1.g: -------------------------------------------------------------------------------- 1 | /** 2 | XPath parser, based on XPath v1 grammar defined by W3C. 3 | http://www.w3.org/TR/xpath 4 | 5 | I would like to remark that the AST output produced by this grammar 6 | still requires a tree grammar to properly disambiguate the resulting 7 | trees. This is due to the fact that only needed to perform a single 8 | pass over an XPath expression. 9 | 10 | As usual, this grammar is free to use and modify. Contact me if you 11 | need more information. 12 | 13 | jjzazuet@gmail.com 14 | */ 15 | 16 | grammar XPath1; 17 | options { output = AST; } 18 | 19 | tokens { 20 | QNAME; STRING; NUMBER; VARREF; 21 | OREXPR; ANDEXPR; UNIONEXPR; EQUEXPRESSION; 22 | PREDICATE; FUNCALL; 23 | NAMED_AXIS_STEP; SIMPLE_AXIS_STEP; ABBREVIATED_AXIS_STEP; 24 | NAME_AXIS; ATTRIBUTE_AXIS; 25 | EXPRLIST; 26 | ANY_NODE; ANY_NAMESPACED_NODE; 27 | } 28 | 29 | // ---------------- Parser Rules ---------------- // 30 | xpath: locationPath; 31 | 32 | locationPath 33 | : relativeLocationPath 34 | | absoluteLocationPath 35 | ; 36 | 37 | absoluteLocationPath 38 | : SingleAxisStep relativeLocationPath? 39 | | abbreviatedAbsoluteLocationPath 40 | ; 41 | 42 | abbreviatedAbsoluteLocationPath: RecursiveAxisStep relativeLocationPath; 43 | 44 | relativeLocationPath 45 | : step 46 | ( simpleAxisStep step )* 47 | ; 48 | 49 | step 50 | : ( namedAxisStep | abbreviatedAxisStep ) predicate* 51 | ; 52 | 53 | simpleAxisStep 54 | : ( SingleAxisStep -> ^(SIMPLE_AXIS_STEP SingleAxisStep) 55 | | RecursiveAxisStep -> ^(SIMPLE_AXIS_STEP RecursiveAxisStep) 56 | ) 57 | ; 58 | 59 | abbreviatedAxisStep 60 | : AbbreviatedStep -> ^(ABBREVIATED_AXIS_STEP AbbreviatedStep); 61 | 62 | namedAxisStep 63 | : (axisSpecifier? nodeTest) -> ^(NAMED_AXIS_STEP axisSpecifier? nodeTest); 64 | 65 | axisSpecifier 66 | : AxisName AxisNameSeparator -> ^(NAME_AXIS AxisName) 67 | | AbbreviatedAxisSpecifier -> ^(ATTRIBUTE_AXIS AbbreviatedAxisSpecifier) 68 | ; 69 | 70 | nodeTest 71 | : nameTest 72 | | NodeType LeftParenthesis RightParenthesis -> ^(ANY_NODE NodeType) 73 | | ProcessingInstruction LeftParenthesis StringLiteral RightParenthesis 74 | ; 75 | 76 | nameTest 77 | : Star -> ^(ANY_NODE) 78 | | NCName Colon Star -> ^(ANY_NAMESPACED_NODE NCName) 79 | | qName 80 | ; 81 | 82 | predicate 83 | : LeftSquareBracket predicateExpr RightSquareBracket -> ^(PREDICATE predicateExpr) 84 | ; 85 | 86 | predicateExpr : expr; 87 | 88 | functionCall 89 | : qName LeftParenthesis 90 | expressionList? 91 | RightParenthesis -> ^(FUNCALL qName expressionList?) 92 | ; 93 | 94 | expressionList 95 | : expr ( Comma expr )* -> ^(EXPRLIST expr+) 96 | ; 97 | 98 | pathExpr 99 | : locationPath 100 | | filterExpr (simpleAxisStep relativeLocationPath)? 101 | ; 102 | 103 | filterExpr: primaryExpr predicate?; 104 | 105 | primaryExpr 106 | : LeftParenthesis expr RightParenthesis 107 | | literal 108 | | functionCall 109 | ; 110 | 111 | expr: orExpr; 112 | 113 | orExpr: andExpr (Or andExpr)* -> ^(OREXPR andExpr+); 114 | 115 | andExpr: equalityExpr (And equalityExpr)? -> ^(ANDEXPR equalityExpr+); 116 | 117 | equalityExpr 118 | : relationalExpr (EqualtyOp relationalExpr)? -> ^(EQUEXPRESSION relationalExpr (EqualtyOp relationalExpr)?); 119 | 120 | relationalExpr: unionExpr; 121 | 122 | unionExpr: pathExpr (Pipe pathExpr)? -> ^(UNIONEXPR pathExpr+); 123 | 124 | literal 125 | : StringLiteral -> ^(STRING StringLiteral) 126 | | numericLiteral -> ^(NUMBER numericLiteral) 127 | | VariableReference -> ^(VARREF VariableReference) 128 | ; 129 | 130 | numericLiteral: IntegerLiteral | DecimalLiteral | DoubleLiteral; 131 | 132 | qName: (NCName Colon)? NCName -> ^(QNAME NCName+); 133 | 134 | // ---------------- Lexer Rules ---------------- // 135 | SingleAxisStep: '/'; 136 | RecursiveAxisStep: '//'; 137 | 138 | AxisNameSeparator: '::'; 139 | AbbreviatedAxisSpecifier: '@'; 140 | 141 | Star: '*'; 142 | Colon: ':'; 143 | Comma: ','; 144 | Pipe: '|'; 145 | 146 | AbbreviatedStep : '.' | '..'; 147 | 148 | LeftParenthesis: '('; 149 | RightParenthesis: ')'; 150 | 151 | LeftSquareBracket: '['; 152 | RightSquareBracket: ']'; 153 | 154 | And : 'and'; 155 | Or : 'or'; 156 | 157 | AxisName 158 | : 'ancestor' | 'ancestor-or-self' | 'attribute' | 159 | 'child' | 'descendant' | 'descendant-or-self' | 160 | 'following' | 'following-sibling' | 'namespace' | 161 | 'parent' | 'preceding' | 'preceding-sibling' | 162 | 'self' 163 | ; 164 | 165 | ProcessingInstruction: 'processing-instruction'; 166 | 167 | NodeType 168 | : 'comment' | 'text' | ProcessingInstruction | 'node'; 169 | 170 | Letter 171 | : '\u0024' | '\u005f'| 172 | '\u0041'..'\u005a' | '\u0061'..'\u007a' | 173 | '\u00c0'..'\u00d6' | '\u00d8'..'\u00f6' | 174 | '\u00f8'..'\u00ff' | '\u0100'..'\u1fff' | 175 | '\u3040'..'\u318f' | '\u3300'..'\u337f' | 176 | '\u3400'..'\u3d2d' | '\u4e00'..'\u9fff' | 177 | '\uf900'..'\ufaff' 178 | ; 179 | 180 | IntegerLiteral : ('0'..'9')+; 181 | DecimalLiteral : ('.' ('0'..'9')+) | (('0'..'9')+ '.' '0'..'9'*); 182 | DoubleLiteral : (('.' ('0'..'9')+) | (('0'..'9')+ ('.' '0'..'9'*)?)) ('e' | 'E') ('+' | '-')? ('0'..'9')+; 183 | 184 | StringLiteral : '"' ~('"')* '"' | '\'' ~('\'')* '\''; 185 | 186 | EqualtyOp: '=' | '!='; 187 | 188 | VariableReference: '$' NCName; 189 | 190 | NCName : Letter (Letter | '0'..'9' | '.' | '-')*; 191 | 192 | WS: (' '|'\t'|'\u000C') {skip();}; 193 | -------------------------------------------------------------------------------- /xpath/examples/example1.txt: -------------------------------------------------------------------------------- 1 | /a/b/c 2 | 3 | 4 | -------------------------------------------------------------------------------- /xpath/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | xpath 5 | jar 6 | ANTLR XPath grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | XPath1.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 34 | org.antlr 35 | antlr3test-maven-plugin 36 | 37 | true 38 | false 39 | xpath 40 | XPath1 41 | 42 | examples/ 43 | 44 | 45 | 46 | 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /xpath/readme.txt: -------------------------------------------------------------------------------- 1 | Jesus Zazueta Mon Jun 15, 2009 10:46 2 | This grammar is an ANTLR v3 port of the XPath 1.0 grammar defined by the W3C. 3 | -------------------------------------------------------------------------------- /xpath2/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | xpath2 5 | jar 6 | ANTLR XPath2 grammar 7 | 8 | com.antlr.grammarsv3 9 | grammarsv3 10 | 1.0-SNAPSHOT 11 | ../pom.xml 12 | 13 | 14 | 15 | 16 | org.antlr 17 | antlr3-maven-plugin 18 | ${antlr.version} 19 | 20 | ${basedir} 21 | XPath2.g 22 | true 23 | true 24 | 25 | 26 | 27 | 28 | antlr 29 | 30 | 31 | 32 | 33 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /xpath2/readme.txt: -------------------------------------------------------------------------------- 1 | Paul Bober and Stephen Tu Mon Jan 25, 2010 14:54 2 | An implementation of the XPath 2.0 grammar 3 | --------------------------------------------------------------------------------