Article View: comp.lang.prolog
Article #256ProYACC??? (was: Pro4th???)
From: Mark William Hopkins
Date: Tue, 25 Jul 1989 23:43
Date: Tue, 25 Jul 1989 23:43
29 lines
1639 bytes
1639 bytes
In article <12746@well.UUCP> jax@well.UUCP (Jack J. Woehr) writes:
>
> So my son asks me last night, "Can you write a Forth in
>Prolog?"
>
> "Yes, but it would run awfully slowly." That should have been
>that, but it got me to thinking, that would be a pretty amusing
>demo of Prolog! I seem to recall it has been done before, but don't remember
>when or by whom.
Yes it could! Here's an outline:
(1) Set up a LR(1) parser generator in Prolog.
(2) Create a YACC-like front end, using Prolog's existing grammar
notation and your parser generator.
(3) Write a Forth compiler using the YACC-like parser generator (choose
your favorite target language for efficiency)
(4) Use the compiler to compile the said Forth program into the target
language
and
(5) Run the executable code.
It's MUCH easier than expected, since Prolog is such a high-level language.
The compiler should be able to create better code since it is written in a
language that makes it easy to write better optimization rules, so the result
should be MORE(!) efficient than otherwise.
Also, steps (1) through (4) only need be done once :-).
Technical Details
Message-ID:
<3526@csd4.milw.wisc.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!markhReferences:
<12746@well.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!markh From: markh@csd4.milw.wisc.edu (Mark William Hopkins) Newsgroups: comp.lang.prolog Subject: ProYACC??? (was: Pro4th???) Keywords: forth, forlog, foobar Message-ID: <3526@csd4.milw.wisc.edu> Date: 25 Jul 89 23:43:20 GMT References: <12746@well.UUCP> Sender: news@csd4.milw.wisc.edu Reply-To: markh@csd4.milw.wisc.edu (Mark William Hopkins) Organization: University of Wisconsin-Milwaukee Lines: 29