[Commits] (twl) Add union, intersect, and difference to grammar

commits at osafoundation.org commits at osafoundation.org
Thu Aug 19 17:11:04 PDT 2004


Commit by: twl
Modified files:
internal/queryparser/QueryParser.g 1.1 1.2

Log message:
Add union, intersect, and difference to grammar
Allow $ prefixed numeric parameters


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/internal/queryparser/QueryParser.g.diff?r1=text&tr1=1.1&r2=text&tr2=1.2

Index: internal/queryparser/QueryParser.g
diff -u internal/queryparser/QueryParser.g:1.1 internal/queryparser/QueryParser.g:1.2
--- internal/queryparser/QueryParser.g:1.1	Fri Aug 13 12:35:43 2004
+++ internal/queryparser/QueryParser.g	Thu Aug 19 17:11:02 2004
@@ -1,5 +1,5 @@
-__revision__  = "$Revision: 1.1 $"
-__date__      = "$Date: 2004/08/13 19:35:43 $"
+__revision__  = "$Revision: 1.2 $"
+__date__      = "$Date: 2004/08/20 00:11:02 $"
 __copyright__ = "Copyright (c) 2004 Open Source Applications Founation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -28,16 +28,34 @@
 parser Query:
     ignore:    "[ \r\t\n]+"
     token NUM: '[0-9]+'
-    token FOR: '[Ff][Oo][Rr]'
-    token ID: '[a-zA-Z]+'
     token STRING: '"([^\\"]+|\\\\.)*"|\'([^\']+|\\\\.)*\''
-    token UNOP: '[+-]'
+    token PARAM: '\$[0-9]+'
+    token UNOP: '(not|\+|-)'
     token MULOP: '(\*|/|div|mod)'
     token ADDOP: '(\+|-)'
     token RELOP: '(==|!=|>=|<=|>|<)'
     token BOOLOP: '(and|or)'
+    token ID: '[a-zA-Z]+'
     token END: '$'
 
+    rule stmt: union_stmt {{ return union_stmt }} 
+        | intersection_stmt {{ return intersection_stmt }}
+        | difference_stmt {{ return difference_stmt }}
+        | for_stmt {{ return for_stmt }}
+
+    rule stmt_list: stmt {{ result = [ stmt ] }}
+        (',' stmt {{ result.append(stmt) }} )*
+        {{ return result }}
+
+    rule union_stmt: 'union' '\(' stmt_list '\)' 
+        {{ return [ 'union', stmt_list] }}
+
+    rule intersection_stmt: 'intersect' '\(' stmt {{ stmt1 = stmt }} ',' stmt {{ stmt2 = stmt }} '\)'
+        {{ return [ 'intersect', stmt1, stmt2] }}
+
+    rule difference_stmt: 'difference' '\(' stmt {{ stmt1 = stmt }} ',' stmt {{ stmt2=stmt }}  '\)'
+        {{ return [ 'difference', stmt1, stmt2] }}
+
     rule for_stmt: 'for' ID 'in' 
                    ( name_expr 'where' and_or_expr 
                      {{ return [ 'for', ID, name_expr, and_or_expr ] }} END 
@@ -82,6 +100,6 @@
                     ( ',' and_or_expr {{ result.append(and_or_expr) }} )*
                     {{ return result }}
 
-    rule name_expr: ID {{ return ID }}
+    rule name_expr: ID {{ return ID }} | PARAM {{ return PARAM }}
 
 %%



More information about the Commits mailing list