[jboss-svn-commits] JBL Code SVN: r20117 - labs/jbossrules/branches/mattgeis/drools-compiler/src/main/resources/org/drools/lang/dsl.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu May 22 19:13:57 EDT 2008


Author: mattgeis
Date: 2008-05-22 19:13:57 -0400 (Thu, 22 May 2008)
New Revision: 20117

Modified:
   labs/jbossrules/branches/mattgeis/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMap.g
   labs/jbossrules/branches/mattgeis/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMapWalker.g
Log:
updates to ANTLR grammars

Modified: labs/jbossrules/branches/mattgeis/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMap.g
===================================================================
--- labs/jbossrules/branches/mattgeis/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMap.g	2008-05-22 23:13:41 UTC (rev 20116)
+++ labs/jbossrules/branches/mattgeis/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMap.g	2008-05-22 23:13:57 UTC (rev 20117)
@@ -1,302 +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);
-	}
-	
-	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)+
-	;	
-	
-literal 
-	//: ( LITERAL | LEFT_SQUARE | RIGHT_SQUARE | COLON) //trying to remove [] from literals
-	: ( LITERAL | 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?
-	;
-	
-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 hasSpace = false;
-}	
-	: lc=LEFT_CURLY { if( ((CommonToken)input.LT(-2)).getStopIndex() < ((CommonToken)lc).getStartIndex() -1 ) hasSpace = true; } 
-	name=LITERAL RIGHT_CURLY
-	-> {hasSpace}? VT_SPACE ^(VT_VAR_REF $name )
-	->  ^(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	:	':'
-	;
-
-
-//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 	:
-		'!' | '@' | '$' | '%' | '^' | '*' | '-' | '+'  | '?' | '/' | '\'' | '"' | '|' | '&' | '(' | ')' | ';'
-	;
-
-
+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 	:
+		'>'|'<'|'!' | '@' | '$' | '%' | '^' | '*' | '-' | '+'  | '?' | '/' | '\'' | '"' | '|' | '&' | '(' | ')' | ';'
+	;
+
+

Modified: labs/jbossrules/branches/mattgeis/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMapWalker.g
===================================================================
--- labs/jbossrules/branches/mattgeis/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMapWalker.g	2008-05-22 23:13:41 UTC (rev 20116)
+++ labs/jbossrules/branches/mattgeis/drools-compiler/src/main/resources/org/drools/lang/dsl/DSLMapWalker.g	2008-05-22 23:13:57 UTC (rev 20117)
@@ -23,7 +23,12 @@
 }
 	: ^(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());
 	}
 	;
 	
@@ -31,6 +36,7 @@
 	: ent=entry
 	{
 		$mapping_file::retval.addEntry(ent);
+		//System.out.println("mapping size is now " + $mapping_file::retval.getEntries().size());
 	}
 	;
 	
@@ -43,19 +49,32 @@
 entry returns [DSLMappingEntry mappingEntry]
 scope {
 	Map variables;
-	DefaultDSLMappingEntry retval;
+	AntlrDSLMappingEntry retval;
 	int counter;
 	StringBuffer keybuffer;
 	StringBuffer valuebuffer;
 }
 @init {
-	$entry::retval = new DefaultDSLMappingEntry() ;
+	$entry::retval = new AntlrDSLMappingEntry() ;
 	$entry::variables = new HashMap();
 	$entry::keybuffer = new StringBuffer();
 	$entry::valuebuffer = new StringBuffer();
 }
-	: ^(VT_ENTRY scope_section meta_section key_section value_section)
+	: ^(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;
 	}
 	;
@@ -81,7 +100,7 @@
 key_section
 	: ^(VT_ENTRY_KEY key_sentence+ )
 	{
-		$entry::retval.setMappingKey($entry::keybuffer.toString());
+		//$entry::retval.setMappingKey($entry::keybuffer.toString());
 	}
 	;
  
@@ -89,6 +108,7 @@
 	: variable_definition
 	| vtl=VT_LITERAL 
 	{
+		//System.out.println("in key_sentence, literal is " + $vtl.text);
 		$entry::keybuffer.append($vtl.text);
 	}
 	| VT_SPACE
@@ -96,11 +116,15 @@
 		$entry::keybuffer.append("\\s+");
 	}
 	;		
-
+/*
+key_chunk
+	: literal+
+	;		
+*/	
 value_section
 	: ^(VT_ENTRY_VAL value_sentence+ )
 	{
-		$entry::retval.setMappingValue($entry::valuebuffer.toString());
+		//$entry::retval.setMappingValue($entry::valuebuffer.toString());
 	}
 	;
 	
@@ -108,16 +132,21 @@
 	: 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("\\s+");
+		$entry::valuebuffer.append(" ");
 	}
 	;	
-
+/*	
+value_chunk
+	: (literal|EQUALS)+
+	;	
+*/	
 literal 
-	: theliteral=VT_LITERAL
+	: theliteral=VT_LITERAL {//System.out.println("theliteral is " + $theliteral.text);}
 	;	
 
 
@@ -125,6 +154,7 @@
 
 	:   ^(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 + ")" : "(.*?)");
@@ -135,7 +165,8 @@
 variable_reference 
 	: ^(varref=VT_VAR_REF lit=LITERAL ) 
 	{
-		$entry::valuebuffer.append("\\$" + $entry::variables.get($lit.text));
+		//System.out.println("varref is " + $varref.text + " and points to " + $lit.text);
+		$entry::valuebuffer.append("$" + $entry::variables.get($lit.text));
 	}
 	;	
 




More information about the jboss-svn-commits mailing list