[jboss-svn-commits] JBL Code SVN: r20311 - in labs/jbossrules/trunk/drools-compiler/src: main/java/org/drools/lang/dsl and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jun 4 14:55:28 EDT 2008
Author: tirelli
Date: 2008-06-04 14:55:28 -0400 (Wed, 04 Jun 2008)
New Revision: 20311
Added:
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/AbstractDSLMappingEntry.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/AntlrDSLMappingEntry.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapLexer.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapParser.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapWalker.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLTokenizedMappingFile.java
labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMapWalker.g
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/ANTLRDSLTest.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/DSLTokenizedMappingFileTest.java
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/dsl/test_antlr.dsl
Modified:
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DrlParser.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMappingFile.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultDSLMappingEntry.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpander.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpanderResolver.java
labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMap.g
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/DrlParserTest.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/DefaultExpanderTest.java
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/dsl/test_metainfo.dsl
Log:
JBRULES-1633: merging DSL improvement changes into trunk
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DrlParser.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DrlParser.java 2008-06-04 18:24:35 UTC (rev 20310)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DrlParser.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -94,7 +94,6 @@
*/
public PackageDescr parse(final String source,
final Reader dsl) throws DroolsParserException {
-
DefaultExpanderResolver resolver = getDefaultResolver(dsl);
final Expander expander = resolver.get( "*",
@@ -130,7 +129,6 @@
final Expander expander = resolver.get( "*",
null );
final String expanded = expander.expand( source );
-
if ( expander.hasErrors() ) {
String err = "";
for ( Iterator iter = expander.getErrors().iterator(); iter.hasNext(); ) {
Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/AbstractDSLMappingEntry.java (from rev 20284, labs/jbossrules/branches/mattgeis/drools-compiler/src/main/java/org/drools/lang/dsl/AbstractDSLMappingEntry.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/AbstractDSLMappingEntry.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/AbstractDSLMappingEntry.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -0,0 +1,169 @@
+package org.drools.lang.dsl;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.drools.lang.dsl.DSLMappingEntry.MetaData;
+import org.drools.lang.dsl.DSLMappingEntry.Section;
+/*
+ * Copyright 2006 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+public abstract class AbstractDSLMappingEntry {
+
+ protected Section section;
+ protected MetaData metadata;
+ protected String key;
+ protected String value;
+ protected Map variables = Collections.EMPTY_MAP;
+ protected Pattern keyPattern;
+ protected String valuePattern;
+
+ public AbstractDSLMappingEntry() {
+ super();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Section getSection() {
+ return this.section;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public DSLMappingEntry.MetaData getMetaData() {
+ return this.metadata;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public String getMappingKey() {
+ return this.key;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public String getMappingValue() {
+ return this.value;
+ }
+
+ /**
+ * @param section the section to set
+ */
+ public void setSection(final Section section) {
+ this.section = section;
+ }
+
+ /**
+ * @param metadata the metadata to set
+ */
+ public void setMetaData(final MetaData metadata) {
+ this.metadata = metadata;
+ }
+
+ /**
+ * @return the keyPattern
+ */
+ public Pattern getKeyPattern() {
+ return this.keyPattern;
+ }
+
+ /**
+ * @return the valuePattern
+ */
+ public String getValuePattern() {
+ return this.valuePattern;
+ }
+
+ /**
+ * @return the variables
+ */
+ public Map getVariables() {
+ return this.variables;
+ }
+
+ public String toPatternString() {
+ return this.section + "[" + this.metadata + "]" + this.keyPattern.pattern() + "=" + this.valuePattern;
+ }
+
+ public String toString() {
+ return this.section + "[" + this.metadata + "]" + this.key + "=" + this.value;
+ }
+
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((this.key == null) ? 0 : this.key.hashCode());
+ result = PRIME * result + ((this.metadata == null) ? 0 : this.metadata.hashCode());
+ result = PRIME * result + ((this.section == null) ? 0 : this.section.hashCode());
+ result = PRIME * result + ((this.value == null) ? 0 : this.value.hashCode());
+ return result;
+ }
+
+ public boolean equals(final Object obj) {
+ if ( this == obj ) {
+ return true;
+ }
+ if ( obj == null ) {
+ return false;
+ }
+ if ( getClass() != obj.getClass() ) {
+ return false;
+ }
+ final AbstractDSLMappingEntry other = (AbstractDSLMappingEntry) obj;
+ if ( this.key == null ) {
+ if ( other.key != null ) {
+ return false;
+ }
+ } else if ( !this.key.equals( other.key ) ) {
+ return false;
+ }
+ if ( this.metadata == null ) {
+ if ( other.metadata != null ) {
+ return false;
+ }
+ } else if ( !this.metadata.equals( other.metadata ) ) {
+ return false;
+ }
+ if ( this.section == null ) {
+ if ( other.section != null ) {
+ return false;
+ }
+ } else if ( !this.section.equals( other.section ) ) {
+ return false;
+ }
+ if ( this.value == null ) {
+ if ( other.value != null ) {
+ return false;
+ }
+ } else if ( !this.value.equals( other.value ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ public List getErrors() {
+ // TODO Need to implement validation here
+ return Collections.EMPTY_LIST;
+ }
+
+}
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/AntlrDSLMappingEntry.java (from rev 20284, labs/jbossrules/branches/mattgeis/drools-compiler/src/main/java/org/drools/lang/dsl/AntlrDSLMappingEntry.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/AntlrDSLMappingEntry.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/AntlrDSLMappingEntry.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2006 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.lang.dsl;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+/**
+ * An ANTLR-driven implementation for the DSL Mapping Entry interface
+ *
+ * @author mattgeis
+ */
+public class AntlrDSLMappingEntry extends AbstractDSLMappingEntry implements DSLMappingEntry {
+ private boolean headMatchGroupAdded = false;
+ private boolean tailMatchGroupAdded = false;
+
+ public AntlrDSLMappingEntry() {
+ this(DSLMappingEntry.ANY, DSLMappingEntry.EMPTY_METADATA, null, null);
+ }
+
+ public AntlrDSLMappingEntry(final Section section, final MetaData metadata,
+ final String key, final String value) {
+ this.section = section;
+ this.metadata = metadata;
+ this.setMappingKey(key);
+ this.setMappingValue(value);
+ }
+
+
+ /**
+ * @param key
+ * the key to set
+ */
+ public void setMappingKey(String key) {
+ //the "key" in this case is already mostly formed into
+ //a pattern by ANTLR, and just requires a bit of post-processing.
+ if (key != null) {
+ key = key.trim();
+ }
+ this.key = key;
+
+ if (key != null) {
+ int substr = 0;
+ // escape '$' to avoid errors
+ //final String escapedKey = key.replaceAll("\\$", "\\\\\\$");
+ // retrieving variables list and creating key pattern
+ final StringBuffer buf = new StringBuffer();
+
+ if (!key.startsWith("^")) {
+ // making it start with a space char or a line start
+ buf.append("(\\W|^)").append(key);
+ redistributeVariables();
+ headMatchGroupAdded = true;
+ }
+
+
+ // if pattern ends with a pure variable whose pattern could create
+ // a greedy match, append a line end to avoid multiple line matching
+ if (buf.toString().endsWith("(.*?)")) {
+ buf.append("$");
+ } else {
+ buf.append("(\\W|$)");
+ tailMatchGroupAdded = true;
+ }
+
+ // setting the key pattern and making it space insensitive
+ String pat = buf.toString();
+ //first, look to see if it's
+ if (key.substring(substr).trim().startsWith("-")
+ && (!key.substring(substr).trim().startsWith("-\\s*"))) {
+ pat = pat.substring(0, pat.indexOf('-') + 1) + "\\s*"
+ + pat.substring(pat.indexOf('-') + 1).trim();
+ }
+ //may not need to do this at all
+ //pat = pat.replaceAll("\\s+", "\\\\s+");
+ this.keyPattern = Pattern.compile(pat, Pattern.DOTALL
+ | Pattern.MULTILINE);
+
+ } else {
+ this.keyPattern = null;
+ }
+ // update value mapping
+ //this.setMappingValue(this.value);
+ }
+
+ /**
+ * The keys for this map are integers, starting at 1. However,
+ * in certain cases we insert a matching group at the start of the
+ * pattern, which means that 1 should become 2, 2 become 3, etc.
+ */
+ private void redistributeVariables(){
+ for (Iterator it = variables.entrySet().iterator(); it.hasNext();) {
+ Map.Entry entry = (Map.Entry) it.next();
+ Integer i = (Integer)entry.getValue();
+ variables.put(entry.getKey(), new Integer(i.intValue() + 1));
+ }
+ }
+
+ /**
+ * @param value
+ * the value to set
+ */
+ public void setMappingValue(final String value) {
+ StringBuffer valuePatternBuffer = new StringBuffer();
+ StringBuffer valueBuffer = new StringBuffer();
+ if(headMatchGroupAdded){
+ valuePatternBuffer.append("$1");
+ valueBuffer.append("$1");
+ }
+ valuePatternBuffer.append(value);
+ valueBuffer.append(value);
+ if(tailMatchGroupAdded){
+ Integer tailMatchGroupIndex = (Integer) Collections.max(variables.values()) + 1;//get max in variables, plus 1
+ valuePatternBuffer.append("$" + tailMatchGroupIndex);
+ valueBuffer.append("$" + tailMatchGroupIndex);
+ }
+ this.valuePattern = valuePatternBuffer.toString();
+ this.value = valueBuffer.toString();
+
+ }
+}
Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapLexer.java (from rev 20284, labs/jbossrules/branches/mattgeis/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapLexer.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapLexer.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapLexer.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -0,0 +1,1079 @@
+// $ANTLR 3.0.1 DSLMap.g 2008-05-27 14:03:45
+
+ package org.drools.lang.dsl;
+
+
+import org.antlr.runtime.*;
+import java.util.Stack;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+public class DSLMapLexer extends Lexer {
+ public static final int COMMA=26;
+ public static final int RIGHT_CURLY=29;
+ public static final int VT_ENTRY_VAL=14;
+ public static final int WS=30;
+ public static final int MISC=34;
+ public static final int VT_META=12;
+ public static final int VT_CONSEQUENCE=9;
+ public static final int VT_SPACE=19;
+ public static final int LINE_COMMENT=21;
+ public static final int VT_ANY=11;
+ public static final int VT_LITERAL=17;
+ public static final int DOT=32;
+ public static final int EQUALS=22;
+ public static final int VT_DSL_GRAMMAR=4;
+ public static final int VT_CONDITION=8;
+ public static final int VT_VAR_DEF=15;
+ public static final int VT_ENTRY=6;
+ public static final int VT_PATTERN=18;
+ public static final int LITERAL=25;
+ public static final int EscapeSequence=31;
+ public static final int VT_COMMENT=5;
+ public static final int EOF=-1;
+ public static final int EOL=20;
+ public static final int LEFT_SQUARE=23;
+ public static final int Tokens=35;
+ public static final int VT_ENTRY_KEY=13;
+ public static final int VT_SCOPE=7;
+ public static final int COLON=27;
+ public static final int VT_KEYWORD=10;
+ public static final int VT_VAR_REF=16;
+ public static final int LEFT_CURLY=28;
+ public static final int POUND=33;
+ public static final int RIGHT_SQUARE=24;
+ public DSLMapLexer() {;}
+ public DSLMapLexer(CharStream input) {
+ super(input);
+ ruleMemo = new HashMap[17+1];
+ }
+ public String getGrammarFileName() { return "DSLMap.g"; }
+
+ // $ANTLR start WS
+ public final void mWS() throws RecognitionException {
+ try {
+ int _type = WS;
+ // DSLMap.g:254:9: ( ( ' ' | '\\t' | '\\f' )+ )
+ // DSLMap.g:254:17: ( ' ' | '\\t' | '\\f' )+
+ {
+ // DSLMap.g:254:17: ( ' ' | '\\t' | '\\f' )+
+ int cnt1=0;
+ loop1:
+ do {
+ int alt1=2;
+ int LA1_0 = input.LA(1);
+
+ if ( (LA1_0=='\t'||LA1_0=='\f'||LA1_0==' ') ) {
+ alt1=1;
+ }
+
+
+ switch (alt1) {
+ case 1 :
+ // DSLMap.g:
+ {
+ if ( input.LA(1)=='\t'||input.LA(1)=='\f'||input.LA(1)==' ' ) {
+ input.consume();
+ failed=false;
+ }
+ else {
+ if (backtracking>0) {failed=true; return ;}
+ MismatchedSetException mse =
+ new MismatchedSetException(null,input);
+ recover(mse); throw mse;
+ }
+
+
+ }
+ break;
+
+ default :
+ if ( cnt1 >= 1 ) break loop1;
+ if (backtracking>0) {failed=true; return ;}
+ EarlyExitException eee =
+ new EarlyExitException(1, input);
+ throw eee;
+ }
+ cnt1++;
+ } while (true);
+
+ if ( backtracking==0 ) {
+ channel=HIDDEN;
+ }
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end WS
+
+ // $ANTLR start EOL
+ public final void mEOL() throws RecognitionException {
+ try {
+ int _type = EOL;
+ // DSLMap.g:261:6: ( ( ( '\\r\\n' )=> '\\r\\n' | '\\r' | '\\n' ) )
+ // DSLMap.g:262:6: ( ( '\\r\\n' )=> '\\r\\n' | '\\r' | '\\n' )
+ {
+ // DSLMap.g:262:6: ( ( '\\r\\n' )=> '\\r\\n' | '\\r' | '\\n' )
+ int alt2=3;
+ int LA2_0 = input.LA(1);
+
+ if ( (LA2_0=='\r') ) {
+ int LA2_1 = input.LA(2);
+
+ if ( (LA2_1=='\n') && (synpred1())) {
+ alt2=1;
+ }
+ else {
+ alt2=2;}
+ }
+ else if ( (LA2_0=='\n') ) {
+ alt2=3;
+ }
+ else {
+ if (backtracking>0) {failed=true; return ;}
+ NoViableAltException nvae =
+ new NoViableAltException("262:6: ( ( '\\r\\n' )=> '\\r\\n' | '\\r' | '\\n' )", 2, 0, input);
+
+ throw nvae;
+ }
+ switch (alt2) {
+ case 1 :
+ // DSLMap.g:262:14: ( '\\r\\n' )=> '\\r\\n'
+ {
+ match("\r\n"); if (failed) return ;
+
+
+ }
+ break;
+ case 2 :
+ // DSLMap.g:263:25: '\\r'
+ {
+ match('\r'); if (failed) return ;
+
+ }
+ break;
+ case 3 :
+ // DSLMap.g:264:25: '\\n'
+ {
+ match('\n'); if (failed) return ;
+
+ }
+ break;
+
+ }
+
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end EOL
+
+ // $ANTLR start EscapeSequence
+ public final void mEscapeSequence() throws RecognitionException {
+ try {
+ // DSLMap.g:270:5: ( '\\\\' ( 'b' | 'B' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' | '.' | 'o' | 'x' | 'a' | 'e' | 'c' | 'd' | 'D' | 's' | 'S' | 'w' | 'W' | 'p' | 'A' | 'G' | 'Z' | 'z' | 'Q' | 'E' | '*' | '[' | ']' | '(' | ')' | '$' | '^' | '{' | '}' | '?' | '+' | '-' | '&' | '|' | '=' | 'u' | '0' | '#' ) )
+ // DSLMap.g:270:9: '\\\\' ( 'b' | 'B' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' | '.' | 'o' | 'x' | 'a' | 'e' | 'c' | 'd' | 'D' | 's' | 'S' | 'w' | 'W' | 'p' | 'A' | 'G' | 'Z' | 'z' | 'Q' | 'E' | '*' | '[' | ']' | '(' | ')' | '$' | '^' | '{' | '}' | '?' | '+' | '-' | '&' | '|' | '=' | 'u' | '0' | '#' )
+ {
+ match('\\'); if (failed) return ;
+ if ( (input.LA(1)>='\"' && input.LA(1)<='$')||(input.LA(1)>='&' && input.LA(1)<='+')||(input.LA(1)>='-' && input.LA(1)<='.')||input.LA(1)=='0'||input.LA(1)=='='||input.LA(1)=='?'||(input.LA(1)>='A' && input.LA(1)<='B')||(input.LA(1)>='D' && input.LA(1)<='E')||input.LA(1)=='G'||input.LA(1)=='Q'||input.LA(1)=='S'||input.LA(1)=='W'||(input.LA(1)>='Z' && input.LA(1)<='^')||(input.LA(1)>='a' && input.LA(1)<='f')||(input.LA(1)>='n' && input.LA(1)<='p')||(input.LA(1)>='r' && input.LA(1)<='u')||(input.LA(1)>='w' && input.LA(1)<='x')||(input.LA(1)>='z' && input.LA(1)<='}') ) {
+ input.consume();
+ failed=false;
+ }
+ else {
+ if (backtracking>0) {failed=true; return ;}
+ MismatchedSetException mse =
+ new MismatchedSetException(null,input);
+ recover(mse); throw mse;
+ }
+
+
+ }
+
+ }
+ finally {
+ }
+ }
+ // $ANTLR end EscapeSequence
+
+ // $ANTLR start LEFT_SQUARE
+ public final void mLEFT_SQUARE() throws RecognitionException {
+ try {
+ int _type = LEFT_SQUARE;
+ // DSLMap.g:277:9: ( '[' )
+ // DSLMap.g:277:11: '['
+ {
+ match('['); if (failed) return ;
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end LEFT_SQUARE
+
+ // $ANTLR start RIGHT_SQUARE
+ public final void mRIGHT_SQUARE() throws RecognitionException {
+ try {
+ int _type = RIGHT_SQUARE;
+ // DSLMap.g:281:9: ( ']' )
+ // DSLMap.g:281:11: ']'
+ {
+ match(']'); if (failed) return ;
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end RIGHT_SQUARE
+
+ // $ANTLR start LEFT_CURLY
+ public final void mLEFT_CURLY() throws RecognitionException {
+ try {
+ int _type = LEFT_CURLY;
+ // DSLMap.g:285:9: ( '{' )
+ // DSLMap.g:285:11: '{'
+ {
+ match('{'); if (failed) return ;
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end LEFT_CURLY
+
+ // $ANTLR start RIGHT_CURLY
+ public final void mRIGHT_CURLY() throws RecognitionException {
+ try {
+ int _type = RIGHT_CURLY;
+ // DSLMap.g:289:9: ( '}' )
+ // DSLMap.g:289:11: '}'
+ {
+ match('}'); if (failed) return ;
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end RIGHT_CURLY
+
+ // $ANTLR start EQUALS
+ public final void mEQUALS() throws RecognitionException {
+ try {
+ int _type = EQUALS;
+ // DSLMap.g:292:8: ( '=' )
+ // DSLMap.g:292:10: '='
+ {
+ match('='); if (failed) return ;
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end EQUALS
+
+ // $ANTLR start DOT
+ public final void mDOT() throws RecognitionException {
+ try {
+ int _type = DOT;
+ // DSLMap.g:295:5: ( '.' )
+ // DSLMap.g:295:7: '.'
+ {
+ match('.'); if (failed) return ;
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end DOT
+
+ // $ANTLR start POUND
+ public final void mPOUND() throws RecognitionException {
+ try {
+ int _type = POUND;
+ // DSLMap.g:298:9: ( '#' )
+ // DSLMap.g:298:11: '#'
+ {
+ match('#'); if (failed) return ;
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end POUND
+
+ // $ANTLR start COLON
+ public final void mCOLON() throws RecognitionException {
+ try {
+ int _type = COLON;
+ // DSLMap.g:301:7: ( ':' )
+ // DSLMap.g:301:9: ':'
+ {
+ match(':'); if (failed) return ;
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end COLON
+
+ // $ANTLR start COMMA
+ public final void mCOMMA() throws RecognitionException {
+ try {
+ int _type = COMMA;
+ // DSLMap.g:304:7: ( ',' )
+ // DSLMap.g:304:9: ','
+ {
+ match(','); if (failed) return ;
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end COMMA
+
+ // $ANTLR start LINE_COMMENT
+ public final void mLINE_COMMENT() throws RecognitionException {
+ try {
+ int _type = LINE_COMMENT;
+ // DSLMap.g:312:2: ( POUND ( options {greedy=false; } : . )* EOL )
+ // DSLMap.g:312:4: POUND ( options {greedy=false; } : . )* EOL
+ {
+ mPOUND(); if (failed) return ;
+ // DSLMap.g:312:10: ( options {greedy=false; } : . )*
+ loop3:
+ do {
+ int alt3=2;
+ int LA3_0 = input.LA(1);
+
+ if ( (LA3_0=='\r') ) {
+ alt3=2;
+ }
+ else if ( (LA3_0=='\n') ) {
+ alt3=2;
+ }
+ else if ( ((LA3_0>='\u0000' && LA3_0<='\t')||(LA3_0>='\u000B' && LA3_0<='\f')||(LA3_0>='\u000E' && LA3_0<='\uFFFE')) ) {
+ alt3=1;
+ }
+
+
+ switch (alt3) {
+ case 1 :
+ // DSLMap.g:312:37: .
+ {
+ matchAny(); if (failed) return ;
+
+ }
+ break;
+
+ default :
+ break loop3;
+ }
+ } while (true);
+
+ mEOL(); if (failed) return ;
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end LINE_COMMENT
+
+ // $ANTLR start LITERAL
+ public final void mLITERAL() throws RecognitionException {
+ try {
+ int _type = LITERAL;
+ // DSLMap.g:320:2: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '\\u00c0' .. '\\u00ff' | MISC | EscapeSequence | DOT )+ )
+ // DSLMap.g:320:4: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '\\u00c0' .. '\\u00ff' | MISC | EscapeSequence | DOT )+
+ {
+ // DSLMap.g:320:4: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '\\u00c0' .. '\\u00ff' | MISC | EscapeSequence | DOT )+
+ int cnt4=0;
+ loop4:
+ do {
+ int alt4=9;
+ switch ( input.LA(1) ) {
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z':
+ {
+ alt4=1;
+ }
+ break;
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
+ {
+ alt4=2;
+ }
+ break;
+ case '_':
+ {
+ alt4=3;
+ }
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ alt4=4;
+ }
+ break;
+ case '\u00C0':
+ case '\u00C1':
+ case '\u00C2':
+ case '\u00C3':
+ case '\u00C4':
+ case '\u00C5':
+ case '\u00C6':
+ case '\u00C7':
+ case '\u00C8':
+ case '\u00C9':
+ case '\u00CA':
+ case '\u00CB':
+ case '\u00CC':
+ case '\u00CD':
+ case '\u00CE':
+ case '\u00CF':
+ case '\u00D0':
+ case '\u00D1':
+ case '\u00D2':
+ case '\u00D3':
+ case '\u00D4':
+ case '\u00D5':
+ case '\u00D6':
+ case '\u00D7':
+ case '\u00D8':
+ case '\u00D9':
+ case '\u00DA':
+ case '\u00DB':
+ case '\u00DC':
+ case '\u00DD':
+ case '\u00DE':
+ case '\u00DF':
+ case '\u00E0':
+ case '\u00E1':
+ case '\u00E2':
+ case '\u00E3':
+ case '\u00E4':
+ case '\u00E5':
+ case '\u00E6':
+ case '\u00E7':
+ case '\u00E8':
+ case '\u00E9':
+ case '\u00EA':
+ case '\u00EB':
+ case '\u00EC':
+ case '\u00ED':
+ case '\u00EE':
+ case '\u00EF':
+ case '\u00F0':
+ case '\u00F1':
+ case '\u00F2':
+ case '\u00F3':
+ case '\u00F4':
+ case '\u00F5':
+ case '\u00F6':
+ case '\u00F7':
+ case '\u00F8':
+ case '\u00F9':
+ case '\u00FA':
+ case '\u00FB':
+ case '\u00FC':
+ case '\u00FD':
+ case '\u00FE':
+ case '\u00FF':
+ {
+ alt4=5;
+ }
+ break;
+ case '!':
+ case '\"':
+ case '$':
+ case '%':
+ case '&':
+ case '\'':
+ case '(':
+ case ')':
+ case '*':
+ case '+':
+ case '-':
+ case '/':
+ case ';':
+ case '<':
+ case '>':
+ case '?':
+ case '@':
+ case '^':
+ case '|':
+ {
+ alt4=6;
+ }
+ break;
+ case '\\':
+ {
+ alt4=7;
+ }
+ break;
+ case '.':
+ {
+ alt4=8;
+ }
+ break;
+
+ }
+
+ switch (alt4) {
+ case 1 :
+ // DSLMap.g:320:5: 'a' .. 'z'
+ {
+ matchRange('a','z'); if (failed) return ;
+
+ }
+ break;
+ case 2 :
+ // DSLMap.g:320:14: 'A' .. 'Z'
+ {
+ matchRange('A','Z'); if (failed) return ;
+
+ }
+ break;
+ case 3 :
+ // DSLMap.g:320:23: '_'
+ {
+ match('_'); if (failed) return ;
+
+ }
+ break;
+ case 4 :
+ // DSLMap.g:320:27: '0' .. '9'
+ {
+ matchRange('0','9'); if (failed) return ;
+
+ }
+ break;
+ case 5 :
+ // DSLMap.g:320:36: '\\u00c0' .. '\\u00ff'
+ {
+ matchRange('\u00C0','\u00FF'); if (failed) return ;
+
+ }
+ break;
+ case 6 :
+ // DSLMap.g:320:55: MISC
+ {
+ mMISC(); if (failed) return ;
+
+ }
+ break;
+ case 7 :
+ // DSLMap.g:320:60: EscapeSequence
+ {
+ mEscapeSequence(); if (failed) return ;
+
+ }
+ break;
+ case 8 :
+ // DSLMap.g:320:75: DOT
+ {
+ mDOT(); if (failed) return ;
+
+ }
+ break;
+
+ default :
+ if ( cnt4 >= 1 ) break loop4;
+ if (backtracking>0) {failed=true; return ;}
+ EarlyExitException eee =
+ new EarlyExitException(4, input);
+ throw eee;
+ }
+ cnt4++;
+ } while (true);
+
+
+ }
+
+ this.type = _type;
+ }
+ finally {
+ }
+ }
+ // $ANTLR end LITERAL
+
+ // $ANTLR start MISC
+ public final void mMISC() throws RecognitionException {
+ try {
+ // DSLMap.g:324:7: ( '>' | '<' | '!' | '@' | '$' | '%' | '^' | '*' | '-' | '+' | '?' | '/' | '\\'' | '\"' | '|' | '&' | '(' | ')' | ';' )
+ // DSLMap.g:
+ {
+ if ( (input.LA(1)>='!' && input.LA(1)<='\"')||(input.LA(1)>='$' && input.LA(1)<='+')||input.LA(1)=='-'||input.LA(1)=='/'||(input.LA(1)>=';' && input.LA(1)<='<')||(input.LA(1)>='>' && input.LA(1)<='@')||input.LA(1)=='^'||input.LA(1)=='|' ) {
+ input.consume();
+ failed=false;
+ }
+ else {
+ if (backtracking>0) {failed=true; return ;}
+ MismatchedSetException mse =
+ new MismatchedSetException(null,input);
+ recover(mse); throw mse;
+ }
+
+
+ }
+
+ }
+ finally {
+ }
+ }
+ // $ANTLR end MISC
+
+ public void mTokens() throws RecognitionException {
+ // DSLMap.g:1:8: ( WS | EOL | LEFT_SQUARE | RIGHT_SQUARE | LEFT_CURLY | RIGHT_CURLY | EQUALS | DOT | POUND | COLON | COMMA | LINE_COMMENT | LITERAL )
+ int alt5=13;
+ switch ( input.LA(1) ) {
+ case '\t':
+ case '\f':
+ case ' ':
+ {
+ alt5=1;
+ }
+ break;
+ case '\n':
+ case '\r':
+ {
+ alt5=2;
+ }
+ break;
+ case '[':
+ {
+ alt5=3;
+ }
+ break;
+ case ']':
+ {
+ alt5=4;
+ }
+ break;
+ case '{':
+ {
+ alt5=5;
+ }
+ break;
+ case '}':
+ {
+ alt5=6;
+ }
+ break;
+ case '=':
+ {
+ alt5=7;
+ }
+ break;
+ case '.':
+ {
+ int LA5_8 = input.LA(2);
+
+ if ( ((LA5_8>='!' && LA5_8<='\"')||(LA5_8>='$' && LA5_8<='+')||(LA5_8>='-' && LA5_8<='9')||(LA5_8>=';' && LA5_8<='<')||(LA5_8>='>' && LA5_8<='Z')||LA5_8=='\\'||(LA5_8>='^' && LA5_8<='_')||(LA5_8>='a' && LA5_8<='z')||LA5_8=='|'||(LA5_8>='\u00C0' && LA5_8<='\u00FF')) ) {
+ alt5=13;
+ }
+ else {
+ alt5=8;}
+ }
+ break;
+ case '#':
+ {
+ int LA5_9 = input.LA(2);
+
+ if ( ((LA5_9>='\u0000' && LA5_9<='\uFFFE')) ) {
+ alt5=12;
+ }
+ else {
+ alt5=9;}
+ }
+ break;
+ case ':':
+ {
+ alt5=10;
+ }
+ break;
+ case ',':
+ {
+ alt5=11;
+ }
+ break;
+ case '!':
+ case '\"':
+ case '$':
+ case '%':
+ case '&':
+ case '\'':
+ case '(':
+ case ')':
+ case '*':
+ case '+':
+ case '-':
+ case '/':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case ';':
+ case '<':
+ case '>':
+ case '?':
+ case '@':
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
+ case '\\':
+ case '^':
+ case '_':
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z':
+ case '|':
+ case '\u00C0':
+ case '\u00C1':
+ case '\u00C2':
+ case '\u00C3':
+ case '\u00C4':
+ case '\u00C5':
+ case '\u00C6':
+ case '\u00C7':
+ case '\u00C8':
+ case '\u00C9':
+ case '\u00CA':
+ case '\u00CB':
+ case '\u00CC':
+ case '\u00CD':
+ case '\u00CE':
+ case '\u00CF':
+ case '\u00D0':
+ case '\u00D1':
+ case '\u00D2':
+ case '\u00D3':
+ case '\u00D4':
+ case '\u00D5':
+ case '\u00D6':
+ case '\u00D7':
+ case '\u00D8':
+ case '\u00D9':
+ case '\u00DA':
+ case '\u00DB':
+ case '\u00DC':
+ case '\u00DD':
+ case '\u00DE':
+ case '\u00DF':
+ case '\u00E0':
+ case '\u00E1':
+ case '\u00E2':
+ case '\u00E3':
+ case '\u00E4':
+ case '\u00E5':
+ case '\u00E6':
+ case '\u00E7':
+ case '\u00E8':
+ case '\u00E9':
+ case '\u00EA':
+ case '\u00EB':
+ case '\u00EC':
+ case '\u00ED':
+ case '\u00EE':
+ case '\u00EF':
+ case '\u00F0':
+ case '\u00F1':
+ case '\u00F2':
+ case '\u00F3':
+ case '\u00F4':
+ case '\u00F5':
+ case '\u00F6':
+ case '\u00F7':
+ case '\u00F8':
+ case '\u00F9':
+ case '\u00FA':
+ case '\u00FB':
+ case '\u00FC':
+ case '\u00FD':
+ case '\u00FE':
+ case '\u00FF':
+ {
+ alt5=13;
+ }
+ break;
+ default:
+ if (backtracking>0) {failed=true; return ;}
+ NoViableAltException nvae =
+ new NoViableAltException("1:1: Tokens : ( WS | EOL | LEFT_SQUARE | RIGHT_SQUARE | LEFT_CURLY | RIGHT_CURLY | EQUALS | DOT | POUND | COLON | COMMA | LINE_COMMENT | LITERAL );", 5, 0, input);
+
+ throw nvae;
+ }
+
+ switch (alt5) {
+ case 1 :
+ // DSLMap.g:1:10: WS
+ {
+ mWS(); if (failed) return ;
+
+ }
+ break;
+ case 2 :
+ // DSLMap.g:1:13: EOL
+ {
+ mEOL(); if (failed) return ;
+
+ }
+ break;
+ case 3 :
+ // DSLMap.g:1:17: LEFT_SQUARE
+ {
+ mLEFT_SQUARE(); if (failed) return ;
+
+ }
+ break;
+ case 4 :
+ // DSLMap.g:1:29: RIGHT_SQUARE
+ {
+ mRIGHT_SQUARE(); if (failed) return ;
+
+ }
+ break;
+ case 5 :
+ // DSLMap.g:1:42: LEFT_CURLY
+ {
+ mLEFT_CURLY(); if (failed) return ;
+
+ }
+ break;
+ case 6 :
+ // DSLMap.g:1:53: RIGHT_CURLY
+ {
+ mRIGHT_CURLY(); if (failed) return ;
+
+ }
+ break;
+ case 7 :
+ // DSLMap.g:1:65: EQUALS
+ {
+ mEQUALS(); if (failed) return ;
+
+ }
+ break;
+ case 8 :
+ // DSLMap.g:1:72: DOT
+ {
+ mDOT(); if (failed) return ;
+
+ }
+ break;
+ case 9 :
+ // DSLMap.g:1:76: POUND
+ {
+ mPOUND(); if (failed) return ;
+
+ }
+ break;
+ case 10 :
+ // DSLMap.g:1:82: COLON
+ {
+ mCOLON(); if (failed) return ;
+
+ }
+ break;
+ case 11 :
+ // DSLMap.g:1:88: COMMA
+ {
+ mCOMMA(); if (failed) return ;
+
+ }
+ break;
+ case 12 :
+ // DSLMap.g:1:94: LINE_COMMENT
+ {
+ mLINE_COMMENT(); if (failed) return ;
+
+ }
+ break;
+ case 13 :
+ // DSLMap.g:1:107: LITERAL
+ {
+ mLITERAL(); if (failed) return ;
+
+ }
+ break;
+
+ }
+
+ }
+
+ // $ANTLR start synpred1
+ public final void synpred1_fragment() throws RecognitionException {
+ // DSLMap.g:262:14: ( '\\r\\n' )
+ // DSLMap.g:262:16: '\\r\\n'
+ {
+ match("\r\n"); if (failed) return ;
+
+
+ }
+ }
+ // $ANTLR end synpred1
+
+ public final boolean synpred1() {
+ backtracking++;
+ int start = input.mark();
+ try {
+ synpred1_fragment(); // can never throw exception
+ } catch (RecognitionException re) {
+ System.err.println("impossible: "+re);
+ }
+ boolean success = !failed;
+ input.rewind(start);
+ backtracking--;
+ failed=false;
+ return success;
+ }
+
+
+
+
+}
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapParser.java (from rev 20284, labs/jbossrules/branches/mattgeis/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapParser.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapParser.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapParser.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -0,0 +1,3018 @@
+// $ANTLR 3.0.1 DSLMap.g 2008-05-27 14:03:44
+
+ package org.drools.lang.dsl;
+
+
+import org.antlr.runtime.*;
+import java.util.Stack;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+
+import org.antlr.runtime.tree.*;
+
+public class DSLMapParser extends Parser {
+ public static final String[] tokenNames = new String[] {
+ "<invalid>", "<EOR>", "<DOWN>", "<UP>", "VT_DSL_GRAMMAR", "VT_COMMENT", "VT_ENTRY", "VT_SCOPE", "VT_CONDITION", "VT_CONSEQUENCE", "VT_KEYWORD", "VT_ANY", "VT_META", "VT_ENTRY_KEY", "VT_ENTRY_VAL", "VT_VAR_DEF", "VT_VAR_REF", "VT_LITERAL", "VT_PATTERN", "VT_SPACE", "EOL", "LINE_COMMENT", "EQUALS", "LEFT_SQUARE", "RIGHT_SQUARE", "LITERAL", "COMMA", "COLON", "LEFT_CURLY", "RIGHT_CURLY", "WS", "EscapeSequence", "DOT", "POUND", "MISC"
+ };
+ public static final int COMMA=26;
+ public static final int RIGHT_CURLY=29;
+ public static final int VT_ENTRY_VAL=14;
+ public static final int WS=30;
+ public static final int MISC=34;
+ public static final int VT_META=12;
+ public static final int VT_CONSEQUENCE=9;
+ public static final int VT_SPACE=19;
+ public static final int LINE_COMMENT=21;
+ public static final int VT_ANY=11;
+ public static final int VT_LITERAL=17;
+ public static final int DOT=32;
+ public static final int EQUALS=22;
+ public static final int VT_DSL_GRAMMAR=4;
+ public static final int VT_CONDITION=8;
+ public static final int VT_ENTRY=6;
+ public static final int VT_VAR_DEF=15;
+ public static final int LITERAL=25;
+ public static final int VT_PATTERN=18;
+ public static final int EscapeSequence=31;
+ public static final int VT_COMMENT=5;
+ public static final int EOF=-1;
+ public static final int EOL=20;
+ public static final int LEFT_SQUARE=23;
+ public static final int VT_ENTRY_KEY=13;
+ public static final int COLON=27;
+ public static final int VT_SCOPE=7;
+ public static final int VT_KEYWORD=10;
+ public static final int POUND=33;
+ public static final int LEFT_CURLY=28;
+ public static final int VT_VAR_REF=16;
+ public static final int RIGHT_SQUARE=24;
+
+ public DSLMapParser(TokenStream input) {
+ super(input);
+ ruleMemo = new HashMap[47+1];
+ }
+
+ protected TreeAdaptor adaptor = new CommonTreeAdaptor();
+
+ public void setTreeAdaptor(TreeAdaptor adaptor) {
+ this.adaptor = adaptor;
+ }
+ public TreeAdaptor getTreeAdaptor() {
+ return adaptor;
+ }
+
+ public String[] getTokenNames() { return tokenNames; }
+ public String getGrammarFileName() { return "DSLMap.g"; }
+
+
+ //we may not need the check on [], as the LITERAL token being examined
+ //should not have them.
+ private boolean validateLT(int LTNumber, String text){
+ if (null == input) return false;
+ if (null == input.LT(LTNumber)) return false;
+ if (null == input.LT(LTNumber).getText()) return false;
+
+ String text2Validate = input.LT(LTNumber).getText();
+ if (text2Validate.startsWith("[") && text2Validate.endsWith("]")){
+ text2Validate = text2Validate.substring(1, text2Validate.length() - 1);
+ }
+
+ return text2Validate.equalsIgnoreCase(text);
+ }
+
+ private boolean validateIdentifierKey(String text){
+ return validateLT(1, text);
+ }
+
+ protected void mismatch(IntStream input, int ttype, BitSet follow)
+ throws RecognitionException{
+ throw new MismatchedTokenException(ttype, input);
+ }
+
+ public void recoverFromMismatchedSet(IntStream input,
+ RecognitionException e, BitSet follow) throws RecognitionException{
+ throw e;
+ }
+
+
+
+ public static class mapping_file_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start mapping_file
+ // DSLMap.g:76:1: mapping_file : ( statement )* -> ^( VT_DSL_GRAMMAR ( statement )* ) ;
+ public final mapping_file_return mapping_file() throws RecognitionException {
+ mapping_file_return retval = new mapping_file_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ statement_return statement1 = null;
+
+
+ RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
+ try {
+ // DSLMap.g:77:2: ( ( statement )* -> ^( VT_DSL_GRAMMAR ( statement )* ) )
+ // DSLMap.g:77:4: ( statement )*
+ {
+ // DSLMap.g:77:4: ( statement )*
+ loop1:
+ do {
+ int alt1=2;
+ int LA1_0 = input.LA(1);
+
+ if ( ((LA1_0>=EOL && LA1_0<=LINE_COMMENT)||LA1_0==LEFT_SQUARE) ) {
+ alt1=1;
+ }
+
+
+ switch (alt1) {
+ case 1 :
+ // DSLMap.g:0:0: statement
+ {
+ pushFollow(FOLLOW_statement_in_mapping_file262);
+ statement1=statement();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_statement.add(statement1.getTree());
+
+ }
+ break;
+
+ default :
+ break loop1;
+ }
+ } while (true);
+
+
+ // AST REWRITE
+ // elements: statement
+ // token labels:
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 78:2: -> ^( VT_DSL_GRAMMAR ( statement )* )
+ {
+ // DSLMap.g:78:5: ^( VT_DSL_GRAMMAR ( statement )* )
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_DSL_GRAMMAR, "VT_DSL_GRAMMAR"), root_1);
+
+ // DSLMap.g:78:22: ( statement )*
+ while ( stream_statement.hasNext() ) {
+ adaptor.addChild(root_1, stream_statement.next());
+
+ }
+ stream_statement.reset();
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end mapping_file
+
+ public static class statement_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start statement
+ // DSLMap.g:81:1: statement : ( entry | comment | EOL );
+ public final statement_return statement() throws RecognitionException {
+ statement_return retval = new statement_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token EOL4=null;
+ entry_return entry2 = null;
+
+ comment_return comment3 = null;
+
+
+ Object EOL4_tree=null;
+
+ try {
+ // DSLMap.g:82:2: ( entry | comment | EOL )
+ int alt2=3;
+ switch ( input.LA(1) ) {
+ case LEFT_SQUARE:
+ {
+ alt2=1;
+ }
+ break;
+ case LINE_COMMENT:
+ {
+ alt2=2;
+ }
+ break;
+ case EOL:
+ {
+ alt2=3;
+ }
+ break;
+ default:
+ if (backtracking>0) {failed=true; return retval;}
+ NoViableAltException nvae =
+ new NoViableAltException("81:1: statement : ( entry | comment | EOL );", 2, 0, input);
+
+ throw nvae;
+ }
+
+ switch (alt2) {
+ case 1 :
+ // DSLMap.g:82:4: entry
+ {
+ root_0 = (Object)adaptor.nil();
+
+ pushFollow(FOLLOW_entry_in_statement285);
+ entry2=entry();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) adaptor.addChild(root_0, entry2.getTree());
+
+ }
+ break;
+ case 2 :
+ // DSLMap.g:83:4: comment
+ {
+ root_0 = (Object)adaptor.nil();
+
+ pushFollow(FOLLOW_comment_in_statement292);
+ comment3=comment();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) adaptor.addChild(root_0, comment3.getTree());
+
+ }
+ break;
+ case 3 :
+ // DSLMap.g:84:4: EOL
+ {
+ root_0 = (Object)adaptor.nil();
+
+ EOL4=(Token)input.LT(1);
+ match(input,EOL,FOLLOW_EOL_in_statement298); if (failed) return retval;
+
+ }
+ break;
+
+ }
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end statement
+
+ public static class comment_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start comment
+ // DSLMap.g:89:1: comment : LINE_COMMENT -> ^( VT_COMMENT[$LINE_COMMENT, \"COMMENT\"] LINE_COMMENT ) ;
+ public final comment_return comment() throws RecognitionException {
+ comment_return retval = new comment_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token LINE_COMMENT5=null;
+
+ Object LINE_COMMENT5_tree=null;
+ RewriteRuleTokenStream stream_LINE_COMMENT=new RewriteRuleTokenStream(adaptor,"token LINE_COMMENT");
+
+ try {
+ // DSLMap.g:89:9: ( LINE_COMMENT -> ^( VT_COMMENT[$LINE_COMMENT, \"COMMENT\"] LINE_COMMENT ) )
+ // DSLMap.g:89:11: LINE_COMMENT
+ {
+ LINE_COMMENT5=(Token)input.LT(1);
+ match(input,LINE_COMMENT,FOLLOW_LINE_COMMENT_in_comment314); if (failed) return retval;
+ if ( backtracking==0 ) stream_LINE_COMMENT.add(LINE_COMMENT5);
+
+
+ // AST REWRITE
+ // elements: LINE_COMMENT
+ // token labels:
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 90:2: -> ^( VT_COMMENT[$LINE_COMMENT, \"COMMENT\"] LINE_COMMENT )
+ {
+ // DSLMap.g:90:5: ^( VT_COMMENT[$LINE_COMMENT, \"COMMENT\"] LINE_COMMENT )
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_COMMENT, LINE_COMMENT5, "COMMENT"), root_1);
+
+ adaptor.addChild(root_1, stream_LINE_COMMENT.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end comment
+
+ public static class entry_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start entry
+ // DSLMap.g:94:1: entry : scope_section ( meta_section )? key_section EQUALS value_section ( EOL | EOF ) -> ^( VT_ENTRY scope_section ( meta_section )? key_section value_section ) ;
+ public final entry_return entry() throws RecognitionException {
+ entry_return retval = new entry_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token EQUALS9=null;
+ Token EOL11=null;
+ Token EOF12=null;
+ scope_section_return scope_section6 = null;
+
+ meta_section_return meta_section7 = null;
+
+ key_section_return key_section8 = null;
+
+ value_section_return value_section10 = null;
+
+
+ Object EQUALS9_tree=null;
+ Object EOL11_tree=null;
+ Object EOF12_tree=null;
+ RewriteRuleTokenStream stream_EQUALS=new RewriteRuleTokenStream(adaptor,"token EQUALS");
+ RewriteRuleTokenStream stream_EOF=new RewriteRuleTokenStream(adaptor,"token EOF");
+ RewriteRuleTokenStream stream_EOL=new RewriteRuleTokenStream(adaptor,"token EOL");
+ RewriteRuleSubtreeStream stream_key_section=new RewriteRuleSubtreeStream(adaptor,"rule key_section");
+ RewriteRuleSubtreeStream stream_value_section=new RewriteRuleSubtreeStream(adaptor,"rule value_section");
+ RewriteRuleSubtreeStream stream_scope_section=new RewriteRuleSubtreeStream(adaptor,"rule scope_section");
+ RewriteRuleSubtreeStream stream_meta_section=new RewriteRuleSubtreeStream(adaptor,"rule meta_section");
+ try {
+ // DSLMap.g:94:8: ( scope_section ( meta_section )? key_section EQUALS value_section ( EOL | EOF ) -> ^( VT_ENTRY scope_section ( meta_section )? key_section value_section ) )
+ // DSLMap.g:94:10: scope_section ( meta_section )? key_section EQUALS value_section ( EOL | EOF )
+ {
+ pushFollow(FOLLOW_scope_section_in_entry339);
+ scope_section6=scope_section();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_scope_section.add(scope_section6.getTree());
+ // DSLMap.g:94:24: ( meta_section )?
+ int alt3=2;
+ int LA3_0 = input.LA(1);
+
+ if ( (LA3_0==LEFT_SQUARE) ) {
+ int LA3_1 = input.LA(2);
+
+ if ( (LA3_1==LITERAL) ) {
+ int LA3_3 = input.LA(3);
+
+ if ( (LA3_3==RIGHT_SQUARE) ) {
+ int LA3_4 = input.LA(4);
+
+ if ( (synpred4()) ) {
+ alt3=1;
+ }
+ }
+ }
+ else if ( (LA3_1==RIGHT_SQUARE) ) {
+ int LA3_4 = input.LA(3);
+
+ if ( (synpred4()) ) {
+ alt3=1;
+ }
+ }
+ }
+ switch (alt3) {
+ case 1 :
+ // DSLMap.g:0:0: meta_section
+ {
+ pushFollow(FOLLOW_meta_section_in_entry341);
+ meta_section7=meta_section();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_meta_section.add(meta_section7.getTree());
+
+ }
+ break;
+
+ }
+
+ pushFollow(FOLLOW_key_section_in_entry344);
+ key_section8=key_section();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_key_section.add(key_section8.getTree());
+ EQUALS9=(Token)input.LT(1);
+ match(input,EQUALS,FOLLOW_EQUALS_in_entry346); if (failed) return retval;
+ if ( backtracking==0 ) stream_EQUALS.add(EQUALS9);
+
+ pushFollow(FOLLOW_value_section_in_entry348);
+ value_section10=value_section();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_value_section.add(value_section10.getTree());
+ // DSLMap.g:94:71: ( EOL | EOF )
+ int alt4=2;
+ int LA4_0 = input.LA(1);
+
+ if ( (LA4_0==EOL) ) {
+ alt4=1;
+ }
+ else if ( (LA4_0==EOF) ) {
+ alt4=2;
+ }
+ else {
+ if (backtracking>0) {failed=true; return retval;}
+ NoViableAltException nvae =
+ new NoViableAltException("94:71: ( EOL | EOF )", 4, 0, input);
+
+ throw nvae;
+ }
+ switch (alt4) {
+ case 1 :
+ // DSLMap.g:94:72: EOL
+ {
+ EOL11=(Token)input.LT(1);
+ match(input,EOL,FOLLOW_EOL_in_entry351); if (failed) return retval;
+ if ( backtracking==0 ) stream_EOL.add(EOL11);
+
+
+ }
+ break;
+ case 2 :
+ // DSLMap.g:94:76: EOF
+ {
+ EOF12=(Token)input.LT(1);
+ match(input,EOF,FOLLOW_EOF_in_entry353); if (failed) return retval;
+ if ( backtracking==0 ) stream_EOF.add(EOF12);
+
+
+ }
+ break;
+
+ }
+
+
+ // AST REWRITE
+ // elements: key_section, value_section, scope_section, meta_section
+ // token labels:
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 95:2: -> ^( VT_ENTRY scope_section ( meta_section )? key_section value_section )
+ {
+ // DSLMap.g:95:5: ^( VT_ENTRY scope_section ( meta_section )? key_section value_section )
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_ENTRY, "VT_ENTRY"), root_1);
+
+ adaptor.addChild(root_1, stream_scope_section.next());
+ // DSLMap.g:95:30: ( meta_section )?
+ if ( stream_meta_section.hasNext() ) {
+ adaptor.addChild(root_1, stream_meta_section.next());
+
+ }
+ stream_meta_section.reset();
+ adaptor.addChild(root_1, stream_key_section.next());
+ adaptor.addChild(root_1, stream_value_section.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end entry
+
+ public static class scope_section_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start scope_section
+ // DSLMap.g:100:1: scope_section : LEFT_SQUARE (value1= condition_key | value2= consequence_key | value3= keyword_key | value4= any_key ) RIGHT_SQUARE -> ^( VT_SCOPE[$LEFT_SQUARE, \"SCOPE SECTION\"] ( $value1)? ( $value2)? ( $value3)? ( $value4)? ) ;
+ public final scope_section_return scope_section() throws RecognitionException {
+ scope_section_return retval = new scope_section_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token LEFT_SQUARE13=null;
+ Token RIGHT_SQUARE14=null;
+ condition_key_return value1 = null;
+
+ consequence_key_return value2 = null;
+
+ keyword_key_return value3 = null;
+
+ any_key_return value4 = null;
+
+
+ Object LEFT_SQUARE13_tree=null;
+ Object RIGHT_SQUARE14_tree=null;
+ RewriteRuleTokenStream stream_LEFT_SQUARE=new RewriteRuleTokenStream(adaptor,"token LEFT_SQUARE");
+ RewriteRuleTokenStream stream_RIGHT_SQUARE=new RewriteRuleTokenStream(adaptor,"token RIGHT_SQUARE");
+ RewriteRuleSubtreeStream stream_condition_key=new RewriteRuleSubtreeStream(adaptor,"rule condition_key");
+ RewriteRuleSubtreeStream stream_any_key=new RewriteRuleSubtreeStream(adaptor,"rule any_key");
+ RewriteRuleSubtreeStream stream_keyword_key=new RewriteRuleSubtreeStream(adaptor,"rule keyword_key");
+ RewriteRuleSubtreeStream stream_consequence_key=new RewriteRuleSubtreeStream(adaptor,"rule consequence_key");
+ try {
+ // DSLMap.g:101:2: ( LEFT_SQUARE (value1= condition_key | value2= consequence_key | value3= keyword_key | value4= any_key ) RIGHT_SQUARE -> ^( VT_SCOPE[$LEFT_SQUARE, \"SCOPE SECTION\"] ( $value1)? ( $value2)? ( $value3)? ( $value4)? ) )
+ // DSLMap.g:101:4: LEFT_SQUARE (value1= condition_key | value2= consequence_key | value3= keyword_key | value4= any_key ) RIGHT_SQUARE
+ {
+ LEFT_SQUARE13=(Token)input.LT(1);
+ match(input,LEFT_SQUARE,FOLLOW_LEFT_SQUARE_in_scope_section384); if (failed) return retval;
+ if ( backtracking==0 ) stream_LEFT_SQUARE.add(LEFT_SQUARE13);
+
+ // DSLMap.g:102:3: (value1= condition_key | value2= consequence_key | value3= keyword_key | value4= any_key )
+ int alt5=4;
+ int LA5_0 = input.LA(1);
+
+ if ( (LA5_0==LITERAL) ) {
+ int LA5_1 = input.LA(2);
+
+ if ( ((synpred6()&&validateIdentifierKey("condition")||validateIdentifierKey("when"))) ) {
+ alt5=1;
+ }
+ else if ( ((synpred7()&&validateIdentifierKey("consequence")||validateIdentifierKey("then"))) ) {
+ alt5=2;
+ }
+ else if ( ((synpred8()&&validateIdentifierKey("keyword"))) ) {
+ alt5=3;
+ }
+ else if ( (validateIdentifierKey("*")) ) {
+ alt5=4;
+ }
+ else {
+ if (backtracking>0) {failed=true; return retval;}
+ NoViableAltException nvae =
+ new NoViableAltException("102:3: (value1= condition_key | value2= consequence_key | value3= keyword_key | value4= any_key )", 5, 1, input);
+
+ throw nvae;
+ }
+ }
+ else {
+ if (backtracking>0) {failed=true; return retval;}
+ NoViableAltException nvae =
+ new NoViableAltException("102:3: (value1= condition_key | value2= consequence_key | value3= keyword_key | value4= any_key )", 5, 0, input);
+
+ throw nvae;
+ }
+ switch (alt5) {
+ case 1 :
+ // DSLMap.g:102:4: value1= condition_key
+ {
+ pushFollow(FOLLOW_condition_key_in_scope_section392);
+ value1=condition_key();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_condition_key.add(value1.getTree());
+
+ }
+ break;
+ case 2 :
+ // DSLMap.g:103:5: value2= consequence_key
+ {
+ pushFollow(FOLLOW_consequence_key_in_scope_section401);
+ value2=consequence_key();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_consequence_key.add(value2.getTree());
+
+ }
+ break;
+ case 3 :
+ // DSLMap.g:104:5: value3= keyword_key
+ {
+ pushFollow(FOLLOW_keyword_key_in_scope_section409);
+ value3=keyword_key();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_keyword_key.add(value3.getTree());
+
+ }
+ break;
+ case 4 :
+ // DSLMap.g:105:5: value4= any_key
+ {
+ pushFollow(FOLLOW_any_key_in_scope_section417);
+ value4=any_key();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_any_key.add(value4.getTree());
+
+ }
+ break;
+
+ }
+
+ RIGHT_SQUARE14=(Token)input.LT(1);
+ match(input,RIGHT_SQUARE,FOLLOW_RIGHT_SQUARE_in_scope_section425); if (failed) return retval;
+ if ( backtracking==0 ) stream_RIGHT_SQUARE.add(RIGHT_SQUARE14);
+
+
+ // AST REWRITE
+ // elements: value1, value2, value4, value3
+ // token labels:
+ // rule labels: value1, value4, value2, retval, value3
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_value1=new RewriteRuleSubtreeStream(adaptor,"token value1",value1!=null?value1.tree:null);
+ RewriteRuleSubtreeStream stream_value4=new RewriteRuleSubtreeStream(adaptor,"token value4",value4!=null?value4.tree:null);
+ RewriteRuleSubtreeStream stream_value2=new RewriteRuleSubtreeStream(adaptor,"token value2",value2!=null?value2.tree:null);
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+ RewriteRuleSubtreeStream stream_value3=new RewriteRuleSubtreeStream(adaptor,"token value3",value3!=null?value3.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 108:2: -> ^( VT_SCOPE[$LEFT_SQUARE, \"SCOPE SECTION\"] ( $value1)? ( $value2)? ( $value3)? ( $value4)? )
+ {
+ // DSLMap.g:108:5: ^( VT_SCOPE[$LEFT_SQUARE, \"SCOPE SECTION\"] ( $value1)? ( $value2)? ( $value3)? ( $value4)? )
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_SCOPE, LEFT_SQUARE13, "SCOPE SECTION"), root_1);
+
+ // DSLMap.g:108:47: ( $value1)?
+ if ( stream_value1.hasNext() ) {
+ adaptor.addChild(root_1, stream_value1.next());
+
+ }
+ stream_value1.reset();
+ // DSLMap.g:108:56: ( $value2)?
+ if ( stream_value2.hasNext() ) {
+ adaptor.addChild(root_1, stream_value2.next());
+
+ }
+ stream_value2.reset();
+ // DSLMap.g:108:65: ( $value3)?
+ if ( stream_value3.hasNext() ) {
+ adaptor.addChild(root_1, stream_value3.next());
+
+ }
+ stream_value3.reset();
+ // DSLMap.g:108:74: ( $value4)?
+ if ( stream_value4.hasNext() ) {
+ adaptor.addChild(root_1, stream_value4.next());
+
+ }
+ stream_value4.reset();
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end scope_section
+
+ public static class meta_section_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start meta_section
+ // DSLMap.g:113:1: meta_section : LEFT_SQUARE ( LITERAL )? RIGHT_SQUARE -> ^( VT_META[$LEFT_SQUARE, \"META SECTION\"] ( LITERAL )? ) ;
+ public final meta_section_return meta_section() throws RecognitionException {
+ meta_section_return retval = new meta_section_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token LEFT_SQUARE15=null;
+ Token LITERAL16=null;
+ Token RIGHT_SQUARE17=null;
+
+ Object LEFT_SQUARE15_tree=null;
+ Object LITERAL16_tree=null;
+ Object RIGHT_SQUARE17_tree=null;
+ RewriteRuleTokenStream stream_LEFT_SQUARE=new RewriteRuleTokenStream(adaptor,"token LEFT_SQUARE");
+ RewriteRuleTokenStream stream_LITERAL=new RewriteRuleTokenStream(adaptor,"token LITERAL");
+ RewriteRuleTokenStream stream_RIGHT_SQUARE=new RewriteRuleTokenStream(adaptor,"token RIGHT_SQUARE");
+
+ try {
+ // DSLMap.g:114:2: ( LEFT_SQUARE ( LITERAL )? RIGHT_SQUARE -> ^( VT_META[$LEFT_SQUARE, \"META SECTION\"] ( LITERAL )? ) )
+ // DSLMap.g:114:4: LEFT_SQUARE ( LITERAL )? RIGHT_SQUARE
+ {
+ LEFT_SQUARE15=(Token)input.LT(1);
+ match(input,LEFT_SQUARE,FOLLOW_LEFT_SQUARE_in_meta_section463); if (failed) return retval;
+ if ( backtracking==0 ) stream_LEFT_SQUARE.add(LEFT_SQUARE15);
+
+ // DSLMap.g:114:16: ( LITERAL )?
+ int alt6=2;
+ int LA6_0 = input.LA(1);
+
+ if ( (LA6_0==LITERAL) ) {
+ alt6=1;
+ }
+ switch (alt6) {
+ case 1 :
+ // DSLMap.g:0:0: LITERAL
+ {
+ LITERAL16=(Token)input.LT(1);
+ match(input,LITERAL,FOLLOW_LITERAL_in_meta_section465); if (failed) return retval;
+ if ( backtracking==0 ) stream_LITERAL.add(LITERAL16);
+
+
+ }
+ break;
+
+ }
+
+ RIGHT_SQUARE17=(Token)input.LT(1);
+ match(input,RIGHT_SQUARE,FOLLOW_RIGHT_SQUARE_in_meta_section468); if (failed) return retval;
+ if ( backtracking==0 ) stream_RIGHT_SQUARE.add(RIGHT_SQUARE17);
+
+
+ // AST REWRITE
+ // elements: LITERAL
+ // token labels:
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 115:2: -> ^( VT_META[$LEFT_SQUARE, \"META SECTION\"] ( LITERAL )? )
+ {
+ // DSLMap.g:115:5: ^( VT_META[$LEFT_SQUARE, \"META SECTION\"] ( LITERAL )? )
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_META, LEFT_SQUARE15, "META SECTION"), root_1);
+
+ // DSLMap.g:115:45: ( LITERAL )?
+ if ( stream_LITERAL.hasNext() ) {
+ adaptor.addChild(root_1, stream_LITERAL.next());
+
+ }
+ stream_LITERAL.reset();
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end meta_section
+
+ public static class key_section_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start key_section
+ // DSLMap.g:118:1: key_section : (ks= key_sentence )+ -> ^( VT_ENTRY_KEY ( key_sentence )+ ) ;
+ public final key_section_return key_section() throws RecognitionException {
+ key_section_return retval = new key_section_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ key_sentence_return ks = null;
+
+
+ RewriteRuleSubtreeStream stream_key_sentence=new RewriteRuleSubtreeStream(adaptor,"rule key_sentence");
+ try {
+ // DSLMap.g:119:2: ( (ks= key_sentence )+ -> ^( VT_ENTRY_KEY ( key_sentence )+ ) )
+ // DSLMap.g:119:4: (ks= key_sentence )+
+ {
+ // DSLMap.g:119:6: (ks= key_sentence )+
+ int cnt7=0;
+ loop7:
+ do {
+ int alt7=2;
+ int LA7_0 = input.LA(1);
+
+ if ( ((LA7_0>=LEFT_SQUARE && LA7_0<=LITERAL)||(LA7_0>=COLON && LA7_0<=LEFT_CURLY)) ) {
+ alt7=1;
+ }
+
+
+ switch (alt7) {
+ case 1 :
+ // DSLMap.g:0:0: ks= key_sentence
+ {
+ pushFollow(FOLLOW_key_sentence_in_key_section492);
+ ks=key_sentence();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_key_sentence.add(ks.getTree());
+
+ }
+ break;
+
+ default :
+ if ( cnt7 >= 1 ) break loop7;
+ if (backtracking>0) {failed=true; return retval;}
+ EarlyExitException eee =
+ new EarlyExitException(7, input);
+ throw eee;
+ }
+ cnt7++;
+ } while (true);
+
+
+ // AST REWRITE
+ // elements: key_sentence
+ // token labels:
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 120:2: -> ^( VT_ENTRY_KEY ( key_sentence )+ )
+ {
+ // DSLMap.g:120:5: ^( VT_ENTRY_KEY ( key_sentence )+ )
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_ENTRY_KEY, "VT_ENTRY_KEY"), root_1);
+
+ if ( !(stream_key_sentence.hasNext()) ) {
+ throw new RewriteEarlyExitException();
+ }
+ while ( stream_key_sentence.hasNext() ) {
+ adaptor.addChild(root_1, stream_key_sentence.next());
+
+ }
+ stream_key_sentence.reset();
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end key_section
+
+ public static class key_sentence_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start key_sentence
+ // DSLMap.g:123:1: key_sentence : ( variable_definition | cb= key_chunk -> VT_LITERAL[$cb.start, text] );
+ public final key_sentence_return key_sentence() throws RecognitionException {
+ key_sentence_return retval = new key_sentence_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ key_chunk_return cb = null;
+
+ variable_definition_return variable_definition18 = null;
+
+
+ RewriteRuleSubtreeStream stream_key_chunk=new RewriteRuleSubtreeStream(adaptor,"rule key_chunk");
+
+ String text = "";
+
+ try {
+ // DSLMap.g:127:2: ( variable_definition | cb= key_chunk -> VT_LITERAL[$cb.start, text] )
+ int alt8=2;
+ int LA8_0 = input.LA(1);
+
+ if ( (LA8_0==LEFT_CURLY) ) {
+ alt8=1;
+ }
+ else if ( ((LA8_0>=LEFT_SQUARE && LA8_0<=LITERAL)||LA8_0==COLON) ) {
+ alt8=2;
+ }
+ else {
+ if (backtracking>0) {failed=true; return retval;}
+ NoViableAltException nvae =
+ new NoViableAltException("123:1: key_sentence : ( variable_definition | cb= key_chunk -> VT_LITERAL[$cb.start, text] );", 8, 0, input);
+
+ throw nvae;
+ }
+ switch (alt8) {
+ case 1 :
+ // DSLMap.g:127:4: variable_definition
+ {
+ root_0 = (Object)adaptor.nil();
+
+ pushFollow(FOLLOW_variable_definition_in_key_sentence523);
+ variable_definition18=variable_definition();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) adaptor.addChild(root_0, variable_definition18.getTree());
+
+ }
+ break;
+ case 2 :
+ // DSLMap.g:128:4: cb= key_chunk
+ {
+ pushFollow(FOLLOW_key_chunk_in_key_sentence530);
+ cb=key_chunk();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_key_chunk.add(cb.getTree());
+ if ( backtracking==0 ) {
+ text = input.toString(cb.start,cb.stop);
+ }
+
+ // AST REWRITE
+ // elements:
+ // token labels:
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 129:2: -> VT_LITERAL[$cb.start, text]
+ {
+ adaptor.addChild(root_0, adaptor.create(VT_LITERAL, ((Token)cb.start), text));
+
+ }
+
+ }
+
+ }
+ break;
+
+ }
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end key_sentence
+
+ public static class key_chunk_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start key_chunk
+ // DSLMap.g:132:1: key_chunk : ( literal )+ ;
+ public final key_chunk_return key_chunk() throws RecognitionException {
+ key_chunk_return retval = new key_chunk_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ literal_return literal19 = null;
+
+
+
+ try {
+ // DSLMap.g:133:2: ( ( literal )+ )
+ // DSLMap.g:133:4: ( literal )+
+ {
+ root_0 = (Object)adaptor.nil();
+
+ // DSLMap.g:133:4: ( literal )+
+ int cnt9=0;
+ loop9:
+ do {
+ int alt9=2;
+ int LA9_0 = input.LA(1);
+
+ if ( ((LA9_0>=LEFT_SQUARE && LA9_0<=LITERAL)||LA9_0==COLON) ) {
+ int LA9_2 = input.LA(2);
+
+ if ( (synpred12()) ) {
+ alt9=1;
+ }
+
+
+ }
+
+
+ switch (alt9) {
+ case 1 :
+ // DSLMap.g:0:0: literal
+ {
+ pushFollow(FOLLOW_literal_in_key_chunk551);
+ literal19=literal();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) adaptor.addChild(root_0, literal19.getTree());
+
+ }
+ break;
+
+ default :
+ if ( cnt9 >= 1 ) break loop9;
+ if (backtracking>0) {failed=true; return retval;}
+ EarlyExitException eee =
+ new EarlyExitException(9, input);
+ throw eee;
+ }
+ cnt9++;
+ } while (true);
+
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end key_chunk
+
+ public static class value_section_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start value_section
+ // DSLMap.g:136:1: value_section : ( value_sentence )+ -> ^( VT_ENTRY_VAL ( value_sentence )+ ) ;
+ public final value_section_return value_section() throws RecognitionException {
+ value_section_return retval = new value_section_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ value_sentence_return value_sentence20 = null;
+
+
+ RewriteRuleSubtreeStream stream_value_sentence=new RewriteRuleSubtreeStream(adaptor,"rule value_sentence");
+ try {
+ // DSLMap.g:137:2: ( ( value_sentence )+ -> ^( VT_ENTRY_VAL ( value_sentence )+ ) )
+ // DSLMap.g:137:4: ( value_sentence )+
+ {
+ // DSLMap.g:137:4: ( value_sentence )+
+ int cnt10=0;
+ loop10:
+ do {
+ int alt10=2;
+ int LA10_0 = input.LA(1);
+
+ if ( ((LA10_0>=EQUALS && LA10_0<=LEFT_CURLY)) ) {
+ alt10=1;
+ }
+
+
+ switch (alt10) {
+ case 1 :
+ // DSLMap.g:0:0: value_sentence
+ {
+ pushFollow(FOLLOW_value_sentence_in_value_section566);
+ value_sentence20=value_sentence();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_value_sentence.add(value_sentence20.getTree());
+
+ }
+ break;
+
+ default :
+ if ( cnt10 >= 1 ) break loop10;
+ if (backtracking>0) {failed=true; return retval;}
+ EarlyExitException eee =
+ new EarlyExitException(10, input);
+ throw eee;
+ }
+ cnt10++;
+ } while (true);
+
+
+ // AST REWRITE
+ // elements: value_sentence
+ // token labels:
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 138:2: -> ^( VT_ENTRY_VAL ( value_sentence )+ )
+ {
+ // DSLMap.g:138:5: ^( VT_ENTRY_VAL ( value_sentence )+ )
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_ENTRY_VAL, "VT_ENTRY_VAL"), root_1);
+
+ if ( !(stream_value_sentence.hasNext()) ) {
+ throw new RewriteEarlyExitException();
+ }
+ while ( stream_value_sentence.hasNext() ) {
+ adaptor.addChild(root_1, stream_value_sentence.next());
+
+ }
+ stream_value_sentence.reset();
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end value_section
+
+ public static class value_sentence_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start value_sentence
+ // DSLMap.g:141:1: value_sentence : ( variable_reference | vc= value_chunk -> VT_LITERAL[$vc.start, text] );
+ public final value_sentence_return value_sentence() throws RecognitionException {
+ value_sentence_return retval = new value_sentence_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ value_chunk_return vc = null;
+
+ variable_reference_return variable_reference21 = null;
+
+
+ RewriteRuleSubtreeStream stream_value_chunk=new RewriteRuleSubtreeStream(adaptor,"rule value_chunk");
+
+ String text = "";
+
+ try {
+ // DSLMap.g:145:2: ( variable_reference | vc= value_chunk -> VT_LITERAL[$vc.start, text] )
+ int alt11=2;
+ int LA11_0 = input.LA(1);
+
+ if ( (LA11_0==LEFT_CURLY) ) {
+ alt11=1;
+ }
+ else if ( ((LA11_0>=EQUALS && LA11_0<=COLON)) ) {
+ alt11=2;
+ }
+ else {
+ if (backtracking>0) {failed=true; return retval;}
+ NoViableAltException nvae =
+ new NoViableAltException("141:1: value_sentence : ( variable_reference | vc= value_chunk -> VT_LITERAL[$vc.start, text] );", 11, 0, input);
+
+ throw nvae;
+ }
+ switch (alt11) {
+ case 1 :
+ // DSLMap.g:145:4: variable_reference
+ {
+ root_0 = (Object)adaptor.nil();
+
+ pushFollow(FOLLOW_variable_reference_in_value_sentence597);
+ variable_reference21=variable_reference();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) adaptor.addChild(root_0, variable_reference21.getTree());
+
+ }
+ break;
+ case 2 :
+ // DSLMap.g:146:4: vc= value_chunk
+ {
+ pushFollow(FOLLOW_value_chunk_in_value_sentence604);
+ vc=value_chunk();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_value_chunk.add(vc.getTree());
+ if ( backtracking==0 ) {
+ text = input.toString(vc.start,vc.stop);
+ }
+
+ // AST REWRITE
+ // elements:
+ // token labels:
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 147:2: -> VT_LITERAL[$vc.start, text]
+ {
+ adaptor.addChild(root_0, adaptor.create(VT_LITERAL, ((Token)vc.start), text));
+
+ }
+
+ }
+
+ }
+ break;
+
+ }
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end value_sentence
+
+ public static class value_chunk_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start value_chunk
+ // DSLMap.g:150:1: value_chunk : ( literal | EQUALS | COMMA )+ ;
+ public final value_chunk_return value_chunk() throws RecognitionException {
+ value_chunk_return retval = new value_chunk_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token EQUALS23=null;
+ Token COMMA24=null;
+ literal_return literal22 = null;
+
+
+ Object EQUALS23_tree=null;
+ Object COMMA24_tree=null;
+
+ try {
+ // DSLMap.g:151:2: ( ( literal | EQUALS | COMMA )+ )
+ // DSLMap.g:151:4: ( literal | EQUALS | COMMA )+
+ {
+ root_0 = (Object)adaptor.nil();
+
+ // DSLMap.g:151:4: ( literal | EQUALS | COMMA )+
+ int cnt12=0;
+ loop12:
+ do {
+ int alt12=4;
+ switch ( input.LA(1) ) {
+ case LEFT_SQUARE:
+ case RIGHT_SQUARE:
+ case LITERAL:
+ case COLON:
+ {
+ int LA12_2 = input.LA(2);
+
+ if ( (synpred15()) ) {
+ alt12=1;
+ }
+
+
+ }
+ break;
+ case EQUALS:
+ {
+ int LA12_3 = input.LA(2);
+
+ if ( (synpred16()) ) {
+ alt12=2;
+ }
+
+
+ }
+ break;
+ case COMMA:
+ {
+ int LA12_4 = input.LA(2);
+
+ if ( (synpred17()) ) {
+ alt12=3;
+ }
+
+
+ }
+ break;
+
+ }
+
+ switch (alt12) {
+ case 1 :
+ // DSLMap.g:151:5: literal
+ {
+ pushFollow(FOLLOW_literal_in_value_chunk626);
+ literal22=literal();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) adaptor.addChild(root_0, literal22.getTree());
+
+ }
+ break;
+ case 2 :
+ // DSLMap.g:151:13: EQUALS
+ {
+ EQUALS23=(Token)input.LT(1);
+ match(input,EQUALS,FOLLOW_EQUALS_in_value_chunk628); if (failed) return retval;
+ if ( backtracking==0 ) {
+ EQUALS23_tree = (Object)adaptor.create(EQUALS23);
+ adaptor.addChild(root_0, EQUALS23_tree);
+ }
+
+ }
+ break;
+ case 3 :
+ // DSLMap.g:151:20: COMMA
+ {
+ COMMA24=(Token)input.LT(1);
+ match(input,COMMA,FOLLOW_COMMA_in_value_chunk630); if (failed) return retval;
+ if ( backtracking==0 ) {
+ COMMA24_tree = (Object)adaptor.create(COMMA24);
+ adaptor.addChild(root_0, COMMA24_tree);
+ }
+
+ }
+ break;
+
+ default :
+ if ( cnt12 >= 1 ) break loop12;
+ if (backtracking>0) {failed=true; return retval;}
+ EarlyExitException eee =
+ new EarlyExitException(12, input);
+ throw eee;
+ }
+ cnt12++;
+ } while (true);
+
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end value_chunk
+
+ public static class literal_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start literal
+ // DSLMap.g:154:1: literal : ( LITERAL | COLON | LEFT_SQUARE | RIGHT_SQUARE ) ;
+ public final literal_return literal() throws RecognitionException {
+ literal_return retval = new literal_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token set25=null;
+
+ Object set25_tree=null;
+
+ try {
+ // DSLMap.g:156:2: ( ( LITERAL | COLON | LEFT_SQUARE | RIGHT_SQUARE ) )
+ // DSLMap.g:156:4: ( LITERAL | COLON | LEFT_SQUARE | RIGHT_SQUARE )
+ {
+ root_0 = (Object)adaptor.nil();
+
+ set25=(Token)input.LT(1);
+ if ( (input.LA(1)>=LEFT_SQUARE && input.LA(1)<=LITERAL)||input.LA(1)==COLON ) {
+ input.consume();
+ if ( backtracking==0 ) adaptor.addChild(root_0, adaptor.create(set25));
+ errorRecovery=false;failed=false;
+ }
+ else {
+ if (backtracking>0) {failed=true; return retval;}
+ MismatchedSetException mse =
+ new MismatchedSetException(null,input);
+ recoverFromMismatchedSet(input,mse,FOLLOW_set_in_literal648); throw mse;
+ }
+
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end literal
+
+ public static class variable_definition_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start variable_definition
+ // DSLMap.g:160:1: variable_definition : lc= LEFT_CURLY name= LITERAL ( COLON pat= pattern )? rc= RIGHT_CURLY -> {hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) -> {!hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) -> {hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name) -> {!hasSpaceBefore && !hasSpaceAfter}? ^( VT_VAR_DEF $name) -> {hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) VT_SPACE -> {!hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) VT_SPACE -> {hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name) VT_SPACE -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_DEF $name) VT_SPACE -> ^( VT_VAR_DEF $name) ;
+ public final variable_definition_return variable_definition() throws RecognitionException {
+ variable_definition_return retval = new variable_definition_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token lc=null;
+ Token name=null;
+ Token rc=null;
+ Token COLON26=null;
+ pattern_return pat = null;
+
+
+ Object lc_tree=null;
+ Object name_tree=null;
+ Object rc_tree=null;
+ Object COLON26_tree=null;
+ RewriteRuleTokenStream stream_COLON=new RewriteRuleTokenStream(adaptor,"token COLON");
+ RewriteRuleTokenStream stream_RIGHT_CURLY=new RewriteRuleTokenStream(adaptor,"token RIGHT_CURLY");
+ RewriteRuleTokenStream stream_LITERAL=new RewriteRuleTokenStream(adaptor,"token LITERAL");
+ RewriteRuleTokenStream stream_LEFT_CURLY=new RewriteRuleTokenStream(adaptor,"token LEFT_CURLY");
+ RewriteRuleSubtreeStream stream_pattern=new RewriteRuleSubtreeStream(adaptor,"rule pattern");
+
+ String text = "";
+ boolean hasSpaceBefore = false;
+ boolean hasSpaceAfter = false;
+
+ try {
+ // DSLMap.g:166:2: (lc= LEFT_CURLY name= LITERAL ( COLON pat= pattern )? rc= RIGHT_CURLY -> {hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) -> {!hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) -> {hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name) -> {!hasSpaceBefore && !hasSpaceAfter}? ^( VT_VAR_DEF $name) -> {hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) VT_SPACE -> {!hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) VT_SPACE -> {hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name) VT_SPACE -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_DEF $name) VT_SPACE -> ^( VT_VAR_DEF $name) )
+ // DSLMap.g:166:4: lc= LEFT_CURLY name= LITERAL ( COLON pat= pattern )? rc= RIGHT_CURLY
+ {
+ lc=(Token)input.LT(1);
+ match(input,LEFT_CURLY,FOLLOW_LEFT_CURLY_in_variable_definition684); if (failed) return retval;
+ if ( backtracking==0 ) stream_LEFT_CURLY.add(lc);
+
+ if ( backtracking==0 ) {
+
+ CommonToken back2 = (CommonToken)input.LT(-2);
+ if( back2!=null && back2.getStopIndex() < ((CommonToken)lc).getStartIndex() -1 ) hasSpaceBefore = true;
+
+ }
+ name=(Token)input.LT(1);
+ match(input,LITERAL,FOLLOW_LITERAL_in_variable_definition695); if (failed) return retval;
+ if ( backtracking==0 ) stream_LITERAL.add(name);
+
+ // DSLMap.g:171:15: ( COLON pat= pattern )?
+ int alt13=2;
+ int LA13_0 = input.LA(1);
+
+ if ( (LA13_0==COLON) ) {
+ alt13=1;
+ }
+ switch (alt13) {
+ case 1 :
+ // DSLMap.g:171:17: COLON pat= pattern
+ {
+ COLON26=(Token)input.LT(1);
+ match(input,COLON,FOLLOW_COLON_in_variable_definition699); if (failed) return retval;
+ if ( backtracking==0 ) stream_COLON.add(COLON26);
+
+ pushFollow(FOLLOW_pattern_in_variable_definition703);
+ pat=pattern();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_pattern.add(pat.getTree());
+ if ( backtracking==0 ) {
+ text = input.toString(pat.start,pat.stop);
+ }
+
+ }
+ break;
+
+ }
+
+ rc=(Token)input.LT(1);
+ match(input,RIGHT_CURLY,FOLLOW_RIGHT_CURLY_in_variable_definition712); if (failed) return retval;
+ if ( backtracking==0 ) stream_RIGHT_CURLY.add(rc);
+
+ if ( backtracking==0 ) {
+
+ CommonToken rc1 = (CommonToken)input.LT(1);
+ if(!"=".equals(rc1.getText()) && ((CommonToken)rc).getStopIndex() < rc1.getStartIndex() - 1) hasSpaceAfter = true;
+
+ }
+
+ // AST REWRITE
+ // elements: name, name, name, name, name, name, name, name, name
+ // token labels: name
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleTokenStream stream_name=new RewriteRuleTokenStream(adaptor,"token name",name);
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 176:2: -> {hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] )
+ if (hasSpaceBefore && !"".equals(text) && !hasSpaceAfter) {
+ adaptor.addChild(root_0, adaptor.create(VT_SPACE, "VT_SPACE"));
+ // DSLMap.g:176:70: ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] )
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+ adaptor.addChild(root_1, adaptor.create(VT_PATTERN, ((Token)pat.start), text));
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+ else // 177:2: -> {!hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] )
+ if (!hasSpaceBefore && !"".equals(text) && !hasSpaceAfter) {
+ // DSLMap.g:177:63: ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] )
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+ adaptor.addChild(root_1, adaptor.create(VT_PATTERN, ((Token)pat.start), text));
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+ else // 178:2: -> {hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name)
+ if (hasSpaceBefore && !hasSpaceAfter) {
+ adaptor.addChild(root_0, adaptor.create(VT_SPACE, "VT_SPACE"));
+ // DSLMap.g:178:51: ^( VT_VAR_DEF $name)
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+ else // 179:2: -> {!hasSpaceBefore && !hasSpaceAfter}? ^( VT_VAR_DEF $name)
+ if (!hasSpaceBefore && !hasSpaceAfter) {
+ // DSLMap.g:179:44: ^( VT_VAR_DEF $name)
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+ else // 181:2: -> {hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) VT_SPACE
+ if (hasSpaceBefore && !"".equals(text) && hasSpaceAfter) {
+ adaptor.addChild(root_0, adaptor.create(VT_SPACE, "VT_SPACE"));
+ // DSLMap.g:181:69: ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] )
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+ adaptor.addChild(root_1, adaptor.create(VT_PATTERN, ((Token)pat.start), text));
+
+ adaptor.addChild(root_0, root_1);
+ }
+ adaptor.addChild(root_0, adaptor.create(VT_SPACE, "VT_SPACE"));
+
+ }
+ else // 182:2: -> {!hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) VT_SPACE
+ if (!hasSpaceBefore && !"".equals(text) && hasSpaceAfter) {
+ // DSLMap.g:182:62: ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] )
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+ adaptor.addChild(root_1, adaptor.create(VT_PATTERN, ((Token)pat.start), text));
+
+ adaptor.addChild(root_0, root_1);
+ }
+ adaptor.addChild(root_0, adaptor.create(VT_SPACE, "VT_SPACE"));
+
+ }
+ else // 183:2: -> {hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name) VT_SPACE
+ if (hasSpaceBefore && hasSpaceAfter) {
+ adaptor.addChild(root_0, adaptor.create(VT_SPACE, "VT_SPACE"));
+ // DSLMap.g:183:50: ^( VT_VAR_DEF $name)
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+ adaptor.addChild(root_0, adaptor.create(VT_SPACE, "VT_SPACE"));
+
+ }
+ else // 184:2: -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_DEF $name) VT_SPACE
+ if (!hasSpaceBefore && hasSpaceAfter) {
+ // DSLMap.g:184:43: ^( VT_VAR_DEF $name)
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+ adaptor.addChild(root_0, adaptor.create(VT_SPACE, "VT_SPACE"));
+
+ }
+ else // 185:2: -> ^( VT_VAR_DEF $name)
+ {
+ // DSLMap.g:185:5: ^( VT_VAR_DEF $name)
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end variable_definition
+
+ public static class variable_definition2_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start variable_definition2
+ // DSLMap.g:188:1: variable_definition2 : LEFT_CURLY name= LITERAL ( COLON pat= pattern )? RIGHT_CURLY -> {!\"\".equals(text)}? ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) -> ^( VT_VAR_DEF $name) ;
+ public final variable_definition2_return variable_definition2() throws RecognitionException {
+ variable_definition2_return retval = new variable_definition2_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token name=null;
+ Token LEFT_CURLY27=null;
+ Token COLON28=null;
+ Token RIGHT_CURLY29=null;
+ pattern_return pat = null;
+
+
+ Object name_tree=null;
+ Object LEFT_CURLY27_tree=null;
+ Object COLON28_tree=null;
+ Object RIGHT_CURLY29_tree=null;
+ RewriteRuleTokenStream stream_COLON=new RewriteRuleTokenStream(adaptor,"token COLON");
+ RewriteRuleTokenStream stream_RIGHT_CURLY=new RewriteRuleTokenStream(adaptor,"token RIGHT_CURLY");
+ RewriteRuleTokenStream stream_LITERAL=new RewriteRuleTokenStream(adaptor,"token LITERAL");
+ RewriteRuleTokenStream stream_LEFT_CURLY=new RewriteRuleTokenStream(adaptor,"token LEFT_CURLY");
+ RewriteRuleSubtreeStream stream_pattern=new RewriteRuleSubtreeStream(adaptor,"rule pattern");
+
+ String text = "";
+
+ try {
+ // DSLMap.g:192:2: ( LEFT_CURLY name= LITERAL ( COLON pat= pattern )? RIGHT_CURLY -> {!\"\".equals(text)}? ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) -> ^( VT_VAR_DEF $name) )
+ // DSLMap.g:192:4: LEFT_CURLY name= LITERAL ( COLON pat= pattern )? RIGHT_CURLY
+ {
+ LEFT_CURLY27=(Token)input.LT(1);
+ match(input,LEFT_CURLY,FOLLOW_LEFT_CURLY_in_variable_definition2888); if (failed) return retval;
+ if ( backtracking==0 ) stream_LEFT_CURLY.add(LEFT_CURLY27);
+
+ name=(Token)input.LT(1);
+ match(input,LITERAL,FOLLOW_LITERAL_in_variable_definition2892); if (failed) return retval;
+ if ( backtracking==0 ) stream_LITERAL.add(name);
+
+ // DSLMap.g:192:28: ( COLON pat= pattern )?
+ int alt14=2;
+ int LA14_0 = input.LA(1);
+
+ if ( (LA14_0==COLON) ) {
+ alt14=1;
+ }
+ switch (alt14) {
+ case 1 :
+ // DSLMap.g:192:30: COLON pat= pattern
+ {
+ COLON28=(Token)input.LT(1);
+ match(input,COLON,FOLLOW_COLON_in_variable_definition2896); if (failed) return retval;
+ if ( backtracking==0 ) stream_COLON.add(COLON28);
+
+ pushFollow(FOLLOW_pattern_in_variable_definition2900);
+ pat=pattern();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) stream_pattern.add(pat.getTree());
+ if ( backtracking==0 ) {
+ text = input.toString(pat.start,pat.stop);
+ }
+
+ }
+ break;
+
+ }
+
+ RIGHT_CURLY29=(Token)input.LT(1);
+ match(input,RIGHT_CURLY,FOLLOW_RIGHT_CURLY_in_variable_definition2907); if (failed) return retval;
+ if ( backtracking==0 ) stream_RIGHT_CURLY.add(RIGHT_CURLY29);
+
+
+ // AST REWRITE
+ // elements: name, name
+ // token labels: name
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleTokenStream stream_name=new RewriteRuleTokenStream(adaptor,"token name",name);
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 193:2: -> {!\"\".equals(text)}? ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] )
+ if (!"".equals(text)) {
+ // DSLMap.g:193:25: ^( VT_VAR_DEF $name VT_PATTERN[$pat.start, text] )
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+ adaptor.addChild(root_1, adaptor.create(VT_PATTERN, ((Token)pat.start), text));
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+ else // 194:2: -> ^( VT_VAR_DEF $name)
+ {
+ // DSLMap.g:194:5: ^( VT_VAR_DEF $name)
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end variable_definition2
+
+ public static class pattern_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start pattern
+ // DSLMap.g:198:1: pattern : ( literal | LEFT_CURLY literal RIGHT_CURLY | LEFT_SQUARE pattern RIGHT_SQUARE )+ ;
+ public final pattern_return pattern() throws RecognitionException {
+ pattern_return retval = new pattern_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token LEFT_CURLY31=null;
+ Token RIGHT_CURLY33=null;
+ Token LEFT_SQUARE34=null;
+ Token RIGHT_SQUARE36=null;
+ literal_return literal30 = null;
+
+ literal_return literal32 = null;
+
+ pattern_return pattern35 = null;
+
+
+ Object LEFT_CURLY31_tree=null;
+ Object RIGHT_CURLY33_tree=null;
+ Object LEFT_SQUARE34_tree=null;
+ Object RIGHT_SQUARE36_tree=null;
+
+ try {
+ // DSLMap.g:199:9: ( ( literal | LEFT_CURLY literal RIGHT_CURLY | LEFT_SQUARE pattern RIGHT_SQUARE )+ )
+ // DSLMap.g:199:11: ( literal | LEFT_CURLY literal RIGHT_CURLY | LEFT_SQUARE pattern RIGHT_SQUARE )+
+ {
+ root_0 = (Object)adaptor.nil();
+
+ // DSLMap.g:199:11: ( literal | LEFT_CURLY literal RIGHT_CURLY | LEFT_SQUARE pattern RIGHT_SQUARE )+
+ int cnt15=0;
+ loop15:
+ do {
+ int alt15=4;
+ switch ( input.LA(1) ) {
+ case RIGHT_SQUARE:
+ {
+ int LA15_2 = input.LA(2);
+
+ if ( (synpred23()) ) {
+ alt15=1;
+ }
+
+
+ }
+ break;
+ case LEFT_SQUARE:
+ {
+ int LA15_3 = input.LA(2);
+
+ if ( (synpred23()) ) {
+ alt15=1;
+ }
+ else if ( (synpred25()) ) {
+ alt15=3;
+ }
+
+
+ }
+ break;
+ case LEFT_CURLY:
+ {
+ alt15=2;
+ }
+ break;
+ case LITERAL:
+ case COLON:
+ {
+ alt15=1;
+ }
+ break;
+
+ }
+
+ switch (alt15) {
+ case 1 :
+ // DSLMap.g:199:13: literal
+ {
+ pushFollow(FOLLOW_literal_in_pattern958);
+ literal30=literal();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) adaptor.addChild(root_0, literal30.getTree());
+
+ }
+ break;
+ case 2 :
+ // DSLMap.g:200:13: LEFT_CURLY literal RIGHT_CURLY
+ {
+ LEFT_CURLY31=(Token)input.LT(1);
+ match(input,LEFT_CURLY,FOLLOW_LEFT_CURLY_in_pattern972); if (failed) return retval;
+ if ( backtracking==0 ) {
+ LEFT_CURLY31_tree = (Object)adaptor.create(LEFT_CURLY31);
+ adaptor.addChild(root_0, LEFT_CURLY31_tree);
+ }
+ pushFollow(FOLLOW_literal_in_pattern974);
+ literal32=literal();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) adaptor.addChild(root_0, literal32.getTree());
+ RIGHT_CURLY33=(Token)input.LT(1);
+ match(input,RIGHT_CURLY,FOLLOW_RIGHT_CURLY_in_pattern976); if (failed) return retval;
+ if ( backtracking==0 ) {
+ RIGHT_CURLY33_tree = (Object)adaptor.create(RIGHT_CURLY33);
+ adaptor.addChild(root_0, RIGHT_CURLY33_tree);
+ }
+
+ }
+ break;
+ case 3 :
+ // DSLMap.g:201:13: LEFT_SQUARE pattern RIGHT_SQUARE
+ {
+ LEFT_SQUARE34=(Token)input.LT(1);
+ match(input,LEFT_SQUARE,FOLLOW_LEFT_SQUARE_in_pattern990); if (failed) return retval;
+ if ( backtracking==0 ) {
+ LEFT_SQUARE34_tree = (Object)adaptor.create(LEFT_SQUARE34);
+ adaptor.addChild(root_0, LEFT_SQUARE34_tree);
+ }
+ pushFollow(FOLLOW_pattern_in_pattern992);
+ pattern35=pattern();
+ _fsp--;
+ if (failed) return retval;
+ if ( backtracking==0 ) adaptor.addChild(root_0, pattern35.getTree());
+ RIGHT_SQUARE36=(Token)input.LT(1);
+ match(input,RIGHT_SQUARE,FOLLOW_RIGHT_SQUARE_in_pattern994); if (failed) return retval;
+ if ( backtracking==0 ) {
+ RIGHT_SQUARE36_tree = (Object)adaptor.create(RIGHT_SQUARE36);
+ adaptor.addChild(root_0, RIGHT_SQUARE36_tree);
+ }
+
+ }
+ break;
+
+ default :
+ if ( cnt15 >= 1 ) break loop15;
+ if (backtracking>0) {failed=true; return retval;}
+ EarlyExitException eee =
+ new EarlyExitException(15, input);
+ throw eee;
+ }
+ cnt15++;
+ } while (true);
+
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end pattern
+
+ public static class variable_reference_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start variable_reference
+ // DSLMap.g:206:1: variable_reference : lc= LEFT_CURLY name= LITERAL rc= RIGHT_CURLY -> {hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF $name) VT_SPACE -> {hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF $name) -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_REF $name) VT_SPACE -> ^( VT_VAR_REF $name) ;
+ public final variable_reference_return variable_reference() throws RecognitionException {
+ variable_reference_return retval = new variable_reference_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token lc=null;
+ Token name=null;
+ Token rc=null;
+
+ Object lc_tree=null;
+ Object name_tree=null;
+ Object rc_tree=null;
+ RewriteRuleTokenStream stream_RIGHT_CURLY=new RewriteRuleTokenStream(adaptor,"token RIGHT_CURLY");
+ RewriteRuleTokenStream stream_LITERAL=new RewriteRuleTokenStream(adaptor,"token LITERAL");
+ RewriteRuleTokenStream stream_LEFT_CURLY=new RewriteRuleTokenStream(adaptor,"token LEFT_CURLY");
+
+
+ boolean hasSpaceBefore = false;
+ boolean hasSpaceAfter = false;
+
+ try {
+ // DSLMap.g:211:2: (lc= LEFT_CURLY name= LITERAL rc= RIGHT_CURLY -> {hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF $name) VT_SPACE -> {hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF $name) -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_REF $name) VT_SPACE -> ^( VT_VAR_REF $name) )
+ // DSLMap.g:211:4: lc= LEFT_CURLY name= LITERAL rc= RIGHT_CURLY
+ {
+ lc=(Token)input.LT(1);
+ match(input,LEFT_CURLY,FOLLOW_LEFT_CURLY_in_variable_reference1029); if (failed) return retval;
+ if ( backtracking==0 ) stream_LEFT_CURLY.add(lc);
+
+ if ( backtracking==0 ) {
+ //try too figure out how to get " {name} " to realize there's a space infron of the { char
+ CommonToken back2 = (CommonToken)input.LT(-2);
+ if( back2!=null && back2.getStopIndex() < ((CommonToken)lc).getStartIndex() -1 ) hasSpaceBefore = true;
+
+ }
+ name=(Token)input.LT(1);
+ match(input,LITERAL,FOLLOW_LITERAL_in_variable_reference1040); if (failed) return retval;
+ if ( backtracking==0 ) stream_LITERAL.add(name);
+
+ rc=(Token)input.LT(1);
+ match(input,RIGHT_CURLY,FOLLOW_RIGHT_CURLY_in_variable_reference1044); if (failed) return retval;
+ if ( backtracking==0 ) stream_RIGHT_CURLY.add(rc);
+
+ if ( backtracking==0 ) {
+ if(((CommonToken)rc).getStopIndex() < ((CommonToken)input.LT(1)).getStartIndex() - 1) hasSpaceAfter = true;
+ }
+
+ // AST REWRITE
+ // elements: name, name, name, name
+ // token labels: name
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleTokenStream stream_name=new RewriteRuleTokenStream(adaptor,"token name",name);
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 218:2: -> {hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF $name) VT_SPACE
+ if (hasSpaceBefore && hasSpaceAfter) {
+ adaptor.addChild(root_0, adaptor.create(VT_SPACE, "VT_SPACE"));
+ // DSLMap.g:218:49: ^( VT_VAR_REF $name)
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+ adaptor.addChild(root_0, adaptor.create(VT_SPACE, "VT_SPACE"));
+
+ }
+ else // 219:2: -> {hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF $name)
+ if (hasSpaceBefore && !hasSpaceAfter) {
+ adaptor.addChild(root_0, adaptor.create(VT_SPACE, "VT_SPACE"));
+ // DSLMap.g:219:50: ^( VT_VAR_REF $name)
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+ else // 220:2: -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_REF $name) VT_SPACE
+ if (!hasSpaceBefore && hasSpaceAfter) {
+ // DSLMap.g:220:42: ^( VT_VAR_REF $name)
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+ adaptor.addChild(root_0, adaptor.create(VT_SPACE, "VT_SPACE"));
+
+ }
+ else // 221:2: -> ^( VT_VAR_REF $name)
+ {
+ // DSLMap.g:221:6: ^( VT_VAR_REF $name)
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end variable_reference
+
+ public static class variable_reference2_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start variable_reference2
+ // DSLMap.g:225:1: variable_reference2 : LEFT_CURLY name= LITERAL RIGHT_CURLY -> ^( VT_VAR_REF $name) ;
+ public final variable_reference2_return variable_reference2() throws RecognitionException {
+ variable_reference2_return retval = new variable_reference2_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token name=null;
+ Token LEFT_CURLY37=null;
+ Token RIGHT_CURLY38=null;
+
+ Object name_tree=null;
+ Object LEFT_CURLY37_tree=null;
+ Object RIGHT_CURLY38_tree=null;
+ RewriteRuleTokenStream stream_RIGHT_CURLY=new RewriteRuleTokenStream(adaptor,"token RIGHT_CURLY");
+ RewriteRuleTokenStream stream_LITERAL=new RewriteRuleTokenStream(adaptor,"token LITERAL");
+ RewriteRuleTokenStream stream_LEFT_CURLY=new RewriteRuleTokenStream(adaptor,"token LEFT_CURLY");
+
+ try {
+ // DSLMap.g:226:2: ( LEFT_CURLY name= LITERAL RIGHT_CURLY -> ^( VT_VAR_REF $name) )
+ // DSLMap.g:226:4: LEFT_CURLY name= LITERAL RIGHT_CURLY
+ {
+ LEFT_CURLY37=(Token)input.LT(1);
+ match(input,LEFT_CURLY,FOLLOW_LEFT_CURLY_in_variable_reference21122); if (failed) return retval;
+ if ( backtracking==0 ) stream_LEFT_CURLY.add(LEFT_CURLY37);
+
+ name=(Token)input.LT(1);
+ match(input,LITERAL,FOLLOW_LITERAL_in_variable_reference21126); if (failed) return retval;
+ if ( backtracking==0 ) stream_LITERAL.add(name);
+
+ RIGHT_CURLY38=(Token)input.LT(1);
+ match(input,RIGHT_CURLY,FOLLOW_RIGHT_CURLY_in_variable_reference21128); if (failed) return retval;
+ if ( backtracking==0 ) stream_RIGHT_CURLY.add(RIGHT_CURLY38);
+
+
+ // AST REWRITE
+ // elements: name
+ // token labels: name
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleTokenStream stream_name=new RewriteRuleTokenStream(adaptor,"token name",name);
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 227:2: -> ^( VT_VAR_REF $name)
+ {
+ // DSLMap.g:227:5: ^( VT_VAR_REF $name)
+ {
+ Object root_1 = (Object)adaptor.nil();
+ root_1 = (Object)adaptor.becomeRoot(adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
+
+ adaptor.addChild(root_1, stream_name.next());
+
+ adaptor.addChild(root_0, root_1);
+ }
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end variable_reference2
+
+ public static class condition_key_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start condition_key
+ // DSLMap.g:231:1: condition_key : {...}?value= LITERAL -> VT_CONDITION[$value] ;
+ public final condition_key_return condition_key() throws RecognitionException {
+ condition_key_return retval = new condition_key_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token value=null;
+
+ Object value_tree=null;
+ RewriteRuleTokenStream stream_LITERAL=new RewriteRuleTokenStream(adaptor,"token LITERAL");
+
+ try {
+ // DSLMap.g:232:2: ({...}?value= LITERAL -> VT_CONDITION[$value] )
+ // DSLMap.g:232:4: {...}?value= LITERAL
+ {
+ if ( !(validateIdentifierKey("condition")||validateIdentifierKey("when")) ) {
+ if (backtracking>0) {failed=true; return retval;}
+ throw new FailedPredicateException(input, "condition_key", "validateIdentifierKey(\"condition\")||validateIdentifierKey(\"when\")");
+ }
+ value=(Token)input.LT(1);
+ match(input,LITERAL,FOLLOW_LITERAL_in_condition_key1157); if (failed) return retval;
+ if ( backtracking==0 ) stream_LITERAL.add(value);
+
+
+ // AST REWRITE
+ // elements:
+ // token labels:
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 233:2: -> VT_CONDITION[$value]
+ {
+ adaptor.addChild(root_0, adaptor.create(VT_CONDITION, value));
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end condition_key
+
+ public static class consequence_key_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start consequence_key
+ // DSLMap.g:236:1: consequence_key : {...}?value= LITERAL -> VT_CONSEQUENCE[$value] ;
+ public final consequence_key_return consequence_key() throws RecognitionException {
+ consequence_key_return retval = new consequence_key_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token value=null;
+
+ Object value_tree=null;
+ RewriteRuleTokenStream stream_LITERAL=new RewriteRuleTokenStream(adaptor,"token LITERAL");
+
+ try {
+ // DSLMap.g:237:2: ({...}?value= LITERAL -> VT_CONSEQUENCE[$value] )
+ // DSLMap.g:237:4: {...}?value= LITERAL
+ {
+ if ( !(validateIdentifierKey("consequence")||validateIdentifierKey("then")) ) {
+ if (backtracking>0) {failed=true; return retval;}
+ throw new FailedPredicateException(input, "consequence_key", "validateIdentifierKey(\"consequence\")||validateIdentifierKey(\"then\")");
+ }
+ value=(Token)input.LT(1);
+ match(input,LITERAL,FOLLOW_LITERAL_in_consequence_key1180); if (failed) return retval;
+ if ( backtracking==0 ) stream_LITERAL.add(value);
+
+
+ // AST REWRITE
+ // elements:
+ // token labels:
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 238:2: -> VT_CONSEQUENCE[$value]
+ {
+ adaptor.addChild(root_0, adaptor.create(VT_CONSEQUENCE, value));
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end consequence_key
+
+ public static class keyword_key_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start keyword_key
+ // DSLMap.g:241:1: keyword_key : {...}?value= LITERAL -> VT_KEYWORD[$value] ;
+ public final keyword_key_return keyword_key() throws RecognitionException {
+ keyword_key_return retval = new keyword_key_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token value=null;
+
+ Object value_tree=null;
+ RewriteRuleTokenStream stream_LITERAL=new RewriteRuleTokenStream(adaptor,"token LITERAL");
+
+ try {
+ // DSLMap.g:242:2: ({...}?value= LITERAL -> VT_KEYWORD[$value] )
+ // DSLMap.g:242:4: {...}?value= LITERAL
+ {
+ if ( !(validateIdentifierKey("keyword")) ) {
+ if (backtracking>0) {failed=true; return retval;}
+ throw new FailedPredicateException(input, "keyword_key", "validateIdentifierKey(\"keyword\")");
+ }
+ value=(Token)input.LT(1);
+ match(input,LITERAL,FOLLOW_LITERAL_in_keyword_key1203); if (failed) return retval;
+ if ( backtracking==0 ) stream_LITERAL.add(value);
+
+
+ // AST REWRITE
+ // elements:
+ // token labels:
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 243:2: -> VT_KEYWORD[$value]
+ {
+ adaptor.addChild(root_0, adaptor.create(VT_KEYWORD, value));
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end keyword_key
+
+ public static class any_key_return extends ParserRuleReturnScope {
+ Object tree;
+ public Object getTree() { return tree; }
+ };
+
+ // $ANTLR start any_key
+ // DSLMap.g:246:1: any_key : {...}?value= LITERAL -> VT_ANY[$value] ;
+ public final any_key_return any_key() throws RecognitionException {
+ any_key_return retval = new any_key_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token value=null;
+
+ Object value_tree=null;
+ RewriteRuleTokenStream stream_LITERAL=new RewriteRuleTokenStream(adaptor,"token LITERAL");
+
+ try {
+ // DSLMap.g:247:2: ({...}?value= LITERAL -> VT_ANY[$value] )
+ // DSLMap.g:247:4: {...}?value= LITERAL
+ {
+ if ( !(validateIdentifierKey("*")) ) {
+ if (backtracking>0) {failed=true; return retval;}
+ throw new FailedPredicateException(input, "any_key", "validateIdentifierKey(\"*\")");
+ }
+ value=(Token)input.LT(1);
+ match(input,LITERAL,FOLLOW_LITERAL_in_any_key1226); if (failed) return retval;
+ if ( backtracking==0 ) stream_LITERAL.add(value);
+
+
+ // AST REWRITE
+ // elements:
+ // token labels:
+ // rule labels: retval
+ // token list labels:
+ // rule list labels:
+ if ( backtracking==0 ) {
+ retval.tree = root_0;
+ RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
+
+ root_0 = (Object)adaptor.nil();
+ // 248:2: -> VT_ANY[$value]
+ {
+ adaptor.addChild(root_0, adaptor.create(VT_ANY, value));
+
+ }
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ if ( backtracking==0 ) {
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+ }
+ }
+
+ catch (RecognitionException e) {
+ throw e;
+ }
+ finally {
+ }
+ return retval;
+ }
+ // $ANTLR end any_key
+
+ // $ANTLR start synpred4
+ public final void synpred4_fragment() throws RecognitionException {
+ // DSLMap.g:94:24: ( meta_section )
+ // DSLMap.g:94:24: meta_section
+ {
+ pushFollow(FOLLOW_meta_section_in_synpred4341);
+ meta_section();
+ _fsp--;
+ if (failed) return ;
+
+ }
+ }
+ // $ANTLR end synpred4
+
+ // $ANTLR start synpred6
+ public final void synpred6_fragment() throws RecognitionException {
+ // DSLMap.g:102:4: ( condition_key )
+ // DSLMap.g:102:4: condition_key
+ {
+ pushFollow(FOLLOW_condition_key_in_synpred6392);
+ condition_key();
+ _fsp--;
+ if (failed) return ;
+
+ }
+ }
+ // $ANTLR end synpred6
+
+ // $ANTLR start synpred7
+ public final void synpred7_fragment() throws RecognitionException {
+ // DSLMap.g:103:5: ( consequence_key )
+ // DSLMap.g:103:5: consequence_key
+ {
+ pushFollow(FOLLOW_consequence_key_in_synpred7401);
+ consequence_key();
+ _fsp--;
+ if (failed) return ;
+
+ }
+ }
+ // $ANTLR end synpred7
+
+ // $ANTLR start synpred8
+ public final void synpred8_fragment() throws RecognitionException {
+ // DSLMap.g:104:5: ( keyword_key )
+ // DSLMap.g:104:5: keyword_key
+ {
+ pushFollow(FOLLOW_keyword_key_in_synpred8409);
+ keyword_key();
+ _fsp--;
+ if (failed) return ;
+
+ }
+ }
+ // $ANTLR end synpred8
+
+ // $ANTLR start synpred12
+ public final void synpred12_fragment() throws RecognitionException {
+ // DSLMap.g:133:4: ( literal )
+ // DSLMap.g:133:4: literal
+ {
+ pushFollow(FOLLOW_literal_in_synpred12551);
+ literal();
+ _fsp--;
+ if (failed) return ;
+
+ }
+ }
+ // $ANTLR end synpred12
+
+ // $ANTLR start synpred15
+ public final void synpred15_fragment() throws RecognitionException {
+ // DSLMap.g:151:5: ( literal )
+ // DSLMap.g:151:5: literal
+ {
+ pushFollow(FOLLOW_literal_in_synpred15626);
+ literal();
+ _fsp--;
+ if (failed) return ;
+
+ }
+ }
+ // $ANTLR end synpred15
+
+ // $ANTLR start synpred16
+ public final void synpred16_fragment() throws RecognitionException {
+ // DSLMap.g:151:13: ( EQUALS )
+ // DSLMap.g:151:13: EQUALS
+ {
+ match(input,EQUALS,FOLLOW_EQUALS_in_synpred16628); if (failed) return ;
+
+ }
+ }
+ // $ANTLR end synpred16
+
+ // $ANTLR start synpred17
+ public final void synpred17_fragment() throws RecognitionException {
+ // DSLMap.g:151:20: ( COMMA )
+ // DSLMap.g:151:20: COMMA
+ {
+ match(input,COMMA,FOLLOW_COMMA_in_synpred17630); if (failed) return ;
+
+ }
+ }
+ // $ANTLR end synpred17
+
+ // $ANTLR start synpred23
+ public final void synpred23_fragment() throws RecognitionException {
+ // DSLMap.g:199:13: ( literal )
+ // DSLMap.g:199:13: literal
+ {
+ pushFollow(FOLLOW_literal_in_synpred23958);
+ literal();
+ _fsp--;
+ if (failed) return ;
+
+ }
+ }
+ // $ANTLR end synpred23
+
+ // $ANTLR start synpred25
+ public final void synpred25_fragment() throws RecognitionException {
+ // DSLMap.g:201:13: ( LEFT_SQUARE pattern RIGHT_SQUARE )
+ // DSLMap.g:201:13: LEFT_SQUARE pattern RIGHT_SQUARE
+ {
+ match(input,LEFT_SQUARE,FOLLOW_LEFT_SQUARE_in_synpred25990); if (failed) return ;
+ pushFollow(FOLLOW_pattern_in_synpred25992);
+ pattern();
+ _fsp--;
+ if (failed) return ;
+ match(input,RIGHT_SQUARE,FOLLOW_RIGHT_SQUARE_in_synpred25994); if (failed) return ;
+
+ }
+ }
+ // $ANTLR end synpred25
+
+ public final boolean synpred12() {
+ backtracking++;
+ int start = input.mark();
+ try {
+ synpred12_fragment(); // can never throw exception
+ } catch (RecognitionException re) {
+ System.err.println("impossible: "+re);
+ }
+ boolean success = !failed;
+ input.rewind(start);
+ backtracking--;
+ failed=false;
+ return success;
+ }
+ public final boolean synpred4() {
+ backtracking++;
+ int start = input.mark();
+ try {
+ synpred4_fragment(); // can never throw exception
+ } catch (RecognitionException re) {
+ System.err.println("impossible: "+re);
+ }
+ boolean success = !failed;
+ input.rewind(start);
+ backtracking--;
+ failed=false;
+ return success;
+ }
+ public final boolean synpred25() {
+ backtracking++;
+ int start = input.mark();
+ try {
+ synpred25_fragment(); // can never throw exception
+ } catch (RecognitionException re) {
+ System.err.println("impossible: "+re);
+ }
+ boolean success = !failed;
+ input.rewind(start);
+ backtracking--;
+ failed=false;
+ return success;
+ }
+ public final boolean synpred23() {
+ backtracking++;
+ int start = input.mark();
+ try {
+ synpred23_fragment(); // can never throw exception
+ } catch (RecognitionException re) {
+ System.err.println("impossible: "+re);
+ }
+ boolean success = !failed;
+ input.rewind(start);
+ backtracking--;
+ failed=false;
+ return success;
+ }
+ public final boolean synpred16() {
+ backtracking++;
+ int start = input.mark();
+ try {
+ synpred16_fragment(); // can never throw exception
+ } catch (RecognitionException re) {
+ System.err.println("impossible: "+re);
+ }
+ boolean success = !failed;
+ input.rewind(start);
+ backtracking--;
+ failed=false;
+ return success;
+ }
+ public final boolean synpred7() {
+ backtracking++;
+ int start = input.mark();
+ try {
+ synpred7_fragment(); // can never throw exception
+ } catch (RecognitionException re) {
+ System.err.println("impossible: "+re);
+ }
+ boolean success = !failed;
+ input.rewind(start);
+ backtracking--;
+ failed=false;
+ return success;
+ }
+ public final boolean synpred17() {
+ backtracking++;
+ int start = input.mark();
+ try {
+ synpred17_fragment(); // can never throw exception
+ } catch (RecognitionException re) {
+ System.err.println("impossible: "+re);
+ }
+ boolean success = !failed;
+ input.rewind(start);
+ backtracking--;
+ failed=false;
+ return success;
+ }
+ public final boolean synpred6() {
+ backtracking++;
+ int start = input.mark();
+ try {
+ synpred6_fragment(); // can never throw exception
+ } catch (RecognitionException re) {
+ System.err.println("impossible: "+re);
+ }
+ boolean success = !failed;
+ input.rewind(start);
+ backtracking--;
+ failed=false;
+ return success;
+ }
+ public final boolean synpred15() {
+ backtracking++;
+ int start = input.mark();
+ try {
+ synpred15_fragment(); // can never throw exception
+ } catch (RecognitionException re) {
+ System.err.println("impossible: "+re);
+ }
+ boolean success = !failed;
+ input.rewind(start);
+ backtracking--;
+ failed=false;
+ return success;
+ }
+ public final boolean synpred8() {
+ backtracking++;
+ int start = input.mark();
+ try {
+ synpred8_fragment(); // can never throw exception
+ } catch (RecognitionException re) {
+ System.err.println("impossible: "+re);
+ }
+ boolean success = !failed;
+ input.rewind(start);
+ backtracking--;
+ failed=false;
+ return success;
+ }
+
+
+
+
+ public static final BitSet FOLLOW_statement_in_mapping_file262 = new BitSet(new long[]{0x0000000000B00002L});
+ public static final BitSet FOLLOW_entry_in_statement285 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_comment_in_statement292 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_EOL_in_statement298 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LINE_COMMENT_in_comment314 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_scope_section_in_entry339 = new BitSet(new long[]{0x000000001B800000L});
+ public static final BitSet FOLLOW_meta_section_in_entry341 = new BitSet(new long[]{0x000000001B800000L});
+ public static final BitSet FOLLOW_key_section_in_entry344 = new BitSet(new long[]{0x0000000000400000L});
+ public static final BitSet FOLLOW_EQUALS_in_entry346 = new BitSet(new long[]{0x000000001FC00000L});
+ public static final BitSet FOLLOW_value_section_in_entry348 = new BitSet(new long[]{0x0000000000100000L});
+ public static final BitSet FOLLOW_EOL_in_entry351 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_EOF_in_entry353 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LEFT_SQUARE_in_scope_section384 = new BitSet(new long[]{0x0000000002000000L});
+ public static final BitSet FOLLOW_condition_key_in_scope_section392 = new BitSet(new long[]{0x0000000001000000L});
+ public static final BitSet FOLLOW_consequence_key_in_scope_section401 = new BitSet(new long[]{0x0000000001000000L});
+ public static final BitSet FOLLOW_keyword_key_in_scope_section409 = new BitSet(new long[]{0x0000000001000000L});
+ public static final BitSet FOLLOW_any_key_in_scope_section417 = new BitSet(new long[]{0x0000000001000000L});
+ public static final BitSet FOLLOW_RIGHT_SQUARE_in_scope_section425 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LEFT_SQUARE_in_meta_section463 = new BitSet(new long[]{0x0000000003000000L});
+ public static final BitSet FOLLOW_LITERAL_in_meta_section465 = new BitSet(new long[]{0x0000000001000000L});
+ public static final BitSet FOLLOW_RIGHT_SQUARE_in_meta_section468 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_key_sentence_in_key_section492 = new BitSet(new long[]{0x000000001B800002L});
+ public static final BitSet FOLLOW_variable_definition_in_key_sentence523 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_key_chunk_in_key_sentence530 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_literal_in_key_chunk551 = new BitSet(new long[]{0x000000000B800002L});
+ public static final BitSet FOLLOW_value_sentence_in_value_section566 = new BitSet(new long[]{0x000000001FC00002L});
+ public static final BitSet FOLLOW_variable_reference_in_value_sentence597 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_value_chunk_in_value_sentence604 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_literal_in_value_chunk626 = new BitSet(new long[]{0x000000000FC00002L});
+ public static final BitSet FOLLOW_EQUALS_in_value_chunk628 = new BitSet(new long[]{0x000000000FC00002L});
+ public static final BitSet FOLLOW_COMMA_in_value_chunk630 = new BitSet(new long[]{0x000000000FC00002L});
+ public static final BitSet FOLLOW_set_in_literal648 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LEFT_CURLY_in_variable_definition684 = new BitSet(new long[]{0x0000000002000000L});
+ public static final BitSet FOLLOW_LITERAL_in_variable_definition695 = new BitSet(new long[]{0x0000000028000000L});
+ public static final BitSet FOLLOW_COLON_in_variable_definition699 = new BitSet(new long[]{0x000000001B800000L});
+ public static final BitSet FOLLOW_pattern_in_variable_definition703 = new BitSet(new long[]{0x0000000020000000L});
+ public static final BitSet FOLLOW_RIGHT_CURLY_in_variable_definition712 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LEFT_CURLY_in_variable_definition2888 = new BitSet(new long[]{0x0000000002000000L});
+ public static final BitSet FOLLOW_LITERAL_in_variable_definition2892 = new BitSet(new long[]{0x0000000028000000L});
+ public static final BitSet FOLLOW_COLON_in_variable_definition2896 = new BitSet(new long[]{0x000000001B800000L});
+ public static final BitSet FOLLOW_pattern_in_variable_definition2900 = new BitSet(new long[]{0x0000000020000000L});
+ public static final BitSet FOLLOW_RIGHT_CURLY_in_variable_definition2907 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_literal_in_pattern958 = new BitSet(new long[]{0x000000001B800002L});
+ public static final BitSet FOLLOW_LEFT_CURLY_in_pattern972 = new BitSet(new long[]{0x000000000B800000L});
+ public static final BitSet FOLLOW_literal_in_pattern974 = new BitSet(new long[]{0x0000000020000000L});
+ public static final BitSet FOLLOW_RIGHT_CURLY_in_pattern976 = new BitSet(new long[]{0x000000001B800002L});
+ public static final BitSet FOLLOW_LEFT_SQUARE_in_pattern990 = new BitSet(new long[]{0x000000001B800000L});
+ public static final BitSet FOLLOW_pattern_in_pattern992 = new BitSet(new long[]{0x0000000001000000L});
+ public static final BitSet FOLLOW_RIGHT_SQUARE_in_pattern994 = new BitSet(new long[]{0x000000001B800002L});
+ public static final BitSet FOLLOW_LEFT_CURLY_in_variable_reference1029 = new BitSet(new long[]{0x0000000002000000L});
+ public static final BitSet FOLLOW_LITERAL_in_variable_reference1040 = new BitSet(new long[]{0x0000000020000000L});
+ public static final BitSet FOLLOW_RIGHT_CURLY_in_variable_reference1044 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LEFT_CURLY_in_variable_reference21122 = new BitSet(new long[]{0x0000000002000000L});
+ public static final BitSet FOLLOW_LITERAL_in_variable_reference21126 = new BitSet(new long[]{0x0000000020000000L});
+ public static final BitSet FOLLOW_RIGHT_CURLY_in_variable_reference21128 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LITERAL_in_condition_key1157 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LITERAL_in_consequence_key1180 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LITERAL_in_keyword_key1203 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LITERAL_in_any_key1226 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_meta_section_in_synpred4341 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_condition_key_in_synpred6392 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_consequence_key_in_synpred7401 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_keyword_key_in_synpred8409 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_literal_in_synpred12551 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_literal_in_synpred15626 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_EQUALS_in_synpred16628 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_COMMA_in_synpred17630 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_literal_in_synpred23958 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LEFT_SQUARE_in_synpred25990 = new BitSet(new long[]{0x000000001B800000L});
+ public static final BitSet FOLLOW_pattern_in_synpred25992 = new BitSet(new long[]{0x0000000001000000L});
+ public static final BitSet FOLLOW_RIGHT_SQUARE_in_synpred25994 = new BitSet(new long[]{0x0000000000000002L});
+
+}
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapWalker.java (from rev 20284, labs/jbossrules/branches/mattgeis/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapWalker.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapWalker.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapWalker.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -0,0 +1,1042 @@
+// $ANTLR 3.0.1 DSLMapWalker.g 2008-05-27 14:03:46
+
+ package org.drools.lang.dsl;
+
+ import java.util.Map;
+ import java.util.HashMap;
+
+
+
+import org.antlr.runtime.*;
+import org.antlr.runtime.tree.*;import java.util.Stack;
+import java.util.List;
+import java.util.ArrayList;
+
+public class DSLMapWalker extends TreeParser {
+ public static final String[] tokenNames = new String[] {
+ "<invalid>", "<EOR>", "<DOWN>", "<UP>", "VT_DSL_GRAMMAR", "VT_COMMENT", "VT_ENTRY", "VT_SCOPE", "VT_CONDITION", "VT_CONSEQUENCE", "VT_KEYWORD", "VT_ANY", "VT_META", "VT_ENTRY_KEY", "VT_ENTRY_VAL", "VT_VAR_DEF", "VT_VAR_REF", "VT_LITERAL", "VT_PATTERN", "VT_SPACE", "EOL", "LINE_COMMENT", "EQUALS", "LEFT_SQUARE", "RIGHT_SQUARE", "LITERAL", "COLON", "LEFT_CURLY", "RIGHT_CURLY", "WS", "EscapeSequence", "DOT", "POUND", "MISC"
+ };
+ public static final int RIGHT_CURLY=28;
+ public static final int VT_ENTRY_VAL=14;
+ public static final int WS=29;
+ public static final int MISC=33;
+ public static final int VT_META=12;
+ public static final int VT_CONSEQUENCE=9;
+ public static final int VT_SPACE=19;
+ public static final int LINE_COMMENT=21;
+ public static final int VT_ANY=11;
+ public static final int VT_LITERAL=17;
+ public static final int DOT=31;
+ public static final int EQUALS=22;
+ public static final int VT_DSL_GRAMMAR=4;
+ public static final int VT_CONDITION=8;
+ public static final int VT_ENTRY=6;
+ public static final int VT_VAR_DEF=15;
+ public static final int VT_PATTERN=18;
+ public static final int LITERAL=25;
+ public static final int EscapeSequence=30;
+ public static final int VT_COMMENT=5;
+ public static final int EOF=-1;
+ public static final int EOL=20;
+ public static final int LEFT_SQUARE=23;
+ public static final int VT_ENTRY_KEY=13;
+ public static final int VT_SCOPE=7;
+ public static final int COLON=26;
+ public static final int VT_KEYWORD=10;
+ public static final int VT_VAR_REF=16;
+ public static final int LEFT_CURLY=27;
+ public static final int POUND=32;
+ public static final int RIGHT_SQUARE=24;
+
+ public DSLMapWalker(TreeNodeStream input) {
+ super(input);
+ }
+
+
+ public String[] getTokenNames() { return tokenNames; }
+ public String getGrammarFileName() { return "DSLMapWalker.g"; }
+
+
+ protected static class mapping_file_scope {
+ DSLMapping retval;
+ }
+ protected Stack mapping_file_stack = new Stack();
+
+
+ // $ANTLR start mapping_file
+ // DSLMapWalker.g:17:1: mapping_file returns [DSLMapping mapping] : ^( VT_DSL_GRAMMAR ( entry )* ) ;
+ public final DSLMapping mapping_file() throws RecognitionException {
+ mapping_file_stack.push(new mapping_file_scope());
+ DSLMapping mapping = null;
+
+
+ ((mapping_file_scope)mapping_file_stack.peek()).retval = new DefaultDSLMapping() ;
+
+ try {
+ // DSLMapWalker.g:24:2: ( ^( VT_DSL_GRAMMAR ( entry )* ) )
+ // DSLMapWalker.g:24:4: ^( VT_DSL_GRAMMAR ( entry )* )
+ {
+ match(input,VT_DSL_GRAMMAR,FOLLOW_VT_DSL_GRAMMAR_in_mapping_file54);
+
+ if ( input.LA(1)==Token.DOWN ) {
+ match(input, Token.DOWN, null);
+ // DSLMapWalker.g:24:21: ( entry )*
+ loop1:
+ do {
+ int alt1=2;
+ int LA1_0 = input.LA(1);
+
+ if ( (LA1_0==VT_ENTRY) ) {
+ alt1=1;
+ }
+
+
+ switch (alt1) {
+ case 1 :
+ // DSLMapWalker.g:24:21: entry
+ {
+ pushFollow(FOLLOW_entry_in_mapping_file56);
+ entry();
+ _fsp--;
+
+
+ }
+ break;
+
+ default :
+ break loop1;
+ }
+ } while (true);
+
+
+ match(input, Token.UP, null);
+ }
+
+ //System.out.println("done parsing file");
+ //System.out.println(((mapping_file_scope)mapping_file_stack.peek()).retval.dumpFile());
+ mapping = ((mapping_file_scope)mapping_file_stack.peek()).retval;
+ //java.io.StringWriter sw = new java.io.StringWriter();
+ //((mapping_file_scope)mapping_file_stack.peek()).retval.saveMapping(sw);
+ //System.out.println(sw.toString());
+
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ mapping_file_stack.pop();
+ }
+ return mapping;
+ }
+ // $ANTLR end mapping_file
+
+
+ // $ANTLR start mapping_entry
+ // DSLMapWalker.g:35:1: mapping_entry : ent= entry ;
+ public final void mapping_entry() throws RecognitionException {
+ DSLMappingEntry ent = null;
+
+
+ try {
+ // DSLMapWalker.g:36:2: (ent= entry )
+ // DSLMapWalker.g:36:4: ent= entry
+ {
+ pushFollow(FOLLOW_entry_in_mapping_entry76);
+ ent=entry();
+ _fsp--;
+
+
+ ((mapping_file_scope)mapping_file_stack.peek()).retval.addEntry(ent);
+ //System.out.println("mapping size is now " + ((mapping_file_scope)mapping_file_stack.peek()).retval.getEntries().size());
+
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end mapping_entry
+
+
+ // $ANTLR start valid_entry
+ // DSLMapWalker.g:43:1: valid_entry returns [DSLMappingEntry mappingEntry] : (ent= entry | VT_COMMENT );
+ public final DSLMappingEntry valid_entry() throws RecognitionException {
+ DSLMappingEntry mappingEntry = null;
+
+ DSLMappingEntry ent = null;
+
+
+ try {
+ // DSLMapWalker.g:44:2: (ent= entry | VT_COMMENT )
+ int alt2=2;
+ int LA2_0 = input.LA(1);
+
+ if ( (LA2_0==VT_ENTRY) ) {
+ alt2=1;
+ }
+ else if ( (LA2_0==VT_COMMENT) ) {
+ alt2=2;
+ }
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("43:1: valid_entry returns [DSLMappingEntry mappingEntry] : (ent= entry | VT_COMMENT );", 2, 0, input);
+
+ throw nvae;
+ }
+ switch (alt2) {
+ case 1 :
+ // DSLMapWalker.g:44:4: ent= entry
+ {
+ pushFollow(FOLLOW_entry_in_valid_entry97);
+ ent=entry();
+ _fsp--;
+
+ mappingEntry = ent;
+
+ }
+ break;
+ case 2 :
+ // DSLMapWalker.g:45:4: VT_COMMENT
+ {
+ match(input,VT_COMMENT,FOLLOW_VT_COMMENT_in_valid_entry104);
+ mappingEntry = null;
+
+ }
+ break;
+
+ }
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return mappingEntry;
+ }
+ // $ANTLR end valid_entry
+
+ protected static class entry_scope {
+ Map variables;
+ AntlrDSLMappingEntry retval;
+ int counter;
+ StringBuffer keybuffer;
+ StringBuffer valuebuffer;
+ }
+ protected Stack entry_stack = new Stack();
+
+
+ // $ANTLR start entry
+ // DSLMapWalker.g:49:1: entry returns [DSLMappingEntry mappingEntry] : ^( VT_ENTRY scope_section ( meta_section )? key_section value_section ) ;
+ public final DSLMappingEntry entry() throws RecognitionException {
+ entry_stack.push(new entry_scope());
+ DSLMappingEntry mappingEntry = null;
+
+
+ ((entry_scope)entry_stack.peek()).retval = new AntlrDSLMappingEntry() ;
+ ((entry_scope)entry_stack.peek()).variables = new HashMap();
+ ((entry_scope)entry_stack.peek()).keybuffer = new StringBuffer();
+ ((entry_scope)entry_stack.peek()).valuebuffer = new StringBuffer();
+
+ try {
+ // DSLMapWalker.g:63:2: ( ^( VT_ENTRY scope_section ( meta_section )? key_section value_section ) )
+ // DSLMapWalker.g:63:4: ^( VT_ENTRY scope_section ( meta_section )? key_section value_section )
+ {
+ match(input,VT_ENTRY,FOLLOW_VT_ENTRY_in_entry132);
+
+ match(input, Token.DOWN, null);
+ pushFollow(FOLLOW_scope_section_in_entry134);
+ scope_section();
+ _fsp--;
+
+ // DSLMapWalker.g:63:29: ( meta_section )?
+ int alt3=2;
+ int LA3_0 = input.LA(1);
+
+ if ( (LA3_0==VT_META) ) {
+ alt3=1;
+ }
+ switch (alt3) {
+ case 1 :
+ // DSLMapWalker.g:63:29: meta_section
+ {
+ pushFollow(FOLLOW_meta_section_in_entry136);
+ meta_section();
+ _fsp--;
+
+
+ }
+ break;
+
+ }
+
+ pushFollow(FOLLOW_key_section_in_entry139);
+ key_section();
+ _fsp--;
+
+ ((entry_scope)entry_stack.peek()).retval.variables = ((entry_scope)entry_stack.peek()).variables; ((entry_scope)entry_stack.peek()).retval.setMappingKey(((entry_scope)entry_stack.peek()).keybuffer.toString());
+ pushFollow(FOLLOW_value_section_in_entry145);
+ value_section();
+ _fsp--;
+
+
+ match(input, Token.UP, null);
+
+ //System.out.println("for this entry, metadata is " + ((entry_scope)entry_stack.peek()).retval.getMetaData().getMetaData());
+ //System.out.println("variables are " + ((entry_scope)entry_stack.peek()).variables);
+
+ //System.out.println("keybuffer: " + ((entry_scope)entry_stack.peek()).keybuffer);
+ //System.out.println("valuebuffer: " + ((entry_scope)entry_stack.peek()).valuebuffer);
+ // ((mapping_file_scope)mapping_file_stack.peek()).retval.addEntry(((entry_scope)entry_stack.peek()).retval);
+ // System.out.println("mapping size is now " + ((mapping_file_scope)mapping_file_stack.peek()).retval.getEntries().size());
+ //((entry_scope)entry_stack.peek()).retval.variables = ((entry_scope)entry_stack.peek()).variables;
+ //((entry_scope)entry_stack.peek()).retval.setMappingKey(((entry_scope)entry_stack.peek()).keybuffer.toString());
+ ((entry_scope)entry_stack.peek()).retval.setMappingValue(((entry_scope)entry_stack.peek()).valuebuffer.toString());
+ //System.out.println("keypattern is " + ((entry_scope)entry_stack.peek()).retval.getKeyPattern());
+ //System.out.println("valuepattern is " + ((entry_scope)entry_stack.peek()).retval.getValuePattern());
+ mappingEntry = ((entry_scope)entry_stack.peek()).retval;
+
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ entry_stack.pop();
+ }
+ return mappingEntry;
+ }
+ // $ANTLR end entry
+
+
+ // $ANTLR start scope_section
+ // DSLMapWalker.g:83:1: scope_section : ^(thescope= VT_SCOPE ( condition_key )? ( consequence_key )? ( keyword_key )? ( any_key )? ) ;
+ public final void scope_section() throws RecognitionException {
+ CommonTree thescope=null;
+
+ try {
+ // DSLMapWalker.g:84:2: ( ^(thescope= VT_SCOPE ( condition_key )? ( consequence_key )? ( keyword_key )? ( any_key )? ) )
+ // DSLMapWalker.g:84:4: ^(thescope= VT_SCOPE ( condition_key )? ( consequence_key )? ( keyword_key )? ( any_key )? )
+ {
+ thescope=(CommonTree)input.LT(1);
+ match(input,VT_SCOPE,FOLLOW_VT_SCOPE_in_scope_section165);
+
+ if ( input.LA(1)==Token.DOWN ) {
+ match(input, Token.DOWN, null);
+ // DSLMapWalker.g:84:24: ( condition_key )?
+ int alt4=2;
+ int LA4_0 = input.LA(1);
+
+ if ( (LA4_0==VT_CONDITION) ) {
+ alt4=1;
+ }
+ switch (alt4) {
+ case 1 :
+ // DSLMapWalker.g:84:24: condition_key
+ {
+ pushFollow(FOLLOW_condition_key_in_scope_section167);
+ condition_key();
+ _fsp--;
+
+
+ }
+ break;
+
+ }
+
+ // DSLMapWalker.g:84:39: ( consequence_key )?
+ int alt5=2;
+ int LA5_0 = input.LA(1);
+
+ if ( (LA5_0==VT_CONSEQUENCE) ) {
+ alt5=1;
+ }
+ switch (alt5) {
+ case 1 :
+ // DSLMapWalker.g:84:39: consequence_key
+ {
+ pushFollow(FOLLOW_consequence_key_in_scope_section170);
+ consequence_key();
+ _fsp--;
+
+
+ }
+ break;
+
+ }
+
+ // DSLMapWalker.g:84:56: ( keyword_key )?
+ int alt6=2;
+ int LA6_0 = input.LA(1);
+
+ if ( (LA6_0==VT_KEYWORD) ) {
+ alt6=1;
+ }
+ switch (alt6) {
+ case 1 :
+ // DSLMapWalker.g:84:56: keyword_key
+ {
+ pushFollow(FOLLOW_keyword_key_in_scope_section173);
+ keyword_key();
+ _fsp--;
+
+
+ }
+ break;
+
+ }
+
+ // DSLMapWalker.g:84:69: ( any_key )?
+ int alt7=2;
+ int LA7_0 = input.LA(1);
+
+ if ( (LA7_0==VT_ANY) ) {
+ alt7=1;
+ }
+ switch (alt7) {
+ case 1 :
+ // DSLMapWalker.g:84:69: any_key
+ {
+ pushFollow(FOLLOW_any_key_in_scope_section176);
+ any_key();
+ _fsp--;
+
+
+ }
+ break;
+
+ }
+
+
+ match(input, Token.UP, null);
+ }
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end scope_section
+
+
+ // $ANTLR start meta_section
+ // DSLMapWalker.g:89:1: meta_section : ^( VT_META (metalit= LITERAL )? ) ;
+ public final void meta_section() throws RecognitionException {
+ CommonTree metalit=null;
+
+ try {
+ // DSLMapWalker.g:90:2: ( ^( VT_META (metalit= LITERAL )? ) )
+ // DSLMapWalker.g:90:4: ^( VT_META (metalit= LITERAL )? )
+ {
+ match(input,VT_META,FOLLOW_VT_META_in_meta_section193);
+
+ if ( input.LA(1)==Token.DOWN ) {
+ match(input, Token.DOWN, null);
+ // DSLMapWalker.g:90:21: (metalit= LITERAL )?
+ int alt8=2;
+ int LA8_0 = input.LA(1);
+
+ if ( (LA8_0==LITERAL) ) {
+ alt8=1;
+ }
+ switch (alt8) {
+ case 1 :
+ // DSLMapWalker.g:90:21: metalit= LITERAL
+ {
+ metalit=(CommonTree)input.LT(1);
+ match(input,LITERAL,FOLLOW_LITERAL_in_meta_section197);
+
+ }
+ break;
+
+ }
+
+
+ match(input, Token.UP, null);
+ }
+
+ if ( metalit == null || metalit.getText() == null || metalit.getText().length() == 0 ) {
+ ((entry_scope)entry_stack.peek()).retval.setMetaData(DSLMappingEntry.EMPTY_METADATA);
+ } else {
+ ((entry_scope)entry_stack.peek()).retval.setMetaData(new DSLMappingEntry.DefaultDSLEntryMetaData( metalit.getText() ));
+ }
+
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end meta_section
+
+
+ // $ANTLR start key_section
+ // DSLMapWalker.g:100:1: key_section : ^( VT_ENTRY_KEY ( key_sentence )+ ) ;
+ public final void key_section() throws RecognitionException {
+ try {
+ // DSLMapWalker.g:101:2: ( ^( VT_ENTRY_KEY ( key_sentence )+ ) )
+ // DSLMapWalker.g:101:4: ^( VT_ENTRY_KEY ( key_sentence )+ )
+ {
+ match(input,VT_ENTRY_KEY,FOLLOW_VT_ENTRY_KEY_in_key_section214);
+
+ match(input, Token.DOWN, null);
+ // DSLMapWalker.g:101:19: ( key_sentence )+
+ int cnt9=0;
+ loop9:
+ do {
+ int alt9=2;
+ int LA9_0 = input.LA(1);
+
+ if ( (LA9_0==VT_VAR_DEF||LA9_0==VT_LITERAL||LA9_0==VT_SPACE) ) {
+ alt9=1;
+ }
+
+
+ switch (alt9) {
+ case 1 :
+ // DSLMapWalker.g:101:19: key_sentence
+ {
+ pushFollow(FOLLOW_key_sentence_in_key_section216);
+ key_sentence();
+ _fsp--;
+
+
+ }
+ break;
+
+ default :
+ if ( cnt9 >= 1 ) break loop9;
+ EarlyExitException eee =
+ new EarlyExitException(9, input);
+ throw eee;
+ }
+ cnt9++;
+ } while (true);
+
+
+ match(input, Token.UP, null);
+
+ //((entry_scope)entry_stack.peek()).retval.setMappingKey(((entry_scope)entry_stack.peek()).keybuffer.toString());
+
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end key_section
+
+
+ // $ANTLR start key_sentence
+ // DSLMapWalker.g:107:1: key_sentence : ( variable_definition | vtl= VT_LITERAL | VT_SPACE );
+ public final void key_sentence() throws RecognitionException {
+ CommonTree vtl=null;
+
+ try {
+ // DSLMapWalker.g:108:2: ( variable_definition | vtl= VT_LITERAL | VT_SPACE )
+ int alt10=3;
+ switch ( input.LA(1) ) {
+ case VT_VAR_DEF:
+ {
+ alt10=1;
+ }
+ break;
+ case VT_LITERAL:
+ {
+ alt10=2;
+ }
+ break;
+ case VT_SPACE:
+ {
+ alt10=3;
+ }
+ break;
+ default:
+ NoViableAltException nvae =
+ new NoViableAltException("107:1: key_sentence : ( variable_definition | vtl= VT_LITERAL | VT_SPACE );", 10, 0, input);
+
+ throw nvae;
+ }
+
+ switch (alt10) {
+ case 1 :
+ // DSLMapWalker.g:108:4: variable_definition
+ {
+ pushFollow(FOLLOW_variable_definition_in_key_sentence234);
+ variable_definition();
+ _fsp--;
+
+
+ }
+ break;
+ case 2 :
+ // DSLMapWalker.g:109:4: vtl= VT_LITERAL
+ {
+ vtl=(CommonTree)input.LT(1);
+ match(input,VT_LITERAL,FOLLOW_VT_LITERAL_in_key_sentence241);
+
+ //System.out.println("in key_sentence, literal is " + vtl.getText());
+ ((entry_scope)entry_stack.peek()).keybuffer.append(vtl.getText());
+
+
+ }
+ break;
+ case 3 :
+ // DSLMapWalker.g:114:4: VT_SPACE
+ {
+ match(input,VT_SPACE,FOLLOW_VT_SPACE_in_key_sentence250);
+
+ ((entry_scope)entry_stack.peek()).keybuffer.append("\\s+");
+
+
+ }
+ break;
+
+ }
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end key_sentence
+
+
+ // $ANTLR start value_section
+ // DSLMapWalker.g:124:1: value_section : ^( VT_ENTRY_VAL ( value_sentence )+ ) ;
+ public final void value_section() throws RecognitionException {
+ try {
+ // DSLMapWalker.g:128:2: ( ^( VT_ENTRY_VAL ( value_sentence )+ ) )
+ // DSLMapWalker.g:128:4: ^( VT_ENTRY_VAL ( value_sentence )+ )
+ {
+ match(input,VT_ENTRY_VAL,FOLLOW_VT_ENTRY_VAL_in_value_section273);
+
+ match(input, Token.DOWN, null);
+ // DSLMapWalker.g:128:19: ( value_sentence )+
+ int cnt11=0;
+ loop11:
+ do {
+ int alt11=2;
+ int LA11_0 = input.LA(1);
+
+ if ( ((LA11_0>=VT_VAR_REF && LA11_0<=VT_LITERAL)||LA11_0==VT_SPACE) ) {
+ alt11=1;
+ }
+
+
+ switch (alt11) {
+ case 1 :
+ // DSLMapWalker.g:128:19: value_sentence
+ {
+ pushFollow(FOLLOW_value_sentence_in_value_section275);
+ value_sentence();
+ _fsp--;
+
+
+ }
+ break;
+
+ default :
+ if ( cnt11 >= 1 ) break loop11;
+ EarlyExitException eee =
+ new EarlyExitException(11, input);
+ throw eee;
+ }
+ cnt11++;
+ } while (true);
+
+
+ match(input, Token.UP, null);
+
+ //((entry_scope)entry_stack.peek()).retval.setMappingValue(((entry_scope)entry_stack.peek()).valuebuffer.toString());
+
+
+ }
+
+
+ ((entry_scope)entry_stack.peek()).valuebuffer.append(" ");
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end value_section
+
+
+ // $ANTLR start value_sentence
+ // DSLMapWalker.g:134:1: value_sentence : ( variable_reference | vtl= VT_LITERAL | VT_SPACE );
+ public final void value_sentence() throws RecognitionException {
+ CommonTree vtl=null;
+
+ try {
+ // DSLMapWalker.g:135:2: ( variable_reference | vtl= VT_LITERAL | VT_SPACE )
+ int alt12=3;
+ switch ( input.LA(1) ) {
+ case VT_VAR_REF:
+ {
+ alt12=1;
+ }
+ break;
+ case VT_LITERAL:
+ {
+ alt12=2;
+ }
+ break;
+ case VT_SPACE:
+ {
+ alt12=3;
+ }
+ break;
+ default:
+ NoViableAltException nvae =
+ new NoViableAltException("134:1: value_sentence : ( variable_reference | vtl= VT_LITERAL | VT_SPACE );", 12, 0, input);
+
+ throw nvae;
+ }
+
+ switch (alt12) {
+ case 1 :
+ // DSLMapWalker.g:135:4: variable_reference
+ {
+ pushFollow(FOLLOW_variable_reference_in_value_sentence295);
+ variable_reference();
+ _fsp--;
+
+
+ }
+ break;
+ case 2 :
+ // DSLMapWalker.g:136:4: vtl= VT_LITERAL
+ {
+ vtl=(CommonTree)input.LT(1);
+ match(input,VT_LITERAL,FOLLOW_VT_LITERAL_in_value_sentence302);
+
+ //System.out.println("in value_sentence, literal is " + vtl.getText());
+ ((entry_scope)entry_stack.peek()).valuebuffer.append(vtl.getText());
+
+
+ }
+ break;
+ case 3 :
+ // DSLMapWalker.g:141:4: VT_SPACE
+ {
+ match(input,VT_SPACE,FOLLOW_VT_SPACE_in_value_sentence310);
+
+ ((entry_scope)entry_stack.peek()).valuebuffer.append(" ");
+
+
+ }
+ break;
+
+ }
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end value_sentence
+
+
+ // $ANTLR start literal
+ // DSLMapWalker.g:151:1: literal : theliteral= VT_LITERAL ;
+ public final void literal() throws RecognitionException {
+ CommonTree theliteral=null;
+
+ try {
+ // DSLMapWalker.g:152:2: (theliteral= VT_LITERAL )
+ // DSLMapWalker.g:152:4: theliteral= VT_LITERAL
+ {
+ theliteral=(CommonTree)input.LT(1);
+ match(input,VT_LITERAL,FOLLOW_VT_LITERAL_in_literal330);
+
+ //System.out.println("theliteral is " + theliteral.getText());
+
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end literal
+
+
+ // $ANTLR start variable_definition
+ // DSLMapWalker.g:159:1: variable_definition : ^( VT_VAR_DEF varname= LITERAL (pattern= VT_PATTERN )? ) ;
+ public final void variable_definition() throws RecognitionException {
+ CommonTree varname=null;
+ CommonTree pattern=null;
+
+ try {
+ // DSLMapWalker.g:161:2: ( ^( VT_VAR_DEF varname= LITERAL (pattern= VT_PATTERN )? ) )
+ // DSLMapWalker.g:161:6: ^( VT_VAR_DEF varname= LITERAL (pattern= VT_PATTERN )? )
+ {
+ match(input,VT_VAR_DEF,FOLLOW_VT_VAR_DEF_in_variable_definition351);
+
+ match(input, Token.DOWN, null);
+ varname=(CommonTree)input.LT(1);
+ match(input,LITERAL,FOLLOW_LITERAL_in_variable_definition355);
+ // DSLMapWalker.g:161:42: (pattern= VT_PATTERN )?
+ int alt13=2;
+ int LA13_0 = input.LA(1);
+
+ if ( (LA13_0==VT_PATTERN) ) {
+ alt13=1;
+ }
+ switch (alt13) {
+ case 1 :
+ // DSLMapWalker.g:161:42: pattern= VT_PATTERN
+ {
+ pattern=(CommonTree)input.LT(1);
+ match(input,VT_PATTERN,FOLLOW_VT_PATTERN_in_variable_definition359);
+
+ }
+ break;
+
+ }
+
+
+ match(input, Token.UP, null);
+
+ //System.out.println("variable " + varname.getText() + " defined with pattern " + pattern);
+ ((entry_scope)entry_stack.peek()).counter++;
+ ((entry_scope)entry_stack.peek()).variables.put(varname.getText(), new Integer(((entry_scope)entry_stack.peek()).counter));
+ ((entry_scope)entry_stack.peek()).keybuffer.append(pattern != null? "(" + pattern.getText() + ")" : "(.*?)");
+
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end variable_definition
+
+
+ // $ANTLR start variable_reference
+ // DSLMapWalker.g:171:1: variable_reference : ^(varref= VT_VAR_REF lit= LITERAL ) ;
+ public final void variable_reference() throws RecognitionException {
+ CommonTree varref=null;
+ CommonTree lit=null;
+
+ try {
+ // DSLMapWalker.g:172:2: ( ^(varref= VT_VAR_REF lit= LITERAL ) )
+ // DSLMapWalker.g:172:4: ^(varref= VT_VAR_REF lit= LITERAL )
+ {
+ varref=(CommonTree)input.LT(1);
+ match(input,VT_VAR_REF,FOLLOW_VT_VAR_REF_in_variable_reference381);
+
+ match(input, Token.DOWN, null);
+ lit=(CommonTree)input.LT(1);
+ match(input,LITERAL,FOLLOW_LITERAL_in_variable_reference385);
+
+ match(input, Token.UP, null);
+
+ //System.out.println("varref is " + varref.getText() + " and points to " + lit.getText());
+ ((entry_scope)entry_stack.peek()).valuebuffer.append("$" + ((entry_scope)entry_stack.peek()).variables.get(lit.getText()));
+
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end variable_reference
+
+
+ // $ANTLR start condition_key
+ // DSLMapWalker.g:179:1: condition_key : VT_CONDITION ;
+ public final void condition_key() throws RecognitionException {
+ try {
+ // DSLMapWalker.g:180:2: ( VT_CONDITION )
+ // DSLMapWalker.g:180:4: VT_CONDITION
+ {
+ match(input,VT_CONDITION,FOLLOW_VT_CONDITION_in_condition_key403);
+ ((entry_scope)entry_stack.peek()).retval.setSection(DSLMappingEntry.CONDITION);
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end condition_key
+
+
+ // $ANTLR start consequence_key
+ // DSLMapWalker.g:184:1: consequence_key : VT_CONSEQUENCE ;
+ public final void consequence_key() throws RecognitionException {
+ try {
+ // DSLMapWalker.g:185:2: ( VT_CONSEQUENCE )
+ // DSLMapWalker.g:185:4: VT_CONSEQUENCE
+ {
+ match(input,VT_CONSEQUENCE,FOLLOW_VT_CONSEQUENCE_in_consequence_key418);
+ ((entry_scope)entry_stack.peek()).retval.setSection(DSLMappingEntry.CONSEQUENCE);
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end consequence_key
+
+
+ // $ANTLR start keyword_key
+ // DSLMapWalker.g:189:1: keyword_key : VT_KEYWORD ;
+ public final void keyword_key() throws RecognitionException {
+ try {
+ // DSLMapWalker.g:190:2: ( VT_KEYWORD )
+ // DSLMapWalker.g:190:4: VT_KEYWORD
+ {
+ match(input,VT_KEYWORD,FOLLOW_VT_KEYWORD_in_keyword_key433);
+ ((entry_scope)entry_stack.peek()).retval.setSection(DSLMappingEntry.KEYWORD);
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end keyword_key
+
+
+ // $ANTLR start any_key
+ // DSLMapWalker.g:194:1: any_key : VT_ANY ;
+ public final void any_key() throws RecognitionException {
+ try {
+ // DSLMapWalker.g:195:2: ( VT_ANY )
+ // DSLMapWalker.g:195:4: VT_ANY
+ {
+ match(input,VT_ANY,FOLLOW_VT_ANY_in_any_key448);
+ ((entry_scope)entry_stack.peek()).retval.setSection(DSLMappingEntry.ANY);
+
+ }
+
+ }
+ catch (RecognitionException re) {
+ reportError(re);
+ recover(input,re);
+ }
+ finally {
+ }
+ return ;
+ }
+ // $ANTLR end any_key
+
+
+
+
+ public static final BitSet FOLLOW_VT_DSL_GRAMMAR_in_mapping_file54 = new BitSet(new long[]{0x0000000000000004L});
+ public static final BitSet FOLLOW_entry_in_mapping_file56 = new BitSet(new long[]{0x0000000000000048L});
+ public static final BitSet FOLLOW_entry_in_mapping_entry76 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_entry_in_valid_entry97 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VT_COMMENT_in_valid_entry104 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VT_ENTRY_in_entry132 = new BitSet(new long[]{0x0000000000000004L});
+ public static final BitSet FOLLOW_scope_section_in_entry134 = new BitSet(new long[]{0x0000000000003000L});
+ public static final BitSet FOLLOW_meta_section_in_entry136 = new BitSet(new long[]{0x0000000000002000L});
+ public static final BitSet FOLLOW_key_section_in_entry139 = new BitSet(new long[]{0x0000000000004000L});
+ public static final BitSet FOLLOW_value_section_in_entry145 = new BitSet(new long[]{0x0000000000000008L});
+ public static final BitSet FOLLOW_VT_SCOPE_in_scope_section165 = new BitSet(new long[]{0x0000000000000004L});
+ public static final BitSet FOLLOW_condition_key_in_scope_section167 = new BitSet(new long[]{0x0000000000000E08L});
+ public static final BitSet FOLLOW_consequence_key_in_scope_section170 = new BitSet(new long[]{0x0000000000000C08L});
+ public static final BitSet FOLLOW_keyword_key_in_scope_section173 = new BitSet(new long[]{0x0000000000000808L});
+ public static final BitSet FOLLOW_any_key_in_scope_section176 = new BitSet(new long[]{0x0000000000000008L});
+ public static final BitSet FOLLOW_VT_META_in_meta_section193 = new BitSet(new long[]{0x0000000000000004L});
+ public static final BitSet FOLLOW_LITERAL_in_meta_section197 = new BitSet(new long[]{0x0000000000000008L});
+ public static final BitSet FOLLOW_VT_ENTRY_KEY_in_key_section214 = new BitSet(new long[]{0x0000000000000004L});
+ public static final BitSet FOLLOW_key_sentence_in_key_section216 = new BitSet(new long[]{0x00000000000A8008L});
+ public static final BitSet FOLLOW_variable_definition_in_key_sentence234 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VT_LITERAL_in_key_sentence241 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VT_SPACE_in_key_sentence250 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VT_ENTRY_VAL_in_value_section273 = new BitSet(new long[]{0x0000000000000004L});
+ public static final BitSet FOLLOW_value_sentence_in_value_section275 = new BitSet(new long[]{0x00000000000B0008L});
+ public static final BitSet FOLLOW_variable_reference_in_value_sentence295 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VT_LITERAL_in_value_sentence302 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VT_SPACE_in_value_sentence310 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VT_LITERAL_in_literal330 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VT_VAR_DEF_in_variable_definition351 = new BitSet(new long[]{0x0000000000000004L});
+ public static final BitSet FOLLOW_LITERAL_in_variable_definition355 = new BitSet(new long[]{0x0000000000040008L});
+ public static final BitSet FOLLOW_VT_PATTERN_in_variable_definition359 = new BitSet(new long[]{0x0000000000000008L});
+ public static final BitSet FOLLOW_VT_VAR_REF_in_variable_reference381 = new BitSet(new long[]{0x0000000000000004L});
+ public static final BitSet FOLLOW_LITERAL_in_variable_reference385 = new BitSet(new long[]{0x0000000000000008L});
+ public static final BitSet FOLLOW_VT_CONDITION_in_condition_key403 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VT_CONSEQUENCE_in_consequence_key418 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VT_KEYWORD_in_keyword_key433 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VT_ANY_in_any_key448 = new BitSet(new long[]{0x0000000000000002L});
+
+}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMappingFile.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMappingFile.java 2008-06-04 18:24:35 UTC (rev 20310)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMappingFile.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -46,8 +46,8 @@
private static final String WHEN = "[when]";
private static final String THEN = "[then]";
- private DSLMapping mapping;
- private List errors;
+ protected DSLMapping mapping;
+ protected List errors;
public DSLMappingFile() {
this.mapping = new DefaultDSLMapping();
Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLTokenizedMappingFile.java (from rev 20284, labs/jbossrules/branches/mattgeis/drools-compiler/src/main/java/org/drools/lang/dsl/DSLTokenizedMappingFile.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLTokenizedMappingFile.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLTokenizedMappingFile.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -0,0 +1,65 @@
+package org.drools.lang.dsl;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.LinkedList;
+import org.antlr.runtime.ANTLRReaderStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.tree.CommonTree;
+import org.antlr.runtime.tree.CommonTreeNodeStream;
+
+public class DSLTokenizedMappingFile extends DSLMappingFile {
+ public DSLTokenizedMappingFile() {
+ super();
+ }
+
+ public boolean parseAndLoad(final Reader dsl) throws IOException {
+ String line = null;
+ int linecounter = 0;
+ final BufferedReader dslFileReader = new BufferedReader( dsl );
+ this.mapping = new DefaultDSLMapping();
+ this.errors = new LinkedList();
+ //Note: Use a string builder for 1.5 targets
+ StringBuffer sb = new StringBuffer();
+ while ( (line = dslFileReader.readLine()) != null ) {
+ linecounter++;
+ String trimmedline = line.trim() + "\n"; //this can be more efficient, get rid of trim(), iterate-- over last chars only.
+ try{
+ final DSLMappingEntry entry = buildEntry(trimmedline);
+ if(entry != null) this.mapping.addEntry(entry);//will be null if a comment
+ }catch(Exception re){
+ final String error = "Error parsing mapping entry: " + line;
+ final DSLMappingParseException exception =
+ new DSLMappingParseException( error, linecounter );
+ this.errors.add( exception );
+ }
+ }
+ return this.errors.isEmpty();
+ }
+
+ private DSLMappingEntry buildEntry(String line) throws IOException, RecognitionException{
+ StringReader sr = new StringReader(line);
+ ANTLRReaderStream reader = new ANTLRReaderStream(sr);
+ DSLMapWalker walker = buildEntryWalker(reader);
+ DSLMappingEntry entry = walker.valid_entry();
+ return entry;
+ }
+
+ private DSLMapWalker buildEntryWalker(CharStream stream) throws RecognitionException{
+ DSLMapLexer lexer = new DSLMapLexer(stream);
+ CommonTokenStream tokens = new CommonTokenStream();
+ tokens.setTokenSource(lexer);
+ DSLMapParser parser = new DSLMapParser(tokens);
+ DSLMapParser.statement_return example = parser.statement();
+ CommonTree tree = (CommonTree) example.getTree();
+ //System.out.println(tree.toStringTree());
+
+ CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
+ DSLMapWalker walker = new DSLMapWalker(nodes);
+ return walker;
+ }
+}
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultDSLMappingEntry.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultDSLMappingEntry.java 2008-06-04 18:24:35 UTC (rev 20310)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultDSLMappingEntry.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -19,7 +19,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -29,20 +28,10 @@
*
* @author etirelli
*/
-public class DefaultDSLMappingEntry
+public class DefaultDSLMappingEntry extends AbstractDSLMappingEntry
implements
DSLMappingEntry {
- private Section section;
- private MetaData metadata;
- private String key;
- private String value;
-
- private Map variables = Collections.EMPTY_MAP;
-
- private Pattern keyPattern;
- private String valuePattern;
-
// following pattern is used to extract all variables names and positions from a mapping.
// Example: for the following String:
//
@@ -51,7 +40,7 @@
// it will return variables:
// This, pattern, easy, say
//
- static final Pattern VAR_FINDER = Pattern.compile( "(^|[^\\\\])\\{([(\\\\\\{)|[^\\{]]*?)\\}",
+ private static final Pattern VAR_FINDER = Pattern.compile( "(^|[^\\\\])\\{([(\\\\\\{)|[^\\{]]*?)\\}",
Pattern.MULTILINE | Pattern.DOTALL );
// following pattern is used to find all the non-escaped parenthesis in the input key
@@ -76,34 +65,6 @@
}
/**
- * @inheritDoc
- */
- public Section getSection() {
- return this.section;
- }
-
- /**
- * @inheritDoc
- */
- public DSLMappingEntry.MetaData getMetaData() {
- return this.metadata;
- }
-
- /**
- * @inheritDoc
- */
- public String getMappingKey() {
- return this.key;
- }
-
- /**
- * @inheritDoc
- */
- public String getMappingValue() {
- return this.value;
- }
-
- /**
* @param key the key to set
*/
public void setMappingKey(String key) {
@@ -177,13 +138,6 @@
}
/**
- * @param section the section to set
- */
- public void setSection(final Section section) {
- this.section = section;
- }
-
- /**
* @param value the value to set
*/
public void setMappingValue(final String value) {
@@ -204,103 +158,4 @@
}
}
- /**
- * @param metadata the metadata to set
- */
- public void setMetaData(final MetaData metadata) {
- this.metadata = metadata;
- }
-
- /**
- * @return the keyPattern
- */
- public Pattern getKeyPattern() {
- return this.keyPattern;
- }
-
- /**
- * @return the valuePattern
- */
- public String getValuePattern() {
- return this.valuePattern;
- }
-
- /**
- * @return the variables
- */
- public Map getVariables() {
- return this.variables;
- }
-
- public String toPatternString() {
- return this.section + "[" + this.metadata + "]" + this.keyPattern.pattern() + "=" + this.valuePattern;
- }
-
- public String toString() {
- return this.section + "[" + this.metadata + "]" + this.key + "=" + this.value;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- final int PRIME = 31;
- int result = 1;
- result = PRIME * result + ((this.key == null) ? 0 : this.key.hashCode());
- result = PRIME * result + ((this.metadata == null) ? 0 : this.metadata.hashCode());
- result = PRIME * result + ((this.section == null) ? 0 : this.section.hashCode());
- result = PRIME * result + ((this.value == null) ? 0 : this.value.hashCode());
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(final Object obj) {
- if ( this == obj ) {
- return true;
- }
- if ( obj == null ) {
- return false;
- }
- if ( getClass() != obj.getClass() ) {
- return false;
- }
- final DefaultDSLMappingEntry other = (DefaultDSLMappingEntry) obj;
- if ( this.key == null ) {
- if ( other.key != null ) {
- return false;
- }
- } else if ( !this.key.equals( other.key ) ) {
- return false;
- }
- if ( this.metadata == null ) {
- if ( other.metadata != null ) {
- return false;
- }
- } else if ( !this.metadata.equals( other.metadata ) ) {
- return false;
- }
- if ( this.section == null ) {
- if ( other.section != null ) {
- return false;
- }
- } else if ( !this.section.equals( other.section ) ) {
- return false;
- }
- if ( this.value == null ) {
- if ( other.value != null ) {
- return false;
- }
- } else if ( !this.value.equals( other.value ) ) {
- return false;
- }
- return true;
- }
-
- public List getErrors() {
- // TODO Need to implement validation here
- return Collections.EMPTY_LIST;
- }
-
}
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpander.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpander.java 2008-06-04 18:24:35 UTC (rev 20310)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpander.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -228,7 +228,11 @@
// expand the expression
for ( final Iterator it = this.condition.iterator(); it.hasNext(); ) {
final DSLMappingEntry entry = (DSLMappingEntry) it.next();
- expanded[lastExpanded] = entry.getKeyPattern().matcher( expanded[lastExpanded] ).replaceAll( entry.getValuePattern() );
+ String vp = entry.getValuePattern();
+// System.out.println("toExpand, st: " + expanded[lastExpanded] + "|");
+// System.out.println("kp: " + entry.getKeyPattern());
+// System.out.println("vp: " + vp);
+ expanded[lastExpanded] = entry.getKeyPattern().matcher(expanded[lastExpanded]).replaceAll(vp);
}
// do we need to report errors for that?
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpanderResolver.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpanderResolver.java 2008-06-04 18:24:35 UTC (rev 20310)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpanderResolver.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -56,7 +56,7 @@
* This is the constructor most people should use.
*/
public DefaultExpanderResolver(final Reader reader) throws IOException {
- final DSLMappingFile file = new DSLMappingFile();
+ final DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
if ( file.parseAndLoad( reader ) ) {
final Expander expander = new DefaultExpander();
expander.addDSLMapping( file.getMapping() );
Modified: labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMap.g
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMap.g 2008-06-04 18:24:35 UTC (rev 20310)
+++ labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMap.g 2008-06-04 18:55:28 UTC (rev 20311)
@@ -1,263 +1,334 @@
-grammar DSLMap;
-
-options { output = AST; backtrack = true; }
-
-tokens {
- // imaginary tokens
- VT_DSL_GRAMMAR;
- VT_COMMENT;
- VT_ENTRY;
-
- VT_SCOPE;
- VT_CONDITION;
- VT_CONSEQUENCE;
- VT_KEYWORD;
- VT_ANY;
-
- VT_META;
- VT_ENTRY_KEY;
- VT_ENTRY_VAL;
- VT_VAR_DEF;
- VT_VAR_REF;
- VT_LITERAL;
- VT_PATTERN;
-
- VT_SPACE;
-}
-
- at parser::header {
- package org.drools.lang.dsl;
-}
-
- at lexer::header {
- package org.drools.lang.dsl;
-}
-
- at parser::members {
-//we may not need the check on [], as the LITERAL token being examined
-//should not have them.
- private boolean validateLT(int LTNumber, String text){
- if (null == input) return false;
- if (null == input.LT(LTNumber)) return false;
- if (null == input.LT(LTNumber).getText()) return false;
-
- String text2Validate = input.LT(LTNumber).getText();
- if (text2Validate.startsWith("[") && text2Validate.endsWith("]")){
- text2Validate = text2Validate.substring(1, text2Validate.length() - 1);
- }
-
- return text2Validate.equalsIgnoreCase(text);
- }
-
- private boolean validateIdentifierKey(String text){
- return validateLT(1, text);
- }
-
-}
-
-// PARSER RULES
-mapping_file
- : statement*
- -> ^(VT_DSL_GRAMMAR statement*)
- ;
-
-statement
- : entry
- | comment
- | EOL!
- ;//bang at end of EOL means to not put it into the AST
-
-comment : LINE_COMMENT
- -> ^(VT_COMMENT[$LINE_COMMENT, "COMMENT"] LINE_COMMENT )
- ;
-
-//we need to make entry so the meta section is optional
-entry : scope_section meta_section key_section EQUALS value_section (EOL|EOF)
- -> ^(VT_ENTRY scope_section meta_section key_section value_section)
- ;
-
-
-
-scope_section
- : LEFT_SQUARE
- (value1=condition_key
- | value2=consequence_key
- | value3=keyword_key
- | value4=any_key
- )
- RIGHT_SQUARE
- -> ^(VT_SCOPE[$LEFT_SQUARE, "SCOPE SECTION"] $value1? $value2? $value3? $value4?)
- ;
-
-
-
-meta_section
- : LEFT_SQUARE LITERAL? RIGHT_SQUARE
- -> ^(VT_META[$LEFT_SQUARE, "META SECTION"] LITERAL?)
- ;
-
-key_section
- : key_sentence+
- -> ^(VT_ENTRY_KEY key_sentence+ )
- ;
-
-key_sentence //problem: if you have foo is {foo:\d{3}}, because the WS is hidden, it rebuilds back to
-// foo is\d{3} when the key pattern is created. Somehow we need to capture the
-//trailing WS in the key_chunk
- at init {
- String text = "";
-}
- : variable_definition
- | cb=key_chunk { text = $cb.text; }
- -> VT_LITERAL[$cb.start, text]
- ;
-
-key_chunk
- : literal+
- ;
-
-value_section
- : value_sentence+
- -> ^(VT_ENTRY_VAL value_sentence+ )
- ;
-
-value_sentence
- at init {
- String text = "";
-}
- : variable_reference
- | vc=value_chunk { text = $vc.text; }
- -> VT_LITERAL[$vc.start, text]
- ;
-
-value_chunk
- : (literal|EQUALS)+
- ;
-
-literal
- : ( LITERAL | LEFT_SQUARE | RIGHT_SQUARE | COLON)
- ;
-
-variable_definition
- at init {
- String text = "";
- boolean hasSpace = false;
-}
- : lc=LEFT_CURLY { if( ((CommonToken)input.LT(-2)).getStopIndex() < ((CommonToken)lc).getStartIndex() -1 ) hasSpace = true; }
- name=LITERAL ( COLON pat=pattern {text = $pat.text;} )? RIGHT_CURLY
- -> {hasSpace && !"".equals(text)}? VT_SPACE ^(VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) //pat can be null if there's no pattern here
- -> {!hasSpace && !"".equals(text)}? ^(VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) //pat can be null if there's no pattern here
- -> {hasSpace}? VT_SPACE ^(VT_VAR_DEF $name ) //do we need to build a VT_LITERAL token for $name?
- -> ^(VT_VAR_DEF $name ) //do we need to build a VT_LITERAL token for $name?
- ;
-
-
-pattern
- : ( literal
- | LEFT_CURLY literal RIGHT_CURLY
- | LEFT_SQUARE pattern RIGHT_SQUARE
- )+
- ;
-
-
-
-
-
-variable_reference
- : LEFT_CURLY name=LITERAL RIGHT_CURLY
- -> ^(VT_VAR_REF $name )
- ;
-
-
-condition_key
- : {validateIdentifierKey("condition")||validateIdentifierKey("when")}? value=LITERAL
- -> VT_CONDITION[$value]
- ;
-
-consequence_key
- : {validateIdentifierKey("consequence")||validateIdentifierKey("then")}? value=LITERAL
- -> VT_CONSEQUENCE[$value]
- ;
-
-keyword_key
- : {validateIdentifierKey("keyword")}? value=LITERAL
- -> VT_KEYWORD[$value]
- ;
-
-any_key
- : {validateIdentifierKey("*")}? value=LITERAL
- -> VT_ANY[$value]
- ;
-
-
-// LEXER RULES
-
-WS : ( ' '
- | '\t'
- | '\f'
- )+
- { $channel=HIDDEN;}
- ;
-
-EOL :
- ( ( '\r\n' )=> '\r\n' // Evil DOS
- | '\r' // Macintosh
- | '\n' // Unix (the right way)
- )
- ;
-
-fragment
-EscapeSequence
- : '\\' ('b'|'B'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\'|'.'|'o'|
- 'x'|'a'|'e'|'c'|'d'|'D'|'s'|'S'|'w'|'W'|'p'|'A'|
- 'G'|'Z'|'z'|'Q'|'E'|'*'|'['|']'|'('|')'|'$'|'^'|
- '{'|'}'|'?'|'+'|'-'|'&'|'|'|'='|'u'|'0'|'#')
- ;
-
-LEFT_SQUARE
- : '['
- ;
-
-RIGHT_SQUARE
- : ']'
- ;
-
-LEFT_CURLY
- : '{'
- ;
-
-RIGHT_CURLY
- : '}'
- ;
-
-EQUALS : '='
- ;
-
-DOT : '.'
- ;
-
-POUND : '#'
- ;
-
-COLON : ':'
- ;
-
-
-//the problem here with LINE COMMENT is that the lexer is not identifying
-//#comment without a EOL character. For example, what if it's the last line in a file?
-//should still be a comment. Changing to (EOL|EOF) causes it to only match the POUND
-LINE_COMMENT
- : POUND ( options{greedy=false;} : .)* EOL /* ('\r')? '\n' */
- ;
-
-
-LITERAL
- : ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'\u00c0'..'\u00ff'|MISC|EscapeSequence|DOT)+
- ;
-
-fragment
-MISC :
- '!' | '@' | '$' | '%' | '^' | '*' | '-' | '+' | '?' | '/' | '\'' | '"' | '|' | '&' | '(' | ')' | ';'
- ;
-
-
+grammar DSLMap;
+
+options { output = AST; backtrack = true; }
+
+tokens {
+ // imaginary tokens
+ VT_DSL_GRAMMAR;
+ VT_COMMENT;
+ VT_ENTRY;
+
+ VT_SCOPE;
+ VT_CONDITION;
+ VT_CONSEQUENCE;
+ VT_KEYWORD;
+ VT_ANY;
+
+ VT_META;
+ VT_ENTRY_KEY;
+ VT_ENTRY_VAL;
+ VT_VAR_DEF;
+ VT_VAR_REF;
+ VT_LITERAL;
+ VT_PATTERN;
+
+ VT_SPACE;
+}
+
+ at parser::header {
+ package org.drools.lang.dsl;
+}
+
+ at lexer::header {
+ package org.drools.lang.dsl;
+}
+
+ at parser::members {
+//we may not need the check on [], as the LITERAL token being examined
+//should not have them.
+ private boolean validateLT(int LTNumber, String text){
+ if (null == input) return false;
+ if (null == input.LT(LTNumber)) return false;
+ if (null == input.LT(LTNumber).getText()) return false;
+
+ String text2Validate = input.LT(LTNumber).getText();
+ if (text2Validate.startsWith("[") && text2Validate.endsWith("]")){
+ text2Validate = text2Validate.substring(1, text2Validate.length() - 1);
+ }
+
+ return text2Validate.equalsIgnoreCase(text);
+ }
+
+ private boolean validateIdentifierKey(String text){
+ return validateLT(1, text);
+ }
+
+ protected void mismatch(IntStream input, int ttype, BitSet follow)
+ throws RecognitionException{
+ throw new MismatchedTokenException(ttype, input);
+ }
+
+ public void recoverFromMismatchedSet(IntStream input,
+ RecognitionException e, BitSet follow) throws RecognitionException{
+ throw e;
+ }
+
+}
+
+
+ at rulecatch {
+ catch (RecognitionException e) {
+ throw e;
+ }
+}
+
+// PARSER RULES
+mapping_file
+ : statement*
+ -> ^(VT_DSL_GRAMMAR statement*)
+ ;
+
+statement
+ : entry
+ | comment
+ | EOL!
+ ;
+ //! after EOL means to not put it into the AST
+
+
+comment : LINE_COMMENT
+ -> ^(VT_COMMENT[$LINE_COMMENT, "COMMENT"] LINE_COMMENT )
+ ;
+
+//we need to make entry so the meta section is optional
+entry : scope_section meta_section? key_section EQUALS value_section (EOL|EOF)
+ -> ^(VT_ENTRY scope_section meta_section? key_section value_section)
+ ;
+
+
+
+scope_section
+ : LEFT_SQUARE
+ (value1=condition_key
+ | value2=consequence_key
+ | value3=keyword_key
+ | value4=any_key
+ )
+ RIGHT_SQUARE
+ -> ^(VT_SCOPE[$LEFT_SQUARE, "SCOPE SECTION"] $value1? $value2? $value3? $value4?)
+ ;
+
+
+
+meta_section
+ : LEFT_SQUARE LITERAL? RIGHT_SQUARE
+ -> ^(VT_META[$LEFT_SQUARE, "META SECTION"] LITERAL?)
+ ;
+
+key_section
+ : key_sentence+
+ -> ^(VT_ENTRY_KEY key_sentence+ )
+ ;
+
+key_sentence
+ at init {
+ String text = "";
+}
+ : variable_definition
+ | cb=key_chunk { text = $cb.text;}
+ -> VT_LITERAL[$cb.start, text]
+ ;
+
+key_chunk
+ : literal+
+ ;
+
+value_section
+ : value_sentence+
+ -> ^(VT_ENTRY_VAL value_sentence+ )
+ ;
+
+value_sentence
+ at init {
+ String text = "";
+}
+ : variable_reference
+ | vc=value_chunk { text = $vc.text; }
+ -> VT_LITERAL[$vc.start, text]
+ ;
+
+value_chunk
+ : (literal|EQUALS|COMMA)+
+ ;
+
+literal
+ //: ( LITERAL | LEFT_SQUARE | RIGHT_SQUARE | COLON)
+ : ( LITERAL | COLON | LEFT_SQUARE | RIGHT_SQUARE)
+ ;
+
+
+variable_definition
+ at init {
+ String text = "";
+ boolean hasSpaceBefore = false;
+ boolean hasSpaceAfter = false;
+}
+ : lc=LEFT_CURLY
+ {
+ CommonToken back2 = (CommonToken)input.LT(-2);
+ if( back2!=null && back2.getStopIndex() < ((CommonToken)lc).getStartIndex() -1 ) hasSpaceBefore = true;
+ }
+ name=LITERAL ( COLON pat=pattern {text = $pat.text;} )? rc=RIGHT_CURLY
+ {
+ CommonToken rc1 = (CommonToken)input.LT(1);
+ //System.out.println("lt1 from rc: " + rc1.getText());
+ if(!"=".equals(rc1.getText()) && ((CommonToken)rc).getStopIndex() < rc1.getStartIndex() - 1) hasSpaceAfter = true;
+ }
+ -> {hasSpaceBefore && !"".equals(text) && !hasSpaceAfter}? VT_SPACE ^(VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) //pat can be null if there's no pattern here
+ -> {!hasSpaceBefore && !"".equals(text) && !hasSpaceAfter}? ^(VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) //pat can be null if there's no pattern here
+ -> {hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^(VT_VAR_DEF $name )
+ -> {!hasSpaceBefore && !hasSpaceAfter}? ^(VT_VAR_DEF $name )
+
+ -> {hasSpaceBefore && !"".equals(text) && hasSpaceAfter}? VT_SPACE ^(VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) VT_SPACE //pat can be null if there's no pattern here
+ -> {!hasSpaceBefore && !"".equals(text) && hasSpaceAfter}? ^(VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) VT_SPACE //pat can be null if there's no pattern here
+ -> {hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^(VT_VAR_DEF $name ) VT_SPACE
+ -> {!hasSpaceBefore && hasSpaceAfter}? ^(VT_VAR_DEF $name ) VT_SPACE
+ -> ^(VT_VAR_DEF $name )
+ ;
+
+variable_definition2
+ at init {
+ String text = "";
+}
+ : LEFT_CURLY name=LITERAL ( COLON pat=pattern {text = $pat.text;} )? RIGHT_CURLY
+ -> {!"".equals(text)}? ^(VT_VAR_DEF $name VT_PATTERN[$pat.start, text] ) //pat can be null if there's no pattern here
+ -> ^(VT_VAR_DEF $name ) //do we need to build a VT_LITERAL token for $name?
+ ;
+
+
+pattern
+ : ( literal
+ | LEFT_CURLY literal RIGHT_CURLY
+ | LEFT_SQUARE pattern RIGHT_SQUARE
+ )+
+ ;
+
+
+variable_reference
+ at init {
+ boolean hasSpaceBefore = false;
+ boolean hasSpaceAfter = false;
+}
+ : lc=LEFT_CURLY
+ {//try too figure out how to get " {name} " to realize there's a space infron of the { char
+ //System.out.println("input is a " + input.getClass().getName());
+ //System.out.println("input is: " + input.toString());
+ //System.out.println("input LA[1]: " + input.LA(1));
+
+ //System.out.println("lc start is: " + ((CommonToken)lc).getStartIndex() );
+ CommonToken back2 = (CommonToken)input.LT(-2);
+ if( back2!=null && back2.getStopIndex() < ((CommonToken)lc).getStartIndex() -1 ) hasSpaceBefore = true;
+ }
+ name=LITERAL rc=RIGHT_CURLY
+ {if(((CommonToken)rc).getStopIndex() < ((CommonToken)input.LT(1)).getStartIndex() - 1) hasSpaceAfter = true;}
+ -> {hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^(VT_VAR_REF $name ) VT_SPACE
+ -> {hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^(VT_VAR_REF $name )
+ -> {!hasSpaceBefore && hasSpaceAfter}? ^(VT_VAR_REF $name ) VT_SPACE
+ -> ^(VT_VAR_REF $name )
+ ;
+
+
+variable_reference2
+ : LEFT_CURLY name=LITERAL RIGHT_CURLY
+ -> ^(VT_VAR_REF $name )
+ ;
+
+
+condition_key
+ : {validateIdentifierKey("condition")||validateIdentifierKey("when")}? value=LITERAL
+ -> VT_CONDITION[$value]
+ ;
+
+consequence_key
+ : {validateIdentifierKey("consequence")||validateIdentifierKey("then")}? value=LITERAL
+ -> VT_CONSEQUENCE[$value]
+ ;
+
+keyword_key
+ : {validateIdentifierKey("keyword")}? value=LITERAL
+ -> VT_KEYWORD[$value]
+ ;
+
+any_key
+ : {validateIdentifierKey("*")}? value=LITERAL
+ -> VT_ANY[$value]
+ ;
+
+
+// LEXER RULES
+
+WS : ( ' '
+ | '\t'
+ | '\f'
+ )+
+ { $channel=HIDDEN;}
+ ;
+
+EOL :
+ ( ( '\r\n' )=> '\r\n' // Evil DOS
+ | '\r' // Macintosh
+ | '\n' // Unix (the right way)
+ )
+ ;
+
+fragment
+EscapeSequence
+ : '\\' ('b'|'B'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\'|'.'|'o'|
+ 'x'|'a'|'e'|'c'|'d'|'D'|'s'|'S'|'w'|'W'|'p'|'A'|
+ 'G'|'Z'|'z'|'Q'|'E'|'*'|'['|']'|'('|')'|'$'|'^'|
+ '{'|'}'|'?'|'+'|'-'|'&'|'|'|'='|'u'|'0'|'#')
+ ;
+
+LEFT_SQUARE
+ : '['
+ ;
+
+RIGHT_SQUARE
+ : ']'
+ ;
+
+LEFT_CURLY
+ : '{'
+ ;
+
+RIGHT_CURLY
+ : '}'
+ ;
+
+EQUALS : '='
+ ;
+
+DOT : '.'
+ ;
+
+POUND : '#'
+ ;
+
+COLON : ':'
+ ;
+
+COMMA : ','
+ ;
+
+
+//the problem here with LINE COMMENT is that the lexer is not identifying
+//#comment without a EOL character. For example, what if it's the last line in a file?
+//should still be a comment. Changing to (EOL|EOF) causes it to only match the POUND
+LINE_COMMENT
+ : POUND ( options{greedy=false;} : .)* EOL /* ('\r')? '\n' */
+ ;
+
+//META_LITERAL
+// : ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'*'|DOT)+
+// ;
+
+LITERAL
+ : ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'\u00c0'..'\u00ff'|MISC|EscapeSequence|DOT)+
+ ;
+
+fragment
+MISC :
+ '>'|'<'|'!' | '@' | '$' | '%' | '^' | '*' | '-' | '+' | '?' | '/' | '\'' | '"' | '|' | '&' | '(' | ')' | ';'
+ ;
+
+
Copied: labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMapWalker.g (from rev 20284, labs/jbossrules/branches/mattgeis/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMapWalker.g)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMapWalker.g (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMapWalker.g 2008-06-04 18:55:28 UTC (rev 20311)
@@ -0,0 +1,191 @@
+tree grammar DSLMapWalker;
+
+options {
+ tokenVocab=DSLMap;
+ ASTLabelType=CommonTree;
+}
+
+ at treeparser::header {
+ package org.drools.lang.dsl;
+
+ import java.util.Map;
+ import java.util.HashMap;
+
+}
+
+
+mapping_file returns [DSLMapping mapping]
+scope {
+ DSLMapping retval;
+}
+ at init {
+ $mapping_file::retval = new DefaultDSLMapping() ;
+}
+ : ^(VT_DSL_GRAMMAR entry*)
+ {
+ //System.out.println("done parsing file");
+ //System.out.println($mapping_file::retval.dumpFile());
+ $mapping = $mapping_file::retval;
+ //java.io.StringWriter sw = new java.io.StringWriter();
+ //$mapping_file::retval.saveMapping(sw);
+ //System.out.println(sw.toString());
+ }
+ ;
+
+mapping_entry
+ : ent=entry
+ {
+ $mapping_file::retval.addEntry(ent);
+ //System.out.println("mapping size is now " + $mapping_file::retval.getEntries().size());
+ }
+ ;
+
+valid_entry returns [DSLMappingEntry mappingEntry]
+ : ent=entry {$mappingEntry = ent;}
+ | VT_COMMENT {$mappingEntry = null;}
+ ;
+
+
+entry returns [DSLMappingEntry mappingEntry]
+scope {
+ Map variables;
+ AntlrDSLMappingEntry retval;
+ int counter;
+ StringBuffer keybuffer;
+ StringBuffer valuebuffer;
+}
+ at init {
+ $entry::retval = new AntlrDSLMappingEntry() ;
+ $entry::variables = new HashMap();
+ $entry::keybuffer = new StringBuffer();
+ $entry::valuebuffer = new StringBuffer();
+}
+ : ^(VT_ENTRY scope_section meta_section? key_section {$entry::retval.variables = $entry::variables; $entry::retval.setMappingKey($entry::keybuffer.toString());}
+ value_section)
+ {
+ //System.out.println("for this entry, metadata is " + $entry::retval.getMetaData().getMetaData());
+ //System.out.println("variables are " + $entry::variables);
+
+ //System.out.println("keybuffer: " + $entry::keybuffer);
+ //System.out.println("valuebuffer: " + $entry::valuebuffer);
+// $mapping_file::retval.addEntry($entry::retval);
+// System.out.println("mapping size is now " + $mapping_file::retval.getEntries().size());
+ //$entry::retval.variables = $entry::variables;
+ //$entry::retval.setMappingKey($entry::keybuffer.toString());
+ $entry::retval.setMappingValue($entry::valuebuffer.toString());
+ //System.out.println("keypattern is " + $entry::retval.getKeyPattern());
+ //System.out.println("valuepattern is " + $entry::retval.getValuePattern());
+ $mappingEntry = $entry::retval;
+ }
+ ;
+
+
+scope_section
+ : ^(thescope=VT_SCOPE condition_key? consequence_key? keyword_key? any_key?)
+ ;
+
+
+
+meta_section
+ : ^(VT_META metalit=LITERAL?)
+ {
+ if ( $metalit == null || $metalit.text == null || $metalit.text.length() == 0 ) {
+ $entry::retval.setMetaData(DSLMappingEntry.EMPTY_METADATA);
+ } else {
+ $entry::retval.setMetaData(new DSLMappingEntry.DefaultDSLEntryMetaData( $metalit.text ));
+ }
+ }
+ ;
+
+key_section
+ : ^(VT_ENTRY_KEY key_sentence+ )
+ {
+ //$entry::retval.setMappingKey($entry::keybuffer.toString());
+ }
+ ;
+
+key_sentence
+ : variable_definition
+ | vtl=VT_LITERAL
+ {
+ //System.out.println("in key_sentence, literal is " + $vtl.text);
+ $entry::keybuffer.append($vtl.text);
+ }
+ | VT_SPACE
+ {
+ $entry::keybuffer.append("\\s+");
+ }
+ ;
+/*
+key_chunk
+ : literal+
+ ;
+*/
+value_section
+ : ^(VT_ENTRY_VAL value_sentence+ )
+ {
+ //$entry::retval.setMappingValue($entry::valuebuffer.toString());
+ }
+ ;
+
+value_sentence
+ : variable_reference
+ | vtl=VT_LITERAL
+ {
+ //System.out.println("in value_sentence, literal is " + $vtl.text);
+ $entry::valuebuffer.append($vtl.text);
+ }
+ | VT_SPACE
+ {
+ $entry::valuebuffer.append(" ");
+ }
+ ;
+/*
+value_chunk
+ : (literal|EQUALS)+
+ ;
+*/
+literal
+ : theliteral=VT_LITERAL {//System.out.println("theliteral is " + $theliteral.text);}
+ ;
+
+
+variable_definition
+
+ : ^(VT_VAR_DEF varname=LITERAL pattern=VT_PATTERN? )
+ {
+ //System.out.println("variable " + $varname.text + " defined with pattern " + $pattern);
+ $entry::counter++;
+ $entry::variables.put($varname.text, new Integer($entry::counter));
+ $entry::keybuffer.append($pattern != null? "(" + $pattern.text + ")" : "(.*?)");
+ }
+ ;
+
+
+variable_reference
+ : ^(varref=VT_VAR_REF lit=LITERAL )
+ {
+ //System.out.println("varref is " + $varref.text + " and points to " + $lit.text);
+ $entry::valuebuffer.append("$" + $entry::variables.get($lit.text));
+ }
+ ;
+
+condition_key
+ : VT_CONDITION
+ {$entry::retval.setSection(DSLMappingEntry.CONDITION);}
+ ;
+
+consequence_key
+ : VT_CONSEQUENCE
+ {$entry::retval.setSection(DSLMappingEntry.CONSEQUENCE);}
+ ;
+
+keyword_key
+ : VT_KEYWORD
+ {$entry::retval.setSection(DSLMappingEntry.KEYWORD);}
+ ;
+
+any_key
+ : VT_ANY
+ {$entry::retval.setSection(DSLMappingEntry.ANY);}
+ ;
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/DrlParserTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/DrlParserTest.java 2008-06-04 18:24:35 UTC (rev 20310)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/DrlParserTest.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -5,6 +5,7 @@
import org.drools.RuntimeDroolsException;
import org.drools.lang.Expander;
import org.drools.lang.dsl.DSLMappingFile;
+import org.drools.lang.dsl.DSLTokenizedMappingFile;
import org.drools.lang.dsl.DefaultExpander;
import org.drools.lang.dsl.DefaultExpanderResolver;
@@ -29,7 +30,7 @@
DefaultExpanderResolver resolver = new DefaultExpanderResolver(new StringReader(dsl));
- final DSLMappingFile file = new DSLMappingFile();
+ final DSLMappingFile file = new DSLTokenizedMappingFile();
if ( file.parseAndLoad( new StringReader(dsl) ) ) {
final Expander expander = new DefaultExpander();
expander.addDSLMapping( file.getMapping() );
Copied: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/ANTLRDSLTest.java (from rev 20284, labs/jbossrules/branches/mattgeis/drools-compiler/src/test/java/org/drools/lang/dsl/ANTLRDSLTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/ANTLRDSLTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/ANTLRDSLTest.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -0,0 +1,49 @@
+package org.drools.lang.dsl;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+public class ANTLRDSLTest extends TestCase {
+
+ public ANTLRDSLTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testMe() throws Exception{
+ DSLTokenizedMappingFile tokenizedFile = null;
+ final String filename = "test_antlr.dsl";
+ final Reader reader = new InputStreamReader( this.getClass().getResourceAsStream( filename ) );
+ tokenizedFile = new DSLTokenizedMappingFile();
+ tokenizedFile.parseAndLoad( reader );
+ reader.close();
+ for (Iterator it = tokenizedFile.getMapping().getEntries().iterator(); it.hasNext();) {
+ DSLMappingEntry entry = (DSLMappingEntry) it.next();
+// System.out.println("ENTRY: " + entry.getKeyPattern() + " ::::: " + entry.getValuePattern());
+ }
+
+ DefaultExpander ex = new DefaultExpander();
+ ex.addDSLMapping( tokenizedFile.getMapping() );
+
+ System.err.println(ex.expand( "rule 'x' \n when \n address is present where name is \"foo\" and age is \"32\" \n then \n end" ));
+ }
+
+ public void testSimple() throws Exception{
+ String input = "u : User() and exists (a: Address( where name is \"foo\" and age is \"32\" ) from u.addresses)";
+ String pattern = "(\\W|^)where\\s+([\\S]+)\\s+is \"(.*?)\"(\\W|$)";
+ java.util.regex.Pattern p = java.util.regex.Pattern.compile(pattern);
+ java.util.regex.Matcher m = p.matcher(input);
+ System.out.println("SIMPLE MATCHER matches: " + m.matches());
+ }
+
+}
Copied: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/DSLTokenizedMappingFileTest.java (from rev 20284, labs/jbossrules/branches/mattgeis/drools-compiler/src/test/java/org/drools/lang/dsl/DSLTokenizedMappingFileTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/DSLTokenizedMappingFileTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/DSLTokenizedMappingFileTest.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -0,0 +1,180 @@
+package org.drools.lang.dsl;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+
+import junit.framework.TestCase;
+
+public class DSLTokenizedMappingFileTest extends TestCase {
+ private DSLMappingFile file = null;
+ private final String filename = "test_metainfo.dsl";
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testParseFile() {
+ try {
+ final Reader reader = new InputStreamReader( this.getClass().getResourceAsStream( this.filename ) );
+ this.file = new DSLTokenizedMappingFile();
+
+ final boolean parsingResult = this.file.parseAndLoad( reader );
+ reader.close();
+
+ assertTrue( this.file.getErrors().toString(),
+ parsingResult );
+ assertTrue( this.file.getErrors().isEmpty() );
+
+ assertEquals( 31,
+ this.file.getMapping().getEntries().size() );
+ } catch ( final IOException e ) {
+ e.printStackTrace();
+ fail( "Should not raise exception " );
+ }
+
+ }
+
+ public void testParseFileWithBrackets() {
+ String file = "[when]ATTRIBUTE \"{attr}\" IS IN [{list}]=Attribute( {attr} in ({list}) )";
+ try {
+ final Reader reader = new StringReader( file );
+ this.file = new DSLTokenizedMappingFile();
+
+ final boolean parsingResult = this.file.parseAndLoad( reader );
+ reader.close();
+
+ assertTrue( this.file.getErrors().toString(),
+ parsingResult );
+ assertTrue( this.file.getErrors().isEmpty() );
+
+ assertEquals( 1,
+ this.file.getMapping().getEntries().size() );
+
+ DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get( 0 );
+
+ assertEquals( DSLMappingEntry.CONDITION,
+ entry.getSection() );
+ assertEquals( DSLMappingEntry.EMPTY_METADATA,
+ entry.getMetaData() );
+ assertEquals( "(\\W|^)ATTRIBUTE \"(.*?)\" IS IN [(.*?)](\\W|$)",
+ entry.getKeyPattern().toString() );
+ //Attribute( {attr} in ({list}) )
+ assertEquals( "Attribute( $2 in ($3) ) ",
+ entry.getValuePattern() );
+
+ } catch ( final IOException e ) {
+ e.printStackTrace();
+ fail( "Should not raise exception " );
+ }
+ }
+
+ public void testParseFileWithEscaptedBrackets() {
+ String file = "[when]ATTRIBUTE \"{attr}\" IS IN \\[{list}\\]=Attribute( {attr} in ({list}) )";
+ try {
+ final Reader reader = new StringReader( file );
+ this.file = new DSLTokenizedMappingFile();
+
+ final boolean parsingResult = this.file.parseAndLoad( reader );
+ reader.close();
+
+ assertTrue( this.file.getErrors().toString(),
+ parsingResult );
+ assertTrue( this.file.getErrors().isEmpty() );
+
+ assertEquals( 1,
+ this.file.getMapping().getEntries().size() );
+
+ DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get( 0 );
+
+ assertEquals( DSLMappingEntry.CONDITION,
+ entry.getSection() );
+ assertEquals( DSLMappingEntry.EMPTY_METADATA,
+ entry.getMetaData() );
+
+ assertEquals( "(\\W|^)ATTRIBUTE \"(.*?)\" IS IN \\[(.*?)\\](\\W|$)",
+ entry.getKeyPattern().toString() );
+ //Attribute( {attr} in ({list}) )
+ assertEquals( "Attribute( $2 in ($3) ) ",
+ entry.getValuePattern() );
+
+ } catch ( final IOException e ) {
+ e.printStackTrace();
+ fail( "Should not raise exception " );
+ }
+
+ }
+
+ public void testParseFileWithEscapes() {
+ String file = "[then]TEST=System.out.println(\"DO_SOMETHING\");\n" +
+ "[when]code {code1} occurs and sum of all digit not equal \\( {code2} \\+ {code3} \\)=AAAA( cd1 == {code1}, cd2 != ( {code2} + {code3} ))\n" +
+ "[when]code {code1} occurs=BBBB\n";
+ try {
+ final Reader reader = new StringReader( file );
+ this.file = new DSLTokenizedMappingFile();
+
+ final boolean parsingResult = this.file.parseAndLoad( reader );
+ reader.close();
+
+ assertTrue( this.file.getErrors().toString(),
+ parsingResult );
+ assertTrue( this.file.getErrors().isEmpty() );
+
+ final String LHS = "code 1041 occurs and sum of all digit not equal ( 1034 + 1035 )";
+ final String rule = "rule \"x\"\nwhen\n" + LHS + "\nthen\nTEST\nend";
+
+ DefaultExpander de = new DefaultExpander();
+ de.addDSLMapping(this.file.getMapping());
+
+ final String ruleAfterExpansion = de.expand(rule);
+
+ final String expected = "rule \"x\"\nwhen\nAAAA( cd1 == 1041, cd2 != ( 1034 + 1035 )) \nthen\nSystem.out.println(\"DO_SOMETHING\"); \nend\n";
+
+ assertEquals( expected, ruleAfterExpansion );
+
+ } catch ( final IOException e ) {
+ e.printStackTrace();
+ fail( "Should not raise exception " );
+ }
+
+ }
+
+ public void testParseFileWithEscaptedEquals() {
+ String file = "[when]something:\\={value}=Attribute( something == \"{value}\" )";
+ try {
+ final Reader reader = new StringReader( file );
+ this.file = new DSLTokenizedMappingFile();
+
+ final boolean parsingResult = this.file.parseAndLoad( reader );
+ reader.close();
+
+ assertTrue( this.file.getErrors().toString(),
+ parsingResult );
+ assertTrue( this.file.getErrors().isEmpty() );
+
+ assertEquals( 1,
+ this.file.getMapping().getEntries().size() );
+
+ DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get( 0 );
+
+ assertEquals( DSLMappingEntry.CONDITION,
+ entry.getSection() );
+ assertEquals( DSLMappingEntry.EMPTY_METADATA,
+ entry.getMetaData() );
+ assertEquals( "(\\W|^)something:\\=(.*?)$",
+ entry.getKeyPattern().toString() );
+ assertEquals( "Attribute( something == \"$2\" ) ",
+ entry.getMappingValue() );
+
+ } catch ( final IOException e ) {
+ e.printStackTrace();
+ fail( "Should not raise exception " );
+ }
+
+ }
+}
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/DefaultExpanderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/DefaultExpanderTest.java 2008-06-04 18:24:35 UTC (rev 20310)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/DefaultExpanderTest.java 2008-06-04 18:55:28 UTC (rev 20311)
@@ -12,15 +12,21 @@
public class DefaultExpanderTest extends TestCase {
private DSLMappingFile file = null;
+ private DSLTokenizedMappingFile tokenizedFile = null;
private DefaultExpander expander = null;
protected void setUp() throws Exception {
final String filename = "test_metainfo.dsl";
final Reader reader = new InputStreamReader( this.getClass().getResourceAsStream( filename ) );
this.file = new DSLMappingFile();
+ this.tokenizedFile = new DSLTokenizedMappingFile();
this.file.parseAndLoad( reader );
reader.close();
-
+
+ final Reader reader2 = new InputStreamReader( this.getClass().getResourceAsStream( filename ) );
+ this.tokenizedFile.parseAndLoad(reader2);
+ reader2.close();
+
this.expander = new DefaultExpander();
super.setUp();
@@ -34,12 +40,23 @@
this.expander.addDSLMapping( this.file.getMapping() );
// should not raise any exception
}
+
+ public void testANTLRAddDSLMapping() {
+ this.expander.addDSLMapping( this.tokenizedFile.getMapping() );
+ // should not raise any exception
+ }
public void testRegexp() throws Exception {
this.expander.addDSLMapping( this.file.getMapping() );
final Reader rules = new InputStreamReader( this.getClass().getResourceAsStream( "test_expansion.dslr" ) );
final String result = this.expander.expand( rules );
}
+
+ public void testANTLRRegexp() throws Exception {
+ this.expander.addDSLMapping( this.tokenizedFile.getMapping() );
+ final Reader rules = new InputStreamReader( this.getClass().getResourceAsStream( "test_expansion.dslr" ) );
+ final String result = this.expander.expand( rules );
+ }
public void testExpandParts() throws Exception {
@@ -54,6 +71,18 @@
System.err.println(ex.expand( "rule 'x' \n when \n foo \n then \n end" ));
}
+ public void testANTLRExpandParts() throws Exception {
+ DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
+ String dsl = "[when]foo=Foo()\n[then]bar {num}=baz({num});";
+ file.parseAndLoad( new StringReader( dsl ) );
+ assertEquals( 0,
+ file.getErrors().size() );
+ DefaultExpander ex = new DefaultExpander();
+ ex.addDSLMapping( file.getMapping() );
+
+ System.err.println(ex.expand( "rule 'x' \n when \n foo \n then \n end" ));
+ }
+
public void testExpandFailure() throws Exception {
DSLMappingFile file = new DSLMappingFile();
@@ -79,7 +108,33 @@
ex.getErrors().size() );
//System.err.println(( (ExpanderException) ex.getErrors().get( 0 )).getMessage());
}
+
+ public void testANTLRExpandFailure() throws Exception {
+ DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
+ String dsl = "[when]foo=Foo()\n[then]bar {num}=baz({num});";
+ file.parseAndLoad( new StringReader( dsl ) );
+ assertEquals( 0,
+ file.getErrors().size() );
+
+ DefaultExpander ex = new DefaultExpander();
+ ex.addDSLMapping( file.getMapping() );
+ String source = "rule 'q'\nagenda-group 'x'\nwhen\n foo \nthen\n bar 42\nend";
+ String drl = ex.expand( source );
+ assertFalse( ex.hasErrors() );
+
+ ex = new DefaultExpander();
+ ex.addDSLMapping( file.getMapping() );
+
+ source = "rule 'q' agenda-group 'x'\nwhen\n foos \nthen\n bar 42\n end";
+ drl = ex.expand( source );
+ //System.out.println( drl );
+ assertTrue( ex.hasErrors() );
+ assertEquals( 1,
+ ex.getErrors().size() );
+ //System.err.println(( (ExpanderException) ex.getErrors().get( 0 )).getMessage());
+ }
+
public void testExpandWithKeywordClashes() throws Exception {
DSLMappingFile file = new DSLMappingFile();
@@ -99,8 +154,28 @@
assertEquals( expected, drl );
}
+
+ public void testANTLRExpandWithKeywordClashes() throws Exception {
+ DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
+ String dsl = "[when]Invoke rule executor=ruleExec: RuleExecutor()\n" + "[then]Execute rule \"{id}\"=ruleExec.ExecuteSubRule( new Long({id}));";
+ file.parseAndLoad( new StringReader( dsl ) );
+ assertEquals( 0,
+ file.getErrors().size() );
+ DefaultExpander ex = new DefaultExpander();
+ ex.addDSLMapping( file.getMapping() );
+ String source = "package something;\n\nrule \"1\"\nwhen\n Invoke rule executor\nthen\n Execute rule \"5\"\nend";
+ String expected = "package something;\n\nrule \"1\"\nwhen\n ruleExec: RuleExecutor() \nthen\n ruleExec.ExecuteSubRule( new Long(5)); \nend\n";
+ String drl = ex.expand( source );
+// System.out.println("["+drl+"]" );
+// System.out.println("["+expected+"]" );
+ assertFalse( ex.hasErrors() );
+ assertEquals( expected, drl );
+
+ }
+
+
public void testLineNumberError() throws Exception {
DSLMappingFile file = new DSLMappingFile();
String dsl = "[when]foo=Foo()\n[then]bar {num}=baz({num});";
@@ -122,6 +197,27 @@
}
+ public void testANTLRLineNumberError() throws Exception {
+ DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
+ String dsl = "[when]foo=Foo()\n[then]bar {num}=baz({num});";
+ file.parseAndLoad( new StringReader( dsl ) );
+
+ DefaultExpander ex = new DefaultExpander();
+ ex.addDSLMapping( file.getMapping() );
+ String source = "rule 'q'\nagenda-group 'x'\nwhen\n __ \nthen\n bar 42\n\tgoober\nend";
+ ex.expand( source );
+ assertTrue( ex.hasErrors() );
+ assertEquals( 2,
+ ex.getErrors().size() );
+ ExpanderException err = (ExpanderException) ex.getErrors().get( 0 );
+ assertEquals( 4,
+ err.getLine() );
+ err = (ExpanderException) ex.getErrors().get( 1 );
+ assertEquals( 7,
+ err.getLine() );
+
+ }
+
private boolean equalsIgnoreWhiteSpace( String expected, String actual ) {
String patternStr = expected.replaceAll( "\\s+", "(\\\\s|\\\\n|\\\\r)*" );//.replaceAll( "\\n", "\\s*\\$" );
Pattern pattern = Pattern.compile( patternStr, Pattern.DOTALL );
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/dsl/test_antlr.dsl (from rev 20284, labs/jbossrules/branches/mattgeis/drools-compiler/src/test/resources/org/drools/lang/dsl/test_antlr.dsl)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/dsl/test_antlr.dsl (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/dsl/test_antlr.dsl 2008-06-04 18:55:28 UTC (rev 20311)
@@ -0,0 +1,37 @@
+#This is a sample DSL for a ficticous E-Commerce website that is building a recommendation engine
+
+
+[condition][]address is present where {constraints}=u : User() and exists (a: Address( where {constraints}) from u.addresses)
+[condition][]where {attr:[A-Za-z0-9]+} is "{value}"= {attr} == "{value}"
+[condition][]and {attr:[A-Za-z0-9]+} is "{value}"= , {attr} == "{value}"
+#[keyword][*]regra {atributos} faça {rhs} se {lhs} fim=rule {atributos} \\n when\\n {lhs}\\n then\\n {rhs}\\n end
+#[keyword][*]consulta=query
+#[keyword][]fim=end
+#[when][woolfel.ecommerce.model.Customer]the Customer=cust : Customer()
+#[when][woolfel.ecommerce.model.Customer]- has an email=emailAddress != null
+#[when][woolfel.ecommerce.model.Customer]- first name is "{first}"=first == "{first}"
+#[when][woolfel.ecommerce.model.Customer]- last name is "{surname}"=sname: surname == "{surname}"
+#[when][woolfel.ecommerce.model.CustomerProfile]a User profile=userprof : CustomerProfile(prfid : profileId)
+#[when][woolfel.ecommerce.model.Response]the Response=resp : Response()
+#[when][woolfel.ecommerce.model.Response]- is empty=userId == usrid, recommendation == null
+#[when][woolfel.ecommerce.model.Response]- is not empty=userId == usrid, recommendation != null
+#[when][woolfel.ecommerce.model.Response]- matches the user=userId == userid
+#[when][woolfel.ecommerce.model.Aggregate]an aggregate=aggr : Aggregate()
+#[when][woolfel.ecommerce.model.Recommendation]the recommendation where=recm : Recommendation()
+#[when][woolfel.ecommerce.model.Recommendation]- the profile is found=profileId == prfid
+#[when][woolfel.ecommerce.model.Product]the Product=prod : Product()
+#[when][woolfel.ecommerce.model.Product]- store is "{store}"=storeCategory == "{store}"
+#[when][woolfel.ecommerce.model.Product]- shop category is "{shopcat}"=shopCategory == "{shopcat}"
+#[when][woolfel.ecommerce.model.Product]- category is "{prodcat}"=productCategory == "{prodcat}"
+#[when][woolfel.ecommerce.model.Product]- subcategory is "{subcat}"=subProductCategory == "{subcat}"
+#[when][woolfel.ecommerce.model.Product]- manufacturer is "{manufac}"=manufacturer == "{manufac}"
+#[when][woolfel.ecommerce.model.Product]- SKU is equal to "{sku}"=SKU == "{sku}"
+#[when][woolfel.ecommerce.model.Order]the Order where=ordr : Order()
+#[when][woolfel.ecommerce.model.Order]- shipping method is "{shipmethod}"=shippingMethod == "{shipmethod}"
+#[when][woolfel.ecommerce.model.Order]- has more than {items}=cartItems > {items}
+#[when][woolfel.ecommerce.model.Order]- has coupons=coupons != null
+#[then][woolfel.ecommerce.model.Recommendation]return the recommendation=resp.setRecommendation(recm);
+#[then][]Log "{msg}"=System.out.println("{msg}");
+#[when][]but not=not
+#[when][woolfel.ecommerce.model.Customer]- last name is not "{surname}"=surname != "{surname}"
+#[then][*]Show last name=System.out.println(cust.getSurname());
Modified: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/dsl/test_metainfo.dsl
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/dsl/test_metainfo.dsl 2008-06-04 18:24:35 UTC (rev 20310)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/dsl/test_metainfo.dsl 2008-06-04 18:55:28 UTC (rev 20311)
@@ -1,32 +1,31 @@
-#This is a sample DSL for a ficticous E-Commerce website that is building a recommendation engine
-[keyword][*]regra {atributos} faça {rhs} se {lhs} fim=rule {atributos} \\n when\\n {lhs}\\n then\\n {rhs}\\n end
-[keyword][*]consulta=query
-[keyword]fim=end
-[when][woolfel.ecommerce.model.Customer]the Customer=cust : Customer()
-[when][woolfel.ecommerce.model.Customer]- has an email=emailAddress != null
-[when][woolfel.ecommerce.model.Customer]- first name is "{first}"=first == "{first}"
-[when][woolfel.ecommerce.model.Customer]- last name is "{surname}"=sname: surname == "{surname}"
-[when][woolfel.ecommerce.model.CustomerProfile]a User profile=userprof : CustomerProfile(prfid : profileId)
-[when][woolfel.ecommerce.model.Response]the Response=resp : Response()
-[when][woolfel.ecommerce.model.Response]- is empty=userId == usrid, recommendation == null
-[when][woolfel.ecommerce.model.Response]- is not empty=userId == usrid, recommendation != null
-[when][woolfel.ecommerce.model.Response]- matches the user=userId == userid
-[when][woolfel.ecommerce.model.Aggregate]an aggregate=aggr : Aggregate()
-[when][woolfel.ecommerce.model.Recommendation]the recommendation where=recm : Recommendation()
-[when][woolfel.ecommerce.model.Recommendation]- the profile is found=profileId == prfid
-[when][woolfel.ecommerce.model.Product]the Product=prod : Product()
-[when][woolfel.ecommerce.model.Product]- store is "{store}"=storeCategory == "{store}"
-[when][woolfel.ecommerce.model.Product]- shop category is "{shopcat}"=shopCategory == "{shopcat}"
-[when][woolfel.ecommerce.model.Product]- category is "{prodcat}"=productCategory == "{prodcat}"
-[when][woolfel.ecommerce.model.Product]- subcategory is "{subcat}"=subProductCategory == "{subcat}"
-[when][woolfel.ecommerce.model.Product]- manufacturer is "{manufac}"=manufacturer == "{manufac}"
-[when][woolfel.ecommerce.model.Product]- SKU is equal to "{sku}"=SKU == "{sku}"
-[when][woolfel.ecommerce.model.Order]the Order where=ordr : Order()
-[when][woolfel.ecommerce.model.Order]- shipping method is "{shipmethod}"=shippingMethod == "{shipmethod}"
-[when][woolfel.ecommerce.model.Order]- has more than {items}=cartItems > {items}
-[when][woolfel.ecommerce.model.Order]- has coupons=coupons != null
-[then][woolfel.ecommerce.model.Recommendation]return the recommendation=resp.setRecommendation(recm);
-[then]Log "{msg}"=System.out.println("{msg}");
-[when]but not=not
-[when][woolfel.ecommerce.model.Customer]- last name is not "{surname}"=surname != "{surname}"
-[then][*]Show last name=System.out.println(cust.getSurname());
+[keyword][*]regra {atributos} faca {rhs} se {lhs} fim=rule {atributos} \\n when\\n {lhs}\\n then\\n {rhs}\\n end
+[keyword][*]consulta=query
+[keyword][]fim=end
+[condition][woolfel.ecommerce.model.Customer]the Customer=cust : Customer()
+[condition][woolfel.ecommerce.model.Customer]- has an email=emailAddress != null
+[condition][woolfel.ecommerce.model.Customer]- first name is "{first}"=first == "{first}"
+[condition][woolfel.ecommerce.model.Customer]- last name is "{surname}"=sname: surname == "{surname}"
+[condition][woolfel.ecommerce.model.CustomerProfile]a User profile=userprof : CustomerProfile(prfid : profileId)
+[condition][woolfel.ecommerce.model.Response]the Response=resp : Response()
+[condition][woolfel.ecommerce.model.Response]- is empty=userId == usrid, recommendation == null
+[condition][woolfel.ecommerce.model.Response]- is not empty=userId == usrid, recommendation != null
+[condition][woolfel.ecommerce.model.Response]- matches the user=userId == userid
+[condition][woolfel.ecommerce.model.Aggregate]an aggregate=aggr : Aggregate()
+[condition][woolfel.ecommerce.model.Recommendation]the recommendation where=recm : Recommendation()
+[condition][woolfel.ecommerce.model.Recommendation]- the profile is found=profileId == prfid
+[condition][woolfel.ecommerce.model.Product]the Product=prod : Product()
+[condition][woolfel.ecommerce.model.Product]- store is "{store}"=storeCategory == "{store}"
+[condition][woolfel.ecommerce.model.Product]- shop category is "{shopcat}"=shopCategory == "{shopcat}"
+[condition][woolfel.ecommerce.model.Product]- category is "{prodcat}"=productCategory == "{prodcat}"
+[condition][woolfel.ecommerce.model.Product]- subcategory is "{subcat}"=subProductCategory == "{subcat}"
+[condition][woolfel.ecommerce.model.Product]- manufacturer is "{manufac}"=manufacturer == "{manufac}"
+[condition][woolfel.ecommerce.model.Product]- SKU is equal to "{sku}"=SKU == "{sku}"
+[condition][woolfel.ecommerce.model.Order]the Order where=ordr : Order()
+[condition][woolfel.ecommerce.model.Order]- shipping method is "{shipmethod}"=shippingMethod == "{shipmethod}"
+[condition][woolfel.ecommerce.model.Order]- has more than {items}=cartItems > {items}
+[condition][woolfel.ecommerce.model.Order]- has coupons=coupons != null
+[consequence][woolfel.ecommerce.model.Recommendation]return the recommendation=resp.setRecommendation(recm);
+[consequence][]Log "{msg}"=System.out.println("{msg}");
+[condition][]but not=not
+[condition][woolfel.ecommerce.model.Customer]- last name is not "{surname}"=surname != "{surname}"
+[consequence][*]Show last name=System.out.println(cust.getSurname());
More information about the jboss-svn-commits
mailing list