timv [Thu, 6 Jun 2013 22:49:43 +0000 (18:49 -0400)]
Interpreter states encapulated in an `Interpreter` instance.
- this was a big refactoring adds a few new files (chart.py, repl.py,
config.py)
Fix: Errors stop on first failed handler.
Adding a new rule is safe. We check that the initializers run and there are no
aggregator conflicts before added the new rules to `Interpreter` state. We stage
propagation.
I've document a few more errors (see `examples/string-quote.dyna`)
Mostly cosmetic changes, but of note:
The planner now uses the alias-tracking contexts for mode analysis (though
it does not actually yet do anything with this power; this change is in
preparation for backward-chaining)
DOpAMine unifications are now tagged with determinisim information, again
in preparation for future work; these are all currently set to DetNon.
DOpAMine and Python OPEmit printout is much more vertically compact.
Now uses destination-passing style and a new theory of contexts. It has
many more opportunities to raise warnings in bizarre cases and no longer
generates quite so much cruft as before.
Added `dict=` (name might changed) and aggregator which stores user variable
assignments. [This is what is used for answering queries like the one above.qq]
Parser now really should just be the parser.
OneshotDriver consumes an entire Dyna program at once, tracking
all the requisite state from line to line, before emitting the
whole mass to the down-stream pipeline.
While here, push through some changes for custom operator symbols, though
this is not quite wired up yet.
Change the world so that the planner generates OPEmit verbs rather
than emissions being magical bits of the backend. Expand the notion of an
emission to include the rule index (required for :=) and a set of variables
for hyper-edge identification. (Currently, we emit all of them, but later
we will want to trim this down to only nondeterministic variables.)
This change is the code-generator mate of timv's changes in 6abdc37.
Tim Vieira [Sat, 1 Jun 2013 03:21:49 +0000 (23:21 -0400)]
First-pass at a REPL
- user can add new rules (LIMITATIONS: no retracting rules; no queries yet.)
- new rules check for aggregator conflict.
- only shows the user what changed as a result of the new rule. rather than
dumping the entire chart. The chart isn't dumped every time we hit go().
Nicer chart pretty printing (only relevant to sets or lists of items), which is
only experimental.
Reverted Wes' changes to eval it seems like the change was not tested. Sorry Wes.
Nicer formatting for tracing messages. Tracing is no longer printed to
stderr. by defualt, it goes to /tmp/dyna.log (there is a cmdline option to
change that; there is also commands in the REPL "trace on" and "trace off").
Switch python selftests to run compiler themselves
And only run the interpreter as a captive process. This change is made with
the intent of more accurately reflecting code coverage when we start
tracking that within self-tests.
Notably, this marks the first commit to fix an externally filed bug report;
thanks to Abram Demski for reporting! Dyna should now build with ghc 7.4
and its Platform releases. :)
(This commit is a little bigger than just the fix as I had already changed
some of the code in my working tree and there seemed to be no reason not to
just commit things.)
Eliminate the awkward old ANF language in favor of direct translation to
Cruxes in Dyna.Analysis.ANF. Evaluation cruxes are now properly indexed
within rules using an Int, so we don't have to rely on the output variable
being unique. There are more flavors of unification cruxes, including
inequality constraints.
The terrible 'handleConflictors' has been replaced with a much more
sane function which operates on cruxes, rather than on DOpAMine, which will
be welcome when we have more interesting OPIter modes.
While here, move python scripts from bin/ to src/Dyna/Backend/Python and
adjust the world. Use this as an excuse to make ./debug invoke the dyna
compiler only once and dump everything to different files in $PROGRAM.d/
This brings the Mercury mode system all the way out through the planner,
though it does not actually really avail itself of any of the improved
functionality. It compiles and passes all selftests, but that, too, is
hardly saying anything.
The beginnings of a re-implementation of Mercury's mode system, as described
in: David Overton. Precise and Expressive Mode Systems for Typed Logic
Programming Languages. University of Melbourne, Department of Computer
Science and Software Engineering. Ph.D. thesis. December, 2003.
<http://www.mercury.csse.unimelb.edu.au/information/papers.html#dmo-thesis>