[libmarpa-r2-perl] 08/14: Adding marpa_g_force_valued(): t+

Jonas Smedegaard dr at jones.dk
Sat May 17 21:24:08 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag Marpa-R2-2.085_003
in repository libmarpa-r2-perl.

commit fa6ef9fed19de7b660d9e80e9504f0ce4dacaf5a
Author: Jeffrey Kegler <JKEGL at cpan.org>
Date:   Sun Apr 20 22:30:16 2014 -0700

    Adding marpa_g_force_valued(): t+
---
 cpan/lib/Marpa/R2/Value.pm |   2 +-
 cpan/libmarpa/dev/api.texi | 259 +++++++++++++++++++--------------------------
 2 files changed, 110 insertions(+), 151 deletions(-)

diff --git a/cpan/lib/Marpa/R2/Value.pm b/cpan/lib/Marpa/R2/Value.pm
index 4a776d0..522ba88 100644
--- a/cpan/lib/Marpa/R2/Value.pm
+++ b/cpan/lib/Marpa/R2/Value.pm
@@ -1554,11 +1554,11 @@ sub Marpa::R2::Recognizer::value {
     $semantics_arg0 //= $per_parse_arg // {};
 
     my $value = Marpa::R2::Thin::V->new($tree);
-    $value->valued_force();
     if ($slr) {
         $value->slr_set( $slr->thin() );
     }
     else {
+        $value->valued_force();
         TOKEN_IX:
         for ( my $token_ix = 2; $token_ix <= $#{$token_values}; $token_ix++ )
         {
diff --git a/cpan/libmarpa/dev/api.texi b/cpan/libmarpa/dev/api.texi
index 0ca371c..480fcd9 100644
--- a/cpan/libmarpa/dev/api.texi
+++ b/cpan/libmarpa/dev/api.texi
@@ -73,6 +73,7 @@ Published @value{UPDATED} by Jeffrey Kegler
 * Error methods macros and codes::  
 * Design notes::                
 * Work in Progress::            
+* Deprecated techniques and methods::  
 * GNU Free Documentation License::  
 
 @detailmenu
@@ -111,7 +112,6 @@ Earlemes
 Semantics
 
 * How Libmarpa semantics work::  
-* Valued and unvalued symbols::  
 
 Introduction to the external interface
 
@@ -209,6 +209,10 @@ Untested methods
 
 * Methods for revising parses::  
 
+Deprecated techniques and methods
+
+* Valued and unvalued symbols::  
+
 @end detailmenu
 @end menu
 
@@ -984,10 +988,9 @@ parse evaluation.
 
 @menu
 * How Libmarpa semantics work::  
-* Valued and unvalued symbols::  
 @end menu
 
- at node How Libmarpa semantics work, Valued and unvalued symbols, Semantics, Semantics
+ at node How Libmarpa semantics work,  , Semantics, Semantics
 @section How the Libmarpa semantics work
 
 Libmarpa handling of semantics is unusual.
@@ -1013,72 +1016,6 @@ The most extensive discussion of the semantics
 is in the section that deals with the methods of the value time class.
 @xref{Value methods}.
 
- at node Valued and unvalued symbols,  , How Libmarpa semantics work, Semantics
- at section Valued and unvalued symbols
-
-Libmarpa symbols can have values,
-which is the traditional way of doing semantics.
-Libmarpa also allows symbols to be unvalued.
-An @dfn{unvalued} symbol is one whose value
-is unpredictable from instance to instance.
-If a symbol is unvalued, we sometimes say that it
-has ``whatever'' semantics.
-
-Situations where the semantics can tolerate unvalued symbols
-are surprisingly frequent.
-For example, the top-level of many languages is a series
-of major units, all of whose semantics are typically accomplished
-via side effects.
-The compiler is typically indifferent to the actual value produced
-by these major units, and tracking them is a waste of time.
-Similarly, the value of the separators in a list is typically
-ignored.
-
-Rules are unvalued if and only if their LHS symbols
-are unvalued.
-When rules and symbols are unvalued,
-Libmarpa optimizes their evaluation.
-
-It is in principle unsafe to check the value 
-of a symbol if it can be unvalued.
-For this reason,
-once a symbol has been treated as valued,
-Libmarpa marks it as valued.
-Similarly,
-once a symbol has been treated as unvalued,
-Libmarpa marks it as unvalued.
-Once marked, a symbol's valued status is
- at dfn{locked} and cannot be changed later.
-
-The valued status of terminals is marked the first
-time they are read.
-The valued status of LHS symbols must be explicitly
-marked by the application when initializing the
-valuator --- this is Libmarpa's equivalent of
-registering a callback.
-
-LHS terminals are disabled by default.
-If allowed, the user should be aware that the valued
-status of a LHS terminal
-will be locked in the recognizer
-if it is used as a terminal,
-and the symbol's use as a rule LHS
-in the valuator must be
-consistent with the recognizer's marking.
-
-Marpa reports an error when a symbol's use
-conflicts with its locked valued status.
-Doing so usually saves the programmer
-some tricky debugging further down the road.
-But it is possible that an application might deliberately
-want to mix
-valued and unvalued uses of a symbol --- an application
-might be able to differentiate them using the larger
-context, or might be tolerant of the uncertainty.
-If there is interest,
-a future Libmarpa extension might allow a locked
-valued status to be overriden.
-
 @node Threads, Fatal Errors, Semantics, Top
 @chapter Threads
 
@@ -1458,6 +1395,9 @@ This distinction has been made in the past in hope
 of gaining efficiencies at evaluation time.
 Current thinking is that the gains do not repay the extra
 complexity.
+
+Return value: On success, a non-negative integer.
+On failure, a negative integer.
 @end deftypefun
 
 @node Grammar reference counting, Symbols, Grammar constructor, Grammar methods
@@ -1788,35 +1728,6 @@ if the grammar @var{g} is precomputed;
 or on other failure, @minus{}2.
 @end deftypefun
 
- at deftypefun int marpa_g_symbol_is_valued ( @
-    Marpa_Grammar @var{g}, @
-    Marpa_Symbol_ID @var{symbol_id})
- at deftypefunx int marpa_g_symbol_is_valued_set ( @
-    Marpa_Grammar @var{g}, @
-    Marpa_Symbol_ID @var{symbol_id}, @
-    int value)
-
-These methods, respectively, set
-and query the ``valued status'' of a symbol.
-Once set to a value with the
- at code{marpa_g_symbol_is_valued_set()} method,
-the valued status of a symbol is ``locked'' at that value.
-It cannot thereafter be changed.
-Subsequent calls to 
- at code{marpa_g_symbol_is_valued_set()}
-for the same @var{sym_id} will fail,
-leaving @var{sym_id}'s valued status unchanged,
-unless @var{value} is the same as the locked-in value.
-
-Return value: On success, 1 if the symbol @var{symbol_id}
-is valued after the call, 0 if not.
-If the valued status is locked and @var{value}
-is different from the current status, @minus{}2.
-If @var{value} is not 0 or 1;
-or on other failure, @minus{}2.
-
- at end deftypefun
-
 @deftypefun Marpa_Symbol_ID marpa_g_symbol_new (Marpa_Grammar @var{g})
 
 Creates a new symbol.
@@ -2417,56 +2328,10 @@ their own, perhaps based on
 the earleme location and @var{token_id},
 instead of using Libmarpa's token values.
 
-A @var{value} of 0 has special significance --- it indicates
-that the token is unvalued --- that its value is allowed
-to be unpredictable.
-Note that if a token is unvalued,
-it must be the case,
-not just that Libmarpa need not care about its value,
-but also that @strong{the application}
-does not care about the value of the token.
-When a token is unvalued, Libmarpa 
-optimizes away the valuator steps that
-give the application an opportunity to provide
-a value for that token.
-Applications that do not use Libmarpa's token values,
-but that @strong{do} care about the token's value,
-must tell Libmarpa not to optimize away the
-relevant valuator steps.
-An application can do this by
-letting @var{value} be any non-zero integer.
-
-When @var{value}
-in a call to @code{marpa_r_alternative()}
-is 0,
-symbol @var{token_id} is considered to have
-been used as an unvalued symbol.
-When @var{value}
-in a call to @code{marpa_r_alternative()}
-is not zero,
-symbol @var{token_id} is considered to have
-been used as an valued symbol.
-On the first read by
- at code{marpa_r_alternative()},
-if symbol @var{token_id} is used as a valued
-symbol,
-the valued status of
-symbol @var{token_id} will be set to 1
-and locked.
-On the first read by
- at code{marpa_r_alternative()},
-if symbol @var{token_id} is used as a unvalued
-symbol,
-the valued status of
-symbol @var{token_id} will be set to 0
-and locked.
-
-If the valued status of
-symbol @var{token_id} is locked at 0,
-it is a failure if that symbol is used as an valued symbol.
-If the valued status of
-symbol @var{token_id} is locked at 1,
-it is a failure if that symbol is used as an unvalued symbol.
+A @var{value} of 0 is reserved for a now-deprecated feature.
+Do not use it.
+For more details on that feature, see the
+section @ref{Valued and unvalued symbols}.
 
 When @code{marpa_r_alternative()}
 is successful,
@@ -5320,7 +5185,7 @@ For this reason,
 the traditional behavior is the default
 in Libmarpa.
 
- at node Work in Progress, GNU Free Documentation License, Design notes, Top
+ at node Work in Progress, Deprecated techniques and methods, Design notes, Top
 @chapter Work in Progress
 
 @menu
@@ -5481,7 +5346,101 @@ The methods in this section provide that capability.
 
 @end deftypefun
 
- at node GNU Free Documentation License,  , Work in Progress, Top
+ at node Deprecated techniques and methods, GNU Free Documentation License, Work in Progress, Top
+ at chapter Deprecated techniques and methods
+
+ at menu
+* Valued and unvalued symbols::  
+ at end menu
+
+ at node Valued and unvalued symbols,  , Deprecated techniques and methods, Deprecated techniques and methods
+ at section Valued and unvalued symbols
+
+Libmarpa symbols can have values,
+which is the traditional way of doing semantics.
+Libmarpa also allows symbols to be unvalued.
+An @dfn{unvalued} symbol is one whose value
+is unpredictable from instance to instance.
+If a symbol is unvalued, we sometimes say that it
+has ``whatever'' semantics.
+
+Situations where the semantics can tolerate unvalued symbols
+are surprisingly frequent.
+For example, the top-level of many languages is a series
+of major units, all of whose semantics are typically accomplished
+via side effects.
+The compiler is typically indifferent to the actual value produced
+by these major units, and tracking them is a waste of time.
+Similarly, the value of the separators in a list is typically
+ignored.
+
+Rules are unvalued if and only if their LHS symbols
+are unvalued.
+When rules and symbols are unvalued,
+Libmarpa optimizes their evaluation.
+
+It is in principle unsafe to check the value 
+of a symbol if it can be unvalued.
+For this reason,
+once a symbol has been treated as valued,
+Libmarpa marks it as valued.
+Similarly,
+once a symbol has been treated as unvalued,
+Libmarpa marks it as unvalued.
+Once marked, a symbol's valued status is
+ at dfn{locked} and cannot be changed later.
+
+The valued status of terminals is marked the first
+time they are read.
+The valued status of LHS symbols must be explicitly
+marked by the application when initializing the
+valuator --- this is Libmarpa's equivalent of
+registering a callback.
+
+LHS terminals are disabled by default.
+If allowed, the user should be aware that the valued
+status of a LHS terminal
+will be locked in the recognizer
+if it is used as a terminal,
+and the symbol's use as a rule LHS
+in the valuator must be
+consistent with the recognizer's marking.
+
+Marpa reports an error when a symbol's use
+conflicts with its locked valued status.
+Doing so usually saves the programmer
+some tricky debugging further down the road.
+
+ at deftypefun int marpa_g_symbol_is_valued ( @
+    Marpa_Grammar @var{g}, @
+    Marpa_Symbol_ID @var{symbol_id})
+ at deftypefunx int marpa_g_symbol_is_valued_set ( @
+    Marpa_Grammar @var{g}, @
+    Marpa_Symbol_ID @var{symbol_id}, @
+    int value)
+
+These methods, respectively, set
+and query the ``valued status'' of a symbol.
+Once set to a value with the
+ at code{marpa_g_symbol_is_valued_set()} method,
+the valued status of a symbol is ``locked'' at that value.
+It cannot thereafter be changed.
+Subsequent calls to 
+ at code{marpa_g_symbol_is_valued_set()}
+for the same @var{sym_id} will fail,
+leaving @var{sym_id}'s valued status unchanged,
+unless @var{value} is the same as the locked-in value.
+
+Return value: On success, 1 if the symbol @var{symbol_id}
+is valued after the call, 0 if not.
+If the valued status is locked and @var{value}
+is different from the current status, @minus{}2.
+If @var{value} is not 0 or 1;
+or on other failure, @minus{}2.
+
+ at end deftypefun
+
+ at node GNU Free Documentation License,  , Deprecated techniques and methods, Top
 @appendix GNU Free Documentation License
 
 @include fdl-1.3.texi

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmarpa-r2-perl.git



More information about the Pkg-perl-cvs-commits mailing list