]> Repositorios git - scryer-prolog.git/commitdiff
allow module export of nonterminals (#281)
authorMark Thom <[email protected]>
Fri, 13 Mar 2020 21:40:03 +0000 (15:40 -0600)
committerMark Thom <[email protected]>
Fri, 13 Mar 2020 21:40:03 +0000 (15:40 -0600)
src/prolog/machine/toplevel.rs

index bcfe128c67a1c4569a779bacb879450232d3fd48..0d93a3940bcd32ecb9d402a99d557d02c69b3d9d 100644 (file)
@@ -224,8 +224,8 @@ fn setup_op_decl(
 fn setup_predicate_indicator(term: &mut Term) -> Result<PredicateKey, ParserError>
 {
     match term {
-        Term::Clause(_, ref name, ref mut terms, Some(_))
-            if name.as_str() == "/" && terms.len() == 2 =>
+        Term::Clause(_, ref slash, ref mut terms, Some(_))
+            if (slash.as_str() == "/" || slash.as_str() == "//") && terms.len() == 2 =>
         {
             let arity = *terms.pop().unwrap();
             let name  = *terms.pop().unwrap();
@@ -241,8 +241,12 @@ fn setup_predicate_indicator(term: &mut Term) -> Result<PredicateKey, ParserErro
                 .and_then(|c| c.to_atom())
                 .ok_or(ParserError::InvalidModuleExport)?;
 
-            Ok((name, arity))
-        }
+            if slash.as_str() == "/" {
+                Ok((name, arity))
+            } else {
+                Ok((name, arity + 2))
+            }
+        }        
         _ => Err(ParserError::InvalidModuleExport),
     }
 }