File tree Expand file tree Collapse file tree 5 files changed +14
-2
lines changed
Expand file tree Collapse file tree 5 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,15 @@ private static bool ProcessDeclaration(object maybeDeclaration)
178178 }
179179 break ;
180180
181+ case "externally_called" :
182+ {
183+ var spec = arg as Call ;
184+ if ( spec == null || ! spec . IsFunctor ( Symbol . Slash , 2 ) )
185+ throw new ArgumentException ( "Invalid predicate specified in externally_called declaration" ) ;
186+ KB . Predicate ( ( Symbol ) spec . Arguments [ 0 ] , ( int ) spec . Arguments [ 1 ] ) . IsExternallyCalled = true ;
187+ }
188+ break ;
189+
181190 default :
182191 return false ;
183192 }
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ private static void PrintClauseWarnings(TextWriter output)
2929 private static void WarnUnreferenced ( TextWriter output , Dictionary < Predicate , List < Predicate > > refs )
3030 {
3131 foreach ( var p in KB . AllRulePredicates )
32- if ( p . IsUserDefined && ! refs . ContainsKey ( p ) )
32+ if ( p . IsUserDefined && ! refs . ContainsKey ( p ) && ! p . IsExternallyCalled )
3333 Warn ( output , "unused predicate {0}" , p ) ;
3434 }
3535
Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ internal IEnumerable<Predicate> ReferencedUserPredicates
157157
158158 public bool IsUserDefined => ( IsRulePredicate && ! IsLocked ) || IsTable ;
159159 public bool IsTable => Table != null ;
160+ public bool IsExternallyCalled ;
160161
161162 #endregion
162163
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ static ExpressionParser()
5252 DefinePrefixOperator ( "signature" , 25 ) ;
5353 DefinePrefixOperator ( "trace" , 25 ) ;
5454 DefinePrefixOperator ( "notrace" , 25 ) ;
55+ DefinePrefixOperator ( "externally_called" , 25 ) ;
5556
5657 DefineBinaryOperator ( "=" , 30 ) ;
5758 DefineBinaryOperator ( "+=" , 30 ) ;
Original file line number Diff line number Diff line change @@ -117,7 +117,8 @@ public static bool RunCommand(string command)
117117 }
118118 else if ( command . StartsWith ( "table " ) || command . StartsWith ( "function " )
119119 || command . StartsWith ( "trace " ) || command . StartsWith ( "notrace " )
120- || command . StartsWith ( "global " ) || command . StartsWith ( "require " ) )
120+ || command . StartsWith ( "global " ) || command . StartsWith ( "require " )
121+ || command . StartsWith ( "externally_called " ) )
121122 {
122123 // Process a declaration
123124 try
You can’t perform that action at this time.
0 commit comments