[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnu-arch-users] Round III: xl and all that
From: |
Jeremy Shaw |
Subject: |
Re: [Gnu-arch-users] Round III: xl and all that |
Date: |
Sat, 24 Jul 2004 17:26:40 -0700 |
User-agent: |
Wanderlust/2.11.30 (Wonderwall) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI) |
At Fri, 23 Jul 2004 18:55:06 -0700 (PDT),
Tom Lord wrote:
>
> Really... this is almost worked out well enough now to convert into
> code which should go pretty quickly once it starts....
Indeed:
address@hidden/xlmachine--main--1.0--base-0
http://www.sourcecontrol.net/?m=showarchive&address@hidden
(mirror is not update-to-date, but will be when the cron job runs next...)
This is a quick and dirty interpreter implementation as described in
tom's email. The code has only been tested with ghc 6.2.1. But should
be relatively portable.
To build, simply run gnu make. This will build the binary:
=build/xl1
Although trivial to add, this version does not currently allow you to
specify how many cycles the interpreter should run for. However, all
xl1 programs will eventually halt.
If you are running some linux distro where installing ghc is a
multi-hour project. There is a statically linked linux binary at:
http://www.n-heptane.com/nhlab/tmp/xl1.static
If it breaks, you keep both pieces. Under debian, just run 'apt-get
install ghc6' to install the ghc compiler.
Here is some sample output:
(0) help
usage: xl1 [options] FILE GOAL
FILE - a file contain an xl1 program
GOAL - $goal
options:
-f - print only the final state of the machine
-xl1 - print final state as a valid xl program
(1) A run of the maybe-prime reduction showing all states:
~/projects/haskell/Xl1Machine $ ./=build/xl1 power.xl1 maybe-prime
--------------
Initial State:
--------------
$program = #(type => 'program
N => 3
maybe-prime => (- two-power 1)
two-power => (power 2 N)
)
$goal = maybe-prime
$subgoal = maybe-prime
--------------
Cycle 1:
--------------
$program = #(type => 'program
N => 3
maybe-prime => (- two-power 1)
two-power => (power 2 3)
)
$goal = maybe-prime
$subgoal = two-power
--------------
Cycle 2:
--------------
$program = #(type => 'program
N => 3
maybe-prime => (- two-power 1)
two-power => 8
)
$goal = maybe-prime
$subgoal = two-power
--------------
Cycle 3:
--------------
$program = #(type => 'program
N => 3
maybe-prime => (- two-power 1)
two-power => 8
)
$goal = maybe-prime
$subgoal = maybe-prime
--------------
Cycle 4:
--------------
$program = #(type => 'program
N => 3
maybe-prime => (- 8 1)
two-power => 8
)
$goal = maybe-prime
$subgoal = maybe-prime
--------------
Cycle 5:
--------------
$program = #(type => 'program
N => 3
maybe-prime => 7
two-power => 8
)
$goal = maybe-prime
$subgoal = maybe-prime
(2) A run of the maybe-prime reduction showing the final state as a
xl1 program
~/projects/haskell/Xl1Machine $ ./=build/xl1 -xl1 power.xl1 maybe-prime
(N 3)
(maybe-prime 7)
(two-power 8)
The only primitive functions implemented are:
* - + = power
If you want to add new primitive functions just modified the function
`appFun'
Jeremy Shaw.
ps. This is really hot off the press, and may contain bugs, so if the
output looks fishy, it may be wrong...