Skip to content
Browse files

Disallow "whatever" tokens above Thin interface: t+

  • Loading branch information...
1 parent 89f3bdf commit c3ded9d65a6205c02ef687f4da5b035418f6de41 Jeffrey Kegler committed Feb 24, 2013
Showing with 83 additions and 11 deletions.
  1. +3 −5 Makefile
  2. +31 −2 r2/libmarpa/dev/api.texi
  3. +30 −3 r2/libmarpa/dev/marpa.w
  4. +17 −0 r2/xs/Makefile
  5. +2 −1 r2/xs/gp_generate.pl
View
8 Makefile
@@ -1,4 +1,4 @@
-# Copyright 2011 Jeffrey Kegler
+# Copyright 2013 Jeffrey Kegler
# This file is part of Marpa::R2. Marpa::R2 is free software: you can
# redistribute it and/or modify it under the terms of the GNU Lesser
# General Public License as published by the Free Software Foundation,
@@ -30,10 +30,8 @@ full_test: etc_make
./Build disttest; \
) 2>&1 | tee full_test.out
-r2/xs/general_pattern.xsh: r2/xs/gp_generate.pl
- (cd r2/xs; perl gp_generate.pl general_pattern.xsh)
-
-install: r2/xs/general_pattern.xsh
+install:
+ (cd r2/xs && make)
test -d r2/libmarpa_dist || mkdir r2/libmarpa_dist
test -d r2/libmarpa_doc_dist || mkdir r2/libmarpa_doc_dist
(cd r2 && sh c_to_dist.sh)
View
33 r2/libmarpa/dev/api.texi
@@ -194,6 +194,7 @@ Design notes
Work in Progress
+* Experimental methods::
* Untested methods::
@end detailmenu
@@ -4774,17 +4775,45 @@ in Libmarpa.
@chapter Work in Progress
@menu
+* Experimental methods::
* Untested methods::
@end menu
-@node Untested methods, , Work in Progress, Work in Progress
+@node Experimental methods, Untested methods, Work in Progress, Work in Progress
+@section Experimental methods
+
+The methods of this section are not in the external interface,
+because they are experimental.
+Their fate is uncertain.
+Users should regard these methods
+as unsupported.
+
+@deftypefun int marpa_v_valued_force ( @
+ Marpa_Value @var{v})
+
+This methods locks the valued status of all symbols
+to 1, indicated that the symbol is valued.
+If this is not possible, for example because one of
+the grammar's symbols already is locked at a valued
+status of 0,
+failure is returned.
+
+Return value: On success, a non-negative number.
+On failure, returns @minus{}2,
+and sets the error code to an appropriate
+value, which will never be
+@code{MARPA_ERR_NONE}.
+
+@end deftypefun
+
+@node Untested methods, , Experimental methods, Work in Progress
@section Untested methods
The methods of this section are not in the external interface,
because they have not been adequately tested.
Their fate is uncertain.
Users should regard these methods
-as experimental and unsupported.
+as unsupported.
@deftypefun Marpa_Rank marpa_g_default_rank ( @
Marpa_Grammar @var{g})
View
33 r2/libmarpa/dev/marpa.w
@@ -12986,8 +12986,7 @@ Marpa_Nook_ID _marpa_v_nook(Marpa_Value public_v)
lbv_copy (v->t_obs, Valued_Locked_BV_of_B (b), xsy_count);
}
-@ The settings here overrides the value
-set with the grammar.
+@
@<Function definitions@> =
int marpa_v_symbol_is_valued(
Marpa_Value public_v,
@@ -13002,7 +13001,9 @@ int marpa_v_symbol_is_valued(
return lbv_bit_test(XSY_is_Valued_BV_of_V(v), xsy_id);
}
-@ @<Function definitions@> =
+@ The setting here overrides the value
+set with the grammar.
+@<Function definitions@> =
PRIVATE int symbol_is_valued_set (
VALUE v, XSYID xsy_id, int value)
{
@@ -13043,6 +13044,32 @@ int marpa_v_symbol_is_valued_set (
return symbol_is_valued_set(v, xsy_id, value);
}
+@ Force all symbols to be locked as valued.
+Return failure if that is not possible.
+@<Function definitions@> =
+int
+marpa_v_valued_force (Marpa_Value public_v)
+{
+ const VALUE v = (VALUE)public_v;
+ @<Return |-2| on failure@>@;
+ XSYID xsy_count;
+ XSYID xsy_id;
+ @<Unpack value objects@>@;
+ @<Fail if fatal error@>@;
+ xsy_count = XSY_Count_of_G (g);
+ for (xsy_id = 0; xsy_id < xsy_count; xsy_id++)
+ {
+ if (UNLIKELY (!lbv_bit_test (XSY_is_Valued_BV_of_V (v), xsy_id) &&
+ lbv_bit_test (Valued_Locked_BV_of_V (v), xsy_id)))
+ {
+ return failure_indicator;
+ }
+ lbv_bit_set (Valued_Locked_BV_of_V (v), xsy_id);
+ lbv_bit_set (XSY_is_Valued_BV_of_V (v), xsy_id);
+ }
+ return xsy_count;
+}
+
@ @<Function definitions@> =
int marpa_v_rule_is_valued_set (
Marpa_Value public_v, Marpa_Rule_ID xrl_id, int value)
View
17 r2/xs/Makefile
@@ -0,0 +1,17 @@
+# Copyright 2013 Jeffrey Kegler
+# This file is part of Marpa::R2. Marpa::R2 is free software: you can
+# redistribute it and/or modify it under the terms of the GNU Lesser
+# General Public License as published by the Free Software Foundation,
+# either version 3 of the License, or (at your option) any later version.
+#
+# Marpa::R2 is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser
+# General Public License along with Marpa::R2. If not, see
+# http://www.gnu.org/licenses/.
+
+general_pattern.xsh: gp_generate.pl
+ perl gp_generate.pl general_pattern.xsh
View
3 r2/xs/gp_generate.pl
@@ -227,8 +227,9 @@ sub gp_generate {
$main::LIBMARPA_CLASS = 'Marpa_Value';
print {$out} 'MODULE = Marpa::R2 PACKAGE = Marpa::R2::Thin::V', "\n\n";
-say {$out} gp_generate(qw(symbol_is_valued_set Marpa_Symbol_ID symbol_id int value));
+say {$out} gp_generate(qw(valued_force));
say {$out} gp_generate(qw(rule_is_valued_set Marpa_Rule_ID symbol_id int value));
+say {$out} gp_generate(qw(symbol_is_valued_set Marpa_Symbol_ID symbol_id int value));
$main::CLASS_LETTER = 'g';
$main::LIBMARPA_CLASS = 'Marpa_Grammar';

0 comments on commit c3ded9d

Please sign in to comment.
Something went wrong with that request. Please try again.