Re: Prolog -> Tex
- From: "Brian Hulley" <brianh@xxxxxxxxxxxx>
- Date: 27 May 2005 13:26:40 -0700
gipsy boy wrote:
> Hello,
>
> I'd like to convert my Prolog code to some fancy looking
> Tex/PDF/HTML/whatever (preferably Tex).
> Any idea how to do that?
A file of Prolog code is just a sequence of Prolog terms. Therefore you
could just read each term in turn, determine whether the term is a
clause or declaration (ie is principal functor :-/1) then recursively
traverse each term writing out the appropriate markup at each step.
I can't rembember any Tex off hand but in HTML, assuming you have a
style *** with the styles for the various elements, you could produce
output like:
<div class="clause">
<div class="functor">member</div>
<div class = "punctuation">(</div>
<div class = "variable">E</div>
<div class = "punctuation">,</div>
....
</div>
to format "member(X, ..."
with code such as:
format_clause(Clause) :-
write_div_begin(clause),
(
Clause = (Head :- Body)
->
format_head(Head),
write_punctuation(':-'),
format_body(Body)
;
format_head(Clause)
),
write_div_end.
write_div_begin(X) :-
write('<div class = \"'),write(X),write('\">').
write_div_end :- write('</div>').
etc
Regards, Brian.
.
- References:
- Prolog -> Tex
- From: gipsy boy
- Prolog -> Tex
- Prev by Date: Re: problem with anonymous variables
- Next by Date: Re: problem with anonymous variables
- Previous by thread: Re: Prolog -> Tex
- Next by thread: Re: Prolog -> Tex
- Index(es):