Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is the correct order to generate WAM code for L0 program terms?

In Hassan Aït-Kaci's "Warren's Abstract Machine: A Tutorial Reconstruction" Section 2.2, the orders for compilation of L0 queries are clear enough: registers must be allocated with left-to-right breadth-first search and code must be generated with left-to-right post-order depth-first search.

In Section 2.3, the order for register allocation (of L0 programs) is clear: left-to-right breadth-first search. The order for code generation isn't. With the only example given, I can't tell if I should use BFS or DFS to generate code.

Can someone give me the WAM code for the following L0 program?

p(q(r(a)),s(b)).

like image 446
matheuscscp Avatar asked Dec 14 '25 07:12

matheuscscp


1 Answers

I put your program in sample.pl:

$ cat sample.pl
p(q(r(a)),s(b)).

Using GNU Prolog, I then did:

$ gplc -w sample.pl

The following WAM instructions are then contained in sample.wbc:

clause(p(q(r(a)),s(b)),[
    get_structure(q/1,0),
    unify_structure(r/1),
    unify_atom(a),
    get_structure(s/1,1),
    unify_atom(b),
    proceed]).
like image 130
mat Avatar answered Dec 15 '25 21:12

mat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!