[jboss-svn-commits] JBL Code SVN: r18088 - in labs/jbossrules/trunk/drools-clips/src: main/resources/org/drools/clp and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jan 24 20:27:56 EST 2008
Author: mark.proctor at jboss.com
Date: 2008-01-24 20:27:55 -0500 (Thu, 24 Jan 2008)
New Revision: 18088
Added:
labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/mvel/SwitchFunction.java
Modified:
labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPMVELLexer.java
labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPMVELParser.java
labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/CLPMVEL.g
labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/mvel/TestMVEL.java
Log:
JBRULES-720 Clips Parser
-Added switch
Modified: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPMVELLexer.java
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPMVELLexer.java 2008-01-24 21:15:43 UTC (rev 18087)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPMVELLexer.java 2008-01-25 01:27:55 UTC (rev 18088)
@@ -1,4 +1,4 @@
-// $ANTLR 3.0.1 C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g 2008-01-24 21:14:26
+// $ANTLR 3.0.1 C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g 2008-01-25 00:37:25
package org.drools.clp;
@@ -1563,8 +1563,8 @@
// $ANTLR start FIRST_SYMBOL_CHAR
public final void mFIRST_SYMBOL_CHAR() throws RecognitionException {
try {
- // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:882:19: ( ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '!' | '$' | '%' | '^' | '*' | '_' | '-' | '+' | '=' | '\\\\' | '/' | '@' | '#' | ':' | '>' | '<' | ',' | '.' | '[' | ']' | '{' | '}' ) )
- // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:882:21: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '!' | '$' | '%' | '^' | '*' | '_' | '-' | '+' | '=' | '\\\\' | '/' | '@' | '#' | ':' | '>' | '<' | ',' | '.' | '[' | ']' | '{' | '}' )
+ // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:874:19: ( ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '!' | '$' | '%' | '^' | '*' | '_' | '-' | '+' | '=' | '\\\\' | '/' | '@' | '#' | ':' | '>' | '<' | ',' | '.' | '[' | ']' | '{' | '}' ) )
+ // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:874:21: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '!' | '$' | '%' | '^' | '*' | '_' | '-' | '+' | '=' | '\\\\' | '/' | '@' | '#' | ':' | '>' | '<' | ',' | '.' | '[' | ']' | '{' | '}' )
{
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)>='a' && input.LA(1)<='{')||input.LA(1)=='}' ) {
input.consume();
@@ -1589,8 +1589,8 @@
// $ANTLR start SYMBOL_CHAR
public final void mSYMBOL_CHAR() throws RecognitionException {
try {
- // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:887:13: ( ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '!' | '$' | '%' | '^' | '*' | '_' | '-' | '+' | '=' | '\\\\' | '/' | '@' | '#' | ':' | '>' | ',' | '.' | '[' | ']' | '{' | '}' | '?' ) )
- // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:887:15: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '!' | '$' | '%' | '^' | '*' | '_' | '-' | '+' | '=' | '\\\\' | '/' | '@' | '#' | ':' | '>' | ',' | '.' | '[' | ']' | '{' | '}' | '?' )
+ // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:879:13: ( ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '!' | '$' | '%' | '^' | '*' | '_' | '-' | '+' | '=' | '\\\\' | '/' | '@' | '#' | ':' | '>' | ',' | '.' | '[' | ']' | '{' | '}' | '?' ) )
+ // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:879:15: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '!' | '$' | '%' | '^' | '*' | '_' | '-' | '+' | '=' | '\\\\' | '/' | '@' | '#' | ':' | '>' | ',' | '.' | '[' | ']' | '{' | '}' | '?' )
{
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)>='a' && input.LA(1)<='{')||input.LA(1)=='}' ) {
input.consume();
Modified: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPMVELParser.java
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPMVELParser.java 2008-01-24 21:15:43 UTC (rev 18087)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPMVELParser.java 2008-01-25 01:27:55 UTC (rev 18088)
@@ -1,4 +1,4 @@
-// $ANTLR 3.0.1 C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g 2008-01-24 21:14:26
+// $ANTLR 3.0.1 C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g 2008-01-25 00:37:25
package org.drools.clp;
@@ -1885,7 +1885,7 @@
// $ANTLR start lisp_list2
- // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:654:1: lisp_list2 returns [SExpression sExpression] : LEFT_PAREN t= ( NAME | VAR ) (a= lisp_atom2 | a= lisp_list2 )+ RIGHT_PAREN ;
+ // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:654:1: lisp_list2 returns [SExpression sExpression] : LEFT_PAREN t= ( NAME | VAR ) (a= lisp_atom2 | a= lisp_list2 )* RIGHT_PAREN ;
public final SExpression lisp_list2() throws RecognitionException {
SExpression sExpression = null;
@@ -1898,8 +1898,8 @@
sExpression = null;
try {
- // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:659:2: ( LEFT_PAREN t= ( NAME | VAR ) (a= lisp_atom2 | a= lisp_list2 )+ RIGHT_PAREN )
- // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:659:4: LEFT_PAREN t= ( NAME | VAR ) (a= lisp_atom2 | a= lisp_list2 )+ RIGHT_PAREN
+ // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:659:2: ( LEFT_PAREN t= ( NAME | VAR ) (a= lisp_atom2 | a= lisp_list2 )* RIGHT_PAREN )
+ // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:659:4: LEFT_PAREN t= ( NAME | VAR ) (a= lisp_atom2 | a= lisp_list2 )* RIGHT_PAREN
{
match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_lisp_list21300); if (failed) return sExpression;
t=(Token)input.LT(1);
@@ -1917,8 +1917,7 @@
if ( backtracking==0 ) {
list.add( new SymbolLispAtom2( t.getText() ) );
}
- // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:661:3: (a= lisp_atom2 | a= lisp_list2 )+
- int cnt18=0;
+ // C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:661:3: (a= lisp_atom2 | a= lisp_list2 )*
loop18:
do {
int alt18=3;
@@ -1961,16 +1960,11 @@
break;
default :
- if ( cnt18 >= 1 ) break loop18;
- if (backtracking>0) {failed=true; return sExpression;}
- EarlyExitException eee =
- new EarlyExitException(18, input);
- throw eee;
+ break loop18;
}
- cnt18++;
} while (true);
- match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_lisp_list21364); if (failed) return sExpression;
+ match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_lisp_list21363); if (failed) return sExpression;
if ( backtracking==0 ) {
sExpression = new LispForm2( ( SExpression[] ) list.toArray( new SExpression[ list.size () ] ) );
}
@@ -2054,7 +2048,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:684:6: t= VAR
{
t=(Token)input.LT(1);
- match(input,VAR,FOLLOW_VAR_in_lisp_atom21414); if (failed) return sExpression;
+ match(input,VAR,FOLLOW_VAR_in_lisp_atom21413); if (failed) return sExpression;
if ( backtracking==0 ) {
sExpression = new VariableLispAtom2( t.getText() );
}
@@ -2065,7 +2059,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:685:6: t= STRING
{
t=(Token)input.LT(1);
- match(input,STRING,FOLLOW_STRING_in_lisp_atom21426); if (failed) return sExpression;
+ match(input,STRING,FOLLOW_STRING_in_lisp_atom21425); if (failed) return sExpression;
if ( backtracking==0 ) {
sExpression = new StringLispAtom2( getString( t ) );
}
@@ -2076,7 +2070,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:686:6: t= FLOAT
{
t=(Token)input.LT(1);
- match(input,FLOAT,FOLLOW_FLOAT_in_lisp_atom21448); if (failed) return sExpression;
+ match(input,FLOAT,FOLLOW_FLOAT_in_lisp_atom21447); if (failed) return sExpression;
if ( backtracking==0 ) {
sExpression = new FloatLispAtom2( t.getText() );
}
@@ -2087,7 +2081,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:687:6: t= INT
{
t=(Token)input.LT(1);
- match(input,INT,FOLLOW_INT_in_lisp_atom21460); if (failed) return sExpression;
+ match(input,INT,FOLLOW_INT_in_lisp_atom21459); if (failed) return sExpression;
if ( backtracking==0 ) {
sExpression = new IntLispAtom2( t.getText() );
}
@@ -2098,7 +2092,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:688:7: t= BOOL
{
t=(Token)input.LT(1);
- match(input,BOOL,FOLLOW_BOOL_in_lisp_atom21473); if (failed) return sExpression;
+ match(input,BOOL,FOLLOW_BOOL_in_lisp_atom21472); if (failed) return sExpression;
if ( backtracking==0 ) {
sExpression = new BoolLispAtom2( t.getText() );
}
@@ -2109,7 +2103,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:689:7: t= NULL
{
t=(Token)input.LT(1);
- match(input,NULL,FOLLOW_NULL_in_lisp_atom21489); if (failed) return sExpression;
+ match(input,NULL,FOLLOW_NULL_in_lisp_atom21488); if (failed) return sExpression;
if ( backtracking==0 ) {
sExpression = new NullLispAtom2( null );
}
@@ -2120,7 +2114,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:690:14: t= NAME
{
t=(Token)input.LT(1);
- match(input,NAME,FOLLOW_NAME_in_lisp_atom21515); if (failed) return sExpression;
+ match(input,NAME,FOLLOW_NAME_in_lisp_atom21514); if (failed) return sExpression;
if ( backtracking==0 ) {
sExpression = new SymbolLispAtom2( "\"" +t.getText() + "\"");
}
@@ -2157,7 +2151,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:696:2: ( LEFT_PAREN (a= lisp_atom[context] | a= lisp_list[context, list.createList()] )* RIGHT_PAREN )
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:696:4: LEFT_PAREN (a= lisp_atom[context] | a= lisp_list[context, list.createList()] )* RIGHT_PAREN
{
- match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_lisp_list1546); if (failed) return valueHandler;
+ match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_lisp_list1545); if (failed) return valueHandler;
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:697:3: (a= lisp_atom[context] | a= lisp_list[context, list.createList()] )*
loop20:
do {
@@ -2176,7 +2170,7 @@
case 1 :
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:697:6: a= lisp_atom[context]
{
- pushFollow(FOLLOW_lisp_atom_in_lisp_list1556);
+ pushFollow(FOLLOW_lisp_atom_in_lisp_list1555);
a=lisp_atom(context);
_fsp--;
if (failed) return valueHandler;
@@ -2189,7 +2183,7 @@
case 2 :
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:698:6: a= lisp_list[context, list.createList()]
{
- pushFollow(FOLLOW_lisp_list_in_lisp_list1572);
+ pushFollow(FOLLOW_lisp_list_in_lisp_list1571);
a=lisp_list(context, list.createList());
_fsp--;
if (failed) return valueHandler;
@@ -2205,7 +2199,7 @@
}
} while (true);
- match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_lisp_list1602); if (failed) return valueHandler;
+ match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_lisp_list1601); if (failed) return valueHandler;
if ( backtracking==0 ) {
valueHandler = list.getValueHandler();
}
@@ -2289,7 +2283,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:709:6: t= VAR
{
t=(Token)input.LT(1);
- match(input,VAR,FOLLOW_VAR_in_lisp_atom1639); if (failed) return value;
+ match(input,VAR,FOLLOW_VAR_in_lisp_atom1638); if (failed) return value;
if ( backtracking==0 ) {
value = context.getVariableValueHandler(t.getText() );
}
@@ -2300,7 +2294,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:710:6: t= STRING
{
t=(Token)input.LT(1);
- match(input,STRING,FOLLOW_STRING_in_lisp_atom1651); if (failed) return value;
+ match(input,STRING,FOLLOW_STRING_in_lisp_atom1650); if (failed) return value;
if ( backtracking==0 ) {
value = new ObjectValueHandler( getString( t ) );
}
@@ -2311,7 +2305,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:711:7: t= NAME
{
t=(Token)input.LT(1);
- match(input,NAME,FOLLOW_NAME_in_lisp_atom1663); if (failed) return value;
+ match(input,NAME,FOLLOW_NAME_in_lisp_atom1662); if (failed) return value;
if ( backtracking==0 ) {
value = new ObjectValueHandler( t.getText() );
}
@@ -2322,7 +2316,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:712:6: t= FLOAT
{
t=(Token)input.LT(1);
- match(input,FLOAT,FOLLOW_FLOAT_in_lisp_atom1678); if (failed) return value;
+ match(input,FLOAT,FOLLOW_FLOAT_in_lisp_atom1677); if (failed) return value;
if ( backtracking==0 ) {
value = new DoubleValueHandler( t.getText() );
}
@@ -2333,7 +2327,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:713:6: t= INT
{
t=(Token)input.LT(1);
- match(input,INT,FOLLOW_INT_in_lisp_atom1690); if (failed) return value;
+ match(input,INT,FOLLOW_INT_in_lisp_atom1689); if (failed) return value;
if ( backtracking==0 ) {
value = new LongValueHandler( t.getText() );
}
@@ -2344,7 +2338,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:714:6: t= BOOL
{
t=(Token)input.LT(1);
- match(input,BOOL,FOLLOW_BOOL_in_lisp_atom1706); if (failed) return value;
+ match(input,BOOL,FOLLOW_BOOL_in_lisp_atom1705); if (failed) return value;
if ( backtracking==0 ) {
value = new BooleanValueHandler( t.getText() );
}
@@ -2355,7 +2349,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:715:6: t= NULL
{
t=(Token)input.LT(1);
- match(input,NULL,FOLLOW_NULL_in_lisp_atom1724); if (failed) return value;
+ match(input,NULL,FOLLOW_NULL_in_lisp_atom1723); if (failed) return value;
if ( backtracking==0 ) {
value = ObjectValueHandler.NULL;
}
@@ -2440,7 +2434,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:723:8: t= STRING
{
t=(Token)input.LT(1);
- match(input,STRING,FOLLOW_STRING_in_literal1760); if (failed) return text;
+ match(input,STRING,FOLLOW_STRING_in_literal1759); if (failed) return text;
if ( backtracking==0 ) {
text = getString( t );
}
@@ -2451,7 +2445,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:724:7: t= NAME
{
t=(Token)input.LT(1);
- match(input,NAME,FOLLOW_NAME_in_literal1773); if (failed) return text;
+ match(input,NAME,FOLLOW_NAME_in_literal1772); if (failed) return text;
if ( backtracking==0 ) {
text = t.getText();
}
@@ -2462,7 +2456,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:725:7: t= INT
{
t=(Token)input.LT(1);
- match(input,INT,FOLLOW_INT_in_literal1789); if (failed) return text;
+ match(input,INT,FOLLOW_INT_in_literal1788); if (failed) return text;
if ( backtracking==0 ) {
text = t.getText();
}
@@ -2473,7 +2467,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:726:7: t= FLOAT
{
t=(Token)input.LT(1);
- match(input,FLOAT,FOLLOW_FLOAT_in_literal1804); if (failed) return text;
+ match(input,FLOAT,FOLLOW_FLOAT_in_literal1803); if (failed) return text;
if ( backtracking==0 ) {
text = t.getText();
}
@@ -2484,7 +2478,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:727:7: t= BOOL
{
t=(Token)input.LT(1);
- match(input,BOOL,FOLLOW_BOOL_in_literal1817); if (failed) return text;
+ match(input,BOOL,FOLLOW_BOOL_in_literal1816); if (failed) return text;
if ( backtracking==0 ) {
text = t.getText();
}
@@ -2495,7 +2489,7 @@
// C:\\dev\\drools\\trunk\\drools-clips\\src\\main\\resources\\org\\drools\\clp\\CLPMVEL.g:728:7: t= NULL
{
t=(Token)input.LT(1);
- match(input,NULL,FOLLOW_NULL_in_literal1831); if (failed) return text;
+ match(input,NULL,FOLLOW_NULL_in_literal1830); if (failed) return text;
if ( backtracking==0 ) {
text = null;
}
@@ -2615,33 +2609,33 @@
public static final BitSet FOLLOW_literal_in_literal_restriction1239 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_lisp_list2_in_eval_sExpressions1271 = new BitSet(new long[]{0x0000000000000012L});
public static final BitSet FOLLOW_LEFT_PAREN_in_lisp_list21300 = new BitSet(new long[]{0x0000000000000120L});
- public static final BitSet FOLLOW_set_in_lisp_list21310 = new BitSet(new long[]{0x0000000007001530L});
+ public static final BitSet FOLLOW_set_in_lisp_list21310 = new BitSet(new long[]{0x0000000007001570L});
public static final BitSet FOLLOW_lisp_atom2_in_lisp_list21325 = new BitSet(new long[]{0x0000000007001570L});
public static final BitSet FOLLOW_lisp_list2_in_lisp_list21336 = new BitSet(new long[]{0x0000000007001570L});
- public static final BitSet FOLLOW_RIGHT_PAREN_in_lisp_list21364 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_VAR_in_lisp_atom21414 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_STRING_in_lisp_atom21426 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_FLOAT_in_lisp_atom21448 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_INT_in_lisp_atom21460 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_BOOL_in_lisp_atom21473 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_NULL_in_lisp_atom21489 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_NAME_in_lisp_atom21515 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_LEFT_PAREN_in_lisp_list1546 = new BitSet(new long[]{0x0000000007001570L});
- public static final BitSet FOLLOW_lisp_atom_in_lisp_list1556 = new BitSet(new long[]{0x0000000007001570L});
- public static final BitSet FOLLOW_lisp_list_in_lisp_list1572 = new BitSet(new long[]{0x0000000007001570L});
- public static final BitSet FOLLOW_RIGHT_PAREN_in_lisp_list1602 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_VAR_in_lisp_atom1639 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_STRING_in_lisp_atom1651 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_NAME_in_lisp_atom1663 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_FLOAT_in_lisp_atom1678 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_INT_in_lisp_atom1690 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_BOOL_in_lisp_atom1706 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_NULL_in_lisp_atom1724 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_STRING_in_literal1760 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_NAME_in_literal1773 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_INT_in_literal1789 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_FLOAT_in_literal1804 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_BOOL_in_literal1817 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_NULL_in_literal1831 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_RIGHT_PAREN_in_lisp_list21363 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VAR_in_lisp_atom21413 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_STRING_in_lisp_atom21425 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_FLOAT_in_lisp_atom21447 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_INT_in_lisp_atom21459 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_BOOL_in_lisp_atom21472 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_NULL_in_lisp_atom21488 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_NAME_in_lisp_atom21514 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LEFT_PAREN_in_lisp_list1545 = new BitSet(new long[]{0x0000000007001570L});
+ public static final BitSet FOLLOW_lisp_atom_in_lisp_list1555 = new BitSet(new long[]{0x0000000007001570L});
+ public static final BitSet FOLLOW_lisp_list_in_lisp_list1571 = new BitSet(new long[]{0x0000000007001570L});
+ public static final BitSet FOLLOW_RIGHT_PAREN_in_lisp_list1601 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_VAR_in_lisp_atom1638 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_STRING_in_lisp_atom1650 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_NAME_in_lisp_atom1662 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_FLOAT_in_lisp_atom1677 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_INT_in_lisp_atom1689 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_BOOL_in_lisp_atom1705 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_NULL_in_lisp_atom1723 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_STRING_in_literal1759 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_NAME_in_literal1772 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_INT_in_literal1788 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_FLOAT_in_literal1803 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_BOOL_in_literal1816 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_NULL_in_literal1830 = new BitSet(new long[]{0x0000000000000002L});
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/CLPMVEL.g
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/CLPMVEL.g 2008-01-24 21:15:43 UTC (rev 18087)
+++ labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/CLPMVEL.g 2008-01-25 01:27:55 UTC (rev 18088)
@@ -660,7 +660,7 @@
t=(NAME|VAR) { list.add( new SymbolLispAtom2( t.getText() ) ); }
( a=lisp_atom2 { list.add( a ); }
| a=lisp_list2 { list.add( a ); }
- )+
+ )*
RIGHT_PAREN
{ sExpression = new LispForm2( ( SExpression[] ) list.toArray( new SExpression[ list.size () ] ) ); }
;
@@ -868,14 +868,6 @@
fragment
SYMBOL : FIRST_SYMBOL_CHAR SYMBOL_CHAR* ;
-/*
-fragment
-START_DELIM : ' '|'\t'|'\n'|'\r'|'"'|'('|')'|';'|'&'|'|'|'~'|'?';
-
-fragment
-DELIM : ' '|'\t'|'\n'|'\r'|'"'|'('|')'|';'|'&'|'|'|'~'|'<';
-*/
-
// allowed <
// not allowed ?
fragment
@@ -884,17 +876,7 @@
// allowed ?
// not allowed <
fragment
-SYMBOL_CHAR : ('a'..'z'|'A'..'Z'|'0'..'9'|'!'|'$'|'%'|'^'|'*'|'_'|'-'|'+'|'='|'\\'|'/'|'@'|'#'|':'|'>'|','|'.'|'['|']'|'{'|'}'|'?');
+SYMBOL_CHAR : ('a'..'z'|'A'..'Z'|'0'..'9'|'!'|'$'|'%'|'^'|'*'|'_'|'-'|'+'|'='|'\\'|'/'|'@'|'#'|':'|'>'|','|'.'|'['|']'|'{'|'}'|'?');
-
-/*
-fragment
-SYMBOL
- : ((~(' '|'\t'|'\n'|'\r'|'"'|'('|')'|';'|'&'|'|'|'~'|'?'|'$'))|('$' ~('?'|' '|'\t'|'\n'|'\r'|'"'|'('|')'|';'|'&'|'|'|'~'|'<')))
- (~(' '|'\t'|'\n'|'\r'|'"'|'('|')'|';'|'&'|'|'|'~'|'<'|'?'))*
- ;
-*/
-
-
Added: labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/mvel/SwitchFunction.java
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/mvel/SwitchFunction.java (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/mvel/SwitchFunction.java 2008-01-25 01:27:55 UTC (rev 18088)
@@ -0,0 +1,55 @@
+package org.drools.clp.mvel;
+
+public class SwitchFunction implements Function {
+ private static String name = "switch";
+
+ public String getName() {
+ return name;
+ }
+
+ public void dump(LispForm2 lispForm, Appendable appendable) {
+ SExpression[] sExpressions = lispForm.getSExpressions();
+
+ appendable.append( "switchvar = " );
+ LispForm2 expr = ( LispForm2 ) sExpressions[1];
+ if ( expr.getSExpressions().length > 1 ) {
+ FunctionHandlers.getInstance().dump( expr, appendable );
+ } else {
+ FunctionHandlers.getInstance().dump( expr.getSExpressions()[0], appendable );
+ }
+ appendable.append( ";\n" );
+
+ LispForm2 caseForm = ( LispForm2 ) sExpressions[2];
+
+ appendable.append( "if ( switchvar == " );
+
+ FunctionHandlers.getInstance().dump( caseForm.getSExpressions()[1], appendable );
+ appendable.append( ") {" );
+ FunctionHandlers.getInstance().dump( caseForm.getSExpressions()[3], appendable );
+ appendable.append( "}" );
+
+ for ( int i = 3, length = sExpressions.length-1; i < length; i++ ) {
+ caseForm = ( LispForm2 ) sExpressions[i];
+
+ appendable.append( " else if ( switchvar == " );
+ FunctionHandlers.getInstance().dump( caseForm.getSExpressions()[1], appendable );
+ appendable.append( ") {" );
+ FunctionHandlers.getInstance().dump( caseForm.getSExpressions()[3], appendable );
+ appendable.append( "}" );
+ }
+
+ caseForm = ( LispForm2 ) sExpressions[ sExpressions.length-1 ];
+ if ( "case".equals( ((LispAtom2)caseForm.getSExpressions()[0]).getValue() ) ) {
+ appendable.append( " else if ( switchvar == " );
+ FunctionHandlers.getInstance().dump( caseForm.getSExpressions()[1], appendable );
+ appendable.append( ") {" );
+ FunctionHandlers.getInstance().dump( caseForm.getSExpressions()[3], appendable );
+ appendable.append( "}" );
+ } else {
+ appendable.append( " else { " );
+ FunctionHandlers.getInstance().dump( caseForm.getSExpressions()[1], appendable );
+ appendable.append( "}" );
+ }
+
+ }
+}
Modified: labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/mvel/TestMVEL.java
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/mvel/TestMVEL.java 2008-01-24 21:15:43 UTC (rev 18087)
+++ labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/mvel/TestMVEL.java 2008-01-25 01:27:55 UTC (rev 18088)
@@ -26,11 +26,12 @@
handlers.registerFunction( new IfFunction() );
handlers.registerFunction( new LessThanFunction() );
handlers.registerFunction( new MoreThanFunction() );
- handlers.registerFunction( new EqFunction() );
+ handlers.registerFunction( new EqFunction() );
+ handlers.registerFunction( new SwitchFunction() );
}
public void test1() {
- String expr = "(* (+ 4 4 ) 2) (create$ 10 20 (+ 10 10) a) (modify ?p (name mark) (age (+ 16 16) ) ) (printout t a b c (+ 4 4) )";
+ String expr = "(* (+ 4 4 ) 2) (create$ 10 20 (+ 10 10) a) (modify ?p (name mark) (location \"london\")(age (+ 16 16) ) ) (printout t a b c (+ 4 4) )";
SExpression[] lisplists = evalString( expr );
@@ -83,10 +84,24 @@
}
System.out.println( appendable );
- }
+ }
+ public void testSwitch() {
+ String expr = "(switch (?x) (case a then (printout t a)) (case b then (printout t b)) (default (printout t b)) )";
+
+ SExpression[] lisplists = evalString( expr );
+
+ StringBuilderAppendable appendable = new StringBuilderAppendable();
+
+ for ( SExpression sExpression : lisplists ) {
+ FunctionHandlers.getInstance().dump( sExpression, appendable );
+ }
+
+ System.out.println( appendable );
+ }
+
public void test3() {
String function = "(deffunction max (?a ?b) (return ?b) )";
String expr = "(max (3 5) )";
More information about the jboss-svn-commits
mailing list