Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add nulls-rank-high flag to Libmarpa: t+
  • Loading branch information
Jeffrey Kegler authored and Jeffrey Kegler committed Jul 4, 2012
1 parent 456c1c1 commit a4720f4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions r2/lib/Marpa/R2/Grammar.pm
Expand Up @@ -66,7 +66,6 @@ BEGIN {
ID
NAME
ACTION { action for this rule as specified by user }
NULL_RANKS_HIGH
DISCARD_SEPARATION
END_OF_STRUCTURE
Expand Down Expand Up @@ -1132,8 +1131,8 @@ sub add_user_rule {
if (defined $rank) {
$grammar_c->rule_rank_set($ordinary_rule_id, $rank);
}
$ordinary_rule->[Marpa::R2::Internal::Rule::NULL_RANKS_HIGH] =
$null_ranking eq 'high';
$grammar_c->rule_null_high_set( $ordinary_rule_id,
( $null_ranking eq 'high' ? 1 : 0 ) );
if ( defined $rule_name ) {
$ordinary_rule->[Marpa::R2::Internal::Rule::NAME] = $rule_name;
$rules_by_name->{$rule_name} = $ordinary_rule;
Expand Down Expand Up @@ -1190,7 +1189,8 @@ sub add_user_rule {
action_set( $original_rule_id, $grammar, $action );
$original_rule->[Marpa::R2::Internal::Rule::DISCARD_SEPARATION] =
$separator_id >= 0 && !$keep_separation;
$original_rule->[Marpa::R2::Internal::Rule::NULL_RANKS_HIGH] = $null_ranking eq 'high';
$grammar_c->rule_null_high_set( $original_rule_id,
( $null_ranking eq 'high' ? 1 : 0 ) );
$grammar_c->rule_rank_set($original_rule_id, $rank);

if ( defined $rule_name ) {
Expand Down
4 changes: 2 additions & 2 deletions r2/lib/Marpa/R2/Value.pm
Expand Up @@ -967,8 +967,8 @@ sub rank_chaf_rules {
my $original_rule =
defined $original_rule_id ? $rules->[$original_rule_id] : undef;
my $null_ranks_high =
defined $original_rule
? $original_rule->[Marpa::R2::Internal::Rule::NULL_RANKS_HIGH]
defined $original_rule_id
? $grammar_c->rule_null_high($original_rule_id)
: 0;

# Default to the rank of a non-nulled rule
Expand Down
2 changes: 1 addition & 1 deletion r2/libmarpa/dev/marpa.w
Expand Up @@ -2181,7 +2181,7 @@ ranking of the null variants, for rules
with properly nullable symbols on their
RHS.
@<Bit aligned rule elements@> =
Marpa_Rank t_null_ranks_high:1;
unsigned int t_null_ranks_high:1;
@ @<Initialize rule elements@> =
rule->t_null_ranks_high = 0;
@
Expand Down

0 comments on commit a4720f4

Please sign in to comment.