cacol89 avatar cacol89 committed 5429335

now negations are restricted exclusively to rterms

Comments (0)

Files changed (3)

     | Rel of rterm
     | Equal of var * const
     | Ineq of string * var * const
-    | Not of term
+    | Not of rterm
 and const =
     | Int of int
     | Real of float
 
 (** get the list of variables of a term *)
 let rec get_varlist t = match t with
-    | Rel r            -> ( match r with
-                            | Pred (x, vl) -> vl
-                        )
+    | Rel r            -> get_rterm_varlist r
     | Equal (s, i)     -> s :: []
     | Ineq  (op,s, i)  -> s :: []
-    | Not t            -> get_varlist t
+    | Not r            -> get_rterm_varlist r
 ;;
 
 (** Given a query, returns the rterm that is defined inside*)
     | Rule(_, t) ->
         let rec extract_rterm acc = function
             | Rel x -> x::acc
-            | Not x -> extract_rterm acc x
+            | Not x -> x::acc
             | _ -> acc in
         List.fold_left extract_rterm [] t
     | Query _    -> invalid_arg "function get_all_rule_rterms called with a query"
     | Rel r             -> string_of_rterm r
     | Equal (s, i)      -> string_of_var s ^ " = " ^ string_of_const i
     | Ineq (op,s, i)    -> string_of_var s ^ " " ^ op ^ " " ^ string_of_const i
-    | Not t             -> "not " ^ string_of_term t
+    | Not rt            -> "not " ^ string_of_rterm rt
 ;;
 
 (** support function for smart stringify of the AST - see to_string below *)
 
   literal:
   | predicate							{ Rel $1 }
-  | NOT predicate 						{ Not (Rel $2) }
+  | NOT predicate 						{ Not $2 }
   | equation							{ $1 }
   | NOT equation					        { negate_eq $2 }
   ;

src/rule_preproc.ml

     | Rel rt ->
         let rt_key = symtkey_of_rterm rt in
         (key_comp key rt_key) = 0
-    | Not t ->
-        if (check_rec_term key t) then
+    | Not rt ->
+        if (check_rec_term key (Rel rt)) then
             raise (Yadi_error (
                 "Predicate "^(string_of_symtkey key)^
                 " is negatively recursive"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.