--- a/semantics/constraints.pl Thu Dec 13 13:53:35 2012 +0000
+++ b/semantics/constraints.pl Thu Dec 13 15:12:00 2012 +0000
@@ -1,4 +1,4 @@
-%% The rules
+%% The rules.
%% A decl is of the form
%% decl(Type,N,Name,Rules)
%% where Type is Inference or Constraint
@@ -17,6 +17,12 @@
%% elements are OK.
+%% TODO: Recognize and do correct thing for special predicates
+%% (equality, membership, precedes). Currently we just represent these
+%% as atoms.
+%% TODO: Allow comments to have multiple representations, depending on the
+%% target (HTML, LaTeX/Wiki)
+
decl('Inference', 5,'communication-generation-use-inference',
rule([id, a_2,a_1,attrs],
[wasInformedBy(id, a_2,a_1,attrs)],
@@ -168,6 +174,7 @@
[],
[entity(e_2, attrs)])).
+%% Constraints. Most of these remain to do.
decl('Constraint',56, 'membership-empty-collection',
rule([c,e],
@@ -317,26 +324,33 @@
emit('</li>'),
htmlRuleList(Rs).
-htmlWiki('Inference',Num,Name,Rules) -->
+htmlDecl('Inference',_Num,Name,Rules) -->
emit('<div class="inference" id="'),
emit(Name),
emit('">'),
htmlRules(Rules),
emit('</div>\n').
+htmlDecl('Constraint',_Num,Name,Rules) -->
+ emit('<div class="constraint" id="'),
+ emit(Name),
+ emit('">'),
+ htmlRules(Rules),
+ emit('</div>\n').
-writeEach(_Out,[]).
-writeEach(Out,[Num|Nums]) :-
- decl('Inference',Num,Name,Rules),
- htmlWiki('Inference',Num,Name,Rules,'',X),
+writeEach(_Target,_Out,[]).
+writeEach(Target,Out,[Num|Nums]) :-
+ decl(Type,Num,Name,Rules),
+ call(Target,Type,Num,Name,Rules,'',X),
write(Out,X),
flush_output(Out),
- writeEach(Out,Nums).
-
-main(F) :- open(F,write,Out),
+ writeEach(Target,Out,Nums).
+
+
+main(Target,F) :- open(F,write,Out),
findall(X, decl(_,X,_,_),Xs),
- writeEach(Out,Xs),
+ writeEach(Target,Out,Xs),
close(Out).
main :- findall(X, decl(_,X,_,_),Xs),
- writeEach(user,Xs).
+ writeEach(htmlDecl,user,Xs).