major commit

parent 29a01677
......@@ -39,6 +39,7 @@ SOURCES = \
logic/guile-log/functional-database.scm \
logic/guile-log/dynamic-features.scm \
logic/guile-log/guile-prolog/closure.scm \
logic/guile-log/prolog/varstat.scm \
logic/guile-log/prolog/pre.scm \
logic/guile-log/prolog/error.scm \
logic/guile-log/prolog/closed.scm \
......
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<html lang="en">
<head>
<title>Preliminary Manual: expressions</title>
<meta name="description" content="Preliminary Manual: expressions">
<meta name="keywords" content="Preliminary Manual: expressions">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index.html#Index" rel="index" title="Index">
<link href="parsing.html#parsing" rel="up" title="parsing">
<link href="sed_002fgrep.html#sed_002fgrep" rel="next" title="sed/grep">
<link href="parser-combinators.html#parser-combinators" rel="previous" title="parser combinators">
<style type="text/css">
<title>expressions - Preliminary Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Preliminary Manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="parsing.html#parsing" title="parsing">
<link rel="prev" href="parser-combinators.html#parser-combinators" title="parser combinators">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<body>
<div class="node">
<a name="expressions"></a>
<div class="header">
<p>
Previous: <a href="parser-combinators.html#parser-combinators" accesskey="p" rel="previous">parser combinators</a>, Up: <a href="parsing.html#parsing" accesskey="u" rel="up">parsing</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
Previous:&nbsp;<a rel="previous" accesskey="p" href="parser-combinators.html#parser-combinators">parser combinators</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="parsing.html#parsing">parsing</a>
<hr>
<a name="Expressions"></a>
</div>
<h3 class="section">7.3 Expressions</h3>
<p>This is a configureable expression parser that can be used for prolog parsing as well as parsing C and C++ expressions. To note is that the data is functionally updated and hence one can store the state at will and later reinstate the parser. The parser ideom is a direct translation of the commonly described prolog parser written in prolog to guile-log. It is then extended to allow ternial operators like <code>?</code> in c as well. To use it load the module <code>(logic guile-log parsing operator-parser)</code>
</p>
<a name="Api-2"></a>
<h4 class="subsection">7.3.1 Api</h4>
<a name="index-make_002dopdata"></a>
<p><code>(make-opdata)</code>, initiates a datastructure to containe needed operator data. The result is a fluid pointing to a functional datastructure.
</p>
<a name="index-add_002doperator"></a>
<p><code>(add-operator data type name level lf)</code>, This will add operator data to the opdata fluid <code>data</code>. <code>type</code> is the type of operator e.g. any of <code>xf,yf,fx,fy,xfx,xfy,yfx</code>, as of the standard meaning of these operators in prolog. <code>name</code> is a string or symbol representing the name of the operator and <code>level</code> is the anti binding strength of the operator e.g. higher value bind less. <code>lf</code> is a parser function that represents possible values to the right of the op-symbol matched, typically this will be <code>tok-ws</code>, but also for e.g. <code>?</code> it can be a parser function matching the middle part of in this operayor which ends with <code>:</code>.
</p>
<a name="index-rem_002doperator"></a>
<p><code>(rem-operator data type name)</code>, removes from the opdata fluid <code>data</code>, the slot represented by the type <code>type</code> and the operator name <code>name</code>.
</p>
<a name="index-mk_002doperator_002dexpression"></a>
<p><code>(mk-operator-expression atom rest-atom data)</code>, will return a parser meta function representing the operator configuration in <code>data</code>, with atom parser function <code>atom</code> and a secondary choised atom if that fails in <code>rest-atom</code>. The returned meta parser function, say <code>ff</code> is typically turned into a parser function for the expression through:
</p>
<p><code>(ff high-level)</code>, with <code>high-level</code>, the highes level found in the table.
</p>
<p>The generator parser <code>f</code> can then be used to match an expression and outpits a syntactic tree with nodes according to e.g.
</p><pre class="verbatim">(parse ``1 + -2'' f)
--&gt;
<p><a name="index-make_002dopdata-217"></a><code>(make-opdata)</code>, initiates a datastructure to containe needed operator data. The result is a fluid pointing to a functional datastructure.
<p><a name="index-add_002doperator-218"></a><code>(add-operator data type name level lf)</code>, This will add operator data to the opdata fluid <code>data</code>. <code>type</code> is the type of operator e.g. any of <code>xf,yf,fx,fy,xfx,xfy,yfx</code>, as of the standard meaning of these operators in prolog. <code>name</code> is a string or symbol representing the name of the operator and <code>level</code> is the anti binding strength of the operator e.g. higher value bind less. <code>lf</code> is a parser function that represents possible values to the right of the op-symbol matched, typically this will be <code>tok-ws</code>, but also for e.g. <code>?</code> it can be a parser function matching the middle part of in this operayor which ends with <code>:</code>.
<p><a name="index-rem_002doperator-219"></a><code>(rem-operator data type name)</code>, removes from the opdata fluid <code>data</code>, the slot represented by the type <code>type</code> and the operator name <code>name</code>.
<p><a name="index-mk_002doperator_002dexpression-220"></a><code>(mk-operator-expression atom rest-atom data)</code>, will return a parser meta function representing the operator configuration in <code>data</code>, with atom parser function <code>atom</code> and a secondary choised atom if that fails in <code>rest-atom</code>. The returned meta parser function, say <code>ff</code> is typically turned into a parser function for the expression through:
<p><code>(ff high-level)</code>, with <code>high-level</code>, the highes level found in the table.
<p>The generator parser <code>f</code> can then be used to match an expression and outpits a syntactic tree with nodes according to e.g.
<pre class="verbatim">(parse ``1 + -2'' f)
-->
(('xfy ``+'' _ _) (#:number 1) (('yf ``-'' _ _) (#:number 2) 4 0) 2 0)
</pre>
<p>That is a binary oparator is of the form,
</p>
<p><code>((type operator-name level _) term-left term-right column line)</code>
</p>
<p>And a unary operator is matched by
</p>
<p><code>((type operator-name level _) term column line)</code>.
</p>
<hr>
<div class="header">
<p>
Previous: <a href="parser-combinators.html#parser-combinators" accesskey="p" rel="previous">parser combinators</a>, Up: <a href="parsing.html#parsing" accesskey="u" rel="up">parsing</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<p>That is a binary oparator is of the form,
<p><code>((type operator-name level _) term-left term-right column line)</code>
<p>And a unary operator is matched by
<p><code>((type operator-name level _) term column line)</code>.
</body></html>
</body>
</html>
This diff is collapsed.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<html lang="en">
<head>
<title>Preliminary Manual: Top</title>
<meta name="description" content="Preliminary Manual: Top">
<meta name="keywords" content="Preliminary Manual: Top">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="#Top" rel="start" title="Top">
<link href="Index.html#Index" rel="index" title="Index">
<link href="../dir/index.html" rel="up" title="(dir)">
<link href="umatch.html#umatch" rel="next" title="umatch">
<style type="text/css">
<title>Preliminary Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Preliminary Manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="../index.html#dir" title="(dir)">
<link rel="next" href="umatch.html#umatch" title="umatch">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<h1 class="settitle" align="center">Preliminary Manual</h1>
<body>
<h1 class="settitle">Preliminary Manual</h1>
<div class="node">
<a name="Top"></a>
<div class="header">
<p>
Next: <a href="umatch.html#umatch" accesskey="n" rel="next">umatch</a>, Up: <a href="../dir/index.html" accesskey="u" rel="up">(dir)</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
Next:&nbsp;<a rel="next" accesskey="n" href="umatch.html#umatch">umatch</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="../index.html#dir">(dir)</a>
<hr>
<a name="Guile-Log"></a>
<h1 class="top">Guile Log</h1>
<p>Documentation for the Guile-Log Logic Programming Environment for Guile 2.0 v0.4
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="umatch.html#umatch" accesskey="1">umatch</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">low level infrastructure.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="guile_002dlog.html#guile_002dlog" accesskey="2">guile-log</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">This is the guile-log basic macro environment
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="acumulators_002fgenerators.html#acumulators_002fgenerators" accesskey="3">acumulators/generators</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Hot to collect and generate sequences of solutions.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="postpone.html#postpone" accesskey="4">postpone</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">To postpone a search.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="dynamics.html#dynamics" accesskey="5">dynamics</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">catch prompt abort
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="dynamic_002dfunctions.html#dynamic_002dfunctions" accesskey="6">dynamic-functions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Dynamicaly add, remove and execute clauses
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="parsing.html#parsing" accesskey="7">parsing</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A parsing framework.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="sed_002fgrep.html#sed_002fgrep" accesskey="8">sed/grep</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Sed and grep functionalities for scheme
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="kanren.html#kanren" accesskey="9">kanren</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Kanren implemented ontop of guile-log
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="prolog.html#prolog">prolog</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">iso-prolog
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="Index.html#Index">Index</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Complete index.
</td></tr>
</table>
<hr>
<div class="header">
<p>
Next: <a href="umatch.html#umatch" accesskey="n" rel="next">umatch</a>, Up: <a href="../dir/index.html" accesskey="u" rel="up">(dir)</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<h2 class="unnumbered">Guile Log</h2>
<p>Documentation for the Guile-Log Logic Programming Environment for Guile 2.0 v0.4
<ul class="menu">
<li><a accesskey="1" href="umatch.html#umatch">umatch</a>: low level infrastructure.
<li><a accesskey="2" href="guile_002dlog.html#guile_002dlog">guile-log</a>: This is the guile-log basic macro environment
<li><a accesskey="3" href="acumulators_002fgenerators.html#acumulators_002fgenerators">acumulators/generators</a>: Hot to collect and generate sequences of solutions.
<li><a accesskey="4" href="postpone.html#postpone">postpone</a>: To postpone a search.
<li><a accesskey="5" href="dynamics.html#dynamics">dynamics</a>: catch prompt abort
<li><a accesskey="6" href="dynamic_002dfunctions.html#dynamic_002dfunctions">dynamic-functions</a>: Dynamicaly add, remove and execute clauses
<li><a accesskey="7" href="parsing.html#parsing">parsing</a>: A parsing framework.
<li><a accesskey="8" href="sed_002fgrep.html#sed_002fgrep">sed/grep</a>: Sed and grep functionalities for scheme
<li><a accesskey="9" href="kanren.html#kanren">kanren</a>: Kanren implemented ontop of guile-log
<li><a href="prolog.html#prolog">prolog</a>: iso-prolog
<li><a href="Index.html#Index">Index</a>: Complete index.
</ul>
</body></html>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<html lang="en">
<head>
<title>Preliminary Manual: postpone</title>
<meta name="description" content="Preliminary Manual: postpone">
<meta name="keywords" content="Preliminary Manual: postpone">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index.html#Index" rel="index" title="Index">
<link href="index.html#Top" rel="up" title="Top">
<link href="dynamics.html#dynamics" rel="next" title="dynamics">
<link href="acumulators_002fgenerators.html#acumulators_002fgenerators" rel="previous" title="acumulators/generators">
<style type="text/css">
<title>postpone - Preliminary Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Preliminary Manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="acumulators_002fgenerators.html#acumulators_002fgenerators" title="acumulators/generators">
<link rel="next" href="dynamics.html#dynamics" title="dynamics">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<body>
<div class="node">
<a name="postpone"></a>
<div class="header">
<p>
Next: <a href="dynamics.html#dynamics" accesskey="n" rel="next">dynamics</a>, Previous: <a href="acumulators_002fgenerators.html#acumulators_002fgenerators" accesskey="p" rel="previous">acumulators/generators</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
Next:&nbsp;<a rel="next" accesskey="n" href="dynamics.html#dynamics">dynamics</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="acumulators_002fgenerators.html#acumulators_002fgenerators">acumulators/generators</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
<a name="Postpone_002c-a-framework-for-postponing-guile_002dlog-evaluations_002e"></a>
</div>
<h2 class="chapter">4 Postpone, a framework for postponing guile-log evaluations.</h2>
<p>This code is available from <code>(logic guile-log postpone)</code> You may have noticed that guile log is a framework to do tree searches to meet a certain criteria and during the path in the tree create data structures that are able to undo and also redo it&rsquo;s state. Most people when approaching this will sooner or later be bitten by the NP hardness of many interesting problems. The solution might then be to try intelligent guesses in which branch the gold is hiding. What one would like to do is try a set of branches, freeze the different states and at that point create some sort of index that represent the likelihood of the gold lying buried beneath. Then an overall global decision can be taken and only the most promising paths will be further examined. It is for this use case the following system is constructed. Postpone mix well with the rest of prolog, but especially the <code>&lt;zip&gt;</code>, forms might behave unexpectedly due to teh postpone mechansim interfering with the synch and produce bad result.
</p>
<a name="Api_002e"></a>
<p>This code is available from <code>(logic guile-log postpone)</code> You may have noticed that guile log is a framework to do tree searches to meet a certain criteria and during the path in the tree create data structures that are able to undo and also redo it's state. Most people when approaching this will sooner or later be bitten by the NP hardness of many interesting problems. The solution might then be to try intelligent guesses in which branch the gold is hiding. What one would like to do is try a set of branches, freeze the different states and at that point create some sort of index that represent the likelihood of the gold lying buried beneath. Then an overall global decision can be taken and only the most promising paths will be further examined. It is for this use case the following system is constructed. Postpone mix well with the rest of prolog, but especially the <code>&lt;zip&gt;</code>, forms might behave unexpectedly due to teh postpone mechansim interfering with the synch and produce bad result.
<h3 class="section">4.1 Api.</h3>
<a name="index-postpone"></a>
<a name="index-postpone_002dframe"></a>
<p><a name="index-postpone-171"></a><a name="index-postpone_002dframe-172"></a>
<pre class="verbatim">G.L. (postpone val power)
G.L. (postpone-frame limit fact maxsize)
</pre><p>To be able to postpone we must have a baseline from which we will base our restarts e.g. <code>postpone-frame</code>. The <code>postpone</code> command will basically evaluate <code>val</code> and postpone if it&rsquo;s larger then a certain limit that is governed by an initial value <code>limit</code> and <code>fact</code> - a factor that adds to the limit each postpone turn. The <code>power</code> is the sorting index used to manage a list of possible restarts for and this list is sorted so that we at restarts will try to use <code>maxsize</code> first elements of the list. The list is never larger then <code>10 * maxsize</code>.
</p>
<hr>
<div class="header">
<p>
Next: <a href="dynamics.html#dynamics" accesskey="n" rel="next">dynamics</a>, Previous: <a href="acumulators_002fgenerators.html#acumulators_002fgenerators" accesskey="p" rel="previous">acumulators/generators</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
</pre>
To be able to postpone we must have a baseline from which we will base our restarts e.g. <code>postpone-frame</code>. The <code>postpone</code> command will basically evaluate <code>val</code> and postpone if it's larger then a certain limit that is governed by an initial value <code>limit</code> and <code>fact</code> - a factor that adds to the limit each postpone turn. The <code>power</code> is the sorting index used to manage a list of possible restarts for and this list is sorted so that we at restarts will try to use <code>maxsize</code> first elements of the list. The list is never larger then <code>10 * maxsize</code>.
</body></html>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<html lang="en">
<head>
<title>Preliminary Manual: sed/grep</title>
<meta name="description" content="Preliminary Manual: sed/grep">
<meta name="keywords" content="Preliminary Manual: sed/grep">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index.html#Index" rel="index" title="Index">
<link href="index.html#Top" rel="up" title="Top">
<link href="kanren.html#kanren" rel="next" title="kanren">
<link href="expressions.html#expressions" rel="previous" title="expressions">
<style type="text/css">
<title>sed/grep - Preliminary Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Preliminary Manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="parsing.html#parsing" title="parsing">
<link rel="next" href="kanren.html#kanren" title="kanren">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<body>
<div class="node">
<a name="sed%2fgrep"></a>
<a name="sed_002fgrep"></a>
<div class="header">
<p>
Next: <a href="kanren.html#kanren" accesskey="n" rel="next">kanren</a>, Previous: <a href="parsing.html#parsing" accesskey="p" rel="previous">parsing</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
Next:&nbsp;<a rel="next" accesskey="n" href="kanren.html#kanren">kanren</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="parsing.html#parsing">parsing</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
<a name="Sed_002fgrep-overview"></a>
</div>
<h2 class="chapter">8 Sed/grep overview</h2>
<p>To overengineer and test out the framework a simple grep and sed utility has been designed. It knows about scheme and can locate and translate scheme files as well as having traditional grep/sed funcitonality. The main interface is in the module <code>(logic guile-log grep)</code>.
</p>
<a name="Api-3"></a>
<h3 class="section">8.1 Api</h3>
<p><code>(grep match code #:key (a 0) (b 0) (c 0))</code>, this will evaluate <code>code</code> in a separate thread and capture standard output and only print what the parser function <code>match</code> matches. <code>a,b,c</code> defines an interval <code>[min(-b,-c),max(a,c)]</code> around the matched line which is printed.
</p>
<p><code>(sed match code)</code>, will print everything but if match matches, it&rsquo;s output will be printed instead by the matcher, e.g. use the pr versions of the parser combinators for printing matches.
</p>
<p><code>(par-grep match code #:key (str q-false) (com q-false) (a 0) (b 0) (c 0))</code>, This is a grep funciton that knows about scheme, it works as before but will print the sexp or part of sexp that is matching. The extra fields are, <code>str</code>, the matcher used inside strings, <code>com</code>, the matcher used in comments, and <code>d</code> prints the lines containing the <code>d</code> level enclosing sexp.
</p>
<p><code>(par-sed match code #:key (str q-false) (com q-false))</code>, This is a sed utility that knows about scheme.
</p>
<a name="The-scheme-matcher_002e"></a>
<p><code>(sed match code)</code>, will print everything but if match matches, it's output will be printed instead by the matcher, e.g. use the pr versions of the parser combinators for printing matches.
<p><code>(par-grep match code #:key (str q-false) (com q-false) (a 0) (b 0) (c 0))</code>, This is a grep funciton that knows about scheme, it works as before but will print the sexp or part of sexp that is matching. The extra fields are, <code>str</code>, the matcher used inside strings, <code>com</code>, the matcher used in comments, and <code>d</code> prints the lines containing the <code>d</code> level enclosing sexp.
<p><code>(par-sed match code #:key (str q-false) (com q-false))</code>, This is a sed utility that knows about scheme.
<h3 class="section">8.2 The scheme matcher.</h3>
<p>In order to translate scheme code we have a nice little monster framework to to the grunt work. You may use it by importing (logic guile-log parsing sch-match).
<p>In order to translate scheme code we have a nice little monster framework to to the grunt work. You may use it by importing (logic guile-log parsing sch-match).
To use this one need to know about how syntax-parse works. We only support a subset of the syntax-parse interface, namlely the directives <code>~and ~or ~not ~var _)</code> added to this we make use of ice-9 match notation for symbols.
</p>
<p>To define a match abstraction use,
</p>
<p><code>(define-match-class [nm | (nm . args)] (pattern pat l ...) ...)</code>,
just use this as with define-syntax-class, but with the exception that you will build and match according to some whitespace rules stated below.
</p>
<p><code>(define-splicing-match-class [nm | (nm . args)] (pattern pat l ...) ...)</code>,
<p>To define a match abstraction use,
<p><code>(define-match-class [nm | (nm . args)] (pattern pat l ...) ...)</code>,
just use this as with define-syntax-class, but with the exception that you will build and match according to some whitespace rules stated below.
<p><code>(define-splicing-match-class [nm | (nm . args)] (pattern pat l ...) ...)</code>,
This works just as with <code>define-splicing-syntax-class</code> in syntax-parse, but again with some extra twarts.
</p>
<p>The actual matchers are,
</p>
<p><code>(scm-sed (pat res ...) ...)</code>, this works just as with syntax-parse, but with the extra build-rules.
</p>
<p><code>(scm-match pat)</code>, use this as a matcher in par-grep, but with the syntax-parse pattern interface to define a match.
</p>
<a name="Building-the-result_002e"></a>
<p>The actual matchers are,
<p><code>(scm-sed (pat res ...) ...)</code>, this works just as with syntax-parse, but with the extra build-rules.
<p><code>(scm-match pat)</code>, use this as a matcher in par-grep, but with the syntax-parse pattern interface to define a match.
<h3 class="section">8.3 Building the result.</h3>
<p>The philosophy is to treat the sed translation as a special syntax transform. A variable <code>x</code> in the pattern will produce three sub matches, <code>x.l,x.it.x.r</code>. e.g. left whitespace, sexp, right whitespace. By matching <code>#(l it r)</code> l will be left whitespace, it the sexp and r the right whitespace, and this is how you define the output as well in order to surround an element with whitespace.
</p>
<a name="Example-2"></a>
<h3 class="section">8.4 Example</h3>
<p>This is an example how one may define a sed translator that swaps the meaning of variable and value in a let form and preserving whitespace as much as possible.
</p>
<pre class="verbatim">(define-match-class swap
(pattern #(l (x y) r)
#:with tr #'#(l (x.l y.it x.r y.l x.it y.r) r)))
(define-match-class (tr-it oldval newval)
(pattern #(l ,oldval r)
#:with tr #`#(l #,(datum-&gt;syntax #'a newval) r)))
#:with tr #`#(l #,(datum->syntax #'a newval) r)))
(define (test f)
(par-sed (scm-sed (#(l ((~var let (tr-it 'let 'tel))
......@@ -112,13 +91,6 @@ This works just as with <code>define-splicing-syntax-class</code> in syntax-pars
#'#(l (let.tr #(a (bind.tr ...) b) body ...) r)))
(f)))
</pre>
<hr>
<div class="header">
<p>
Next: <a href="kanren.html#kanren" accesskey="n" rel="next">kanren</a>, Previous: <a href="parsing.html#parsing" accesskey="p" rel="previous">parsing</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
</body></html>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<html lang="en">
<head>
<title>Preliminary Manual: stream ideom</title>
<meta name="description" content="Preliminary Manual: stream ideom">
<meta name="keywords" content="Preliminary Manual: stream ideom">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index.html#Index" rel="index" title="Index">
<link href="parsing.html#parsing" rel="up" title="parsing">
<link href="parser-combinators.html#parser-combinators" rel="next" title="parser combinators">
<link href="parsing.html#parsing" rel="previous" title="parsing">
<style type="text/css">
<title>stream ideom - Preliminary Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Preliminary Manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="parsing.html#parsing" title="parsing">
<link rel="next" href="parser-combinators.html#parser-combinators" title="parser combinators">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}