| 1 |
/* |
| 2 |
* Copyright 2022 Jeffrey Kegler |
| 3 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 4 |
* copy of this software and associated documentation files (the "Software"), |
| 5 |
* to deal in the Software without restriction, including without limitation |
| 6 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 7 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 8 |
* Software is furnished to do so, subject to the following conditions: |
| 9 |
* |
| 10 |
* The above copyright notice and this permission notice shall be included |
| 11 |
* in all copies or substantial portions of the Software. |
| 12 |
* |
| 13 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 16 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 17 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 18 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 19 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 20 |
*/ |
| 21 |
|
| 22 |
/* |
| 23 |
* DO NOT EDIT DIRECTLY |
| 24 |
* This file is written by the Marpa build process |
| 25 |
* It is not intended to be modified directly |
| 26 |
*/ |
| 27 |
|
| 28 |
/*1383:*/ |
| 29 |
#line 16788 "./marpa.w" |
| 30 |
|
| 31 |
|
| 32 |
#include "config.h" |
| 33 |
|
| 34 |
#ifndef MARPA_DEBUG |
| 35 |
#define MARPA_DEBUG 0 |
| 36 |
#endif |
| 37 |
|
| 38 |
#include "marpa.h" |
| 39 |
#include "marpa_ami.h" |
| 40 |
#define PRIVATE_NOT_INLINE static |
| 41 |
#define PRIVATE static inline \ |
| 42 |
|
| 43 |
#define HEADER_VERSION_MISMATCH ( \ |
| 44 |
MARPA_LIB_MAJOR_VERSION!=MARPA_MAJOR_VERSION \ |
| 45 |
||MARPA_LIB_MINOR_VERSION!=MARPA_MINOR_VERSION \ |
| 46 |
||MARPA_LIB_MICRO_VERSION!=MARPA_MICRO_VERSION \ |
| 47 |
) |
| 48 |
#define XSY_Count_of_G(g) (MARPA_DSTACK_LENGTH((g) ->t_xsy_stack) ) |
| 49 |
#define XSY_by_ID(id) (*MARPA_DSTACK_INDEX(g->t_xsy_stack,XSY,(id) ) ) \ |
| 50 |
|
| 51 |
#define XSYID_is_Malformed(xsy_id) ((xsy_id) <0) |
| 52 |
#define XSYID_of_G_Exists(xsy_id) ((xsy_id) <XSY_Count_of_G(g) ) |
| 53 |
#define NSYID_is_Malformed(nsy_id) ((nsy_id) <0) |
| 54 |
#define NSYID_of_G_Exists(nsy_id) ((nsy_id) <NSY_Count_of_G(g) ) |
| 55 |
#define XRL_Count_of_G(g) (MARPA_DSTACK_LENGTH((g) ->t_xrl_stack) ) |
| 56 |
#define IRL_Count_of_G(g) (MARPA_DSTACK_LENGTH((g) ->t_irl_stack) ) |
| 57 |
#define XRL_by_ID(id) (*MARPA_DSTACK_INDEX((g) ->t_xrl_stack,XRL,(id) ) ) |
| 58 |
#define IRL_by_ID(id) (*MARPA_DSTACK_INDEX((g) ->t_irl_stack,IRL,(id) ) ) \ |
| 59 |
|
| 60 |
#define XRLID_is_Malformed(rule_id) ((rule_id) <0) |
| 61 |
#define XRLID_of_G_Exists(rule_id) ((rule_id) <XRL_Count_of_G(g) ) |
| 62 |
#define IRLID_of_G_is_Valid(irl_id) \ |
| 63 |
((irl_id) >=0&&(irl_id) <IRL_Count_of_G(g) ) \ |
| 64 |
|
| 65 |
#define G_is_Trivial(g) (!(g) ->t_start_irl) |
| 66 |
#define External_Size_of_G(g) ((g) ->t_external_size) |
| 67 |
#define MAXIMUM_RANK (INT_MAX/4) |
| 68 |
#define MINIMUM_RANK (INT_MIN/4+(INT_MIN%4> 0?1:0) ) |
| 69 |
#define Default_Rank_of_G(g) ((g) ->t_default_rank) |
| 70 |
#define G_is_Precomputed(g) ((g) ->t_is_precomputed) |
| 71 |
#define G_EVENT_COUNT(g) MARPA_DSTACK_LENGTH((g) ->t_events) |
| 72 |
#define INITIAL_G_EVENTS_CAPACITY (1024/sizeof(int) ) |
| 73 |
#define G_EVENTS_CLEAR(g) MARPA_DSTACK_CLEAR((g) ->t_events) |
| 74 |
#define G_EVENT_PUSH(g) MARPA_DSTACK_PUSH((g) ->t_events,GEV_Object) |
| 75 |
#define I_AM_OK 0x69734f4b |
| 76 |
#define IS_G_OK(g) ((g) ->t_is_ok==I_AM_OK) |
| 77 |
#define ID_of_XSY(xsy) ((xsy) ->t_symbol_id) |
| 78 |
#define Rank_of_XSY(symbol) ((symbol) ->t_rank) |
| 79 |
#define XSY_is_LHS(xsy) ((xsy) ->t_is_lhs) |
| 80 |
#define XSY_is_Sequence_LHS(xsy) ((xsy) ->t_is_sequence_lhs) |
| 81 |
#define XSY_is_Valued(symbol) ((symbol) ->t_is_valued) |
| 82 |
#define XSY_is_Valued_Locked(symbol) ((symbol) ->t_is_valued_locked) |
| 83 |
#define XSY_is_Accessible(xsy) ((xsy) ->t_is_accessible) |
| 84 |
#define XSY_is_Nulling(sym) ((sym) ->t_is_nulling) |
| 85 |
#define XSY_is_Nullable(xsy) ((xsy) ->t_is_nullable) |
| 86 |
#define XSYID_is_Nullable(xsyid) XSY_is_Nullable(XSY_by_ID(xsyid) ) |
| 87 |
#define XSY_is_Terminal(xsy) ((xsy) ->t_is_terminal) |
| 88 |
#define XSY_is_Locked_Terminal(xsy) ((xsy) ->t_is_locked_terminal) |
| 89 |
#define XSYID_is_Terminal(id) (XSY_is_Terminal(XSY_by_ID(id) ) ) |
| 90 |
#define XSY_is_Productive(xsy) ((xsy) ->t_is_productive) |
| 91 |
#define XSY_is_Completion_Event(xsy) ((xsy) ->t_is_completion_event) |
| 92 |
#define XSYID_is_Completion_Event(xsyid) XSY_is_Completion_Event(XSY_by_ID(xsyid) ) |
| 93 |
#define XSY_Completion_Event_Starts_Active(xsy) ((xsy) ->t_completion_event_starts_active) |
| 94 |
#define XSYID_Completion_Event_Starts_Active(xsyid) XSY_Completion_Event_Starts_Active(XSY_by_ID(xsyid) ) |
| 95 |
#define XSY_is_Nulled_Event(xsy) ((xsy) ->t_is_nulled_event) |
| 96 |
#define XSYID_is_Nulled_Event(xsyid) XSY_is_Nulled_Event(XSY_by_ID(xsyid) ) |
| 97 |
#define XSY_Nulled_Event_Starts_Active(xsy) ((xsy) ->t_nulled_event_starts_active) |
| 98 |
#define XSYID_Nulled_Event_Starts_Active(xsyid) XSY_Nulled_Event_Starts_Active(XSY_by_ID(xsyid) ) |
| 99 |
#define XSY_is_Prediction_Event(xsy) ((xsy) ->t_is_prediction_event) |
| 100 |
#define XSYID_is_Prediction_Event(xsyid) XSY_is_Prediction_Event(XSY_by_ID(xsyid) ) |
| 101 |
#define XSY_Prediction_Event_Starts_Active(xsy) ((xsy) ->t_prediction_event_starts_active) |
| 102 |
#define XSYID_Prediction_Event_Starts_Active(xsyid) XSY_Prediction_Event_Starts_Active(XSY_by_ID(xsyid) ) |
| 103 |
#define Nulled_XSYIDs_of_XSY(xsy) ((xsy) ->t_nulled_event_xsyids) |
| 104 |
#define Nulled_XSYIDs_of_XSYID(xsyid) \ |
| 105 |
Nulled_XSYIDs_of_XSY(XSY_by_ID(xsyid) ) |
| 106 |
#define NSY_of_XSY(xsy) ((xsy) ->t_nsy_equivalent) |
| 107 |
#define NSYID_of_XSY(xsy) ID_of_NSY(NSY_of_XSY(xsy) ) |
| 108 |
#define NSY_by_XSYID(xsy_id) (XSY_by_ID(xsy_id) ->t_nsy_equivalent) |
| 109 |
#define NSYID_by_XSYID(xsy_id) ID_of_NSY(NSY_of_XSY(XSY_by_ID(xsy_id) ) ) |
| 110 |
#define Nulling_NSY_of_XSY(xsy) ((xsy) ->t_nulling_nsy) |
| 111 |
#define Nulling_NSY_by_XSYID(xsy) (XSY_by_ID(xsy) ->t_nulling_nsy) |
| 112 |
#define Nulling_NSYID_by_XSYID(xsy) ID_of_NSY(XSY_by_ID(xsy) ->t_nulling_nsy) |
| 113 |
#define Nulling_OR_by_NSYID(nsyid) ((OR) &NSY_by_ID(nsyid) ->t_nulling_or_node) |
| 114 |
#define Unvalued_OR_by_NSYID(nsyid) ((OR) &NSY_by_ID(nsyid) ->t_unvalued_or_node) |
| 115 |
#define NSY_by_ID(id) (*MARPA_DSTACK_INDEX(g->t_nsy_stack,NSY,(id) ) ) |
| 116 |
#define ID_of_NSY(nsy) ((nsy) ->t_nulling_or_node.t_nsyid) \ |
| 117 |
|
| 118 |
#define NSY_Count_of_G(g) (MARPA_DSTACK_LENGTH((g) ->t_nsy_stack) ) |
| 119 |
#define NSY_is_Start(nsy) ((nsy) ->t_is_start) |
| 120 |
#define NSY_is_LHS(nsy) ((nsy) ->t_is_lhs) |
| 121 |
#define NSY_is_Nulling(nsy) ((nsy) ->t_nsy_is_nulling) |
| 122 |
#define LHS_CIL_of_NSY(nsy) ((nsy) ->t_lhs_cil) |
| 123 |
#define LHS_CIL_of_NSYID(nsyid) LHS_CIL_of_NSY(NSY_by_ID(nsyid) ) |
| 124 |
#define NSY_is_Semantic(nsy) ((nsy) ->t_is_semantic) |
| 125 |
#define NSYID_is_Semantic(nsyid) (NSY_is_Semantic(NSY_by_ID(nsyid) ) ) |
| 126 |
#define Source_XSY_of_NSY(nsy) ((nsy) ->t_source_xsy) |
| 127 |
#define Source_XSY_of_NSYID(nsyid) (Source_XSY_of_NSY(NSY_by_ID(nsyid) ) ) |
| 128 |
#define Source_XSYID_of_NSYID(nsyid) \ |
| 129 |
ID_of_XSY(Source_XSY_of_NSYID(nsyid) ) |
| 130 |
#define LHS_XRL_of_NSY(nsy) ((nsy) ->t_lhs_xrl) |
| 131 |
#define XRL_Offset_of_NSY(nsy) ((nsy) ->t_xrl_offset) |
| 132 |
#define NSY_Rank_by_XSY(xsy) \ |
| 133 |
((xsy) ->t_rank*EXTERNAL_RANK_FACTOR+MAXIMUM_CHAF_RANK) |
| 134 |
#define Rank_of_NSY(nsy) ((nsy) ->t_rank) |
| 135 |
#define MAX_RHS_LENGTH (INT_MAX>>(2) ) |
| 136 |
#define Length_of_XRL(xrl) ((xrl) ->t_rhs_length) |
| 137 |
#define LHS_ID_of_RULE(rule) ((rule) ->t_symbols[0]) |
| 138 |
#define LHS_ID_of_XRL(xrl) ((xrl) ->t_symbols[0]) |
| 139 |
#define RHS_ID_of_RULE(rule,position) \ |
| 140 |
((rule) ->t_symbols[(position) +1]) |
| 141 |
#define RHS_ID_of_XRL(xrl,position) \ |
| 142 |
((xrl) ->t_symbols[(position) +1]) \ |
| 143 |
|
| 144 |
#define ID_of_XRL(xrl) ((xrl) ->t_id) |
| 145 |
#define ID_of_RULE(rule) ID_of_XRL(rule) |
| 146 |
#define Rank_of_XRL(rule) ((rule) ->t_rank) |
| 147 |
#define Null_Ranks_High_of_RULE(rule) ((rule) ->t_null_ranks_high) |
| 148 |
#define XRL_is_BNF(rule) ((rule) ->t_is_bnf) |
| 149 |
#define XRL_is_Sequence(rule) ((rule) ->t_is_sequence) |
| 150 |
#define Minimum_of_XRL(rule) ((rule) ->t_minimum) |
| 151 |
#define Separator_of_XRL(rule) ((rule) ->t_separator_id) |
| 152 |
#define XRL_is_Proper_Separation(rule) ((rule) ->t_is_proper_separation) |
| 153 |
#define XRL_is_Nulling(rule) ((rule) ->t_is_nulling) |
| 154 |
#define XRL_is_Nullable(rule) ((rule) ->t_is_nullable) |
| 155 |
#define XRL_is_Accessible(rule) ((rule) ->t_is_accessible) |
| 156 |
#define XRL_is_Productive(rule) ((rule) ->t_is_productive) |
| 157 |
#define XRL_is_Used(rule) ((rule) ->t_is_used) |
| 158 |
#define ID_of_IRL(irl) ((irl) ->t_irl_id) |
| 159 |
#define LHSID_of_IRL(irlid) ((irlid) ->t_nsyid_array[0]) |
| 160 |
#define LHS_of_IRL(irl) (NSY_by_ID(LHSID_of_IRL(irl) ) ) \ |
| 161 |
|
| 162 |
#define RHSID_of_IRL(irl,position) ((irl) ->t_nsyid_array[(position) +1]) |
| 163 |
#define RHS_of_IRL(irl,position) NSY_by_ID(RHSID_of_IRL((irl) ,(position) ) ) |
| 164 |
#define Length_of_IRL(irl) ((irl) ->t_length) |
| 165 |
#define IRL_is_Unit_Rule(irl) ((irl) ->t_ahm_count==2) |
| 166 |
#define AHM_Count_of_IRL(irl) ((irl) ->t_ahm_count) |
| 167 |
#define IRL_has_Virtual_LHS(irl) ((irl) ->t_is_virtual_lhs) |
| 168 |
#define IRL_has_Virtual_RHS(irl) ((irl) ->t_is_virtual_rhs) |
| 169 |
#define IRL_is_Right_Recursive(irl) ((irl) ->t_is_right_recursive) |
| 170 |
#define IRL_is_Leo(irl) IRL_is_Right_Recursive(irl) |
| 171 |
#define Real_SYM_Count_of_IRL(irl) ((irl) ->t_real_symbol_count) |
| 172 |
#define Virtual_Start_of_IRL(irl) ((irl) ->t_virtual_start) |
| 173 |
#define Virtual_End_of_IRL(irl) ((irl) ->t_virtual_end) |
| 174 |
#define Source_XRL_of_IRL(irl) ((irl) ->t_source_xrl) |
| 175 |
#define EXTERNAL_RANK_FACTOR 4 |
| 176 |
#define MAXIMUM_CHAF_RANK 3 |
| 177 |
#define IRL_CHAF_Rank_by_XRL(xrl,chaf_rank) ( \ |
| 178 |
((xrl) ->t_rank*EXTERNAL_RANK_FACTOR) + \ |
| 179 |
(((xrl) ->t_null_ranks_high) ?(MAXIMUM_CHAF_RANK- \ |
| 180 |
(chaf_rank) ) :(chaf_rank) ) \ |
| 181 |
) |
| 182 |
#define IRL_Rank_by_XRL(xrl) IRL_CHAF_Rank_by_XRL((xrl) ,MAXIMUM_CHAF_RANK) |
| 183 |
#define Rank_of_IRL(irl) ((irl) ->t_rank) |
| 184 |
#define First_AHM_of_IRL(irl) ((irl) ->t_first_ahm) |
| 185 |
#define First_AHM_of_IRLID(irlid) (IRL_by_ID(irlid) ->t_first_ahm) |
| 186 |
#define IRL_is_CHAF(irl) ((irl) ->t_is_chaf) |
| 187 |
#define AHM_by_ID(id) (g->t_ahms+(id) ) |
| 188 |
#define ID_of_AHM(ahm) (AHMID) ((ahm) -g->t_ahms) |
| 189 |
#define Next_AHM_of_AHM(ahm) ((ahm) +1) |
| 190 |
#define Prev_AHM_of_AHM(ahm) ((ahm) -1) \ |
| 191 |
|
| 192 |
#define AHM_Count_of_G(g) ((g) ->t_ahm_count) |
| 193 |
#define IRL_of_AHM(ahm) ((ahm) ->t_irl) |
| 194 |
#define IRLID_of_AHM(item) ID_of_IRL(IRL_of_AHM(item) ) |
| 195 |
#define LHS_NSYID_of_AHM(item) LHSID_of_IRL(IRL_of_AHM(item) ) |
| 196 |
#define LHSID_of_AHM(item) LHS_NSYID_of_AHM(item) |
| 197 |
#define Postdot_NSYID_of_AHM(item) ((item) ->t_postdot_nsyid) |
| 198 |
#define AHM_is_Completion(ahm) (Postdot_NSYID_of_AHM(ahm) <0) |
| 199 |
#define AHM_is_Leo(ahm) (IRL_is_Leo(IRL_of_AHM(ahm) ) ) |
| 200 |
#define AHM_is_Leo_Completion(ahm) \ |
| 201 |
(AHM_is_Completion(ahm) &&AHM_is_Leo(ahm) ) |
| 202 |
#define Null_Count_of_AHM(ahm) ((ahm) ->t_leading_nulls) |
| 203 |
#define Position_of_AHM(ahm) ((ahm) ->t_position) |
| 204 |
#define Raw_Position_of_AHM(ahm) \ |
| 205 |
(Position_of_AHM(ahm) <0 \ |
| 206 |
?((Length_of_IRL(IRL_of_AHM(ahm) ) ) +Position_of_AHM(ahm) +1) \ |
| 207 |
:Position_of_AHM(ahm) ) |
| 208 |
#define AHM_is_Prediction(ahm) (Quasi_Position_of_AHM(ahm) ==0) \ |
| 209 |
|
| 210 |
#define Quasi_Position_of_AHM(ahm) ((ahm) ->t_quasi_position) |
| 211 |
#define SYMI_of_AHM(ahm) ((ahm) ->t_symbol_instance) |
| 212 |
#define SYMI_Count_of_G(g) ((g) ->t_symbol_instance_count) |
| 213 |
#define SYMI_of_IRL(irl) ((irl) ->t_symbol_instance_base) |
| 214 |
#define Last_Proper_SYMI_of_IRL(irl) ((irl) ->t_last_proper_symi) |
| 215 |
#define SYMI_of_Completed_IRL(irl) \ |
| 216 |
(SYMI_of_IRL(irl) +Length_of_IRL(irl) -1) |
| 217 |
#define Predicted_IRL_CIL_of_AHM(ahm) ((ahm) ->t_predicted_irl_cil) |
| 218 |
#define LHS_CIL_of_AHM(ahm) ((ahm) ->t_lhs_cil) |
| 219 |
#define ZWA_CIL_of_AHM(ahm) ((ahm) ->t_zwa_cil) |
| 220 |
#define AHM_predicts_ZWA(ahm) ((ahm) ->t_predicts_zwa) |
| 221 |
#define Completion_XSYIDs_of_AHM(ahm) ((ahm) ->t_completion_xsyids) |
| 222 |
#define Nulled_XSYIDs_of_AHM(ahm) ((ahm) ->t_nulled_xsyids) |
| 223 |
#define Prediction_XSYIDs_of_AHM(ahm) ((ahm) ->t_prediction_xsyids) |
| 224 |
#define AHM_was_Predicted(ahm) ((ahm) ->t_was_predicted) |
| 225 |
#define YIM_was_Predicted(yim) AHM_was_Predicted(AHM_of_YIM(yim) ) |
| 226 |
#define AHM_is_Initial(ahm) ((ahm) ->t_is_initial) |
| 227 |
#define YIM_is_Initial(yim) AHM_is_Initial(AHM_of_YIM(yim) ) |
| 228 |
#define XRL_of_AHM(ahm) ((ahm) ->t_xrl) |
| 229 |
#define XRL_Position_of_AHM(ahm) ((ahm) ->t_xrl_position) |
| 230 |
#define Raw_XRL_Position_of_AHM(ahm) ( \ |
| 231 |
XRL_Position_of_AHM(ahm) <0 \ |
| 232 |
?Length_of_XRL(XRL_of_AHM(ahm) ) \ |
| 233 |
:XRL_Position_of_AHM(ahm) \ |
| 234 |
) |
| 235 |
#define Event_Group_Size_of_AHM(ahm) ((ahm) ->t_event_group_size) |
| 236 |
#define Event_AHMIDs_of_AHM(ahm) ((ahm) ->t_event_ahmids) |
| 237 |
#define AHM_has_Event(ahm) (Count_of_CIL(Event_AHMIDs_of_AHM(ahm) ) !=0) |
| 238 |
#define ZWAID_is_Malformed(zwaid) ((zwaid) <0) |
| 239 |
#define ZWAID_of_G_Exists(zwaid) ((zwaid) <ZWA_Count_of_G(g) ) |
| 240 |
#define ZWA_Count_of_G(g) (MARPA_DSTACK_LENGTH((g) ->t_gzwa_stack) ) |
| 241 |
#define GZWA_by_ID(id) (*MARPA_DSTACK_INDEX((g) ->t_gzwa_stack,GZWA,(id) ) ) |
| 242 |
#define ID_of_GZWA(zwa) ((zwa) ->t_id) |
| 243 |
#define Default_Value_of_GZWA(zwa) ((zwa) ->t_default_value) |
| 244 |
#define XRLID_of_ZWP(zwp) ((zwp) ->t_xrl_id) |
| 245 |
#define Dot_of_ZWP(zwp) ((zwp) ->t_dot) |
| 246 |
#define ZWAID_of_ZWP(zwp) ((zwp) ->t_zwaid) |
| 247 |
#define G_of_R(r) ((r) ->t_grammar) |
| 248 |
#define R_BEFORE_INPUT 0x1 |
| 249 |
#define R_DURING_INPUT 0x2 |
| 250 |
#define R_AFTER_INPUT 0x3 |
| 251 |
#define Input_Phase_of_R(r) ((r) ->t_input_phase) |
| 252 |
#define First_YS_of_R(r) ((r) ->t_first_earley_set) |
| 253 |
#define Latest_YS_of_R(r) ((r) ->t_latest_earley_set) |
| 254 |
#define Current_Earleme_of_R(r) ((r) ->t_current_earleme) |
| 255 |
#define YS_at_Current_Earleme_of_R(r) ys_at_current_earleme(r) |
| 256 |
#define DEFAULT_YIM_WARNING_THRESHOLD (100) |
| 257 |
#define Furthest_Earleme_of_R(r) ((r) ->t_furthest_earleme) |
| 258 |
#define R_is_Exhausted(r) ((r) ->t_is_exhausted) |
| 259 |
#define First_Inconsistent_YS_of_R(r) ((r) ->t_first_inconsistent_ys) |
| 260 |
#define R_is_Consistent(r) ((r) ->t_first_inconsistent_ys<0) |
| 261 |
#define ID_of_ZWA(zwa) ((zwa) ->t_id) |
| 262 |
#define Memo_YSID_of_ZWA(zwa) ((zwa) ->t_memoized_ysid) |
| 263 |
#define Memo_Value_of_ZWA(zwa) ((zwa) ->t_memoized_value) |
| 264 |
#define Default_Value_of_ZWA(zwa) ((zwa) ->t_default_value) |
| 265 |
#define ZWA_Count_of_R(r) (ZWA_Count_of_G(G_of_R(r) ) ) |
| 266 |
#define RZWA_by_ID(id) (&(r) ->t_zwas[(zwaid) ]) |
| 267 |
#define JEARLEME_THRESHOLD (INT_MAX/4) |
| 268 |
#define Next_YS_of_YS(set) ((set) ->t_next_earley_set) |
| 269 |
#define Postdot_SYM_Count_of_YS(set) ((set) ->t_postdot_sym_count) |
| 270 |
#define First_PIM_of_YS_by_NSYID(set,nsyid) (first_pim_of_ys_by_nsyid((set) ,(nsyid) ) ) |
| 271 |
#define PIM_NSY_P_of_YS_by_NSYID(set,nsyid) (pim_nsy_p_find((set) ,(nsyid) ) ) |
| 272 |
#define YIM_Count_of_YS(set) ((set) ->t_yim_count) |
| 273 |
#define YIMs_of_YS(set) ((set) ->t_earley_items) |
| 274 |
#define YS_Count_of_R(r) ((r) ->t_earley_set_count) |
| 275 |
#define Ord_of_YS(set) ((set) ->t_ordinal) |
| 276 |
#define YS_Ord_is_Valid(r,ordinal) \ |
| 277 |
((ordinal) >=0&&(ordinal) <YS_Count_of_R(r) ) |
| 278 |
#define Earleme_of_YS(set) ((set) ->t_key.t_earleme) \ |
| 279 |
|
| 280 |
#define Value_of_YS(set) ((set) ->t_value) |
| 281 |
#define PValue_of_YS(set) ((set) ->t_pvalue) |
| 282 |
#define LHS_NSYID_of_YIM(yim) \ |
| 283 |
LHS_NSYID_of_AHM(AHM_of_YIM(yim) ) |
| 284 |
#define YIM_is_Completion(item) \ |
| 285 |
(AHM_is_Completion(AHM_of_YIM(item) ) ) |
| 286 |
#define YS_of_YIM(yim) ((yim) ->t_key.t_set) |
| 287 |
#define YS_Ord_of_YIM(yim) (Ord_of_YS(YS_of_YIM(yim) ) ) |
| 288 |
#define Ord_of_YIM(yim) ((yim) ->t_ordinal) |
| 289 |
#define Earleme_of_YIM(yim) Earleme_of_YS(YS_of_YIM(yim) ) |
| 290 |
#define AHM_of_YIM(yim) ((yim) ->t_key.t_ahm) |
| 291 |
#define AHMID_of_YIM(yim) ID_of_AHM(AHM_of_YIM(yim) ) |
| 292 |
#define Postdot_NSYID_of_YIM(yim) Postdot_NSYID_of_AHM(AHM_of_YIM(yim) ) |
| 293 |
#define IRL_of_YIM(yim) IRL_of_AHM(AHM_of_YIM(yim) ) |
| 294 |
#define IRLID_of_YIM(yim) ID_of_IRL(IRL_of_YIM(yim) ) |
| 295 |
#define XRL_of_YIM(yim) XRL_of_AHM(AHM_of_YIM(yim) ) |
| 296 |
#define Origin_Earleme_of_YIM(yim) (Earleme_of_YS(Origin_of_YIM(yim) ) ) |
| 297 |
#define Origin_Ord_of_YIM(yim) (Ord_of_YS(Origin_of_YIM(yim) ) ) |
| 298 |
#define Origin_of_YIM(yim) ((yim) ->t_key.t_origin) |
| 299 |
#define YIM_ORDINAL_WIDTH 16 |
| 300 |
#define YIM_ORDINAL_CLAMP(x) (((1<<(YIM_ORDINAL_WIDTH) ) -1) &(x) ) |
| 301 |
#define YIM_FATAL_THRESHOLD ((1<<(YIM_ORDINAL_WIDTH) ) -2) |
| 302 |
#define YIM_is_Rejected(yim) ((yim) ->t_is_rejected) |
| 303 |
#define YIM_is_Active(yim) ((yim) ->t_is_active) |
| 304 |
#define YIM_was_Scanned(yim) ((yim) ->t_was_scanned) |
| 305 |
#define YIM_was_Fusion(yim) ((yim) ->t_was_fusion) |
| 306 |
#define NO_SOURCE (0U) |
| 307 |
#define SOURCE_IS_TOKEN (1U) |
| 308 |
#define SOURCE_IS_COMPLETION (2U) |
| 309 |
#define SOURCE_IS_LEO (3U) |
| 310 |
#define SOURCE_IS_AMBIGUOUS (4U) |
| 311 |
#define Source_Type_of_YIM(item) ((item) ->t_source_type) |
| 312 |
#define Earley_Item_has_No_Source(item) ((item) ->t_source_type==NO_SOURCE) |
| 313 |
#define Earley_Item_has_Token_Source(item) ((item) ->t_source_type==SOURCE_IS_TOKEN) |
| 314 |
#define Earley_Item_has_Complete_Source(item) ((item) ->t_source_type==SOURCE_IS_COMPLETION) |
| 315 |
#define Earley_Item_has_Leo_Source(item) ((item) ->t_source_type==SOURCE_IS_LEO) |
| 316 |
#define Earley_Item_is_Ambiguous(item) ((item) ->t_source_type==SOURCE_IS_AMBIGUOUS) \ |
| 317 |
|
| 318 |
#define Next_PIM_of_YIX(yix) ((yix) ->t_next) |
| 319 |
#define YIM_of_YIX(yix) ((yix) ->t_earley_item) |
| 320 |
#define Postdot_NSYID_of_YIX(yix) ((yix) ->t_postdot_nsyid) |
| 321 |
#define YIX_of_LIM(lim) ((YIX) (lim) ) |
| 322 |
#define Postdot_NSYID_of_LIM(leo) (Postdot_NSYID_of_YIX(YIX_of_LIM(leo) ) ) |
| 323 |
#define Next_PIM_of_LIM(leo) (Next_PIM_of_YIX(YIX_of_LIM(leo) ) ) |
| 324 |
#define Origin_of_LIM(leo) ((leo) ->t_origin) |
| 325 |
#define Top_AHM_of_LIM(leo) ((leo) ->t_top_ahm) |
| 326 |
#define Trailhead_AHM_of_LIM(leo) ((leo) ->t_trailhead_ahm) |
| 327 |
#define Predecessor_LIM_of_LIM(leo) ((leo) ->t_predecessor) |
| 328 |
#define Trailhead_YIM_of_LIM(leo) ((leo) ->t_base) |
| 329 |
#define YS_of_LIM(leo) ((leo) ->t_set) |
| 330 |
#define Earleme_of_LIM(lim) Earleme_of_YS(YS_of_LIM(lim) ) |
| 331 |
#define LIM_is_Rejected(lim) ((lim) ->t_is_rejected) |
| 332 |
#define LIM_is_Active(lim) ((lim) ->t_is_active) |
| 333 |
#define CIL_of_LIM(lim) ((lim) ->t_cil) |
| 334 |
#define LIM_of_PIM(pim) ((LIM) (pim) ) |
| 335 |
#define YIX_of_PIM(pim) ((YIX) (pim) ) |
| 336 |
#define Postdot_NSYID_of_PIM(pim) (Postdot_NSYID_of_YIX(YIX_of_PIM(pim) ) ) |
| 337 |
#define YIM_of_PIM(pim) (YIM_of_YIX(YIX_of_PIM(pim) ) ) |
| 338 |
#define Next_PIM_of_PIM(pim) (Next_PIM_of_YIX(YIX_of_PIM(pim) ) ) \ |
| 339 |
|
| 340 |
#define PIM_of_LIM(pim) ((PIM) (pim) ) |
| 341 |
#define PIM_is_LIM(pim) (YIM_of_PIM(pim) ==NULL) |
| 342 |
#define Next_SRCL_of_SRCL(link) ((link) ->t_next) |
| 343 |
#define Source_of_SRCL(link) ((link) ->t_source) |
| 344 |
#define SRC_of_SRCL(link) (&Source_of_SRCL(link) ) |
| 345 |
#define SRCL_of_YIM(yim) (&(yim) ->t_container.t_unique) |
| 346 |
#define Source_of_YIM(yim) ((yim) ->t_container.t_unique.t_source) |
| 347 |
#define SRC_of_YIM(yim) (&Source_of_YIM(yim) ) |
| 348 |
#define Predecessor_of_Source(srcd) ((srcd) .t_predecessor) |
| 349 |
#define Predecessor_of_SRC(source) Predecessor_of_Source(*(source) ) |
| 350 |
#define Predecessor_of_YIM(item) Predecessor_of_Source(Source_of_YIM(item) ) |
| 351 |
#define Predecessor_of_SRCL(link) Predecessor_of_Source(Source_of_SRCL(link) ) |
| 352 |
#define LIM_of_SRCL(link) ((LIM) Predecessor_of_SRCL(link) ) |
| 353 |
#define Cause_of_Source(srcd) ((srcd) .t_cause.t_completion) |
| 354 |
#define Cause_of_SRC(source) Cause_of_Source(*(source) ) |
| 355 |
#define Cause_of_YIM(item) Cause_of_Source(Source_of_YIM(item) ) |
| 356 |
#define Cause_of_SRCL(link) Cause_of_Source(Source_of_SRCL(link) ) |
| 357 |
#define TOK_of_Source(srcd) ((srcd) .t_cause.t_token) |
| 358 |
#define TOK_of_SRC(source) TOK_of_Source(*(source) ) |
| 359 |
#define TOK_of_YIM(yim) TOK_of_Source(Source_of_YIM(yim) ) |
| 360 |
#define TOK_of_SRCL(link) TOK_of_Source(Source_of_SRCL(link) ) |
| 361 |
#define NSYID_of_Source(srcd) ((srcd) .t_cause.t_token.t_nsyid) |
| 362 |
#define NSYID_of_SRC(source) NSYID_of_Source(*(source) ) |
| 363 |
#define NSYID_of_YIM(yim) NSYID_of_Source(Source_of_YIM(yim) ) |
| 364 |
#define NSYID_of_SRCL(link) NSYID_of_Source(Source_of_SRCL(link) ) |
| 365 |
#define Value_of_Source(srcd) ((srcd) .t_cause.t_token.t_value) |
| 366 |
#define Value_of_SRC(source) Value_of_Source(*(source) ) |
| 367 |
#define Value_of_SRCL(link) Value_of_Source(Source_of_SRCL(link) ) \ |
| 368 |
|
| 369 |
#define SRC_is_Active(src) ((src) ->t_is_active) |
| 370 |
#define SRC_is_Rejected(src) ((src) ->t_is_rejected) |
| 371 |
#define SRCL_is_Active(link) ((link) ->t_source.t_is_active) |
| 372 |
#define SRCL_is_Rejected(link) ((link) ->t_source.t_is_rejected) \ |
| 373 |
|
| 374 |
#define Cause_AHMID_of_SRCL(srcl) \ |
| 375 |
AHMID_of_YIM((YIM) Cause_of_SRCL(srcl) ) |
| 376 |
#define Leo_Transition_NSYID_of_SRCL(leo_source_link) \ |
| 377 |
Postdot_NSYID_of_LIM(LIM_of_SRCL(leo_source_link) ) \ |
| 378 |
|
| 379 |
#define LV_First_Completion_SRCL_of_YIM(item) ((item) ->t_container.t_ambiguous.t_completion) |
| 380 |
#define First_Completion_SRCL_of_YIM(item) \ |
| 381 |
(Source_Type_of_YIM(item) ==SOURCE_IS_COMPLETION?(SRCL) SRCL_of_YIM(item) : \ |
| 382 |
Source_Type_of_YIM(item) ==SOURCE_IS_AMBIGUOUS? \ |
| 383 |
LV_First_Completion_SRCL_of_YIM(item) :NULL) \ |
| 384 |
|
| 385 |
#define LV_First_Token_SRCL_of_YIM(item) ((item) ->t_container.t_ambiguous.t_token) |
| 386 |
#define First_Token_SRCL_of_YIM(item) \ |
| 387 |
(Source_Type_of_YIM(item) ==SOURCE_IS_TOKEN?(SRCL) SRCL_of_YIM(item) : \ |
| 388 |
Source_Type_of_YIM(item) ==SOURCE_IS_AMBIGUOUS? \ |
| 389 |
LV_First_Token_SRCL_of_YIM(item) :NULL) \ |
| 390 |
|
| 391 |
#define LV_First_Leo_SRCL_of_YIM(item) ((item) ->t_container.t_ambiguous.t_leo) |
| 392 |
#define First_Leo_SRCL_of_YIM(item) \ |
| 393 |
(Source_Type_of_YIM(item) ==SOURCE_IS_LEO?(SRCL) SRCL_of_YIM(item) : \ |
| 394 |
Source_Type_of_YIM(item) ==SOURCE_IS_AMBIGUOUS? \ |
| 395 |
LV_First_Leo_SRCL_of_YIM(item) :NULL) \ |
| 396 |
|
| 397 |
#define NSYID_of_ALT(alt) ((alt) ->t_nsyid) |
| 398 |
#define Value_of_ALT(alt) ((alt) ->t_value) |
| 399 |
#define ALT_is_Valued(alt) ((alt) ->t_is_valued) |
| 400 |
#define Start_YS_of_ALT(alt) ((alt) ->t_start_earley_set) |
| 401 |
#define Start_Earleme_of_ALT(alt) Earleme_of_YS(Start_YS_of_ALT(alt) ) |
| 402 |
#define End_Earleme_of_ALT(alt) ((alt) ->t_end_earleme) |
| 403 |
#define Work_YIMs_of_R(r) MARPA_DSTACK_BASE((r) ->t_yim_work_stack,YIM) |
| 404 |
#define Work_YIM_Count_of_R(r) MARPA_DSTACK_LENGTH((r) ->t_yim_work_stack) |
| 405 |
#define WORK_YIMS_CLEAR(r) MARPA_DSTACK_CLEAR((r) ->t_yim_work_stack) |
| 406 |
#define WORK_YIM_PUSH(r) MARPA_DSTACK_PUSH((r) ->t_yim_work_stack,YIM) |
| 407 |
#define WORK_YIM_ITEM(r,ix) (*MARPA_DSTACK_INDEX((r) ->t_yim_work_stack,YIM,ix) ) |
| 408 |
#define P_YS_of_R_by_Ord(r,ord) MARPA_DSTACK_INDEX((r) ->t_earley_set_stack,YS,(ord) ) |
| 409 |
#define YS_of_R_by_Ord(r,ord) (*P_YS_of_R_by_Ord((r) ,(ord) ) ) |
| 410 |
#define LIM_is_Populated(leo) (Origin_of_LIM(leo) !=NULL) |
| 411 |
#define RULEID_of_PROGRESS(report) ((report) ->t_rule_id) |
| 412 |
#define Position_of_PROGRESS(report) ((report) ->t_position) |
| 413 |
#define Origin_of_PROGRESS(report) ((report) ->t_origin) \ |
| 414 |
|
| 415 |
#define Prev_UR_of_UR(ur) ((ur) ->t_prev) |
| 416 |
#define Next_UR_of_UR(ur) ((ur) ->t_next) |
| 417 |
#define YIM_of_UR(ur) ((ur) ->t_earley_item) \ |
| 418 |
|
| 419 |
#define URS_of_R(r) (&(r) ->t_ur_node_stack) |
| 420 |
#define DUMMY_OR_NODE -1 |
| 421 |
#define MAX_TOKEN_OR_NODE -2 |
| 422 |
#define VALUED_TOKEN_OR_NODE -2 |
| 423 |
#define NULLING_TOKEN_OR_NODE -3 |
| 424 |
#define UNVALUED_TOKEN_OR_NODE -4 |
| 425 |
#define OR_is_Token(or) (Type_of_OR(or) <=MAX_TOKEN_OR_NODE) |
| 426 |
#define Position_of_OR(or) ((or) ->t_final.t_position) |
| 427 |
#define Type_of_OR(or) ((or) ->t_final.t_position) |
| 428 |
#define IRL_of_OR(or) ((or) ->t_final.t_irl) |
| 429 |
#define IRLID_of_OR(or) ID_of_IRL(IRL_of_OR(or) ) |
| 430 |
#define Origin_Ord_of_OR(or) ((or) ->t_final.t_start_set_ordinal) |
| 431 |
#define ID_of_OR(or) ((or) ->t_final.t_id) |
| 432 |
#define YS_Ord_of_OR(or) ((or) ->t_draft.t_end_set_ordinal) |
| 433 |
#define Length_of_OR(or) (YS_Ord_of_OR(or) -Origin_Ord_of_OR(or) ) |
| 434 |
#define DANDs_of_OR(or) ((or) ->t_draft.t_draft_and_node) |
| 435 |
#define First_ANDID_of_OR(or) ((or) ->t_final.t_first_and_node_id) |
| 436 |
#define AND_Count_of_OR(or) ((or) ->t_final.t_and_node_count) |
| 437 |
#define NSYID_of_OR(or) ((or) ->t_token.t_nsyid) |
| 438 |
#define Value_of_OR(or) ((or) ->t_token.t_value) |
| 439 |
#define ORs_of_B(b) ((b) ->t_or_nodes) |
| 440 |
#define OR_of_B_by_ID(b,id) (ORs_of_B(b) [(id) ]) |
| 441 |
#define OR_Count_of_B(b) ((b) ->t_or_node_count) |
| 442 |
#define OR_Capacity_of_B(b) ((b) ->t_or_node_capacity) |
| 443 |
#define ANDs_of_B(b) ((b) ->t_and_nodes) |
| 444 |
#define AND_Count_of_B(b) ((b) ->t_and_node_count) |
| 445 |
#define Top_ORID_of_B(b) ((b) ->t_top_or_node_id) |
| 446 |
#define G_of_B(b) ((b) ->t_grammar) |
| 447 |
#define WHEID_of_NSYID(nsyid) (irl_count+(nsyid) ) |
| 448 |
#define WHEID_of_IRLID(irlid) (irlid) |
| 449 |
#define WHEID_of_IRL(irl) WHEID_of_IRLID(ID_of_IRL(irl) ) |
| 450 |
#define WHEID_of_OR(or) ( \ |
| 451 |
wheid= OR_is_Token(or) ? \ |
| 452 |
WHEID_of_NSYID(NSYID_of_OR(or) ) : \ |
| 453 |
WHEID_of_IRL(IRL_of_OR(or) ) \ |
| 454 |
) \ |
| 455 |
|
| 456 |
#define Next_DAND_of_DAND(dand) ((dand) ->t_next) |
| 457 |
#define Predecessor_OR_of_DAND(dand) ((dand) ->t_predecessor) |
| 458 |
#define Cause_OR_of_DAND(dand) ((dand) ->t_cause) |
| 459 |
#define OR_of_AND(and) ((and) ->t_current) |
| 460 |
#define Predecessor_OR_of_AND(and) ((and) ->t_predecessor) |
| 461 |
#define Cause_OR_of_AND(and) ((and) ->t_cause) |
| 462 |
#define OBS_of_B(b) ((b) ->t_obs) |
| 463 |
#define Valued_BV_of_B(b) ((b) ->t_valued_bv) |
| 464 |
#define Valued_Locked_BV_of_B(b) ((b) ->t_valued_locked_bv) |
| 465 |
#define XSYID_is_Valued_in_B(b,xsyid) \ |
| 466 |
(lbv_bit_test(Valued_BV_of_B(b) ,(xsyid) ) ) |
| 467 |
#define NSYID_is_Valued_in_B(b,nsyid) \ |
| 468 |
XSYID_is_Valued_in_B((b) ,Source_XSYID_of_NSYID(nsyid) ) |
| 469 |
#define OR_by_PSI(psi_data,set_ordinal,item_ordinal) \ |
| 470 |
(((psi_data) [(set_ordinal) ].t_or_node_by_item) [(item_ordinal) ]) |
| 471 |
#define Ambiguity_Metric_of_B(b) ((b) ->t_ambiguity_metric) |
| 472 |
#define B_is_Nulling(b) ((b) ->t_is_nulling) |
| 473 |
#define OBS_of_O(order) ((order) ->t_ordering_obs) |
| 474 |
#define O_is_Default(order) (!OBS_of_O(order) ) |
| 475 |
#define O_is_Frozen(o) ((o) ->t_is_frozen) |
| 476 |
#define B_of_O(b) ((b) ->t_bocage) |
| 477 |
#define Ambiguity_Metric_of_O(o) ((o) ->t_ambiguity_metric) |
| 478 |
#define O_is_Nulling(o) ((o) ->t_is_nulling) |
| 479 |
#define High_Rank_Count_of_O(order) ((order) ->t_high_rank_count) |
| 480 |
#define OR_of_NOOK(nook) ((nook) ->t_or_node) |
| 481 |
#define Choice_of_NOOK(nook) ((nook) ->t_choice) |
| 482 |
#define Parent_of_NOOK(nook) ((nook) ->t_parent) |
| 483 |
#define NOOK_Cause_is_Expanded(nook) ((nook) ->t_is_cause_ready) |
| 484 |
#define NOOK_is_Cause(nook) ((nook) ->t_is_cause_of_parent) |
| 485 |
#define NOOK_Predecessor_is_Expanded(nook) ((nook) ->t_is_predecessor_ready) |
| 486 |
#define NOOK_is_Predecessor(nook) ((nook) ->t_is_predecessor_of_parent) |
| 487 |
#define Size_of_TREE(tree) MARPA_DSTACK_LENGTH((tree) ->t_nook_stack) |
| 488 |
#define NOOK_of_TREE_by_IX(tree,nook_id) \ |
| 489 |
MARPA_DSTACK_INDEX((tree) ->t_nook_stack,NOOK_Object,nook_id) |
| 490 |
#define O_of_T(t) ((t) ->t_order) |
| 491 |
#define T_is_Paused(t) ((t) ->t_pause_counter> 0) |
| 492 |
#define T_is_Exhausted(t) ((t) ->t_is_exhausted) |
| 493 |
#define T_is_Nulling(t) ((t) ->t_is_nulling) |
| 494 |
#define Size_of_T(t) MARPA_DSTACK_LENGTH((t) ->t_nook_stack) |
| 495 |
#define Next_Value_Type_of_V(val) ((val) ->t_next_value_type) |
| 496 |
#define V_is_Active(val) (Next_Value_Type_of_V(val) !=MARPA_STEP_INACTIVE) |
| 497 |
#define T_of_V(v) ((v) ->t_tree) |
| 498 |
#define Step_Type_of_V(val) ((val) ->public.t_step_type) |
| 499 |
#define XSYID_of_V(val) ((val) ->public.t_token_id) |
| 500 |
#define RULEID_of_V(val) ((val) ->public.t_rule_id) |
| 501 |
#define Token_Value_of_V(val) ((val) ->public.t_token_value) |
| 502 |
#define Token_Type_of_V(val) ((val) ->t_token_type) |
| 503 |
#define Arg_0_of_V(val) ((val) ->public.t_arg_0) |
| 504 |
#define Arg_N_of_V(val) ((val) ->public.t_arg_n) |
| 505 |
#define Result_of_V(val) ((val) ->public.t_result) |
| 506 |
#define Rule_Start_of_V(val) ((val) ->public.t_rule_start_ys_id) |
| 507 |
#define Token_Start_of_V(val) ((val) ->public.t_token_start_ys_id) |
| 508 |
#define YS_ID_of_V(val) ((val) ->public.t_ys_id) |
| 509 |
#define VStack_of_V(val) ((val) ->t_virtual_stack) |
| 510 |
#define V_is_Nulling(v) ((v) ->t_is_nulling) |
| 511 |
#define V_is_Trace(val) ((val) ->t_trace) |
| 512 |
#define NOOK_of_V(val) ((val) ->t_nook) |
| 513 |
#define XSY_is_Valued_BV_of_V(v) ((v) ->t_xsy_is_valued) |
| 514 |
#define XRL_is_Valued_BV_of_V(v) ((v) ->t_xrl_is_valued) |
| 515 |
#define Valued_Locked_BV_of_V(v) ((v) ->t_valued_locked) |
| 516 |
#define STEP_GET_DATA MARPA_STEP_INTERNAL2 \ |
| 517 |
|
| 518 |
#define lbv_wordbits (sizeof(LBW) *8u) |
| 519 |
#define lbv_lsb (1u) |
| 520 |
#define lbv_msb (1u<<(lbv_wordbits-1u) ) |
| 521 |
#define lbv_w(lbv,bit) ((lbv) +((bit) /lbv_wordbits) ) |
| 522 |
#define lbv_b(bit) (lbv_lsb<<((bit) %bv_wordbits) ) |
| 523 |
#define lbv_bit_set(lbv,bit) \ |
| 524 |
(*lbv_w((lbv) ,(LBW) (bit) ) |= lbv_b((LBW) (bit) ) ) |
| 525 |
#define lbv_bit_clear(lbv,bit) \ |
| 526 |
(*lbv_w((lbv) ,((LBW) (bit) ) ) &= ~lbv_b((LBW) (bit) ) ) |
| 527 |
#define lbv_bit_test(lbv,bit) \ |
| 528 |
((*lbv_w((lbv) ,((LBW) (bit) ) ) &lbv_b((LBW) (bit) ) ) !=0U) \ |
| 529 |
|
| 530 |
#define BV_BITS(bv) *(bv-3) |
| 531 |
#define BV_SIZE(bv) *(bv-2) |
| 532 |
#define BV_MASK(bv) *(bv-1) |
| 533 |
#define FSTACK_DECLARE(stack,type) struct{int t_count;type*t_base;}stack; |
| 534 |
#define FSTACK_CLEAR(stack) ((stack) .t_count= 0) |
| 535 |
#define FSTACK_INIT(stack,type,n) (FSTACK_CLEAR(stack) , \ |
| 536 |
((stack) .t_base= marpa_new(type,n) ) ) |
| 537 |
#define FSTACK_SAFE(stack) ((stack) .t_base= NULL) |
| 538 |
#define FSTACK_BASE(stack,type) ((type*) (stack) .t_base) |
| 539 |
#define FSTACK_INDEX(this,type,ix) (FSTACK_BASE((this) ,type) +(ix) ) |
| 540 |
#define FSTACK_TOP(this,type) (FSTACK_LENGTH(this) <=0 \ |
| 541 |
?NULL \ |
| 542 |
:FSTACK_INDEX((this) ,type,FSTACK_LENGTH(this) -1) ) |
| 543 |
#define FSTACK_LENGTH(stack) ((stack) .t_count) |
| 544 |
#define FSTACK_PUSH(stack) ((stack) .t_base+stack.t_count++) |
| 545 |
#define FSTACK_POP(stack) ((stack) .t_count<=0?NULL:(stack) .t_base+(--(stack) .t_count) ) |
| 546 |
#define FSTACK_IS_INITIALIZED(stack) ((stack) .t_base) |
| 547 |
#define FSTACK_DESTROY(stack) (my_free((stack) .t_base) ) \ |
| 548 |
|
| 549 |
#define DQUEUE_DECLARE(this) struct s_dqueue this |
| 550 |
#define DQUEUE_INIT(this,type,initial_size) \ |
| 551 |
((this.t_current= 0) ,MARPA_DSTACK_INIT(this.t_stack,type,initial_size) ) |
| 552 |
#define DQUEUE_PUSH(this,type) MARPA_DSTACK_PUSH(this.t_stack,type) |
| 553 |
#define DQUEUE_POP(this,type) MARPA_DSTACK_POP(this.t_stack,type) |
| 554 |
#define DQUEUE_NEXT(this,type) (this.t_current>=MARPA_DSTACK_LENGTH(this.t_stack) \ |
| 555 |
?NULL \ |
| 556 |
:(MARPA_DSTACK_BASE(this.t_stack,type) ) +this.t_current++) |
| 557 |
#define DQUEUE_BASE(this,type) MARPA_DSTACK_BASE(this.t_stack,type) |
| 558 |
#define DQUEUE_END(this) MARPA_DSTACK_LENGTH(this.t_stack) |
| 559 |
#define STOLEN_DQUEUE_DATA_FREE(data) MARPA_STOLEN_DSTACK_DATA_FREE(data) \ |
| 560 |
|
| 561 |
#define Count_of_CIL(cil) (cil[0]) |
| 562 |
#define Item_of_CIL(cil,ix) (cil[1+(ix) ]) |
| 563 |
#define Sizeof_CIL(ix) (sizeof(int) *(1+(ix) ) ) |
| 564 |
#define CAPACITY_OF_CILAR(cilar) (CAPACITY_OF_DSTACK(cilar->t_buffer) -1) |
| 565 |
#define Sizeof_PSL(psar) \ |
| 566 |
(sizeof(PSL_Object) +((size_t) psar->t_psl_length-1) *sizeof(void*) ) |
| 567 |
#define PSL_Datum(psl,i) ((psl) ->t_data[(i) ]) |
| 568 |
#define Dot_PSAR_of_R(r) (&(r) ->t_dot_psar_object) |
| 569 |
#define Dot_PSL_of_YS(ys) ((ys) ->t_dot_psl) |
| 570 |
#define FATAL_FLAG (0x1u) |
| 571 |
#define MARPA_DEV_ERROR(message) (set_error(g,MARPA_ERR_DEVELOPMENT,(message) ,0u) ) |
| 572 |
#define MARPA_INTERNAL_ERROR(message) (set_error(g,MARPA_ERR_INTERNAL,(message) ,0u) ) |
| 573 |
#define MARPA_ERROR(code) (set_error(g,(code) ,NULL,0u) ) |
| 574 |
#define MARPA_FATAL(code) (set_error(g,(code) ,NULL,FATAL_FLAG) ) |
| 575 |
|
| 576 |
#line 16798 "./marpa.w" |
| 577 |
|
| 578 |
#include "marpa_obs.h" |
| 579 |
#include "marpa_avl.h" |
| 580 |
/*107:*/ |
| 581 |
#line 1026 "./marpa.w" |
| 582 |
|
| 583 |
struct s_g_event; |
| 584 |
typedef struct s_g_event*GEV; |
| 585 |
/*:107*//*143:*/ |
| 586 |
#line 1255 "./marpa.w" |
| 587 |
|
| 588 |
struct s_xsy; |
| 589 |
typedef struct s_xsy*XSY; |
| 590 |
typedef const struct s_xsy*XSY_Const; |
| 591 |
|
| 592 |
/*:143*//*454:*/ |
| 593 |
#line 4848 "./marpa.w" |
| 594 |
|
| 595 |
struct s_ahm; |
| 596 |
typedef struct s_ahm*AHM; |
| 597 |
typedef Marpa_AHM_ID AHMID; |
| 598 |
|
| 599 |
/*:454*//*528:*/ |
| 600 |
#line 5775 "./marpa.w" |
| 601 |
|
| 602 |
struct s_g_zwa; |
| 603 |
struct s_r_zwa; |
| 604 |
/*:528*//*535:*/ |
| 605 |
#line 5812 "./marpa.w" |
| 606 |
|
| 607 |
struct s_zwp; |
| 608 |
/*:535*//*628:*/ |
| 609 |
#line 6717 "./marpa.w" |
| 610 |
|
| 611 |
struct s_earley_set; |
| 612 |
typedef struct s_earley_set*YS; |
| 613 |
typedef const struct s_earley_set*YS_Const; |
| 614 |
struct s_earley_set_key; |
| 615 |
typedef struct s_earley_set_key*YSK; |
| 616 |
/*:628*//*650:*/ |
| 617 |
#line 6933 "./marpa.w" |
| 618 |
|
| 619 |
struct s_earley_item; |
| 620 |
typedef struct s_earley_item*YIM; |
| 621 |
typedef const struct s_earley_item*YIM_Const; |
| 622 |
struct s_earley_item_key; |
| 623 |
typedef struct s_earley_item_key*YIK; |
| 624 |
|
| 625 |
/*:650*//*660:*/ |
| 626 |
#line 7107 "./marpa.w" |
| 627 |
|
| 628 |
struct s_earley_ix; |
| 629 |
typedef struct s_earley_ix*YIX; |
| 630 |
/*:660*//*663:*/ |
| 631 |
#line 7143 "./marpa.w" |
| 632 |
|
| 633 |
struct s_leo_item; |
| 634 |
typedef struct s_leo_item*LIM; |
| 635 |
/*:663*//*698:*/ |
| 636 |
#line 7538 "./marpa.w" |
| 637 |
|
| 638 |
struct s_alternative; |
| 639 |
typedef struct s_alternative*ALT; |
| 640 |
typedef const struct s_alternative*ALT_Const; |
| 641 |
/*:698*//*855:*/ |
| 642 |
#line 10019 "./marpa.w" |
| 643 |
|
| 644 |
struct s_ur_node_stack; |
| 645 |
struct s_ur_node; |
| 646 |
typedef struct s_ur_node_stack*URS; |
| 647 |
typedef struct s_ur_node*UR; |
| 648 |
typedef const struct s_ur_node*UR_Const; |
| 649 |
/*:855*//*876:*/ |
| 650 |
#line 10281 "./marpa.w" |
| 651 |
|
| 652 |
union u_or_node; |
| 653 |
typedef union u_or_node*OR; |
| 654 |
/*:876*//*904:*/ |
| 655 |
#line 10688 "./marpa.w" |
| 656 |
|
| 657 |
struct s_draft_and_node; |
| 658 |
typedef struct s_draft_and_node*DAND; |
| 659 |
/*:904*//*930:*/ |
| 660 |
#line 11087 "./marpa.w" |
| 661 |
|
| 662 |
struct s_and_node; |
| 663 |
typedef struct s_and_node*AND; |
| 664 |
/*:930*//*936:*/ |
| 665 |
#line 11149 "./marpa.w" |
| 666 |
|
| 667 |
typedef struct marpa_bocage*BOCAGE; |
| 668 |
/*:936*//*946:*/ |
| 669 |
#line 11254 "./marpa.w" |
| 670 |
|
| 671 |
struct s_bocage_setup_per_ys; |
| 672 |
/*:946*//*1016:*/ |
| 673 |
#line 12021 "./marpa.w" |
| 674 |
|
| 675 |
struct s_nook; |
| 676 |
typedef struct s_nook*NOOK; |
| 677 |
/*:1016*//*1022:*/ |
| 678 |
#line 12062 "./marpa.w" |
| 679 |
|
| 680 |
typedef Marpa_Tree TREE; |
| 681 |
/*:1022*//*1070:*/ |
| 682 |
#line 12710 "./marpa.w" |
| 683 |
|
| 684 |
typedef struct s_value*VALUE; |
| 685 |
/*:1070*//*1180:*/ |
| 686 |
#line 14244 "./marpa.w" |
| 687 |
|
| 688 |
struct s_dqueue; |
| 689 |
typedef struct s_dqueue*DQUEUE; |
| 690 |
/*:1180*//*1186:*/ |
| 691 |
#line 14298 "./marpa.w" |
| 692 |
|
| 693 |
struct s_cil_arena; |
| 694 |
/*:1186*//*1206:*/ |
| 695 |
#line 14633 "./marpa.w" |
| 696 |
|
| 697 |
struct s_per_earley_set_list; |
| 698 |
typedef struct s_per_earley_set_list*PSL; |
| 699 |
/*:1206*//*1208:*/ |
| 700 |
#line 14648 "./marpa.w" |
| 701 |
|
| 702 |
struct s_per_earley_set_arena; |
| 703 |
typedef struct s_per_earley_set_arena*PSAR; |
| 704 |
/*:1208*/ |
| 705 |
#line 16801 "./marpa.w" |
| 706 |
|
| 707 |
/*49:*/ |
| 708 |
#line 664 "./marpa.w" |
| 709 |
|
| 710 |
typedef struct marpa_g*GRAMMAR; |
| 711 |
|
| 712 |
/*:49*//*142:*/ |
| 713 |
#line 1253 "./marpa.w" |
| 714 |
|
| 715 |
typedef Marpa_Symbol_ID XSYID; |
| 716 |
/*:142*//*216:*/ |
| 717 |
#line 1896 "./marpa.w" |
| 718 |
|
| 719 |
struct s_nsy; |
| 720 |
typedef struct s_nsy*NSY; |
| 721 |
typedef Marpa_NSY_ID NSYID; |
| 722 |
|
| 723 |
/*:216*//*255:*/ |
| 724 |
#line 2181 "./marpa.w" |
| 725 |
|
| 726 |
struct s_xrl; |
| 727 |
typedef struct s_xrl*XRL; |
| 728 |
typedef XRL RULE; |
| 729 |
typedef Marpa_Rule_ID RULEID; |
| 730 |
typedef Marpa_Rule_ID XRLID; |
| 731 |
|
| 732 |
/*:255*//*328:*/ |
| 733 |
#line 2908 "./marpa.w" |
| 734 |
|
| 735 |
struct s_irl; |
| 736 |
typedef struct s_irl*IRL; |
| 737 |
typedef Marpa_IRL_ID IRLID; |
| 738 |
|
| 739 |
/*:328*//*470:*/ |
| 740 |
#line 4962 "./marpa.w" |
| 741 |
typedef int SYMI; |
| 742 |
/*:470*//*529:*/ |
| 743 |
#line 5784 "./marpa.w" |
| 744 |
|
| 745 |
typedef Marpa_Assertion_ID ZWAID; |
| 746 |
typedef struct s_g_zwa*GZWA; |
| 747 |
typedef struct s_r_zwa*ZWA; |
| 748 |
|
| 749 |
/*:529*//*536:*/ |
| 750 |
#line 5815 "./marpa.w" |
| 751 |
|
| 752 |
typedef struct s_zwp*ZWP; |
| 753 |
typedef const struct s_zwp*ZWP_Const; |
| 754 |
/*:536*//*549:*/ |
| 755 |
#line 6011 "./marpa.w" |
| 756 |
|
| 757 |
typedef struct marpa_r*RECCE; |
| 758 |
/*:549*//*625:*/ |
| 759 |
#line 6707 "./marpa.w" |
| 760 |
typedef Marpa_Earleme JEARLEME; |
| 761 |
|
| 762 |
/*:625*//*627:*/ |
| 763 |
#line 6711 "./marpa.w" |
| 764 |
typedef Marpa_Earley_Set_ID YSID; |
| 765 |
/*:627*//*652:*/ |
| 766 |
#line 6974 "./marpa.w" |
| 767 |
|
| 768 |
typedef int YIMID; |
| 769 |
|
| 770 |
/*:652*//*670:*/ |
| 771 |
#line 7189 "./marpa.w" |
| 772 |
|
| 773 |
typedef union _Marpa_PIM_Object PIM_Object; |
| 774 |
typedef union _Marpa_PIM_Object*PIM; |
| 775 |
|
| 776 |
/*:670*//*679:*/ |
| 777 |
#line 7269 "./marpa.w" |
| 778 |
|
| 779 |
struct s_source; |
| 780 |
typedef struct s_source*SRC; |
| 781 |
typedef const struct s_source*SRC_Const; |
| 782 |
/*:679*//*682:*/ |
| 783 |
#line 7294 "./marpa.w" |
| 784 |
|
| 785 |
struct s_source_link; |
| 786 |
typedef struct s_source_link*SRCL; |
| 787 |
/*:682*//*823:*/ |
| 788 |
#line 9614 "./marpa.w" |
| 789 |
|
| 790 |
typedef struct marpa_progress_item*PROGRESS; |
| 791 |
/*:823*//*875:*/ |
| 792 |
#line 10278 "./marpa.w" |
| 793 |
|
| 794 |
typedef Marpa_Or_Node_ID ORID; |
| 795 |
|
| 796 |
/*:875*//*903:*/ |
| 797 |
#line 10677 "./marpa.w" |
| 798 |
|
| 799 |
typedef int WHEID; |
| 800 |
|
| 801 |
/*:903*//*929:*/ |
| 802 |
#line 11083 "./marpa.w" |
| 803 |
|
| 804 |
typedef Marpa_And_Node_ID ANDID; |
| 805 |
|
| 806 |
/*:929*//*1015:*/ |
| 807 |
#line 12017 "./marpa.w" |
| 808 |
|
| 809 |
typedef Marpa_Nook_ID NOOKID; |
| 810 |
/*:1015*//*1117:*/ |
| 811 |
#line 13414 "./marpa.w" |
| 812 |
|
| 813 |
typedef unsigned int LBW; |
| 814 |
typedef LBW*LBV; |
| 815 |
|
| 816 |
/*:1117*//*1125:*/ |
| 817 |
#line 13506 "./marpa.w" |
| 818 |
|
| 819 |
typedef LBW Bit_Vector_Word; |
| 820 |
typedef Bit_Vector_Word*Bit_Vector; |
| 821 |
/*:1125*//*1183:*/ |
| 822 |
#line 14265 "./marpa.w" |
| 823 |
|
| 824 |
typedef int*CIL; |
| 825 |
|
| 826 |
/*:1183*//*1187:*/ |
| 827 |
#line 14301 "./marpa.w" |
| 828 |
|
| 829 |
typedef struct s_cil_arena*CILAR; |
| 830 |
/*:1187*/ |
| 831 |
#line 16802 "./marpa.w" |
| 832 |
|
| 833 |
/*1185:*/ |
| 834 |
#line 14290 "./marpa.w" |
| 835 |
|
| 836 |
struct s_cil_arena{ |
| 837 |
struct marpa_obstack*t_obs; |
| 838 |
MARPA_AVL_TREE t_avl; |
| 839 |
MARPA_DSTACK_DECLARE(t_buffer); |
| 840 |
}; |
| 841 |
typedef struct s_cil_arena CILAR_Object; |
| 842 |
|
| 843 |
/*:1185*/ |
| 844 |
#line 16803 "./marpa.w" |
| 845 |
|
| 846 |
/*48:*/ |
| 847 |
#line 658 "./marpa.w" |
| 848 |
struct marpa_g{ |
| 849 |
/*133:*/ |
| 850 |
#line 1200 "./marpa.w" |
| 851 |
|
| 852 |
int t_is_ok; |
| 853 |
|
| 854 |
/*:133*/ |
| 855 |
#line 659 "./marpa.w" |
| 856 |
|
| 857 |
/*59:*/ |
| 858 |
#line 741 "./marpa.w" |
| 859 |
|
| 860 |
MARPA_DSTACK_DECLARE(t_xsy_stack); |
| 861 |
MARPA_DSTACK_DECLARE(t_nsy_stack); |
| 862 |
|
| 863 |
/*:59*//*68:*/ |
| 864 |
#line 800 "./marpa.w" |
| 865 |
|
| 866 |
MARPA_DSTACK_DECLARE(t_xrl_stack); |
| 867 |
MARPA_DSTACK_DECLARE(t_irl_stack); |
| 868 |
/*:68*//*103:*/ |
| 869 |
#line 995 "./marpa.w" |
| 870 |
Bit_Vector t_bv_nsyid_is_terminal; |
| 871 |
/*:103*//*105:*/ |
| 872 |
#line 1004 "./marpa.w" |
| 873 |
|
| 874 |
Bit_Vector t_lbv_xsyid_is_completion_event; |
| 875 |
Bit_Vector t_lbv_xsyid_completion_event_starts_active; |
| 876 |
Bit_Vector t_lbv_xsyid_is_nulled_event; |
| 877 |
Bit_Vector t_lbv_xsyid_nulled_event_starts_active; |
| 878 |
Bit_Vector t_lbv_xsyid_is_prediction_event; |
| 879 |
Bit_Vector t_lbv_xsyid_prediction_event_starts_active; |
| 880 |
/*:105*//*112:*/ |
| 881 |
#line 1048 "./marpa.w" |
| 882 |
|
| 883 |
MARPA_DSTACK_DECLARE(t_events); |
| 884 |
/*:112*//*120:*/ |
| 885 |
#line 1122 "./marpa.w" |
| 886 |
|
| 887 |
MARPA_AVL_TREE t_xrl_tree; |
| 888 |
/*:120*//*124:*/ |
| 889 |
#line 1152 "./marpa.w" |
| 890 |
|
| 891 |
struct marpa_obstack*t_obs; |
| 892 |
struct marpa_obstack*t_xrl_obs; |
| 893 |
/*:124*//*127:*/ |
| 894 |
#line 1169 "./marpa.w" |
| 895 |
|
| 896 |
CILAR_Object t_cilar; |
| 897 |
/*:127*//*135:*/ |
| 898 |
#line 1215 "./marpa.w" |
| 899 |
|
| 900 |
const char*t_error_string; |
| 901 |
/*:135*//*456:*/ |
| 902 |
#line 4865 "./marpa.w" |
| 903 |
|
| 904 |
AHM t_ahms; |
| 905 |
/*:456*//*530:*/ |
| 906 |
#line 5791 "./marpa.w" |
| 907 |
|
| 908 |
MARPA_DSTACK_DECLARE(t_gzwa_stack); |
| 909 |
/*:530*//*538:*/ |
| 910 |
#line 5830 "./marpa.w" |
| 911 |
|
| 912 |
MARPA_AVL_TREE t_zwp_tree; |
| 913 |
/*:538*/ |
| 914 |
#line 660 "./marpa.w" |
| 915 |
|
| 916 |
/*53:*/ |
| 917 |
#line 688 "./marpa.w" |
| 918 |
int t_ref_count; |
| 919 |
/*:53*//*78:*/ |
| 920 |
#line 850 "./marpa.w" |
| 921 |
XSYID t_start_xsy_id; |
| 922 |
/*:78*//*82:*/ |
| 923 |
#line 887 "./marpa.w" |
| 924 |
|
| 925 |
IRL t_start_irl; |
| 926 |
/*:82*//*85:*/ |
| 927 |
#line 901 "./marpa.w" |
| 928 |
|
| 929 |
int t_external_size; |
| 930 |
/*:85*//*88:*/ |
| 931 |
#line 915 "./marpa.w" |
| 932 |
int t_max_rule_length; |
| 933 |
/*:88*//*92:*/ |
| 934 |
#line 928 "./marpa.w" |
| 935 |
Marpa_Rank t_default_rank; |
| 936 |
/*:92*//*136:*/ |
| 937 |
#line 1217 "./marpa.w" |
| 938 |
|
| 939 |
Marpa_Error_Code t_error; |
| 940 |
/*:136*//*161:*/ |
| 941 |
#line 1381 "./marpa.w" |
| 942 |
int t_force_valued; |
| 943 |
/*:161*//*457:*/ |
| 944 |
#line 4869 "./marpa.w" |
| 945 |
|
| 946 |
int t_ahm_count; |
| 947 |
/*:457*//*471:*/ |
| 948 |
#line 4964 "./marpa.w" |
| 949 |
|
| 950 |
int t_symbol_instance_count; |
| 951 |
/*:471*/ |
| 952 |
#line 661 "./marpa.w" |
| 953 |
|
| 954 |
/*97:*/ |
| 955 |
#line 963 "./marpa.w" |
| 956 |
BITFIELD t_is_precomputed:1; |
| 957 |
/*:97*//*100:*/ |
| 958 |
#line 975 "./marpa.w" |
| 959 |
BITFIELD t_has_cycle:1; |
| 960 |
/*:100*/ |
| 961 |
#line 662 "./marpa.w" |
| 962 |
|
| 963 |
}; |
| 964 |
/*:48*//*111:*/ |
| 965 |
#line 1041 "./marpa.w" |
| 966 |
|
| 967 |
struct s_g_event{ |
| 968 |
int t_type; |
| 969 |
int t_value; |
| 970 |
}; |
| 971 |
typedef struct s_g_event GEV_Object; |
| 972 |
/*:111*//*144:*/ |
| 973 |
#line 1260 "./marpa.w" |
| 974 |
|
| 975 |
struct s_xsy{ |
| 976 |
/*202:*/ |
| 977 |
#line 1796 "./marpa.w" |
| 978 |
|
| 979 |
CIL t_nulled_event_xsyids; |
| 980 |
/*:202*//*205:*/ |
| 981 |
#line 1823 "./marpa.w" |
| 982 |
NSY t_nsy_equivalent; |
| 983 |
/*:205*//*209:*/ |
| 984 |
#line 1855 "./marpa.w" |
| 985 |
NSY t_nulling_nsy; |
| 986 |
/*:209*/ |
| 987 |
#line 1262 "./marpa.w" |
| 988 |
|
| 989 |
/*145:*/ |
| 990 |
#line 1269 "./marpa.w" |
| 991 |
XSYID t_symbol_id; |
| 992 |
|
| 993 |
/*:145*//*150:*/ |
| 994 |
#line 1302 "./marpa.w" |
| 995 |
|
| 996 |
Marpa_Rank t_rank; |
| 997 |
/*:150*/ |
| 998 |
#line 1263 "./marpa.w" |
| 999 |
|
| 1000 |
/*154:*/ |
| 1001 |
#line 1349 "./marpa.w" |
| 1002 |
BITFIELD t_is_lhs:1; |
| 1003 |
/*:154*//*156:*/ |
| 1004 |
#line 1356 "./marpa.w" |
| 1005 |
BITFIELD t_is_sequence_lhs:1; |
| 1006 |
/*:156*//*158:*/ |
| 1007 |
#line 1370 "./marpa.w" |
| 1008 |
|
| 1009 |
BITFIELD t_is_valued:1; |
| 1010 |
BITFIELD t_is_valued_locked:1; |
| 1011 |
/*:158*//*166:*/ |
| 1012 |
#line 1440 "./marpa.w" |
| 1013 |
BITFIELD t_is_accessible:1; |
| 1014 |
/*:166*//*169:*/ |
| 1015 |
#line 1461 "./marpa.w" |
| 1016 |
BITFIELD t_is_counted:1; |
| 1017 |
/*:169*//*172:*/ |
| 1018 |
#line 1477 "./marpa.w" |
| 1019 |
BITFIELD t_is_nulling:1; |
| 1020 |
/*:172*//*175:*/ |
| 1021 |
#line 1494 "./marpa.w" |
| 1022 |
BITFIELD t_is_nullable:1; |
| 1023 |
/*:175*//*178:*/ |
| 1024 |
#line 1515 "./marpa.w" |
| 1025 |
|
| 1026 |
BITFIELD t_is_terminal:1; |
| 1027 |
BITFIELD t_is_locked_terminal:1; |
| 1028 |
/*:178*//*183:*/ |
| 1029 |
#line 1562 "./marpa.w" |
| 1030 |
BITFIELD t_is_productive:1; |
| 1031 |
/*:183*//*186:*/ |
| 1032 |
#line 1583 "./marpa.w" |
| 1033 |
|
| 1034 |
BITFIELD t_is_completion_event:1; |
| 1035 |
BITFIELD t_completion_event_starts_active:1; |
| 1036 |
/*:186*//*191:*/ |
| 1037 |
#line 1653 "./marpa.w" |
| 1038 |
|
| 1039 |
BITFIELD t_is_nulled_event:1; |
| 1040 |
BITFIELD t_nulled_event_starts_active:1; |
| 1041 |
/*:191*//*196:*/ |
| 1042 |
#line 1726 "./marpa.w" |
| 1043 |
|
| 1044 |
BITFIELD t_is_prediction_event:1; |
| 1045 |
BITFIELD t_prediction_event_starts_active:1; |
| 1046 |
/*:196*/ |
| 1047 |
#line 1264 "./marpa.w" |
| 1048 |
|
| 1049 |
}; |
| 1050 |
|
| 1051 |
/*:144*//*217:*/ |
| 1052 |
#line 1911 "./marpa.w" |
| 1053 |
|
| 1054 |
struct s_unvalued_token_or_node{ |
| 1055 |
int t_or_node_type; |
| 1056 |
NSYID t_nsyid; |
| 1057 |
}; |
| 1058 |
|
| 1059 |
struct s_nsy{ |
| 1060 |
/*236:*/ |
| 1061 |
#line 2048 "./marpa.w" |
| 1062 |
CIL t_lhs_cil; |
| 1063 |
/*:236*//*241:*/ |
| 1064 |
#line 2079 "./marpa.w" |
| 1065 |
XSY t_source_xsy; |
| 1066 |
/*:241*//*245:*/ |
| 1067 |
#line 2102 "./marpa.w" |
| 1068 |
|
| 1069 |
XRL t_lhs_xrl; |
| 1070 |
int t_xrl_offset; |
| 1071 |
/*:245*/ |
| 1072 |
#line 1918 "./marpa.w" |
| 1073 |
|
| 1074 |
/*250:*/ |
| 1075 |
#line 2155 "./marpa.w" |
| 1076 |
Marpa_Rank t_rank; |
| 1077 |
/*:250*/ |
| 1078 |
#line 1919 "./marpa.w" |
| 1079 |
|
| 1080 |
/*227:*/ |
| 1081 |
#line 2003 "./marpa.w" |
| 1082 |
BITFIELD t_is_start:1; |
| 1083 |
/*:227*//*230:*/ |
| 1084 |
#line 2017 "./marpa.w" |
| 1085 |
BITFIELD t_is_lhs:1; |
| 1086 |
/*:230*//*233:*/ |
| 1087 |
#line 2031 "./marpa.w" |
| 1088 |
BITFIELD t_nsy_is_nulling:1; |
| 1089 |
/*:233*//*238:*/ |
| 1090 |
#line 2056 "./marpa.w" |
| 1091 |
BITFIELD t_is_semantic:1; |
| 1092 |
/*:238*/ |
| 1093 |
#line 1920 "./marpa.w" |
| 1094 |
|
| 1095 |
struct s_unvalued_token_or_node t_nulling_or_node; |
| 1096 |
struct s_unvalued_token_or_node t_unvalued_or_node; |
| 1097 |
}; |
| 1098 |
/*:217*//*254:*/ |
| 1099 |
#line 2172 "./marpa.w" |
| 1100 |
|
| 1101 |
struct s_xrl{ |
| 1102 |
/*267:*/ |
| 1103 |
#line 2475 "./marpa.w" |
| 1104 |
int t_rhs_length; |
| 1105 |
/*:267*//*275:*/ |
| 1106 |
#line 2540 "./marpa.w" |
| 1107 |
Marpa_Rule_ID t_id; |
| 1108 |
|
| 1109 |
/*:275*//*276:*/ |
| 1110 |
#line 2543 "./marpa.w" |
| 1111 |
|
| 1112 |
Marpa_Rank t_rank; |
| 1113 |
/*:276*/ |
| 1114 |
#line 2174 "./marpa.w" |
| 1115 |
|
| 1116 |
/*280:*/ |
| 1117 |
#line 2592 "./marpa.w" |
| 1118 |
|
| 1119 |
BITFIELD t_null_ranks_high:1; |
| 1120 |
/*:280*//*284:*/ |
| 1121 |
#line 2633 "./marpa.w" |
| 1122 |
BITFIELD t_is_bnf:1; |
| 1123 |
/*:284*//*286:*/ |
| 1124 |
#line 2639 "./marpa.w" |
| 1125 |
BITFIELD t_is_sequence:1; |
| 1126 |
/*:286*//*288:*/ |
| 1127 |
#line 2653 "./marpa.w" |
| 1128 |
int t_minimum; |
| 1129 |
/*:288*//*291:*/ |
| 1130 |
#line 2679 "./marpa.w" |
| 1131 |
XSYID t_separator_id; |
| 1132 |
/*:291*//*296:*/ |
| 1133 |
#line 2716 "./marpa.w" |
| 1134 |
BITFIELD t_is_discard:1; |
| 1135 |
/*:296*//*300:*/ |
| 1136 |
#line 2752 "./marpa.w" |
| 1137 |
BITFIELD t_is_proper_separation:1; |
| 1138 |
/*:300*//*304:*/ |
| 1139 |
#line 2773 "./marpa.w" |
| 1140 |
BITFIELD t_is_loop:1; |
| 1141 |
/*:304*//*307:*/ |
| 1142 |
#line 2791 "./marpa.w" |
| 1143 |
BITFIELD t_is_nulling:1; |
| 1144 |
/*:307*//*310:*/ |
| 1145 |
#line 2810 "./marpa.w" |
| 1146 |
BITFIELD t_is_nullable:1; |
| 1147 |
/*:310*//*314:*/ |
| 1148 |
#line 2829 "./marpa.w" |
| 1149 |
BITFIELD t_is_accessible:1; |
| 1150 |
/*:314*//*317:*/ |
| 1151 |
#line 2848 "./marpa.w" |
| 1152 |
BITFIELD t_is_productive:1; |
| 1153 |
/*:317*//*320:*/ |
| 1154 |
#line 2866 "./marpa.w" |
| 1155 |
BITFIELD t_is_used:1; |
| 1156 |
/*:320*/ |
| 1157 |
#line 2175 "./marpa.w" |
| 1158 |
|
| 1159 |
/*268:*/ |
| 1160 |
#line 2478 "./marpa.w" |
| 1161 |
Marpa_Symbol_ID t_symbols[1]; |
| 1162 |
|
| 1163 |
|
| 1164 |
/*:268*/ |
| 1165 |
#line 2176 "./marpa.w" |
| 1166 |
|
| 1167 |
}; |
| 1168 |
/*:254*//*326:*/ |
| 1169 |
#line 2897 "./marpa.w" |
| 1170 |
|
| 1171 |
struct s_irl{ |
| 1172 |
/*359:*/ |
| 1173 |
#line 3110 "./marpa.w" |
| 1174 |
XRL t_source_xrl; |
| 1175 |
/*:359*//*365:*/ |
| 1176 |
#line 3159 "./marpa.w" |
| 1177 |
AHM t_first_ahm; |
| 1178 |
/*:365*/ |
| 1179 |
#line 2899 "./marpa.w" |
| 1180 |
|
| 1181 |
/*329:*/ |
| 1182 |
#line 2919 "./marpa.w" |
| 1183 |
IRLID t_irl_id; |
| 1184 |
|
| 1185 |
/*:329*//*336:*/ |
| 1186 |
#line 2956 "./marpa.w" |
| 1187 |
int t_length; |
| 1188 |
/*:336*//*338:*/ |
| 1189 |
#line 2971 "./marpa.w" |
| 1190 |
int t_ahm_count; |
| 1191 |
|
| 1192 |
/*:338*//*350:*/ |
| 1193 |
#line 3050 "./marpa.w" |
| 1194 |
int t_real_symbol_count; |
| 1195 |
/*:350*//*353:*/ |
| 1196 |
#line 3068 "./marpa.w" |
| 1197 |
int t_virtual_start; |
| 1198 |
/*:353*//*356:*/ |
| 1199 |
#line 3088 "./marpa.w" |
| 1200 |
int t_virtual_end; |
| 1201 |
/*:356*//*362:*/ |
| 1202 |
#line 3137 "./marpa.w" |
| 1203 |
Marpa_Rank t_rank; |
| 1204 |
/*:362*//*472:*/ |
| 1205 |
#line 4970 "./marpa.w" |
| 1206 |
|
| 1207 |
int t_symbol_instance_base; |
| 1208 |
int t_last_proper_symi; |
| 1209 |
/*:472*/ |
| 1210 |
#line 2900 "./marpa.w" |
| 1211 |
|
| 1212 |
/*341:*/ |
| 1213 |
#line 3004 "./marpa.w" |
| 1214 |
BITFIELD t_is_virtual_lhs:1; |
| 1215 |
/*:341*//*344:*/ |
| 1216 |
#line 3020 "./marpa.w" |
| 1217 |
BITFIELD t_is_virtual_rhs:1; |
| 1218 |
/*:344*//*347:*/ |
| 1219 |
#line 3039 "./marpa.w" |
| 1220 |
BITFIELD t_is_right_recursive:1; |
| 1221 |
/*:347*//*409:*/ |
| 1222 |
#line 4057 "./marpa.w" |
| 1223 |
BITFIELD t_is_chaf:1; |
| 1224 |
/*:409*/ |
| 1225 |
#line 2901 "./marpa.w" |
| 1226 |
|
| 1227 |
/*331:*/ |
| 1228 |
#line 2924 "./marpa.w" |
| 1229 |
|
| 1230 |
NSYID t_nsyid_array[1]; |
| 1231 |
|
| 1232 |
/*:331*/ |
| 1233 |
#line 2902 "./marpa.w" |
| 1234 |
|
| 1235 |
}; |
| 1236 |
typedef struct s_irl IRL_Object; |
| 1237 |
|
| 1238 |
/*:326*//*378:*/ |
| 1239 |
#line 3345 "./marpa.w" |
| 1240 |
|
| 1241 |
struct sym_rule_pair |
| 1242 |
{ |
| 1243 |
XSYID t_symid; |
| 1244 |
RULEID t_ruleid; |
| 1245 |
}; |
| 1246 |
|
| 1247 |
/*:378*//*453:*/ |
| 1248 |
#line 4842 "./marpa.w" |
| 1249 |
|
| 1250 |
struct s_ahm{ |
| 1251 |
/*462:*/ |
| 1252 |
#line 4892 "./marpa.w" |
| 1253 |
|
| 1254 |
IRL t_irl; |
| 1255 |
|
| 1256 |
/*:462*//*475:*/ |
| 1257 |
#line 4985 "./marpa.w" |
| 1258 |
|
| 1259 |
CIL t_predicted_irl_cil; |
| 1260 |
CIL t_lhs_cil; |
| 1261 |
|
| 1262 |
/*:475*//*476:*/ |
| 1263 |
#line 4993 "./marpa.w" |
| 1264 |
|
| 1265 |
CIL t_zwa_cil; |
| 1266 |
|
| 1267 |
/*:476*//*496:*/ |
| 1268 |
#line 5218 "./marpa.w" |
| 1269 |
|
| 1270 |
CIL t_completion_xsyids; |
| 1271 |
CIL t_nulled_xsyids; |
| 1272 |
CIL t_prediction_xsyids; |
| 1273 |
|
| 1274 |
/*:496*//*500:*/ |
| 1275 |
#line 5248 "./marpa.w" |
| 1276 |
|
| 1277 |
XRL t_xrl; |
| 1278 |
/*:500*//*503:*/ |
| 1279 |
#line 5287 "./marpa.w" |
| 1280 |
|
| 1281 |
CIL t_event_ahmids; |
| 1282 |
/*:503*/ |
| 1283 |
#line 4844 "./marpa.w" |
| 1284 |
|
| 1285 |
/*463:*/ |
| 1286 |
#line 4902 "./marpa.w" |
| 1287 |
NSYID t_postdot_nsyid; |
| 1288 |
|
| 1289 |
/*:463*//*464:*/ |
| 1290 |
#line 4911 "./marpa.w" |
| 1291 |
|
| 1292 |
int t_leading_nulls; |
| 1293 |
|
| 1294 |
/*:464*//*465:*/ |
| 1295 |
#line 4924 "./marpa.w" |
| 1296 |
|
| 1297 |
int t_position; |
| 1298 |
|
| 1299 |
/*:465*//*467:*/ |
| 1300 |
#line 4940 "./marpa.w" |
| 1301 |
|
| 1302 |
int t_quasi_position; |
| 1303 |
|
| 1304 |
/*:467*//*469:*/ |
| 1305 |
#line 4960 "./marpa.w" |
| 1306 |
|
| 1307 |
int t_symbol_instance; |
| 1308 |
/*:469*//*501:*/ |
| 1309 |
#line 5266 "./marpa.w" |
| 1310 |
|
| 1311 |
int t_xrl_position; |
| 1312 |
|
| 1313 |
/*:501*//*504:*/ |
| 1314 |
#line 5291 "./marpa.w" |
| 1315 |
|
| 1316 |
int t_event_group_size; |
| 1317 |
/*:504*/ |
| 1318 |
#line 4845 "./marpa.w" |
| 1319 |
|
| 1320 |
/*477:*/ |
| 1321 |
#line 5002 "./marpa.w" |
| 1322 |
|
| 1323 |
BITFIELD t_predicts_zwa:1; |
| 1324 |
|
| 1325 |
/*:477*//*499:*/ |
| 1326 |
#line 5239 "./marpa.w" |
| 1327 |
|
| 1328 |
BITFIELD t_was_predicted:1; |
| 1329 |
BITFIELD t_is_initial:1; |
| 1330 |
|
| 1331 |
/*:499*/ |
| 1332 |
#line 4846 "./marpa.w" |
| 1333 |
|
| 1334 |
}; |
| 1335 |
/*:453*//*534:*/ |
| 1336 |
#line 5805 "./marpa.w" |
| 1337 |
|
| 1338 |
struct s_g_zwa{ |
| 1339 |
ZWAID t_id; |
| 1340 |
BITFIELD t_default_value:1; |
| 1341 |
}; |
| 1342 |
typedef struct s_g_zwa GZWA_Object; |
| 1343 |
|
| 1344 |
/*:534*//*537:*/ |
| 1345 |
#line 5822 "./marpa.w" |
| 1346 |
|
| 1347 |
struct s_zwp{ |
| 1348 |
XRLID t_xrl_id; |
| 1349 |
int t_dot; |
| 1350 |
ZWAID t_zwaid; |
| 1351 |
}; |
| 1352 |
typedef struct s_zwp ZWP_Object; |
| 1353 |
|
| 1354 |
/*:537*//*618:*/ |
| 1355 |
#line 6653 "./marpa.w" |
| 1356 |
|
| 1357 |
struct s_r_zwa{ |
| 1358 |
ZWAID t_id; |
| 1359 |
YSID t_memoized_ysid; |
| 1360 |
BITFIELD t_default_value:1; |
| 1361 |
BITFIELD t_memoized_value:1; |
| 1362 |
}; |
| 1363 |
typedef struct s_r_zwa ZWA_Object; |
| 1364 |
|
| 1365 |
/*:618*//*629:*/ |
| 1366 |
#line 6723 "./marpa.w" |
| 1367 |
|
| 1368 |
struct s_earley_set_key{ |
| 1369 |
JEARLEME t_earleme; |
| 1370 |
}; |
| 1371 |
typedef struct s_earley_set_key YSK_Object; |
| 1372 |
/*:629*//*630:*/ |
| 1373 |
#line 6728 "./marpa.w" |
| 1374 |
|
| 1375 |
struct s_earley_set{ |
| 1376 |
YSK_Object t_key; |
| 1377 |
PIM*t_postdot_ary; |
| 1378 |
YS t_next_earley_set; |
| 1379 |
/*632:*/ |
| 1380 |
#line 6744 "./marpa.w" |
| 1381 |
|
| 1382 |
YIM*t_earley_items; |
| 1383 |
|
| 1384 |
/*:632*//*1217:*/ |
| 1385 |
#line 14736 "./marpa.w" |
| 1386 |
|
| 1387 |
PSL t_dot_psl; |
| 1388 |
/*:1217*/ |
| 1389 |
#line 6733 "./marpa.w" |
| 1390 |
|
| 1391 |
int t_postdot_sym_count; |
| 1392 |
/*631:*/ |
| 1393 |
#line 6741 "./marpa.w" |
| 1394 |
|
| 1395 |
int t_yim_count; |
| 1396 |
/*:631*//*633:*/ |
| 1397 |
#line 6755 "./marpa.w" |
| 1398 |
|
| 1399 |
int t_ordinal; |
| 1400 |
/*:633*//*637:*/ |
| 1401 |
#line 6773 "./marpa.w" |
| 1402 |
|
| 1403 |
int t_value; |
| 1404 |
void*t_pvalue; |
| 1405 |
/*:637*/ |
| 1406 |
#line 6735 "./marpa.w" |
| 1407 |
|
| 1408 |
}; |
| 1409 |
typedef struct s_earley_set YS_Object; |
| 1410 |
|
| 1411 |
/*:630*//*661:*/ |
| 1412 |
#line 7110 "./marpa.w" |
| 1413 |
|
| 1414 |
struct s_earley_ix{ |
| 1415 |
PIM t_next; |
| 1416 |
NSYID t_postdot_nsyid; |
| 1417 |
YIM t_earley_item; |
| 1418 |
}; |
| 1419 |
typedef struct s_earley_ix YIX_Object; |
| 1420 |
|
| 1421 |
/*:661*//*664:*/ |
| 1422 |
#line 7146 "./marpa.w" |
| 1423 |
|
| 1424 |
struct s_leo_item{ |
| 1425 |
YIX_Object t_earley_ix; |
| 1426 |
/*665:*/ |
| 1427 |
#line 7162 "./marpa.w" |
| 1428 |
|
| 1429 |
CIL t_cil; |
| 1430 |
|
| 1431 |
/*:665*/ |
| 1432 |
#line 7149 "./marpa.w" |
| 1433 |
|
| 1434 |
YS t_origin; |
| 1435 |
AHM t_top_ahm; |
| 1436 |
AHM t_trailhead_ahm; |
| 1437 |
LIM t_predecessor; |
| 1438 |
YIM t_base; |
| 1439 |
YS t_set; |
| 1440 |
BITFIELD t_is_rejected:1; |
| 1441 |
BITFIELD t_is_active:1; |
| 1442 |
}; |
| 1443 |
typedef struct s_leo_item LIM_Object; |
| 1444 |
|
| 1445 |
/*:664*//*699:*/ |
| 1446 |
#line 7549 "./marpa.w" |
| 1447 |
|
| 1448 |
struct s_alternative{ |
| 1449 |
YS t_start_earley_set; |
| 1450 |
JEARLEME t_end_earleme; |
| 1451 |
NSYID t_nsyid; |
| 1452 |
int t_value; |
| 1453 |
BITFIELD t_is_valued:1; |
| 1454 |
}; |
| 1455 |
typedef struct s_alternative ALT_Object; |
| 1456 |
|
| 1457 |
/*:699*//*856:*/ |
| 1458 |
#line 10035 "./marpa.w" |
| 1459 |
|
| 1460 |
struct s_ur_node_stack{ |
| 1461 |
struct marpa_obstack*t_obs; |
| 1462 |
UR t_base; |
| 1463 |
UR t_top; |
| 1464 |
}; |
| 1465 |
|
| 1466 |
/*:856*//*857:*/ |
| 1467 |
#line 10042 "./marpa.w" |
| 1468 |
|
| 1469 |
struct s_ur_node{ |
| 1470 |
UR t_prev; |
| 1471 |
UR t_next; |
| 1472 |
YIM t_earley_item; |
| 1473 |
}; |
| 1474 |
typedef struct s_ur_node UR_Object; |
| 1475 |
|
| 1476 |
/*:857*//*880:*/ |
| 1477 |
#line 10325 "./marpa.w" |
| 1478 |
|
| 1479 |
struct s_draft_or_node |
| 1480 |
{ |
| 1481 |
/*879:*/ |
| 1482 |
#line 10318 "./marpa.w" |
| 1483 |
|
| 1484 |
/*878:*/ |
| 1485 |
#line 10315 "./marpa.w" |
| 1486 |
|
| 1487 |
int t_position; |
| 1488 |
|
| 1489 |
/*:878*/ |
| 1490 |
#line 10319 "./marpa.w" |
| 1491 |
|
| 1492 |
int t_end_set_ordinal; |
| 1493 |
int t_start_set_ordinal; |
| 1494 |
ORID t_id; |
| 1495 |
IRL t_irl; |
| 1496 |
|
| 1497 |
/*:879*/ |
| 1498 |
#line 10328 "./marpa.w" |
| 1499 |
|
| 1500 |
DAND t_draft_and_node; |
| 1501 |
}; |
| 1502 |
|
| 1503 |
/*:880*//*881:*/ |
| 1504 |
#line 10332 "./marpa.w" |
| 1505 |
|
| 1506 |
struct s_final_or_node |
| 1507 |
{ |
| 1508 |
/*879:*/ |
| 1509 |
#line 10318 "./marpa.w" |
| 1510 |
|
| 1511 |
/*878:*/ |
| 1512 |
#line 10315 "./marpa.w" |
| 1513 |
|
| 1514 |
int t_position; |
| 1515 |
|
| 1516 |
/*:878*/ |
| 1517 |
#line 10319 "./marpa.w" |
| 1518 |
|
| 1519 |
int t_end_set_ordinal; |
| 1520 |
int t_start_set_ordinal; |
| 1521 |
ORID t_id; |
| 1522 |
IRL t_irl; |
| 1523 |
|
| 1524 |
/*:879*/ |
| 1525 |
#line 10335 "./marpa.w" |
| 1526 |
|
| 1527 |
int t_first_and_node_id; |
| 1528 |
int t_and_node_count; |
| 1529 |
}; |
| 1530 |
|
| 1531 |
/*:881*//*882:*/ |
| 1532 |
#line 10340 "./marpa.w" |
| 1533 |
|
| 1534 |
struct s_valued_token_or_node |
| 1535 |
{ |
| 1536 |
/*878:*/ |
| 1537 |
#line 10315 "./marpa.w" |
| 1538 |
|
| 1539 |
int t_position; |
| 1540 |
|
| 1541 |
/*:878*/ |
| 1542 |
#line 10343 "./marpa.w" |
| 1543 |
|
| 1544 |
NSYID t_nsyid; |
| 1545 |
int t_value; |
| 1546 |
}; |
| 1547 |
|
| 1548 |
/*:882*//*883:*/ |
| 1549 |
#line 10351 "./marpa.w" |
| 1550 |
|
| 1551 |
union u_or_node{ |
| 1552 |
struct s_draft_or_node t_draft; |
| 1553 |
struct s_final_or_node t_final; |
| 1554 |
struct s_valued_token_or_node t_token; |
| 1555 |
}; |
| 1556 |
typedef union u_or_node OR_Object; |
| 1557 |
|
| 1558 |
/*:883*//*905:*/ |
| 1559 |
#line 10695 "./marpa.w" |
| 1560 |
|
| 1561 |
struct s_draft_and_node{ |
| 1562 |
DAND t_next; |
| 1563 |
OR t_predecessor; |
| 1564 |
OR t_cause; |
| 1565 |
}; |
| 1566 |
typedef struct s_draft_and_node DAND_Object; |
| 1567 |
|
| 1568 |
/*:905*//*931:*/ |
| 1569 |
#line 11094 "./marpa.w" |
| 1570 |
|
| 1571 |
struct s_and_node{ |
| 1572 |
OR t_current; |
| 1573 |
OR t_predecessor; |
| 1574 |
OR t_cause; |
| 1575 |
}; |
| 1576 |
typedef struct s_and_node AND_Object; |
| 1577 |
|
| 1578 |
/*:931*//*947:*/ |
| 1579 |
#line 11260 "./marpa.w" |
| 1580 |
|
| 1581 |
struct s_bocage_setup_per_ys{ |
| 1582 |
OR*t_or_node_by_item; |
| 1583 |
PSL t_or_psl; |
| 1584 |
PSL t_and_psl; |
| 1585 |
}; |
| 1586 |
/*:947*//*974:*/ |
| 1587 |
#line 11489 "./marpa.w" |
| 1588 |
|
| 1589 |
struct marpa_order{ |
| 1590 |
struct marpa_obstack*t_ordering_obs; |
| 1591 |
ANDID**t_and_node_orderings; |
| 1592 |
/*977:*/ |
| 1593 |
#line 11507 "./marpa.w" |
| 1594 |
|
| 1595 |
BOCAGE t_bocage; |
| 1596 |
|
| 1597 |
/*:977*/ |
| 1598 |
#line 11493 "./marpa.w" |
| 1599 |
|
| 1600 |
/*980:*/ |
| 1601 |
#line 11527 "./marpa.w" |
| 1602 |
int t_ref_count; |
| 1603 |
/*:980*//*987:*/ |
| 1604 |
#line 11583 "./marpa.w" |
| 1605 |
int t_ambiguity_metric; |
| 1606 |
|
| 1607 |
/*:987*//*993:*/ |
| 1608 |
#line 11695 "./marpa.w" |
| 1609 |
int t_high_rank_count; |
| 1610 |
/*:993*/ |
| 1611 |
#line 11494 "./marpa.w" |
| 1612 |
|
| 1613 |
/*991:*/ |
| 1614 |
#line 11677 "./marpa.w" |
| 1615 |
|
| 1616 |
BITFIELD t_is_nulling:1; |
| 1617 |
/*:991*/ |
| 1618 |
#line 11495 "./marpa.w" |
| 1619 |
|
| 1620 |
BITFIELD t_is_frozen:1; |
| 1621 |
}; |
| 1622 |
/*:974*//*1023:*/ |
| 1623 |
#line 12074 "./marpa.w" |
| 1624 |
|
| 1625 |
/*1017:*/ |
| 1626 |
#line 12032 "./marpa.w" |
| 1627 |
|
| 1628 |
struct s_nook{ |
| 1629 |
OR t_or_node; |
| 1630 |
int t_choice; |
| 1631 |
NOOKID t_parent; |
| 1632 |
BITFIELD t_is_cause_ready:1; |
| 1633 |
BITFIELD t_is_predecessor_ready:1; |
| 1634 |
BITFIELD t_is_cause_of_parent:1; |
| 1635 |
BITFIELD t_is_predecessor_of_parent:1; |
| 1636 |
}; |
| 1637 |
typedef struct s_nook NOOK_Object; |
| 1638 |
|
| 1639 |
/*:1017*/ |
| 1640 |
#line 12075 "./marpa.w" |
| 1641 |
|
| 1642 |
/*1072:*/ |
| 1643 |
#line 12724 "./marpa.w" |
| 1644 |
|
| 1645 |
struct s_value{ |
| 1646 |
struct marpa_value public; |
| 1647 |
Marpa_Tree t_tree; |
| 1648 |
/*1076:*/ |
| 1649 |
#line 12802 "./marpa.w" |
| 1650 |
|
| 1651 |
struct marpa_obstack*t_obs; |
| 1652 |
/*:1076*//*1081:*/ |
| 1653 |
#line 12849 "./marpa.w" |
| 1654 |
|
| 1655 |
MARPA_DSTACK_DECLARE(t_virtual_stack); |
| 1656 |
/*:1081*//*1103:*/ |
| 1657 |
#line 13002 "./marpa.w" |
| 1658 |
|
| 1659 |
LBV t_xsy_is_valued; |
| 1660 |
LBV t_xrl_is_valued; |
| 1661 |
LBV t_valued_locked; |
| 1662 |
|
| 1663 |
/*:1103*/ |
| 1664 |
#line 12728 "./marpa.w" |
| 1665 |
|
| 1666 |
/*1086:*/ |
| 1667 |
#line 12897 "./marpa.w" |
| 1668 |
|
| 1669 |
int t_ref_count; |
| 1670 |
/*:1086*//*1098:*/ |
| 1671 |
#line 12978 "./marpa.w" |
| 1672 |
|
| 1673 |
NOOKID t_nook; |
| 1674 |
/*:1098*/ |
| 1675 |
#line 12729 "./marpa.w" |
| 1676 |
|
| 1677 |
int t_token_type; |
| 1678 |
int t_next_value_type; |
| 1679 |
/*1093:*/ |
| 1680 |
#line 12950 "./marpa.w" |
| 1681 |
|
| 1682 |
BITFIELD t_is_nulling:1; |
| 1683 |
/*:1093*//*1095:*/ |
| 1684 |
#line 12957 "./marpa.w" |
| 1685 |
|
| 1686 |
BITFIELD t_trace:1; |
| 1687 |
/*:1095*/ |
| 1688 |
#line 12732 "./marpa.w" |
| 1689 |
|
| 1690 |
}; |
| 1691 |
|
| 1692 |
/*:1072*/ |
| 1693 |
#line 12076 "./marpa.w" |
| 1694 |
|
| 1695 |
struct marpa_tree{ |
| 1696 |
MARPA_DSTACK_DECLARE(t_nook_stack); |
| 1697 |
MARPA_DSTACK_DECLARE(t_nook_worklist); |
| 1698 |
Bit_Vector t_or_node_in_use; |
| 1699 |
Marpa_Order t_order; |
| 1700 |
/*1029:*/ |
| 1701 |
#line 12147 "./marpa.w" |
| 1702 |
|
| 1703 |
int t_ref_count; |
| 1704 |
/*:1029*//*1036:*/ |
| 1705 |
#line 12227 "./marpa.w" |
| 1706 |
int t_pause_counter; |
| 1707 |
/*:1036*/ |
| 1708 |
#line 12082 "./marpa.w" |
| 1709 |
|
| 1710 |
/*1042:*/ |
| 1711 |
#line 12299 "./marpa.w" |
| 1712 |
|
| 1713 |
BITFIELD t_is_exhausted:1; |
| 1714 |
/*:1042*//*1045:*/ |
| 1715 |
#line 12307 "./marpa.w" |
| 1716 |
|
| 1717 |
BITFIELD t_is_nulling:1; |
| 1718 |
|
| 1719 |
/*:1045*/ |
| 1720 |
#line 12083 "./marpa.w" |
| 1721 |
|
| 1722 |
int t_parse_count; |
| 1723 |
}; |
| 1724 |
|
| 1725 |
/*:1023*//*1160:*/ |
| 1726 |
#line 14028 "./marpa.w" |
| 1727 |
|
| 1728 |
struct s_bit_matrix{ |
| 1729 |
int t_row_count; |
| 1730 |
Bit_Vector_Word t_row_data[1]; |
| 1731 |
}; |
| 1732 |
typedef struct s_bit_matrix*Bit_Matrix; |
| 1733 |
typedef struct s_bit_matrix Bit_Matrix_Object; |
| 1734 |
|
| 1735 |
/*:1160*//*1181:*/ |
| 1736 |
#line 14247 "./marpa.w" |
| 1737 |
|
| 1738 |
struct s_dqueue{int t_current;struct marpa_dstack_s t_stack;}; |
| 1739 |
|
| 1740 |
/*:1181*//*1207:*/ |
| 1741 |
#line 14639 "./marpa.w" |
| 1742 |
|
| 1743 |
struct s_per_earley_set_list{ |
| 1744 |
PSL t_prev; |
| 1745 |
PSL t_next; |
| 1746 |
PSL*t_owner; |
| 1747 |
void*t_data[1]; |
| 1748 |
}; |
| 1749 |
typedef struct s_per_earley_set_list PSL_Object; |
| 1750 |
/*:1207*//*1209:*/ |
| 1751 |
#line 14664 "./marpa.w" |
| 1752 |
|
| 1753 |
struct s_per_earley_set_arena{ |
| 1754 |
int t_psl_length; |
| 1755 |
PSL t_first_psl; |
| 1756 |
PSL t_first_free_psl; |
| 1757 |
}; |
| 1758 |
typedef struct s_per_earley_set_arena PSAR_Object; |
| 1759 |
/*:1209*/ |
| 1760 |
#line 16804 "./marpa.w" |
| 1761 |
|
| 1762 |
/*669:*/ |
| 1763 |
#line 7184 "./marpa.w" |
| 1764 |
|
| 1765 |
union _Marpa_PIM_Object{ |
| 1766 |
LIM_Object t_leo; |
| 1767 |
YIX_Object t_earley; |
| 1768 |
}; |
| 1769 |
/*:669*/ |
| 1770 |
#line 16805 "./marpa.w" |
| 1771 |
|
| 1772 |
|
| 1773 |
/*:1383*//*1384:*/ |
| 1774 |
#line 16810 "./marpa.w" |
| 1775 |
|
| 1776 |
/*40:*/ |
| 1777 |
#line 574 "./marpa.w" |
| 1778 |
|
| 1779 |
const int marpa_major_version= MARPA_LIB_MAJOR_VERSION; |
| 1780 |
const int marpa_minor_version= MARPA_LIB_MINOR_VERSION; |
| 1781 |
const int marpa_micro_version= MARPA_LIB_MICRO_VERSION; |
| 1782 |
|
| 1783 |
/*:40*//*829:*/ |
| 1784 |
#line 9640 "./marpa.w" |
| 1785 |
|
| 1786 |
static const struct marpa_progress_item progress_report_not_ready= {-2,-2,-2}; |
| 1787 |
|
| 1788 |
/*:829*//*884:*/ |
| 1789 |
#line 10359 "./marpa.w" |
| 1790 |
|
| 1791 |
static const int dummy_or_node_type= DUMMY_OR_NODE; |
| 1792 |
static const OR dummy_or_node= (OR)&dummy_or_node_type; |
| 1793 |
|
| 1794 |
/*:884*//*1126:*/ |
| 1795 |
#line 13513 "./marpa.w" |
| 1796 |
|
| 1797 |
static const unsigned int bv_wordbits= lbv_wordbits; |
| 1798 |
static const unsigned int bv_modmask= lbv_wordbits-1u; |
| 1799 |
static const unsigned int bv_hiddenwords= 3; |
| 1800 |
static const unsigned int bv_lsb= lbv_lsb; |
| 1801 |
static const unsigned int bv_msb= lbv_msb; |
| 1802 |
|
| 1803 |
/*:1126*/ |
| 1804 |
#line 16811 "./marpa.w" |
| 1805 |
|
| 1806 |
|
| 1807 |
/*:1384*//*1385:*/ |
| 1808 |
#line 16813 "./marpa.w" |
| 1809 |
|
| 1810 |
/*550:*/ |
| 1811 |
#line 6013 "./marpa.w" |
| 1812 |
|
| 1813 |
struct marpa_r{ |
| 1814 |
/*558:*/ |
| 1815 |
#line 6093 "./marpa.w" |
| 1816 |
|
| 1817 |
GRAMMAR t_grammar; |
| 1818 |
/*:558*//*565:*/ |
| 1819 |
#line 6120 "./marpa.w" |
| 1820 |
|
| 1821 |
YS t_first_earley_set; |
| 1822 |
YS t_latest_earley_set; |
| 1823 |
JEARLEME t_current_earleme; |
| 1824 |
/*:565*//*577:*/ |
| 1825 |
#line 6211 "./marpa.w" |
| 1826 |
|
| 1827 |
Bit_Vector t_lbv_xsyid_completion_event_is_active; |
| 1828 |
Bit_Vector t_lbv_xsyid_nulled_event_is_active; |
| 1829 |
Bit_Vector t_lbv_xsyid_prediction_event_is_active; |
| 1830 |
/*:577*//*580:*/ |
| 1831 |
#line 6236 "./marpa.w" |
| 1832 |
Bit_Vector t_bv_nsyid_is_expected; |
| 1833 |
/*:580*//*584:*/ |
| 1834 |
#line 6313 "./marpa.w" |
| 1835 |
LBV t_nsy_expected_is_event; |
| 1836 |
/*:584*//*606:*/ |
| 1837 |
#line 6590 "./marpa.w" |
| 1838 |
|
| 1839 |
Bit_Vector t_bv_irl_seen; |
| 1840 |
MARPA_DSTACK_DECLARE(t_irl_cil_stack); |
| 1841 |
/*:606*//*615:*/ |
| 1842 |
#line 6644 "./marpa.w" |
| 1843 |
struct marpa_obstack*t_obs; |
| 1844 |
/*:615*//*619:*/ |
| 1845 |
#line 6665 "./marpa.w" |
| 1846 |
|
| 1847 |
ZWA t_zwas; |
| 1848 |
/*:619*//*700:*/ |
| 1849 |
#line 7559 "./marpa.w" |
| 1850 |
|
| 1851 |
MARPA_DSTACK_DECLARE(t_alternatives); |
| 1852 |
/*:700*//*717:*/ |
| 1853 |
#line 7846 "./marpa.w" |
| 1854 |
|
| 1855 |
LBV t_valued_terminal; |
| 1856 |
LBV t_unvalued_terminal; |
| 1857 |
LBV t_valued; |
| 1858 |
LBV t_unvalued; |
| 1859 |
LBV t_valued_locked; |
| 1860 |
|
| 1861 |
/*:717*//*725:*/ |
| 1862 |
#line 8059 "./marpa.w" |
| 1863 |
MARPA_DSTACK_DECLARE(t_yim_work_stack); |
| 1864 |
/*:725*//*729:*/ |
| 1865 |
#line 8074 "./marpa.w" |
| 1866 |
MARPA_DSTACK_DECLARE(t_completion_stack); |
| 1867 |
/*:729*//*733:*/ |
| 1868 |
#line 8085 "./marpa.w" |
| 1869 |
MARPA_DSTACK_DECLARE(t_earley_set_stack); |
| 1870 |
/*:733*//*770:*/ |
| 1871 |
#line 8715 "./marpa.w" |
| 1872 |
|
| 1873 |
Bit_Vector t_bv_lim_symbols; |
| 1874 |
Bit_Vector t_bv_pim_symbols; |
| 1875 |
void**t_pim_workarea; |
| 1876 |
/*:770*//*789:*/ |
| 1877 |
#line 8999 "./marpa.w" |
| 1878 |
|
| 1879 |
void**t_lim_chain; |
| 1880 |
/*:789*//*824:*/ |
| 1881 |
#line 9616 "./marpa.w" |
| 1882 |
|
| 1883 |
const struct marpa_progress_item*t_current_report_item; |
| 1884 |
MARPA_AVL_TRAV t_progress_report_traverser; |
| 1885 |
/*:824*//*858:*/ |
| 1886 |
#line 10051 "./marpa.w" |
| 1887 |
|
| 1888 |
struct s_ur_node_stack t_ur_node_stack; |
| 1889 |
/*:858*//*1210:*/ |
| 1890 |
#line 14672 "./marpa.w" |
| 1891 |
|
| 1892 |
PSAR_Object t_dot_psar_object; |
| 1893 |
/*:1210*//*1261:*/ |
| 1894 |
#line 15140 "./marpa.w" |
| 1895 |
|
| 1896 |
struct s_earley_set*t_trace_earley_set; |
| 1897 |
/*:1261*//*1268:*/ |
| 1898 |
#line 15216 "./marpa.w" |
| 1899 |
|
| 1900 |
YIM t_trace_earley_item; |
| 1901 |
/*:1268*//*1283:*/ |
| 1902 |
#line 15432 "./marpa.w" |
| 1903 |
|
| 1904 |
PIM*t_trace_pim_nsy_p; |
| 1905 |
PIM t_trace_postdot_item; |
| 1906 |
/*:1283*//*1290:*/ |
| 1907 |
#line 15581 "./marpa.w" |
| 1908 |
|
| 1909 |
SRCL t_trace_source_link; |
| 1910 |
/*:1290*/ |
| 1911 |
#line 6015 "./marpa.w" |
| 1912 |
|
| 1913 |
/*553:*/ |
| 1914 |
#line 6043 "./marpa.w" |
| 1915 |
int t_ref_count; |
| 1916 |
/*:553*//*569:*/ |
| 1917 |
#line 6159 "./marpa.w" |
| 1918 |
int t_earley_item_warning_threshold; |
| 1919 |
/*:569*//*573:*/ |
| 1920 |
#line 6189 "./marpa.w" |
| 1921 |
JEARLEME t_furthest_earleme; |
| 1922 |
/*:573*//*578:*/ |
| 1923 |
#line 6215 "./marpa.w" |
| 1924 |
|
| 1925 |
int t_active_event_count; |
| 1926 |
/*:578*//*613:*/ |
| 1927 |
#line 6637 "./marpa.w" |
| 1928 |
YSID t_first_inconsistent_ys; |
| 1929 |
/*:613*//*634:*/ |
| 1930 |
#line 6759 "./marpa.w" |
| 1931 |
|
| 1932 |
int t_earley_set_count; |
| 1933 |
/*:634*/ |
| 1934 |
#line 6016 "./marpa.w" |
| 1935 |
|
| 1936 |
/*562:*/ |
| 1937 |
#line 6111 "./marpa.w" |
| 1938 |
|
| 1939 |
BITFIELD t_input_phase:2; |
| 1940 |
/*:562*//*602:*/ |
| 1941 |
#line 6557 "./marpa.w" |
| 1942 |
|
| 1943 |
BITFIELD t_use_leo_flag:1; |
| 1944 |
BITFIELD t_is_using_leo:1; |
| 1945 |
/*:602*//*609:*/ |
| 1946 |
#line 6609 "./marpa.w" |
| 1947 |
BITFIELD t_is_exhausted:1; |
| 1948 |
/*:609*//*1291:*/ |
| 1949 |
#line 15583 "./marpa.w" |
| 1950 |
|
| 1951 |
BITFIELD t_trace_source_type:3; |
| 1952 |
/*:1291*/ |
| 1953 |
#line 6017 "./marpa.w" |
| 1954 |
|
| 1955 |
}; |
| 1956 |
|
| 1957 |
/*:550*/ |
| 1958 |
#line 16814 "./marpa.w" |
| 1959 |
|
| 1960 |
/*680:*/ |
| 1961 |
#line 7273 "./marpa.w" |
| 1962 |
|
| 1963 |
struct s_token_source{ |
| 1964 |
NSYID t_nsyid; |
| 1965 |
int t_value; |
| 1966 |
}; |
| 1967 |
|
| 1968 |
/*:680*//*681:*/ |
| 1969 |
#line 7282 "./marpa.w" |
| 1970 |
|
| 1971 |
struct s_source{ |
| 1972 |
void*t_predecessor; |
| 1973 |
union{ |
| 1974 |
void*t_completion; |
| 1975 |
struct s_token_source t_token; |
| 1976 |
}t_cause; |
| 1977 |
BITFIELD t_is_rejected:1; |
| 1978 |
BITFIELD t_is_active:1; |
| 1979 |
|
| 1980 |
}; |
| 1981 |
|
| 1982 |
/*:681*//*683:*/ |
| 1983 |
#line 7297 "./marpa.w" |
| 1984 |
|
| 1985 |
struct s_source_link{ |
| 1986 |
SRCL t_next; |
| 1987 |
struct s_source t_source; |
| 1988 |
}; |
| 1989 |
typedef struct s_source_link SRCL_Object; |
| 1990 |
|
| 1991 |
/*:683*//*684:*/ |
| 1992 |
#line 7304 "./marpa.w" |
| 1993 |
|
| 1994 |
struct s_ambiguous_source{ |
| 1995 |
SRCL t_leo; |
| 1996 |
SRCL t_token; |
| 1997 |
SRCL t_completion; |
| 1998 |
}; |
| 1999 |
|
| 2000 |
/*:684*//*685:*/ |
| 2001 |
#line 7311 "./marpa.w" |
| 2002 |
|
| 2003 |
union u_source_container{ |
| 2004 |
struct s_ambiguous_source t_ambiguous; |
| 2005 |
struct s_source_link t_unique; |
| 2006 |
}; |
| 2007 |
|
| 2008 |
/*:685*/ |
| 2009 |
#line 16815 "./marpa.w" |
| 2010 |
|
| 2011 |
/*651:*/ |
| 2012 |
#line 6953 "./marpa.w" |
| 2013 |
|
| 2014 |
struct s_earley_item_key{ |
| 2015 |
AHM t_ahm; |
| 2016 |
YS t_origin; |
| 2017 |
YS t_set; |
| 2018 |
}; |
| 2019 |
typedef struct s_earley_item_key YIK_Object; |
| 2020 |
struct s_earley_item{ |
| 2021 |
YIK_Object t_key; |
| 2022 |
union u_source_container t_container; |
| 2023 |
BITFIELD t_ordinal:YIM_ORDINAL_WIDTH; |
| 2024 |
BITFIELD t_source_type:3; |
| 2025 |
BITFIELD t_is_rejected:1; |
| 2026 |
BITFIELD t_is_active:1; |
| 2027 |
BITFIELD t_was_scanned:1; |
| 2028 |
BITFIELD t_was_fusion:1; |
| 2029 |
}; |
| 2030 |
typedef struct s_earley_item YIM_Object; |
| 2031 |
|
| 2032 |
/*:651*/ |
| 2033 |
#line 16816 "./marpa.w" |
| 2034 |
|
| 2035 |
/*937:*/ |
| 2036 |
#line 11151 "./marpa.w" |
| 2037 |
|
| 2038 |
struct marpa_bocage{ |
| 2039 |
/*885:*/ |
| 2040 |
#line 10370 "./marpa.w" |
| 2041 |
|
| 2042 |
OR*t_or_nodes; |
| 2043 |
AND t_and_nodes; |
| 2044 |
/*:885*//*889:*/ |
| 2045 |
#line 10399 "./marpa.w" |
| 2046 |
|
| 2047 |
GRAMMAR t_grammar; |
| 2048 |
|
| 2049 |
/*:889*//*940:*/ |
| 2050 |
#line 11166 "./marpa.w" |
| 2051 |
|
| 2052 |
struct marpa_obstack*t_obs; |
| 2053 |
/*:940*//*943:*/ |
| 2054 |
#line 11234 "./marpa.w" |
| 2055 |
|
| 2056 |
LBV t_valued_bv; |
| 2057 |
LBV t_valued_locked_bv; |
| 2058 |
|
| 2059 |
/*:943*/ |
| 2060 |
#line 11153 "./marpa.w" |
| 2061 |
|
| 2062 |
/*886:*/ |
| 2063 |
#line 10373 "./marpa.w" |
| 2064 |
|
| 2065 |
int t_or_node_capacity; |
| 2066 |
int t_or_node_count; |
| 2067 |
int t_and_node_count; |
| 2068 |
ORID t_top_or_node_id; |
| 2069 |
|
| 2070 |
/*:886*//*958:*/ |
| 2071 |
#line 11389 "./marpa.w" |
| 2072 |
int t_ambiguity_metric; |
| 2073 |
/*:958*//*962:*/ |
| 2074 |
#line 11403 "./marpa.w" |
| 2075 |
int t_ref_count; |
| 2076 |
/*:962*/ |
| 2077 |
#line 11154 "./marpa.w" |
| 2078 |
|
| 2079 |
/*969:*/ |
| 2080 |
#line 11461 "./marpa.w" |
| 2081 |
|
| 2082 |
BITFIELD t_is_nulling:1; |
| 2083 |
/*:969*/ |
| 2084 |
#line 11155 "./marpa.w" |
| 2085 |
|
| 2086 |
}; |
| 2087 |
|
| 2088 |
/*:937*/ |
| 2089 |
#line 16817 "./marpa.w" |
| 2090 |
|
| 2091 |
|
| 2092 |
/*:1385*/ |
| 2093 |
|
| 2094 |
#line 1 "./marpa.c.p40" |
| 2095 |
static RULE rule_new(GRAMMAR g, |
| 2096 |
const XSYID lhs, const XSYID *rhs, int length); |
| 2097 |
static int |
| 2098 |
duplicate_rule_cmp (const void *ap, const void *bp, void *param UNUSED); |
| 2099 |
static int sym_rule_cmp( |
| 2100 |
const void* ap, |
| 2101 |
const void* bp, |
| 2102 |
void *param UNUSED); |
| 2103 |
static int zwp_cmp ( |
| 2104 |
const void* ap, |
| 2105 |
const void* bp, |
| 2106 |
void *param UNUSED); |
| 2107 |
static Marpa_Error_Code invalid_source_type_code(unsigned int type); |
| 2108 |
static void earley_item_ambiguate (struct marpa_r * r, YIM item); |
| 2109 |
static void |
| 2110 |
postdot_items_create (RECCE r, |
| 2111 |
Bit_Vector bv_ok_for_chain, |
| 2112 |
const YS current_earley_set); |
| 2113 |
static int report_item_cmp ( |
| 2114 |
const void* ap, |
| 2115 |
const void* bp, |
| 2116 |
void *param UNUSED); |
| 2117 |
static int bv_scan(Bit_Vector bv, int raw_start, int* raw_min, int* raw_max); |
| 2118 |
static void transitive_closure(Bit_Matrix matrix); |
| 2119 |
static int |
| 2120 |
cil_cmp (const void *ap, const void *bp, void *param UNUSED); |
| 2121 |
static void |
| 2122 |
set_error (GRAMMAR g, Marpa_Error_Code code, const char* message, unsigned int flags); |
| 2123 |
static void* |
| 2124 |
marpa__default_out_of_memory(void); |
| 2125 |
static inline void |
| 2126 |
grammar_unref (GRAMMAR g); |
| 2127 |
static inline GRAMMAR |
| 2128 |
grammar_ref (GRAMMAR g); |
| 2129 |
static inline void grammar_free(GRAMMAR g); |
| 2130 |
static inline void symbol_add( GRAMMAR g, XSY symbol); |
| 2131 |
static inline int xsy_id_is_valid(GRAMMAR g, XSYID xsy_id); |
| 2132 |
static inline int nsy_is_valid(GRAMMAR g, NSYID nsyid); |
| 2133 |
static inline void |
| 2134 |
rule_add (GRAMMAR g, RULE rule); |
| 2135 |
static inline void event_new(GRAMMAR g, int type); |
| 2136 |
static inline void int_event_new(GRAMMAR g, int type, int value); |
| 2137 |
static inline XSY |
| 2138 |
symbol_new (GRAMMAR g); |
| 2139 |
static inline NSY symbol_alias_create(GRAMMAR g, XSY symbol); |
| 2140 |
static inline NSY |
| 2141 |
nsy_start(GRAMMAR g); |
| 2142 |
static inline NSY |
| 2143 |
nsy_new(GRAMMAR g, XSY source); |
| 2144 |
static inline NSY |
| 2145 |
semantic_nsy_new(GRAMMAR g, XSY source); |
| 2146 |
static inline NSY |
| 2147 |
nsy_clone(GRAMMAR g, XSY xsy); |
| 2148 |
static inline XRL xrl_start (GRAMMAR g, const XSYID lhs, const XSYID * rhs, int length); |
| 2149 |
static inline XRL xrl_finish(GRAMMAR g, XRL rule); |
| 2150 |
static inline IRL |
| 2151 |
irl_start(GRAMMAR g, int length); |
| 2152 |
static inline void |
| 2153 |
irl_finish( GRAMMAR g, IRL irl); |
| 2154 |
static inline Marpa_Symbol_ID rule_lhs_get(RULE rule); |
| 2155 |
static inline Marpa_Symbol_ID* rule_rhs_get(RULE rule); |
| 2156 |
static inline int ahm_is_valid( |
| 2157 |
GRAMMAR g, AHMID item_id); |
| 2158 |
static inline void |
| 2159 |
memoize_xrl_data_for_AHM(AHM current_item, IRL irl); |
| 2160 |
static inline void |
| 2161 |
recce_unref (RECCE r); |
| 2162 |
static inline RECCE recce_ref (RECCE r); |
| 2163 |
static inline void recce_free(struct marpa_r *r); |
| 2164 |
static inline YS ys_at_current_earleme(RECCE r); |
| 2165 |
static inline YS |
| 2166 |
earley_set_new( RECCE r, JEARLEME id); |
| 2167 |
static inline YIM earley_item_create(const RECCE r, |
| 2168 |
const YIK_Object key); |
| 2169 |
static inline YIM |
| 2170 |
earley_item_assign (const RECCE r, const YS set, const YS origin, |
| 2171 |
const AHM ahm); |
| 2172 |
static inline PIM* |
| 2173 |
pim_nsy_p_find (YS set, NSYID nsyid); |
| 2174 |
static inline PIM first_pim_of_ys_by_nsyid(YS set, NSYID nsyid); |
| 2175 |
static inline SRCL unique_srcl_new( struct marpa_obstack* t_obs); |
| 2176 |
static inline void |
| 2177 |
completion_link_add (RECCE r, |
| 2178 |
YIM item, |
| 2179 |
YIM predecessor, |
| 2180 |
YIM cause); |
| 2181 |
static inline void |
| 2182 |
leo_link_add (RECCE r, |
| 2183 |
YIM item, |
| 2184 |
LIM predecessor, |
| 2185 |
YIM cause); |
| 2186 |
static inline int |
| 2187 |
alternative_insertion_point (RECCE r, ALT new_alternative); |
| 2188 |
static inline int alternative_cmp(const ALT_Const a, const ALT_Const b); |
| 2189 |
static inline ALT alternative_pop(RECCE r, JEARLEME earleme); |
| 2190 |
static inline int alternative_insert(RECCE r, ALT new_alternative); |
| 2191 |
static inline int evaluate_zwas(RECCE r, YSID ysid, AHM ahm); |
| 2192 |
static inline void trigger_events(RECCE r); |
| 2193 |
static inline int trigger_trivial_events(RECCE r); |
| 2194 |
static inline void earley_set_update_items(RECCE r, YS set); |
| 2195 |
static inline void r_update_earley_sets(RECCE r); |
| 2196 |
static inline int alternative_is_acceptable(ALT alternative); |
| 2197 |
static inline void |
| 2198 |
progress_report_items_insert(MARPA_AVL_TREE report_tree, |
| 2199 |
AHM report_ahm, |
| 2200 |
YIM origin_yim); |
| 2201 |
static inline void ur_node_stack_init(URS stack); |
| 2202 |
static inline void ur_node_stack_reset(URS stack); |
| 2203 |
static inline void ur_node_stack_destroy(URS stack); |
| 2204 |
static inline UR ur_node_new(URS stack, UR prev); |
| 2205 |
static inline void |
| 2206 |
ur_node_push (URS stack, YIM earley_item); |
| 2207 |
static inline UR |
| 2208 |
ur_node_pop (URS stack); |
| 2209 |
static inline void push_ur_if_new( |
| 2210 |
struct s_bocage_setup_per_ys* per_ys_data, |
| 2211 |
URS ur_node_stack, YIM yim); |
| 2212 |
static inline int psi_test_and_set( |
| 2213 |
struct s_bocage_setup_per_ys* per_ys_data, |
| 2214 |
YIM earley_item |
| 2215 |
); |
| 2216 |
static inline void |
| 2217 |
Set_boolean_in_PSI_for_initial_nulls (struct s_bocage_setup_per_ys *per_ys_data, |
| 2218 |
YIM yim); |
| 2219 |
static inline OR or_node_new(BOCAGE b); |
| 2220 |
static inline DAND draft_and_node_new(struct marpa_obstack *obs, OR predecessor, OR cause); |
| 2221 |
static inline void draft_and_node_add(struct marpa_obstack *obs, OR parent, OR predecessor, OR cause); |
| 2222 |
static inline OR or_by_origin_and_symi ( struct s_bocage_setup_per_ys *per_ys_data, |
| 2223 |
YSID origin, |
| 2224 |
SYMI symbol_instance); |
| 2225 |
static inline int dands_are_equal(OR predecessor_a, OR cause_a, |
| 2226 |
OR predecessor_b, OR cause_b); |
| 2227 |
static inline int dand_is_duplicate(OR parent, OR predecessor, OR cause); |
| 2228 |
static inline OR set_or_from_yim ( struct s_bocage_setup_per_ys *per_ys_data, |
| 2229 |
YIM psi_yim); |
| 2230 |
static inline OR safe_or_from_yim( |
| 2231 |
struct s_bocage_setup_per_ys* per_ys_data, |
| 2232 |
YIM yim); |
| 2233 |
static inline void |
| 2234 |
bocage_unref (BOCAGE b); |
| 2235 |
static inline BOCAGE |
| 2236 |
bocage_ref (BOCAGE b); |
| 2237 |
static inline void |
| 2238 |
bocage_free (BOCAGE b); |
| 2239 |
static inline void |
| 2240 |
order_unref (ORDER o); |
| 2241 |
static inline ORDER |
| 2242 |
order_ref (ORDER o); |
| 2243 |
static inline void order_free(ORDER o); |
| 2244 |
static inline ANDID and_order_ix_is_valid(ORDER o, OR or_node, int ix); |
| 2245 |
static inline ANDID and_order_get(ORDER o, OR or_node, int ix); |
| 2246 |
static inline void tree_exhaust(TREE t); |
| 2247 |
static inline void |
| 2248 |
tree_unref (TREE t); |
| 2249 |
static inline TREE |
| 2250 |
tree_ref (TREE t); |
| 2251 |
static inline void tree_free(TREE t); |
| 2252 |
static inline void |
| 2253 |
tree_pause (TREE t); |
| 2254 |
static inline void |
| 2255 |
tree_unpause (TREE t); |
| 2256 |
static inline int tree_or_node_try(TREE tree, ORID or_node_id); |
| 2257 |
static inline void tree_or_node_release(TREE tree, ORID or_node_id); |
| 2258 |
static inline void |
| 2259 |
value_unref (VALUE v); |
| 2260 |
static inline VALUE |
| 2261 |
value_ref (VALUE v); |
| 2262 |
static inline void value_free(VALUE v); |
| 2263 |
static inline int symbol_is_valued( |
| 2264 |
VALUE v, |
| 2265 |
Marpa_Symbol_ID xsy_id); |
| 2266 |
static inline int symbol_is_valued_set ( |
| 2267 |
VALUE v, XSYID xsy_id, int value); |
| 2268 |
static inline int lbv_bits_to_size(int bits); |
| 2269 |
static inline Bit_Vector |
| 2270 |
lbv_obs_new (struct marpa_obstack *obs, int bits); |
| 2271 |
static inline Bit_Vector |
| 2272 |
lbv_zero (Bit_Vector lbv, int bits); |
| 2273 |
static inline Bit_Vector |
| 2274 |
lbv_obs_new0 (struct marpa_obstack *obs, int bits); |
| 2275 |
static inline LBV lbv_clone( |
| 2276 |
struct marpa_obstack* obs, LBV old_lbv, int bits); |
| 2277 |
static inline LBV lbv_fill( |
| 2278 |
LBV lbv, int bits); |
| 2279 |
static inline unsigned int bv_bits_to_size(int bits); |
| 2280 |
static inline unsigned int bv_bits_to_unused_mask(int bits); |
| 2281 |
static inline Bit_Vector bv_create(int bits); |
| 2282 |
static inline Bit_Vector |
| 2283 |
bv_obs_create (struct marpa_obstack *obs, int bits); |
| 2284 |
static inline Bit_Vector bv_shadow(Bit_Vector bv); |
| 2285 |
static inline Bit_Vector bv_obs_shadow(struct marpa_obstack * obs, Bit_Vector bv); |
| 2286 |
static inline Bit_Vector bv_copy(Bit_Vector bv_to, Bit_Vector bv_from); |
| 2287 |
static inline Bit_Vector bv_clone(Bit_Vector bv); |
| 2288 |
static inline Bit_Vector bv_obs_clone(struct marpa_obstack *obs, Bit_Vector bv); |
| 2289 |
static inline void bv_free(Bit_Vector vector); |
| 2290 |
static inline void bv_fill(Bit_Vector bv); |
| 2291 |
static inline void bv_clear(Bit_Vector bv); |
| 2292 |
static inline void bv_over_clear(Bit_Vector bv, int raw_bit); |
| 2293 |
static inline void bv_bit_set(Bit_Vector vector, int raw_bit); |
| 2294 |
static inline void bv_bit_clear(Bit_Vector vector, int raw_bit); |
| 2295 |
static inline int bv_bit_test(Bit_Vector vector, int raw_bit); |
| 2296 |
static inline int |
| 2297 |
bv_bit_test_then_set (Bit_Vector vector, int raw_bit); |
| 2298 |
static inline int bv_is_empty(Bit_Vector addr); |
| 2299 |
static inline void bv_not(Bit_Vector X, Bit_Vector Y); |
| 2300 |
static inline void bv_and(Bit_Vector X, Bit_Vector Y, Bit_Vector Z); |
| 2301 |
static inline void bv_or(Bit_Vector X, Bit_Vector Y, Bit_Vector Z); |
| 2302 |
static inline void bv_or_assign(Bit_Vector X, Bit_Vector Y); |
| 2303 |
static inline int |
| 2304 |
bv_count (Bit_Vector v); |
| 2305 |
static inline void |
| 2306 |
rhs_closure (GRAMMAR g, Bit_Vector bv, XRLID ** xrl_list_x_rh_sym); |
| 2307 |
static inline Bit_Matrix |
| 2308 |
matrix_buffer_create (void *buffer, int rows, int columns); |
| 2309 |
static inline size_t matrix_sizeof(int rows, int columns); |
| 2310 |
static inline Bit_Matrix matrix_obs_create( |
| 2311 |
struct marpa_obstack *obs, |
| 2312 |
int rows, |
| 2313 |
int columns); |
| 2314 |
static inline void matrix_clear(Bit_Matrix matrix); |
| 2315 |
static inline int matrix_columns(Bit_Matrix matrix); |
| 2316 |
static inline Bit_Vector matrix_row(Bit_Matrix matrix, int row); |
| 2317 |
static inline void matrix_bit_set(Bit_Matrix matrix, int row, int column); |
| 2318 |
static inline void matrix_bit_clear(Bit_Matrix matrix, int row, int column); |
| 2319 |
static inline int matrix_bit_test(Bit_Matrix matrix, int row, int column); |
| 2320 |
static inline void |
| 2321 |
cilar_init (const CILAR cilar); |
| 2322 |
static inline void |
| 2323 |
cilar_buffer_reinit (const CILAR cilar); |
| 2324 |
static inline void cilar_destroy(const CILAR cilar); |
| 2325 |
static inline CIL cil_empty(CILAR cilar); |
| 2326 |
static inline CIL cil_singleton(CILAR cilar, int element); |
| 2327 |
static inline CIL cil_buffer_add(CILAR cilar); |
| 2328 |
static inline CIL cil_bv_add(CILAR cilar, Bit_Vector bv); |
| 2329 |
static inline void cil_buffer_clear(CILAR cilar); |
| 2330 |
static inline CIL cil_buffer_push(CILAR cilar, int new_item); |
| 2331 |
static inline CIL cil_buffer_reserve(CILAR cilar, int element_count); |
| 2332 |
static inline CIL cil_merge(CILAR cilar, CIL cil1, CIL cil2); |
| 2333 |
static inline CIL cil_merge_one(CILAR cilar, CIL cil, int new_element); |
| 2334 |
static inline void |
| 2335 |
psar_safe (const PSAR psar); |
| 2336 |
static inline void |
| 2337 |
psar_init (const PSAR psar, int length); |
| 2338 |
static inline void psar_destroy(const PSAR psar); |
| 2339 |
static inline PSL psl_new(const PSAR psar); |
| 2340 |
static inline void psar_reset(const PSAR psar); |
| 2341 |
static inline void psar_dealloc(const PSAR psar); |
| 2342 |
static inline void psl_claim( |
| 2343 |
PSL* const psl_owner, const PSAR psar); |
| 2344 |
static inline PSL psl_claim_by_es( |
| 2345 |
PSAR or_psar, |
| 2346 |
struct s_bocage_setup_per_ys* per_ys_data, |
| 2347 |
YSID ysid); |
| 2348 |
static inline PSL psl_alloc(const PSAR psar); |
| 2349 |
static inline Marpa_Error_Code |
| 2350 |
clear_error (GRAMMAR g); |
| 2351 |
static inline void trace_earley_item_clear(RECCE r); |
| 2352 |
static inline void trace_source_link_clear(RECCE r); |
| 2353 |
static inline int look_yim(Marpa_Earley_Item_Look* look, |
| 2354 |
YS earley_set, Marpa_Earley_Item_ID eim_id); |
| 2355 |
|
| 2356 |
/*1386:*/ |
| 2357 |
#line 16819 "./marpa.w" |
| 2358 |
|
| 2359 |
/*1259:*/ |
| 2360 |
#line 15116 "./marpa.w" |
| 2361 |
|
| 2362 |
extern void*(*const marpa__out_of_memory)(void); |
| 2363 |
|
| 2364 |
/*:1259*//*1366:*/ |
| 2365 |
#line 16634 "./marpa.w" |
| 2366 |
|
| 2367 |
extern int marpa__default_debug_handler(const char*format,...); |
| 2368 |
extern int(*marpa__debug_handler)(const char*,...); |
| 2369 |
extern int marpa__debug_level; |
| 2370 |
|
| 2371 |
/*:1366*/ |
| 2372 |
#line 16820 "./marpa.w" |
| 2373 |
|
| 2374 |
#if MARPA_DEBUG |
| 2375 |
/*1371:*/ |
| 2376 |
#line 16666 "./marpa.w" |
| 2377 |
|
| 2378 |
static const char*yim_tag_safe( |
| 2379 |
char*buffer,GRAMMAR g,YIM yim)UNUSED; |
| 2380 |
static const char*yim_tag(GRAMMAR g,YIM yim)UNUSED; |
| 2381 |
/*:1371*//*1373:*/ |
| 2382 |
#line 16692 "./marpa.w" |
| 2383 |
|
| 2384 |
static char*lim_tag_safe(char*buffer,LIM lim)UNUSED; |
| 2385 |
static char*lim_tag(LIM lim)UNUSED; |
| 2386 |
/*:1373*//*1375:*/ |
| 2387 |
#line 16718 "./marpa.w" |
| 2388 |
|
| 2389 |
static const char*or_tag_safe(char*buffer,OR or)UNUSED; |
| 2390 |
static const char*or_tag(OR or)UNUSED; |
| 2391 |
/*:1375*//*1377:*/ |
| 2392 |
#line 16750 "./marpa.w" |
| 2393 |
|
| 2394 |
static const char*ahm_tag_safe(char*buffer,AHM ahm)UNUSED; |
| 2395 |
static const char*ahm_tag(AHM ahm)UNUSED; |
| 2396 |
/*:1377*/ |
| 2397 |
#line 16822 "./marpa.w" |
| 2398 |
|
| 2399 |
/*1372:*/ |
| 2400 |
#line 16671 "./marpa.w" |
| 2401 |
|
| 2402 |
static const char* |
| 2403 |
yim_tag_safe(char*buffer,GRAMMAR g,YIM yim) |
| 2404 |
{ |
| 2405 |
if(!yim)return"NULL"; |
| 2406 |
sprintf(buffer,"S%d@%d-%d", |
| 2407 |
AHMID_of_YIM(yim),Origin_Earleme_of_YIM(yim), |
| 2408 |
Earleme_of_YIM(yim)); |
| 2409 |
return buffer; |
| 2410 |
} |
| 2411 |
|
| 2412 |
static char DEBUG_yim_tag_buffer[1000]; |
| 2413 |
static const char* |
| 2414 |
yim_tag(GRAMMAR g,YIM yim) |
| 2415 |
{ |
| 2416 |
return yim_tag_safe(DEBUG_yim_tag_buffer,g,yim); |
| 2417 |
} |
| 2418 |
|
| 2419 |
/*:1372*//*1374:*/ |
| 2420 |
#line 16697 "./marpa.w" |
| 2421 |
|
| 2422 |
static char* |
| 2423 |
lim_tag_safe(char*buffer,LIM lim) |
| 2424 |
{ |
| 2425 |
sprintf(buffer,"L%d@%d", |
| 2426 |
Postdot_NSYID_of_LIM(lim),Earleme_of_LIM(lim)); |
| 2427 |
return buffer; |
| 2428 |
} |
| 2429 |
|
| 2430 |
static char DEBUG_lim_tag_buffer[1000]; |
| 2431 |
static char* |
| 2432 |
lim_tag(LIM lim) |
| 2433 |
{ |
| 2434 |
return lim_tag_safe(DEBUG_lim_tag_buffer,lim); |
| 2435 |
} |
| 2436 |
|
| 2437 |
/*:1374*//*1376:*/ |
| 2438 |
#line 16722 "./marpa.w" |
| 2439 |
|
| 2440 |
static const char* |
| 2441 |
or_tag_safe(char*buffer,OR or) |
| 2442 |
{ |
| 2443 |
if(!or)return"NULL"; |
| 2444 |
if(OR_is_Token(or))return"TOKEN"; |
| 2445 |
if(Type_of_OR(or)==DUMMY_OR_NODE)return"DUMMY"; |
| 2446 |
sprintf(buffer,"R%d:%d@%d-%d", |
| 2447 |
IRLID_of_OR(or),Position_of_OR(or), |
| 2448 |
Origin_Ord_of_OR(or), |
| 2449 |
YS_Ord_of_OR(or)); |
| 2450 |
return buffer; |
| 2451 |
} |
| 2452 |
|
| 2453 |
static char DEBUG_or_tag_buffer[1000]; |
| 2454 |
static const char* |
| 2455 |
or_tag(OR or) |
| 2456 |
{ |
| 2457 |
return or_tag_safe(DEBUG_or_tag_buffer,or); |
| 2458 |
} |
| 2459 |
|
| 2460 |
/*:1376*//*1378:*/ |
| 2461 |
#line 16753 "./marpa.w" |
| 2462 |
|
| 2463 |
static const char* |
| 2464 |
ahm_tag_safe(char*buffer,AHM ahm) |
| 2465 |
{ |
| 2466 |
if(!ahm)return"NULL"; |
| 2467 |
const int ahm_position= Position_of_AHM(ahm); |
| 2468 |
if(ahm_position>=0){ |
| 2469 |
sprintf(buffer,"R%d@%d",IRLID_of_AHM(ahm),Position_of_AHM(ahm)); |
| 2470 |
}else{ |
| 2471 |
sprintf(buffer,"R%d@end",IRLID_of_AHM(ahm)); |
| 2472 |
} |
| 2473 |
return buffer; |
| 2474 |
} |
| 2475 |
|
| 2476 |
static char DEBUG_ahm_tag_buffer[1000]; |
| 2477 |
static const char* |
| 2478 |
ahm_tag(AHM ahm) |
| 2479 |
{ |
| 2480 |
return ahm_tag_safe(DEBUG_ahm_tag_buffer,ahm); |
| 2481 |
} |
| 2482 |
|
| 2483 |
/*:1378*/ |
| 2484 |
#line 16823 "./marpa.w" |
| 2485 |
|
| 2486 |
#endif |
| 2487 |
/*1370:*/ |
| 2488 |
#line 16658 "./marpa.w" |
| 2489 |
|
| 2490 |
int(*marpa__debug_handler)(const char*,...)= |
| 2491 |
marpa__default_debug_handler; |
| 2492 |
int marpa__debug_level= 0; |
| 2493 |
|
| 2494 |
/*:1370*/ |
| 2495 |
#line 16825 "./marpa.w" |
| 2496 |
|
| 2497 |
/*41:*/ |
| 2498 |
#line 585 "./marpa.w" |
| 2499 |
|
| 2500 |
Marpa_Error_Code |
| 2501 |
marpa_check_version(int required_major, |
| 2502 |
int required_minor, |
| 2503 |
int required_micro) |
| 2504 |
{ |
| 2505 |
if(required_major!=marpa_major_version) |
| 2506 |
return MARPA_ERR_MAJOR_VERSION_MISMATCH; |
| 2507 |
if(required_minor!=marpa_minor_version) |
| 2508 |
return MARPA_ERR_MINOR_VERSION_MISMATCH; |
| 2509 |
if(required_micro!=marpa_micro_version) |
| 2510 |
return MARPA_ERR_MICRO_VERSION_MISMATCH; |
| 2511 |
return MARPA_ERR_NONE; |
| 2512 |
} |
| 2513 |
|
| 2514 |
/*:41*//*42:*/ |
| 2515 |
#line 603 "./marpa.w" |
| 2516 |
|
| 2517 |
Marpa_Error_Code |
| 2518 |
marpa_version(int*version) |
| 2519 |
{ |
| 2520 |
*version++= marpa_major_version; |
| 2521 |
*version++= marpa_minor_version; |
| 2522 |
*version= marpa_micro_version; |
| 2523 |
return 0; |
| 2524 |
} |
| 2525 |
|
| 2526 |
/*:42*//*45:*/ |
| 2527 |
#line 622 "./marpa.w" |
| 2528 |
|
| 2529 |
int marpa_c_init(Marpa_Config*config) |
| 2530 |
{ |
| 2531 |
config->t_is_ok= I_AM_OK; |
| 2532 |
config->t_error= MARPA_ERR_NONE; |
| 2533 |
config->t_error_string= NULL; |
| 2534 |
return 0; |
| 2535 |
} |
| 2536 |
|
| 2537 |
/*:45*//*46:*/ |
| 2538 |
#line 631 "./marpa.w" |
| 2539 |
|
| 2540 |
Marpa_Error_Code marpa_c_error(Marpa_Config*config,const char**p_error_string) |
| 2541 |
{ |
| 2542 |
const Marpa_Error_Code error_code= config->t_error; |
| 2543 |
const char*error_string= config->t_error_string; |
| 2544 |
if(p_error_string){ |
| 2545 |
*p_error_string= error_string; |
| 2546 |
} |
| 2547 |
return error_code; |
| 2548 |
} |
| 2549 |
|
| 2550 |
const char*_marpa_tag(void) |
| 2551 |
{ |
| 2552 |
#if defined(MARPA_TAG) |
| 2553 |
return STRINGIFY(MARPA_TAG); |
| 2554 |
#elif defined(__GNUC__) |
| 2555 |
return __DATE__" "__TIME__; |
| 2556 |
#else |
| 2557 |
return"[no tag]"; |
| 2558 |
#endif |
| 2559 |
} |
| 2560 |
|
| 2561 |
/*:46*//*51:*/ |
| 2562 |
#line 668 "./marpa.w" |
| 2563 |
|
| 2564 |
Marpa_Grammar marpa_g_new(Marpa_Config*configuration) |
| 2565 |
{ |
| 2566 |
GRAMMAR g; |
| 2567 |
if(configuration&&configuration->t_is_ok!=I_AM_OK){ |
| 2568 |
configuration->t_error= MARPA_ERR_I_AM_NOT_OK; |
| 2569 |
return NULL; |
| 2570 |
} |
| 2571 |
g= my_malloc(sizeof(struct marpa_g)); |
| 2572 |
|
| 2573 |
|
| 2574 |
g->t_is_ok= 0; |
| 2575 |
/*54:*/ |
| 2576 |
#line 689 "./marpa.w" |
| 2577 |
|
| 2578 |
g->t_ref_count= 1; |
| 2579 |
|
| 2580 |
/*:54*//*60:*/ |
| 2581 |
#line 745 "./marpa.w" |
| 2582 |
|
| 2583 |
MARPA_DSTACK_INIT2(g->t_xsy_stack,XSY); |
| 2584 |
MARPA_DSTACK_SAFE(g->t_nsy_stack); |
| 2585 |
|
| 2586 |
/*:60*//*69:*/ |
| 2587 |
#line 803 "./marpa.w" |
| 2588 |
|
| 2589 |
MARPA_DSTACK_INIT2(g->t_xrl_stack,RULE); |
| 2590 |
MARPA_DSTACK_SAFE(g->t_irl_stack); |
| 2591 |
|
| 2592 |
/*:69*//*79:*/ |
| 2593 |
#line 851 "./marpa.w" |
| 2594 |
|
| 2595 |
g->t_start_xsy_id= -1; |
| 2596 |
/*:79*//*83:*/ |
| 2597 |
#line 889 "./marpa.w" |
| 2598 |
|
| 2599 |
g->t_start_irl= NULL; |
| 2600 |
|
| 2601 |
/*:83*//*86:*/ |
| 2602 |
#line 903 "./marpa.w" |
| 2603 |
|
| 2604 |
External_Size_of_G(g)= 0; |
| 2605 |
|
| 2606 |
/*:86*//*89:*/ |
| 2607 |
#line 916 "./marpa.w" |
| 2608 |
|
| 2609 |
g->t_max_rule_length= 0; |
| 2610 |
|
| 2611 |
/*:89*//*93:*/ |
| 2612 |
#line 929 "./marpa.w" |
| 2613 |
|
| 2614 |
g->t_default_rank= 0; |
| 2615 |
/*:93*//*98:*/ |
| 2616 |
#line 964 "./marpa.w" |
| 2617 |
|
| 2618 |
g->t_is_precomputed= 0; |
| 2619 |
/*:98*//*101:*/ |
| 2620 |
#line 976 "./marpa.w" |
| 2621 |
|
| 2622 |
g->t_has_cycle= 0; |
| 2623 |
/*:101*//*104:*/ |
| 2624 |
#line 996 "./marpa.w" |
| 2625 |
g->t_bv_nsyid_is_terminal= NULL; |
| 2626 |
|
| 2627 |
/*:104*//*106:*/ |
| 2628 |
#line 1011 "./marpa.w" |
| 2629 |
|
| 2630 |
g->t_lbv_xsyid_is_completion_event= NULL; |
| 2631 |
g->t_lbv_xsyid_completion_event_starts_active= NULL; |
| 2632 |
g->t_lbv_xsyid_is_nulled_event= NULL; |
| 2633 |
g->t_lbv_xsyid_nulled_event_starts_active= NULL; |
| 2634 |
g->t_lbv_xsyid_is_prediction_event= NULL; |
| 2635 |
g->t_lbv_xsyid_prediction_event_starts_active= NULL; |
| 2636 |
|
| 2637 |
/*:106*//*113:*/ |
| 2638 |
#line 1052 "./marpa.w" |
| 2639 |
|
| 2640 |
MARPA_DSTACK_INIT(g->t_events,GEV_Object,INITIAL_G_EVENTS_CAPACITY); |
| 2641 |
/*:113*//*121:*/ |
| 2642 |
#line 1124 "./marpa.w" |
| 2643 |
|
| 2644 |
(g)->t_xrl_tree= _marpa_avl_create(duplicate_rule_cmp,NULL); |
| 2645 |
/*:121*//*125:*/ |
| 2646 |
#line 1155 "./marpa.w" |
| 2647 |
|
| 2648 |
g->t_obs= marpa_obs_init; |
| 2649 |
g->t_xrl_obs= marpa_obs_init; |
| 2650 |
/*:125*//*128:*/ |
| 2651 |
#line 1171 "./marpa.w" |
| 2652 |
|
| 2653 |
cilar_init(&(g)->t_cilar); |
| 2654 |
/*:128*//*137:*/ |
| 2655 |
#line 1219 "./marpa.w" |
| 2656 |
|
| 2657 |
g->t_error= MARPA_ERR_NONE; |
| 2658 |
g->t_error_string= NULL; |
| 2659 |
/*:137*//*162:*/ |
| 2660 |
#line 1382 "./marpa.w" |
| 2661 |
|
| 2662 |
g->t_force_valued= 0; |
| 2663 |
/*:162*//*459:*/ |
| 2664 |
#line 4874 "./marpa.w" |
| 2665 |
|
| 2666 |
g->t_ahms= NULL; |
| 2667 |
/*:459*//*531:*/ |
| 2668 |
#line 5793 "./marpa.w" |
| 2669 |
|
| 2670 |
MARPA_DSTACK_INIT2(g->t_gzwa_stack,GZWA); |
| 2671 |
/*:531*//*539:*/ |
| 2672 |
#line 5832 "./marpa.w" |
| 2673 |
|
| 2674 |
(g)->t_zwp_tree= _marpa_avl_create(zwp_cmp,NULL); |
| 2675 |
/*:539*/ |
| 2676 |
#line 680 "./marpa.w" |
| 2677 |
|
| 2678 |
|
| 2679 |
|
| 2680 |
g->t_is_ok= I_AM_OK; |
| 2681 |
return g; |
| 2682 |
} |
| 2683 |
|
| 2684 |
/*:51*//*55:*/ |
| 2685 |
#line 699 "./marpa.w" |
| 2686 |
|
| 2687 |
PRIVATE |
| 2688 |
void |
| 2689 |
grammar_unref(GRAMMAR g) |
| 2690 |
{ |
| 2691 |
MARPA_ASSERT(g->t_ref_count> 0) |
| 2692 |
g->t_ref_count--; |
| 2693 |
if(g->t_ref_count<=0) |
| 2694 |
{ |
| 2695 |
grammar_free(g); |
| 2696 |
} |
| 2697 |
} |
| 2698 |
void |
| 2699 |
marpa_g_unref(Marpa_Grammar g) |
| 2700 |
{grammar_unref(g);} |
| 2701 |
|
| 2702 |
/*:55*//*57:*/ |
| 2703 |
#line 716 "./marpa.w" |
| 2704 |
|
| 2705 |
PRIVATE GRAMMAR |
| 2706 |
grammar_ref(GRAMMAR g) |
| 2707 |
{ |
| 2708 |
MARPA_ASSERT(g->t_ref_count> 0) |
| 2709 |
g->t_ref_count++; |
| 2710 |
return g; |
| 2711 |
} |
| 2712 |
Marpa_Grammar |
| 2713 |
marpa_g_ref(Marpa_Grammar g) |
| 2714 |
{return grammar_ref(g);} |
| 2715 |
|
| 2716 |
/*:57*//*58:*/ |
| 2717 |
#line 728 "./marpa.w" |
| 2718 |
|
| 2719 |
PRIVATE |
| 2720 |
void grammar_free(GRAMMAR g) |
| 2721 |
{ |
| 2722 |
/*61:*/ |
| 2723 |
#line 749 "./marpa.w" |
| 2724 |
|
| 2725 |
{ |
| 2726 |
MARPA_DSTACK_DESTROY(g->t_xsy_stack); |
| 2727 |
MARPA_DSTACK_DESTROY(g->t_nsy_stack); |
| 2728 |
} |
| 2729 |
|
| 2730 |
/*:61*//*70:*/ |
| 2731 |
#line 807 "./marpa.w" |
| 2732 |
|
| 2733 |
MARPA_DSTACK_DESTROY(g->t_irl_stack); |
| 2734 |
MARPA_DSTACK_DESTROY(g->t_xrl_stack); |
| 2735 |
|
| 2736 |
/*:70*//*114:*/ |
| 2737 |
#line 1054 "./marpa.w" |
| 2738 |
MARPA_DSTACK_DESTROY(g->t_events); |
| 2739 |
|
| 2740 |
/*:114*//*123:*/ |
| 2741 |
#line 1131 "./marpa.w" |
| 2742 |
|
| 2743 |
/*122:*/ |
| 2744 |
#line 1126 "./marpa.w" |
| 2745 |
|
| 2746 |
{ |
| 2747 |
_marpa_avl_destroy((g)->t_xrl_tree); |
| 2748 |
(g)->t_xrl_tree= NULL; |
| 2749 |
} |
| 2750 |
/*:122*/ |
| 2751 |
#line 1132 "./marpa.w" |
| 2752 |
|
| 2753 |
|
| 2754 |
/*:123*//*126:*/ |
| 2755 |
#line 1158 "./marpa.w" |
| 2756 |
|
| 2757 |
marpa_obs_free(g->t_obs); |
| 2758 |
marpa_obs_free(g->t_xrl_obs); |
| 2759 |
|
| 2760 |
/*:126*//*129:*/ |
| 2761 |
#line 1173 "./marpa.w" |
| 2762 |
|
| 2763 |
cilar_destroy(&(g)->t_cilar); |
| 2764 |
|
| 2765 |
/*:129*//*460:*/ |
| 2766 |
#line 4876 "./marpa.w" |
| 2767 |
|
| 2768 |
my_free(g->t_ahms); |
| 2769 |
|
| 2770 |
/*:460*//*532:*/ |
| 2771 |
#line 5795 "./marpa.w" |
| 2772 |
|
| 2773 |
MARPA_DSTACK_DESTROY(g->t_gzwa_stack); |
| 2774 |
|
| 2775 |
/*:532*//*540:*/ |
| 2776 |
#line 5834 "./marpa.w" |
| 2777 |
|
| 2778 |
{ |
| 2779 |
_marpa_avl_destroy((g)->t_zwp_tree); |
| 2780 |
(g)->t_zwp_tree= NULL; |
| 2781 |
} |
| 2782 |
|
| 2783 |
/*:540*//*541:*/ |
| 2784 |
#line 5840 "./marpa.w" |
| 2785 |
|
| 2786 |
/*122:*/ |
| 2787 |
#line 1126 "./marpa.w" |
| 2788 |
|
| 2789 |
{ |
| 2790 |
_marpa_avl_destroy((g)->t_xrl_tree); |
| 2791 |
(g)->t_xrl_tree= NULL; |
| 2792 |
} |
| 2793 |
/*:122*/ |
| 2794 |
#line 5841 "./marpa.w" |
| 2795 |
|
| 2796 |
|
| 2797 |
/*:541*/ |
| 2798 |
#line 732 "./marpa.w" |
| 2799 |
|
| 2800 |
my_free(g); |
| 2801 |
} |
| 2802 |
|
| 2803 |
/*:58*//*63:*/ |
| 2804 |
#line 757 "./marpa.w" |
| 2805 |
|
| 2806 |
int marpa_g_highest_symbol_id(Marpa_Grammar g){ |
| 2807 |
/*1230:*/ |
| 2808 |
#line 14864 "./marpa.w" |
| 2809 |
const int failure_indicator= -2; |
| 2810 |
|
| 2811 |
/*:1230*/ |
| 2812 |
#line 759 "./marpa.w" |
| 2813 |
|
| 2814 |
/*1250:*/ |
| 2815 |
#line 14997 "./marpa.w" |
| 2816 |
|
| 2817 |
if(HEADER_VERSION_MISMATCH){ |
| 2818 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 2819 |
return failure_indicator; |
| 2820 |
} |
| 2821 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 2822 |
MARPA_ERROR(g->t_error); |
| 2823 |
return failure_indicator; |
| 2824 |
} |
| 2825 |
|
| 2826 |
/*:1250*/ |
| 2827 |
#line 760 "./marpa.w" |
| 2828 |
|
| 2829 |
return XSY_Count_of_G(g)-1; |
| 2830 |
} |
| 2831 |
|
| 2832 |
/*:63*//*65:*/ |
| 2833 |
#line 769 "./marpa.w" |
| 2834 |
|
| 2835 |
PRIVATE |
| 2836 |
void symbol_add(GRAMMAR g,XSY symbol) |
| 2837 |
{ |
| 2838 |
const XSYID new_id= MARPA_DSTACK_LENGTH((g)->t_xsy_stack); |
| 2839 |
*MARPA_DSTACK_PUSH((g)->t_xsy_stack,XSY)= symbol; |
| 2840 |
symbol->t_symbol_id= new_id; |
| 2841 |
} |
| 2842 |
|
| 2843 |
/*:65*//*66:*/ |
| 2844 |
#line 781 "./marpa.w" |
| 2845 |
|
| 2846 |
PRIVATE int xsy_id_is_valid(GRAMMAR g,XSYID xsy_id) |
| 2847 |
{ |
| 2848 |
return!XSYID_is_Malformed(xsy_id)&&XSYID_of_G_Exists(xsy_id); |
| 2849 |
} |
| 2850 |
|
| 2851 |
/*:66*//*67:*/ |
| 2852 |
#line 790 "./marpa.w" |
| 2853 |
|
| 2854 |
PRIVATE int nsy_is_valid(GRAMMAR g,NSYID nsyid) |
| 2855 |
{ |
| 2856 |
return nsyid>=0&&nsyid<NSY_Count_of_G(g); |
| 2857 |
} |
| 2858 |
|
| 2859 |
/*:67*//*74:*/ |
| 2860 |
#line 814 "./marpa.w" |
| 2861 |
|
| 2862 |
int marpa_g_highest_rule_id(Marpa_Grammar g){ |
| 2863 |
/*1230:*/ |
| 2864 |
#line 14864 "./marpa.w" |
| 2865 |
const int failure_indicator= -2; |
| 2866 |
|
| 2867 |
/*:1230*/ |
| 2868 |
#line 816 "./marpa.w" |
| 2869 |
|
| 2870 |
/*1250:*/ |
| 2871 |
#line 14997 "./marpa.w" |
| 2872 |
|
| 2873 |
if(HEADER_VERSION_MISMATCH){ |
| 2874 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 2875 |
return failure_indicator; |
| 2876 |
} |
| 2877 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 2878 |
MARPA_ERROR(g->t_error); |
| 2879 |
return failure_indicator; |
| 2880 |
} |
| 2881 |
|
| 2882 |
/*:1250*/ |
| 2883 |
#line 817 "./marpa.w" |
| 2884 |
|
| 2885 |
return XRL_Count_of_G(g)-1; |
| 2886 |
} |
| 2887 |
int _marpa_g_irl_count(Marpa_Grammar g){ |
| 2888 |
/*1230:*/ |
| 2889 |
#line 14864 "./marpa.w" |
| 2890 |
const int failure_indicator= -2; |
| 2891 |
|
| 2892 |
/*:1230*/ |
| 2893 |
#line 821 "./marpa.w" |
| 2894 |
|
| 2895 |
/*1250:*/ |
| 2896 |
#line 14997 "./marpa.w" |
| 2897 |
|
| 2898 |
if(HEADER_VERSION_MISMATCH){ |
| 2899 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 2900 |
return failure_indicator; |
| 2901 |
} |
| 2902 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 2903 |
MARPA_ERROR(g->t_error); |
| 2904 |
return failure_indicator; |
| 2905 |
} |
| 2906 |
|
| 2907 |
/*:1250*/ |
| 2908 |
#line 822 "./marpa.w" |
| 2909 |
|
| 2910 |
return IRL_Count_of_G(g); |
| 2911 |
} |
| 2912 |
|
| 2913 |
/*:74*//*76:*/ |
| 2914 |
#line 832 "./marpa.w" |
| 2915 |
|
| 2916 |
PRIVATE void |
| 2917 |
rule_add(GRAMMAR g,RULE rule) |
| 2918 |
{ |
| 2919 |
const RULEID new_id= MARPA_DSTACK_LENGTH((g)->t_xrl_stack); |
| 2920 |
*MARPA_DSTACK_PUSH((g)->t_xrl_stack,RULE)= rule; |
| 2921 |
rule->t_id= new_id; |
| 2922 |
External_Size_of_G(g)+= 1+Length_of_XRL(rule); |
| 2923 |
g->t_max_rule_length= MAX(Length_of_XRL(rule),g->t_max_rule_length); |
| 2924 |
} |
| 2925 |
|
| 2926 |
/*:76*//*80:*/ |
| 2927 |
#line 853 "./marpa.w" |
| 2928 |
|
| 2929 |
Marpa_Symbol_ID marpa_g_start_symbol(Marpa_Grammar g) |
| 2930 |
{ |
| 2931 |
/*1230:*/ |
| 2932 |
#line 14864 "./marpa.w" |
| 2933 |
const int failure_indicator= -2; |
| 2934 |
|
| 2935 |
/*:1230*/ |
| 2936 |
#line 856 "./marpa.w" |
| 2937 |
|
| 2938 |
/*1250:*/ |
| 2939 |
#line 14997 "./marpa.w" |
| 2940 |
|
| 2941 |
if(HEADER_VERSION_MISMATCH){ |
| 2942 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 2943 |
return failure_indicator; |
| 2944 |
} |
| 2945 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 2946 |
MARPA_ERROR(g->t_error); |
| 2947 |
return failure_indicator; |
| 2948 |
} |
| 2949 |
|
| 2950 |
/*:1250*/ |
| 2951 |
#line 857 "./marpa.w" |
| 2952 |
|
| 2953 |
if(g->t_start_xsy_id<0){ |
| 2954 |
MARPA_ERROR(MARPA_ERR_NO_START_SYMBOL); |
| 2955 |
return-1; |
| 2956 |
} |
| 2957 |
return g->t_start_xsy_id; |
| 2958 |
} |
| 2959 |
/*:80*//*81:*/ |
| 2960 |
#line 870 "./marpa.w" |
| 2961 |
|
| 2962 |
Marpa_Symbol_ID marpa_g_start_symbol_set(Marpa_Grammar g,Marpa_Symbol_ID xsy_id) |
| 2963 |
{ |
| 2964 |
/*1230:*/ |
| 2965 |
#line 14864 "./marpa.w" |
| 2966 |
const int failure_indicator= -2; |
| 2967 |
|
| 2968 |
/*:1230*/ |
| 2969 |
#line 873 "./marpa.w" |
| 2970 |
|
| 2971 |
/*1250:*/ |
| 2972 |
#line 14997 "./marpa.w" |
| 2973 |
|
| 2974 |
if(HEADER_VERSION_MISMATCH){ |
| 2975 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 2976 |
return failure_indicator; |
| 2977 |
} |
| 2978 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 2979 |
MARPA_ERROR(g->t_error); |
| 2980 |
return failure_indicator; |
| 2981 |
} |
| 2982 |
|
| 2983 |
/*:1250*/ |
| 2984 |
#line 874 "./marpa.w" |
| 2985 |
|
| 2986 |
/*1231:*/ |
| 2987 |
#line 14869 "./marpa.w" |
| 2988 |
|
| 2989 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 2990 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 2991 |
return failure_indicator; |
| 2992 |
} |
| 2993 |
|
| 2994 |
/*:1231*/ |
| 2995 |
#line 875 "./marpa.w" |
| 2996 |
|
| 2997 |
/*1233:*/ |
| 2998 |
#line 14880 "./marpa.w" |
| 2999 |
|
| 3000 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 3001 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 3002 |
return failure_indicator; |
| 3003 |
} |
| 3004 |
/*:1233*/ |
| 3005 |
#line 876 "./marpa.w" |
| 3006 |
|
| 3007 |
/*1234:*/ |
| 3008 |
#line 14887 "./marpa.w" |
| 3009 |
|
| 3010 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 3011 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 3012 |
return-1; |
| 3013 |
} |
| 3014 |
/*:1234*/ |
| 3015 |
#line 877 "./marpa.w" |
| 3016 |
|
| 3017 |
return g->t_start_xsy_id= xsy_id; |
| 3018 |
} |
| 3019 |
|
| 3020 |
/*:81*//*94:*/ |
| 3021 |
#line 931 "./marpa.w" |
| 3022 |
|
| 3023 |
Marpa_Rank marpa_g_default_rank(Marpa_Grammar g) |
| 3024 |
{ |
| 3025 |
/*1230:*/ |
| 3026 |
#line 14864 "./marpa.w" |
| 3027 |
const int failure_indicator= -2; |
| 3028 |
|
| 3029 |
/*:1230*/ |
| 3030 |
#line 934 "./marpa.w" |
| 3031 |
|
| 3032 |
clear_error(g); |
| 3033 |
/*1250:*/ |
| 3034 |
#line 14997 "./marpa.w" |
| 3035 |
|
| 3036 |
if(HEADER_VERSION_MISMATCH){ |
| 3037 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3038 |
return failure_indicator; |
| 3039 |
} |
| 3040 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3041 |
MARPA_ERROR(g->t_error); |
| 3042 |
return failure_indicator; |
| 3043 |
} |
| 3044 |
|
| 3045 |
/*:1250*/ |
| 3046 |
#line 936 "./marpa.w" |
| 3047 |
|
| 3048 |
return Default_Rank_of_G(g); |
| 3049 |
} |
| 3050 |
/*:94*//*95:*/ |
| 3051 |
#line 941 "./marpa.w" |
| 3052 |
|
| 3053 |
Marpa_Rank marpa_g_default_rank_set(Marpa_Grammar g,Marpa_Rank rank) |
| 3054 |
{ |
| 3055 |
/*1230:*/ |
| 3056 |
#line 14864 "./marpa.w" |
| 3057 |
const int failure_indicator= -2; |
| 3058 |
|
| 3059 |
/*:1230*/ |
| 3060 |
#line 944 "./marpa.w" |
| 3061 |
|
| 3062 |
clear_error(g); |
| 3063 |
/*1250:*/ |
| 3064 |
#line 14997 "./marpa.w" |
| 3065 |
|
| 3066 |
if(HEADER_VERSION_MISMATCH){ |
| 3067 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3068 |
return failure_indicator; |
| 3069 |
} |
| 3070 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3071 |
MARPA_ERROR(g->t_error); |
| 3072 |
return failure_indicator; |
| 3073 |
} |
| 3074 |
|
| 3075 |
/*:1250*/ |
| 3076 |
#line 946 "./marpa.w" |
| 3077 |
|
| 3078 |
/*1231:*/ |
| 3079 |
#line 14869 "./marpa.w" |
| 3080 |
|
| 3081 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 3082 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 3083 |
return failure_indicator; |
| 3084 |
} |
| 3085 |
|
| 3086 |
/*:1231*/ |
| 3087 |
#line 947 "./marpa.w" |
| 3088 |
|
| 3089 |
if(_MARPA_UNLIKELY(rank<MINIMUM_RANK)) |
| 3090 |
{ |
| 3091 |
MARPA_ERROR(MARPA_ERR_RANK_TOO_LOW); |
| 3092 |
return failure_indicator; |
| 3093 |
} |
| 3094 |
if(_MARPA_UNLIKELY(rank> MAXIMUM_RANK)) |
| 3095 |
{ |
| 3096 |
MARPA_ERROR(MARPA_ERR_RANK_TOO_HIGH); |
| 3097 |
return failure_indicator; |
| 3098 |
} |
| 3099 |
return Default_Rank_of_G(g)= rank; |
| 3100 |
} |
| 3101 |
|
| 3102 |
/*:95*//*99:*/ |
| 3103 |
#line 966 "./marpa.w" |
| 3104 |
|
| 3105 |
int marpa_g_is_precomputed(Marpa_Grammar g) |
| 3106 |
{ |
| 3107 |
/*1230:*/ |
| 3108 |
#line 14864 "./marpa.w" |
| 3109 |
const int failure_indicator= -2; |
| 3110 |
|
| 3111 |
/*:1230*/ |
| 3112 |
#line 969 "./marpa.w" |
| 3113 |
|
| 3114 |
/*1250:*/ |
| 3115 |
#line 14997 "./marpa.w" |
| 3116 |
|
| 3117 |
if(HEADER_VERSION_MISMATCH){ |
| 3118 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3119 |
return failure_indicator; |
| 3120 |
} |
| 3121 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3122 |
MARPA_ERROR(g->t_error); |
| 3123 |
return failure_indicator; |
| 3124 |
} |
| 3125 |
|
| 3126 |
/*:1250*/ |
| 3127 |
#line 970 "./marpa.w" |
| 3128 |
|
| 3129 |
return G_is_Precomputed(g); |
| 3130 |
} |
| 3131 |
|
| 3132 |
/*:99*//*102:*/ |
| 3133 |
#line 978 "./marpa.w" |
| 3134 |
|
| 3135 |
int marpa_g_has_cycle(Marpa_Grammar g) |
| 3136 |
{ |
| 3137 |
/*1230:*/ |
| 3138 |
#line 14864 "./marpa.w" |
| 3139 |
const int failure_indicator= -2; |
| 3140 |
|
| 3141 |
/*:1230*/ |
| 3142 |
#line 981 "./marpa.w" |
| 3143 |
|
| 3144 |
/*1250:*/ |
| 3145 |
#line 14997 "./marpa.w" |
| 3146 |
|
| 3147 |
if(HEADER_VERSION_MISMATCH){ |
| 3148 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3149 |
return failure_indicator; |
| 3150 |
} |
| 3151 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3152 |
MARPA_ERROR(g->t_error); |
| 3153 |
return failure_indicator; |
| 3154 |
} |
| 3155 |
|
| 3156 |
/*:1250*/ |
| 3157 |
#line 982 "./marpa.w" |
| 3158 |
|
| 3159 |
return g->t_has_cycle; |
| 3160 |
} |
| 3161 |
|
| 3162 |
/*:102*//*116:*/ |
| 3163 |
#line 1064 "./marpa.w" |
| 3164 |
|
| 3165 |
PRIVATE |
| 3166 |
void event_new(GRAMMAR g,int type) |
| 3167 |
{ |
| 3168 |
|
| 3169 |
|
| 3170 |
GEV end_of_stack= G_EVENT_PUSH(g); |
| 3171 |
end_of_stack->t_type= type; |
| 3172 |
end_of_stack->t_value= 0; |
| 3173 |
} |
| 3174 |
/*:116*//*117:*/ |
| 3175 |
#line 1074 "./marpa.w" |
| 3176 |
|
| 3177 |
PRIVATE |
| 3178 |
void int_event_new(GRAMMAR g,int type,int value) |
| 3179 |
{ |
| 3180 |
|
| 3181 |
|
| 3182 |
GEV end_of_stack= G_EVENT_PUSH(g); |
| 3183 |
end_of_stack->t_type= type; |
| 3184 |
end_of_stack->t_value= value; |
| 3185 |
} |
| 3186 |
|
| 3187 |
/*:117*//*118:*/ |
| 3188 |
#line 1085 "./marpa.w" |
| 3189 |
|
| 3190 |
Marpa_Event_Type |
| 3191 |
marpa_g_event(Marpa_Grammar g,Marpa_Event*public_event, |
| 3192 |
int ix) |
| 3193 |
{ |
| 3194 |
/*1230:*/ |
| 3195 |
#line 14864 "./marpa.w" |
| 3196 |
const int failure_indicator= -2; |
| 3197 |
|
| 3198 |
/*:1230*/ |
| 3199 |
#line 1090 "./marpa.w" |
| 3200 |
|
| 3201 |
MARPA_DSTACK events= &g->t_events; |
| 3202 |
GEV internal_event; |
| 3203 |
int type; |
| 3204 |
|
| 3205 |
if(ix<0){ |
| 3206 |
MARPA_ERROR(MARPA_ERR_EVENT_IX_NEGATIVE); |
| 3207 |
return failure_indicator; |
| 3208 |
} |
| 3209 |
if(ix>=MARPA_DSTACK_LENGTH(*events)){ |
| 3210 |
MARPA_ERROR(MARPA_ERR_EVENT_IX_OOB); |
| 3211 |
return failure_indicator; |
| 3212 |
} |
| 3213 |
internal_event= MARPA_DSTACK_INDEX(*events,GEV_Object,ix); |
| 3214 |
type= internal_event->t_type; |
| 3215 |
public_event->t_type= type; |
| 3216 |
public_event->t_value= internal_event->t_value; |
| 3217 |
return type; |
| 3218 |
} |
| 3219 |
|
| 3220 |
/*:118*//*119:*/ |
| 3221 |
#line 1110 "./marpa.w" |
| 3222 |
|
| 3223 |
Marpa_Event_Type |
| 3224 |
marpa_g_event_count(Marpa_Grammar g) |
| 3225 |
{ |
| 3226 |
/*1230:*/ |
| 3227 |
#line 14864 "./marpa.w" |
| 3228 |
const int failure_indicator= -2; |
| 3229 |
|
| 3230 |
/*:1230*/ |
| 3231 |
#line 1114 "./marpa.w" |
| 3232 |
|
| 3233 |
/*1250:*/ |
| 3234 |
#line 14997 "./marpa.w" |
| 3235 |
|
| 3236 |
if(HEADER_VERSION_MISMATCH){ |
| 3237 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3238 |
return failure_indicator; |
| 3239 |
} |
| 3240 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3241 |
MARPA_ERROR(g->t_error); |
| 3242 |
return failure_indicator; |
| 3243 |
} |
| 3244 |
|
| 3245 |
/*:1250*/ |
| 3246 |
#line 1115 "./marpa.w" |
| 3247 |
|
| 3248 |
return MARPA_DSTACK_LENGTH(g->t_events); |
| 3249 |
} |
| 3250 |
|
| 3251 |
/*:119*//*139:*/ |
| 3252 |
#line 1230 "./marpa.w" |
| 3253 |
|
| 3254 |
Marpa_Error_Code marpa_g_error(Marpa_Grammar g,const char**p_error_string) |
| 3255 |
{ |
| 3256 |
const Marpa_Error_Code error_code= g->t_error; |
| 3257 |
const char*error_string= g->t_error_string; |
| 3258 |
if(p_error_string){ |
| 3259 |
*p_error_string= error_string; |
| 3260 |
} |
| 3261 |
return error_code; |
| 3262 |
} |
| 3263 |
|
| 3264 |
/*:139*//*140:*/ |
| 3265 |
#line 1241 "./marpa.w" |
| 3266 |
|
| 3267 |
Marpa_Error_Code |
| 3268 |
marpa_g_error_clear(Marpa_Grammar g) |
| 3269 |
{ |
| 3270 |
clear_error(g); |
| 3271 |
return g->t_error; |
| 3272 |
} |
| 3273 |
|
| 3274 |
/*:140*//*146:*/ |
| 3275 |
#line 1271 "./marpa.w" |
| 3276 |
|
| 3277 |
PRIVATE XSY |
| 3278 |
symbol_new(GRAMMAR g) |
| 3279 |
{ |
| 3280 |
XSY xsy= marpa_obs_new(g->t_obs,struct s_xsy,1); |
| 3281 |
/*151:*/ |
| 3282 |
#line 1304 "./marpa.w" |
| 3283 |
|
| 3284 |
xsy->t_rank= Default_Rank_of_G(g); |
| 3285 |
/*:151*//*155:*/ |
| 3286 |
#line 1350 "./marpa.w" |
| 3287 |
|
| 3288 |
XSY_is_LHS(xsy)= 0; |
| 3289 |
|
| 3290 |
/*:155*//*157:*/ |
| 3291 |
#line 1357 "./marpa.w" |
| 3292 |
|
| 3293 |
XSY_is_Sequence_LHS(xsy)= 0; |
| 3294 |
|
| 3295 |
/*:157*//*159:*/ |
| 3296 |
#line 1373 "./marpa.w" |
| 3297 |
|
| 3298 |
XSY_is_Valued(xsy)= g->t_force_valued?1:0; |
| 3299 |
XSY_is_Valued_Locked(xsy)= g->t_force_valued?1:0; |
| 3300 |
|
| 3301 |
/*:159*//*167:*/ |
| 3302 |
#line 1441 "./marpa.w" |
| 3303 |
|
| 3304 |
xsy->t_is_accessible= 0; |
| 3305 |
/*:167*//*170:*/ |
| 3306 |
#line 1462 "./marpa.w" |
| 3307 |
|
| 3308 |
xsy->t_is_counted= 0; |
| 3309 |
/*:170*//*173:*/ |
| 3310 |
#line 1478 "./marpa.w" |
| 3311 |
|
| 3312 |
xsy->t_is_nulling= 0; |
| 3313 |
/*:173*//*176:*/ |
| 3314 |
#line 1495 "./marpa.w" |
| 3315 |
|
| 3316 |
xsy->t_is_nullable= 0; |
| 3317 |
/*:176*//*179:*/ |
| 3318 |
#line 1518 "./marpa.w" |
| 3319 |
|
| 3320 |
xsy->t_is_terminal= 0; |
| 3321 |
xsy->t_is_locked_terminal= 0; |
| 3322 |
/*:179*//*184:*/ |
| 3323 |
#line 1563 "./marpa.w" |
| 3324 |
|
| 3325 |
xsy->t_is_productive= 0; |
| 3326 |
/*:184*//*187:*/ |
| 3327 |
#line 1586 "./marpa.w" |
| 3328 |
|
| 3329 |
xsy->t_is_completion_event= 0; |
| 3330 |
xsy->t_completion_event_starts_active= 0; |
| 3331 |
/*:187*//*192:*/ |
| 3332 |
#line 1656 "./marpa.w" |
| 3333 |
|
| 3334 |
xsy->t_is_nulled_event= 0; |
| 3335 |
xsy->t_nulled_event_starts_active= 0; |
| 3336 |
/*:192*//*197:*/ |
| 3337 |
#line 1729 "./marpa.w" |
| 3338 |
|
| 3339 |
xsy->t_is_prediction_event= 0; |
| 3340 |
xsy->t_prediction_event_starts_active= 0; |
| 3341 |
/*:197*//*203:*/ |
| 3342 |
#line 1808 "./marpa.w" |
| 3343 |
|
| 3344 |
Nulled_XSYIDs_of_XSY(xsy)= NULL; |
| 3345 |
|
| 3346 |
/*:203*//*206:*/ |
| 3347 |
#line 1824 "./marpa.w" |
| 3348 |
NSY_of_XSY(xsy)= NULL; |
| 3349 |
/*:206*//*210:*/ |
| 3350 |
#line 1856 "./marpa.w" |
| 3351 |
Nulling_NSY_of_XSY(xsy)= NULL; |
| 3352 |
/*:210*/ |
| 3353 |
#line 1276 "./marpa.w" |
| 3354 |
|
| 3355 |
symbol_add(g,xsy); |
| 3356 |
return xsy; |
| 3357 |
} |
| 3358 |
|
| 3359 |
/*:146*//*147:*/ |
| 3360 |
#line 1281 "./marpa.w" |
| 3361 |
|
| 3362 |
Marpa_Symbol_ID |
| 3363 |
marpa_g_symbol_new(Marpa_Grammar g) |
| 3364 |
{ |
| 3365 |
const XSY symbol= symbol_new(g); |
| 3366 |
return ID_of_XSY(symbol); |
| 3367 |
} |
| 3368 |
|
| 3369 |
/*:147*//*149:*/ |
| 3370 |
#line 1290 "./marpa.w" |
| 3371 |
|
| 3372 |
int marpa_g_symbol_is_start(Marpa_Grammar g,Marpa_Symbol_ID xsy_id) |
| 3373 |
{ |
| 3374 |
/*1230:*/ |
| 3375 |
#line 14864 "./marpa.w" |
| 3376 |
const int failure_indicator= -2; |
| 3377 |
|
| 3378 |
/*:1230*/ |
| 3379 |
#line 1293 "./marpa.w" |
| 3380 |
|
| 3381 |
/*1250:*/ |
| 3382 |
#line 14997 "./marpa.w" |
| 3383 |
|
| 3384 |
if(HEADER_VERSION_MISMATCH){ |
| 3385 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3386 |
return failure_indicator; |
| 3387 |
} |
| 3388 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3389 |
MARPA_ERROR(g->t_error); |
| 3390 |
return failure_indicator; |
| 3391 |
} |
| 3392 |
|
| 3393 |
/*:1250*/ |
| 3394 |
#line 1294 "./marpa.w" |
| 3395 |
|
| 3396 |
/*1233:*/ |
| 3397 |
#line 14880 "./marpa.w" |
| 3398 |
|
| 3399 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 3400 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 3401 |
return failure_indicator; |
| 3402 |
} |
| 3403 |
/*:1233*/ |
| 3404 |
#line 1295 "./marpa.w" |
| 3405 |
|
| 3406 |
/*1234:*/ |
| 3407 |
#line 14887 "./marpa.w" |
| 3408 |
|
| 3409 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 3410 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 3411 |
return-1; |
| 3412 |
} |
| 3413 |
/*:1234*/ |
| 3414 |
#line 1296 "./marpa.w" |
| 3415 |
|
| 3416 |
if(g->t_start_xsy_id<0)return 0; |
| 3417 |
return xsy_id==g->t_start_xsy_id?1:0; |
| 3418 |
} |
| 3419 |
|
| 3420 |
/*:149*//*152:*/ |
| 3421 |
#line 1307 "./marpa.w" |
| 3422 |
|
| 3423 |
int marpa_g_symbol_rank(Marpa_Grammar g, |
| 3424 |
Marpa_Symbol_ID xsy_id) |
| 3425 |
{ |
| 3426 |
XSY xsy; |
| 3427 |
/*1230:*/ |
| 3428 |
#line 14864 "./marpa.w" |
| 3429 |
const int failure_indicator= -2; |
| 3430 |
|
| 3431 |
/*:1230*/ |
| 3432 |
#line 1312 "./marpa.w" |
| 3433 |
|
| 3434 |
clear_error(g); |
| 3435 |
/*1250:*/ |
| 3436 |
#line 14997 "./marpa.w" |
| 3437 |
|
| 3438 |
if(HEADER_VERSION_MISMATCH){ |
| 3439 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3440 |
return failure_indicator; |
| 3441 |
} |
| 3442 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3443 |
MARPA_ERROR(g->t_error); |
| 3444 |
return failure_indicator; |
| 3445 |
} |
| 3446 |
|
| 3447 |
/*:1250*/ |
| 3448 |
#line 1314 "./marpa.w" |
| 3449 |
|
| 3450 |
/*1233:*/ |
| 3451 |
#line 14880 "./marpa.w" |
| 3452 |
|
| 3453 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 3454 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 3455 |
return failure_indicator; |
| 3456 |
} |
| 3457 |
/*:1233*/ |
| 3458 |
#line 1315 "./marpa.w" |
| 3459 |
|
| 3460 |
/*1235:*/ |
| 3461 |
#line 14892 "./marpa.w" |
| 3462 |
|
| 3463 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 3464 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 3465 |
return failure_indicator; |
| 3466 |
} |
| 3467 |
|
| 3468 |
/*:1235*/ |
| 3469 |
#line 1316 "./marpa.w" |
| 3470 |
|
| 3471 |
xsy= XSY_by_ID(xsy_id); |
| 3472 |
return Rank_of_XSY(xsy); |
| 3473 |
} |
| 3474 |
/*:152*//*153:*/ |
| 3475 |
#line 1320 "./marpa.w" |
| 3476 |
|
| 3477 |
int marpa_g_symbol_rank_set( |
| 3478 |
Marpa_Grammar g,Marpa_Symbol_ID xsy_id,Marpa_Rank rank) |
| 3479 |
{ |
| 3480 |
XSY xsy; |
| 3481 |
/*1230:*/ |
| 3482 |
#line 14864 "./marpa.w" |
| 3483 |
const int failure_indicator= -2; |
| 3484 |
|
| 3485 |
/*:1230*/ |
| 3486 |
#line 1325 "./marpa.w" |
| 3487 |
|
| 3488 |
clear_error(g); |
| 3489 |
/*1250:*/ |
| 3490 |
#line 14997 "./marpa.w" |
| 3491 |
|
| 3492 |
if(HEADER_VERSION_MISMATCH){ |
| 3493 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3494 |
return failure_indicator; |
| 3495 |
} |
| 3496 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3497 |
MARPA_ERROR(g->t_error); |
| 3498 |
return failure_indicator; |
| 3499 |
} |
| 3500 |
|
| 3501 |
/*:1250*/ |
| 3502 |
#line 1327 "./marpa.w" |
| 3503 |
|
| 3504 |
/*1231:*/ |
| 3505 |
#line 14869 "./marpa.w" |
| 3506 |
|
| 3507 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 3508 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 3509 |
return failure_indicator; |
| 3510 |
} |
| 3511 |
|
| 3512 |
/*:1231*/ |
| 3513 |
#line 1328 "./marpa.w" |
| 3514 |
|
| 3515 |
/*1233:*/ |
| 3516 |
#line 14880 "./marpa.w" |
| 3517 |
|
| 3518 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 3519 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 3520 |
return failure_indicator; |
| 3521 |
} |
| 3522 |
/*:1233*/ |
| 3523 |
#line 1329 "./marpa.w" |
| 3524 |
|
| 3525 |
/*1235:*/ |
| 3526 |
#line 14892 "./marpa.w" |
| 3527 |
|
| 3528 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 3529 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 3530 |
return failure_indicator; |
| 3531 |
} |
| 3532 |
|
| 3533 |
/*:1235*/ |
| 3534 |
#line 1330 "./marpa.w" |
| 3535 |
|
| 3536 |
xsy= XSY_by_ID(xsy_id); |
| 3537 |
if(_MARPA_UNLIKELY(rank<MINIMUM_RANK)) |
| 3538 |
{ |
| 3539 |
MARPA_ERROR(MARPA_ERR_RANK_TOO_LOW); |
| 3540 |
return failure_indicator; |
| 3541 |
} |
| 3542 |
if(_MARPA_UNLIKELY(rank> MAXIMUM_RANK)) |
| 3543 |
{ |
| 3544 |
MARPA_ERROR(MARPA_ERR_RANK_TOO_HIGH); |
| 3545 |
return failure_indicator; |
| 3546 |
} |
| 3547 |
return Rank_of_XSY(xsy)= rank; |
| 3548 |
} |
| 3549 |
|
| 3550 |
/*:153*//*163:*/ |
| 3551 |
#line 1384 "./marpa.w" |
| 3552 |
|
| 3553 |
int marpa_g_force_valued(Marpa_Grammar g) |
| 3554 |
{ |
| 3555 |
XSYID xsyid; |
| 3556 |
/*1230:*/ |
| 3557 |
#line 14864 "./marpa.w" |
| 3558 |
const int failure_indicator= -2; |
| 3559 |
|
| 3560 |
/*:1230*/ |
| 3561 |
#line 1388 "./marpa.w" |
| 3562 |
|
| 3563 |
for(xsyid= 0;xsyid<XSY_Count_of_G(g);xsyid++){ |
| 3564 |
const XSY xsy= XSY_by_ID(xsyid); |
| 3565 |
if(!XSY_is_Valued(xsy)&&XSY_is_Valued_Locked(xsy)) |
| 3566 |
{ |
| 3567 |
MARPA_ERROR(MARPA_ERR_VALUED_IS_LOCKED); |
| 3568 |
return failure_indicator; |
| 3569 |
} |
| 3570 |
XSY_is_Valued(xsy)= 1; |
| 3571 |
XSY_is_Valued_Locked(xsy)= 1; |
| 3572 |
} |
| 3573 |
g->t_force_valued= 1; |
| 3574 |
return 0; |
| 3575 |
} |
| 3576 |
|
| 3577 |
/*:163*//*164:*/ |
| 3578 |
#line 1403 "./marpa.w" |
| 3579 |
|
| 3580 |
int marpa_g_symbol_is_valued( |
| 3581 |
Marpa_Grammar g, |
| 3582 |
Marpa_Symbol_ID xsy_id) |
| 3583 |
{ |
| 3584 |
/*1230:*/ |
| 3585 |
#line 14864 "./marpa.w" |
| 3586 |
const int failure_indicator= -2; |
| 3587 |
|
| 3588 |
/*:1230*/ |
| 3589 |
#line 1408 "./marpa.w" |
| 3590 |
|
| 3591 |
/*1233:*/ |
| 3592 |
#line 14880 "./marpa.w" |
| 3593 |
|
| 3594 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 3595 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 3596 |
return failure_indicator; |
| 3597 |
} |
| 3598 |
/*:1233*/ |
| 3599 |
#line 1409 "./marpa.w" |
| 3600 |
|
| 3601 |
/*1234:*/ |
| 3602 |
#line 14887 "./marpa.w" |
| 3603 |
|
| 3604 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 3605 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 3606 |
return-1; |
| 3607 |
} |
| 3608 |
/*:1234*/ |
| 3609 |
#line 1410 "./marpa.w" |
| 3610 |
|
| 3611 |
return XSY_is_Valued(XSY_by_ID(xsy_id)); |
| 3612 |
} |
| 3613 |
|
| 3614 |
/*:164*//*165:*/ |
| 3615 |
#line 1414 "./marpa.w" |
| 3616 |
|
| 3617 |
int marpa_g_symbol_is_valued_set( |
| 3618 |
Marpa_Grammar g,Marpa_Symbol_ID xsy_id,int value) |
| 3619 |
{ |
| 3620 |
XSY symbol; |
| 3621 |
/*1230:*/ |
| 3622 |
#line 14864 "./marpa.w" |
| 3623 |
const int failure_indicator= -2; |
| 3624 |
|
| 3625 |
/*:1230*/ |
| 3626 |
#line 1419 "./marpa.w" |
| 3627 |
|
| 3628 |
/*1233:*/ |
| 3629 |
#line 14880 "./marpa.w" |
| 3630 |
|
| 3631 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 3632 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 3633 |
return failure_indicator; |
| 3634 |
} |
| 3635 |
/*:1233*/ |
| 3636 |
#line 1420 "./marpa.w" |
| 3637 |
|
| 3638 |
/*1234:*/ |
| 3639 |
#line 14887 "./marpa.w" |
| 3640 |
|
| 3641 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 3642 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 3643 |
return-1; |
| 3644 |
} |
| 3645 |
/*:1234*/ |
| 3646 |
#line 1421 "./marpa.w" |
| 3647 |
|
| 3648 |
symbol= XSY_by_ID(xsy_id); |
| 3649 |
if(_MARPA_UNLIKELY(value<0||value> 1)) |
| 3650 |
{ |
| 3651 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 3652 |
return failure_indicator; |
| 3653 |
} |
| 3654 |
if(_MARPA_UNLIKELY(XSY_is_Valued_Locked(symbol) |
| 3655 |
&&value!=XSY_is_Valued(symbol))) |
| 3656 |
{ |
| 3657 |
MARPA_ERROR(MARPA_ERR_VALUED_IS_LOCKED); |
| 3658 |
return failure_indicator; |
| 3659 |
} |
| 3660 |
XSY_is_Valued(symbol)= Boolean(value); |
| 3661 |
return value; |
| 3662 |
} |
| 3663 |
|
| 3664 |
/*:165*//*168:*/ |
| 3665 |
#line 1449 "./marpa.w" |
| 3666 |
|
| 3667 |
int marpa_g_symbol_is_accessible(Marpa_Grammar g,Marpa_Symbol_ID xsy_id) |
| 3668 |
{ |
| 3669 |
/*1230:*/ |
| 3670 |
#line 14864 "./marpa.w" |
| 3671 |
const int failure_indicator= -2; |
| 3672 |
|
| 3673 |
/*:1230*/ |
| 3674 |
#line 1452 "./marpa.w" |
| 3675 |
|
| 3676 |
/*1250:*/ |
| 3677 |
#line 14997 "./marpa.w" |
| 3678 |
|
| 3679 |
if(HEADER_VERSION_MISMATCH){ |
| 3680 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3681 |
return failure_indicator; |
| 3682 |
} |
| 3683 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3684 |
MARPA_ERROR(g->t_error); |
| 3685 |
return failure_indicator; |
| 3686 |
} |
| 3687 |
|
| 3688 |
/*:1250*/ |
| 3689 |
#line 1453 "./marpa.w" |
| 3690 |
|
| 3691 |
/*1232:*/ |
| 3692 |
#line 14875 "./marpa.w" |
| 3693 |
|
| 3694 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 3695 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 3696 |
return failure_indicator; |
| 3697 |
} |
| 3698 |
/*:1232*/ |
| 3699 |
#line 1454 "./marpa.w" |
| 3700 |
|
| 3701 |
/*1233:*/ |
| 3702 |
#line 14880 "./marpa.w" |
| 3703 |
|
| 3704 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 3705 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 3706 |
return failure_indicator; |
| 3707 |
} |
| 3708 |
/*:1233*/ |
| 3709 |
#line 1455 "./marpa.w" |
| 3710 |
|
| 3711 |
/*1234:*/ |
| 3712 |
#line 14887 "./marpa.w" |
| 3713 |
|
| 3714 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 3715 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 3716 |
return-1; |
| 3717 |
} |
| 3718 |
/*:1234*/ |
| 3719 |
#line 1456 "./marpa.w" |
| 3720 |
|
| 3721 |
return XSY_is_Accessible(XSY_by_ID(xsy_id)); |
| 3722 |
} |
| 3723 |
|
| 3724 |
/*:168*//*171:*/ |
| 3725 |
#line 1464 "./marpa.w" |
| 3726 |
|
| 3727 |
int marpa_g_symbol_is_counted(Marpa_Grammar g, |
| 3728 |
Marpa_Symbol_ID xsy_id) |
| 3729 |
{ |
| 3730 |
/*1230:*/ |
| 3731 |
#line 14864 "./marpa.w" |
| 3732 |
const int failure_indicator= -2; |
| 3733 |
|
| 3734 |
/*:1230*/ |
| 3735 |
#line 1468 "./marpa.w" |
| 3736 |
|
| 3737 |
/*1250:*/ |
| 3738 |
#line 14997 "./marpa.w" |
| 3739 |
|
| 3740 |
if(HEADER_VERSION_MISMATCH){ |
| 3741 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3742 |
return failure_indicator; |
| 3743 |
} |
| 3744 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3745 |
MARPA_ERROR(g->t_error); |
| 3746 |
return failure_indicator; |
| 3747 |
} |
| 3748 |
|
| 3749 |
/*:1250*/ |
| 3750 |
#line 1469 "./marpa.w" |
| 3751 |
|
| 3752 |
/*1233:*/ |
| 3753 |
#line 14880 "./marpa.w" |
| 3754 |
|
| 3755 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 3756 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 3757 |
return failure_indicator; |
| 3758 |
} |
| 3759 |
/*:1233*/ |
| 3760 |
#line 1470 "./marpa.w" |
| 3761 |
|
| 3762 |
/*1234:*/ |
| 3763 |
#line 14887 "./marpa.w" |
| 3764 |
|
| 3765 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 3766 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 3767 |
return-1; |
| 3768 |
} |
| 3769 |
/*:1234*/ |
| 3770 |
#line 1471 "./marpa.w" |
| 3771 |
|
| 3772 |
return XSY_by_ID(xsy_id)->t_is_counted; |
| 3773 |
} |
| 3774 |
|
| 3775 |
/*:171*//*174:*/ |
| 3776 |
#line 1480 "./marpa.w" |
| 3777 |
|
| 3778 |
int marpa_g_symbol_is_nulling(Marpa_Grammar g,Marpa_Symbol_ID xsy_id) |
| 3779 |
{ |
| 3780 |
/*1230:*/ |
| 3781 |
#line 14864 "./marpa.w" |
| 3782 |
const int failure_indicator= -2; |
| 3783 |
|
| 3784 |
/*:1230*/ |
| 3785 |
#line 1483 "./marpa.w" |
| 3786 |
|
| 3787 |
/*1250:*/ |
| 3788 |
#line 14997 "./marpa.w" |
| 3789 |
|
| 3790 |
if(HEADER_VERSION_MISMATCH){ |
| 3791 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3792 |
return failure_indicator; |
| 3793 |
} |
| 3794 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3795 |
MARPA_ERROR(g->t_error); |
| 3796 |
return failure_indicator; |
| 3797 |
} |
| 3798 |
|
| 3799 |
/*:1250*/ |
| 3800 |
#line 1484 "./marpa.w" |
| 3801 |
|
| 3802 |
/*1232:*/ |
| 3803 |
#line 14875 "./marpa.w" |
| 3804 |
|
| 3805 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 3806 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 3807 |
return failure_indicator; |
| 3808 |
} |
| 3809 |
/*:1232*/ |
| 3810 |
#line 1485 "./marpa.w" |
| 3811 |
|
| 3812 |
/*1233:*/ |
| 3813 |
#line 14880 "./marpa.w" |
| 3814 |
|
| 3815 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 3816 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 3817 |
return failure_indicator; |
| 3818 |
} |
| 3819 |
/*:1233*/ |
| 3820 |
#line 1486 "./marpa.w" |
| 3821 |
|
| 3822 |
/*1234:*/ |
| 3823 |
#line 14887 "./marpa.w" |
| 3824 |
|
| 3825 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 3826 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 3827 |
return-1; |
| 3828 |
} |
| 3829 |
/*:1234*/ |
| 3830 |
#line 1487 "./marpa.w" |
| 3831 |
|
| 3832 |
return XSY_is_Nulling(XSY_by_ID(xsy_id)); |
| 3833 |
} |
| 3834 |
|
| 3835 |
/*:174*//*177:*/ |
| 3836 |
#line 1497 "./marpa.w" |
| 3837 |
|
| 3838 |
int marpa_g_symbol_is_nullable(Marpa_Grammar g,Marpa_Symbol_ID xsy_id) |
| 3839 |
{ |
| 3840 |
/*1230:*/ |
| 3841 |
#line 14864 "./marpa.w" |
| 3842 |
const int failure_indicator= -2; |
| 3843 |
|
| 3844 |
/*:1230*/ |
| 3845 |
#line 1500 "./marpa.w" |
| 3846 |
|
| 3847 |
/*1250:*/ |
| 3848 |
#line 14997 "./marpa.w" |
| 3849 |
|
| 3850 |
if(HEADER_VERSION_MISMATCH){ |
| 3851 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3852 |
return failure_indicator; |
| 3853 |
} |
| 3854 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3855 |
MARPA_ERROR(g->t_error); |
| 3856 |
return failure_indicator; |
| 3857 |
} |
| 3858 |
|
| 3859 |
/*:1250*/ |
| 3860 |
#line 1501 "./marpa.w" |
| 3861 |
|
| 3862 |
/*1232:*/ |
| 3863 |
#line 14875 "./marpa.w" |
| 3864 |
|
| 3865 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 3866 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 3867 |
return failure_indicator; |
| 3868 |
} |
| 3869 |
/*:1232*/ |
| 3870 |
#line 1502 "./marpa.w" |
| 3871 |
|
| 3872 |
/*1233:*/ |
| 3873 |
#line 14880 "./marpa.w" |
| 3874 |
|
| 3875 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 3876 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 3877 |
return failure_indicator; |
| 3878 |
} |
| 3879 |
/*:1233*/ |
| 3880 |
#line 1503 "./marpa.w" |
| 3881 |
|
| 3882 |
/*1234:*/ |
| 3883 |
#line 14887 "./marpa.w" |
| 3884 |
|
| 3885 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 3886 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 3887 |
return-1; |
| 3888 |
} |
| 3889 |
/*:1234*/ |
| 3890 |
#line 1504 "./marpa.w" |
| 3891 |
|
| 3892 |
return XSYID_is_Nullable(xsy_id); |
| 3893 |
} |
| 3894 |
|
| 3895 |
/*:177*//*181:*/ |
| 3896 |
#line 1524 "./marpa.w" |
| 3897 |
|
| 3898 |
int marpa_g_symbol_is_terminal(Marpa_Grammar g, |
| 3899 |
Marpa_Symbol_ID xsy_id) |
| 3900 |
{ |
| 3901 |
/*1230:*/ |
| 3902 |
#line 14864 "./marpa.w" |
| 3903 |
const int failure_indicator= -2; |
| 3904 |
|
| 3905 |
/*:1230*/ |
| 3906 |
#line 1528 "./marpa.w" |
| 3907 |
|
| 3908 |
/*1250:*/ |
| 3909 |
#line 14997 "./marpa.w" |
| 3910 |
|
| 3911 |
if(HEADER_VERSION_MISMATCH){ |
| 3912 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3913 |
return failure_indicator; |
| 3914 |
} |
| 3915 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3916 |
MARPA_ERROR(g->t_error); |
| 3917 |
return failure_indicator; |
| 3918 |
} |
| 3919 |
|
| 3920 |
/*:1250*/ |
| 3921 |
#line 1529 "./marpa.w" |
| 3922 |
|
| 3923 |
/*1233:*/ |
| 3924 |
#line 14880 "./marpa.w" |
| 3925 |
|
| 3926 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 3927 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 3928 |
return failure_indicator; |
| 3929 |
} |
| 3930 |
/*:1233*/ |
| 3931 |
#line 1530 "./marpa.w" |
| 3932 |
|
| 3933 |
/*1234:*/ |
| 3934 |
#line 14887 "./marpa.w" |
| 3935 |
|
| 3936 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 3937 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 3938 |
return-1; |
| 3939 |
} |
| 3940 |
/*:1234*/ |
| 3941 |
#line 1531 "./marpa.w" |
| 3942 |
|
| 3943 |
return XSYID_is_Terminal(xsy_id); |
| 3944 |
} |
| 3945 |
/*:181*//*182:*/ |
| 3946 |
#line 1534 "./marpa.w" |
| 3947 |
|
| 3948 |
int marpa_g_symbol_is_terminal_set( |
| 3949 |
Marpa_Grammar g,Marpa_Symbol_ID xsy_id,int value) |
| 3950 |
{ |
| 3951 |
XSY symbol; |
| 3952 |
/*1230:*/ |
| 3953 |
#line 14864 "./marpa.w" |
| 3954 |
const int failure_indicator= -2; |
| 3955 |
|
| 3956 |
/*:1230*/ |
| 3957 |
#line 1539 "./marpa.w" |
| 3958 |
|
| 3959 |
/*1250:*/ |
| 3960 |
#line 14997 "./marpa.w" |
| 3961 |
|
| 3962 |
if(HEADER_VERSION_MISMATCH){ |
| 3963 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 3964 |
return failure_indicator; |
| 3965 |
} |
| 3966 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 3967 |
MARPA_ERROR(g->t_error); |
| 3968 |
return failure_indicator; |
| 3969 |
} |
| 3970 |
|
| 3971 |
/*:1250*/ |
| 3972 |
#line 1540 "./marpa.w" |
| 3973 |
|
| 3974 |
/*1231:*/ |
| 3975 |
#line 14869 "./marpa.w" |
| 3976 |
|
| 3977 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 3978 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 3979 |
return failure_indicator; |
| 3980 |
} |
| 3981 |
|
| 3982 |
/*:1231*/ |
| 3983 |
#line 1541 "./marpa.w" |
| 3984 |
|
| 3985 |
/*1233:*/ |
| 3986 |
#line 14880 "./marpa.w" |
| 3987 |
|
| 3988 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 3989 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 3990 |
return failure_indicator; |
| 3991 |
} |
| 3992 |
/*:1233*/ |
| 3993 |
#line 1542 "./marpa.w" |
| 3994 |
|
| 3995 |
/*1234:*/ |
| 3996 |
#line 14887 "./marpa.w" |
| 3997 |
|
| 3998 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 3999 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4000 |
return-1; |
| 4001 |
} |
| 4002 |
/*:1234*/ |
| 4003 |
#line 1543 "./marpa.w" |
| 4004 |
|
| 4005 |
symbol= XSY_by_ID(xsy_id); |
| 4006 |
if(_MARPA_UNLIKELY(value<0||value> 1)) |
| 4007 |
{ |
| 4008 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 4009 |
return failure_indicator; |
| 4010 |
} |
| 4011 |
if(_MARPA_UNLIKELY(XSY_is_Locked_Terminal(symbol)) |
| 4012 |
&&XSY_is_Terminal(symbol)!=value) |
| 4013 |
{ |
| 4014 |
MARPA_ERROR(MARPA_ERR_TERMINAL_IS_LOCKED); |
| 4015 |
return failure_indicator; |
| 4016 |
} |
| 4017 |
XSY_is_Locked_Terminal(symbol)= 1; |
| 4018 |
return XSY_is_Terminal(symbol)= Boolean(value); |
| 4019 |
} |
| 4020 |
|
| 4021 |
/*:182*//*185:*/ |
| 4022 |
#line 1565 "./marpa.w" |
| 4023 |
|
| 4024 |
int marpa_g_symbol_is_productive( |
| 4025 |
Marpa_Grammar g, |
| 4026 |
Marpa_Symbol_ID xsy_id) |
| 4027 |
{ |
| 4028 |
/*1230:*/ |
| 4029 |
#line 14864 "./marpa.w" |
| 4030 |
const int failure_indicator= -2; |
| 4031 |
|
| 4032 |
/*:1230*/ |
| 4033 |
#line 1570 "./marpa.w" |
| 4034 |
|
| 4035 |
/*1250:*/ |
| 4036 |
#line 14997 "./marpa.w" |
| 4037 |
|
| 4038 |
if(HEADER_VERSION_MISMATCH){ |
| 4039 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4040 |
return failure_indicator; |
| 4041 |
} |
| 4042 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4043 |
MARPA_ERROR(g->t_error); |
| 4044 |
return failure_indicator; |
| 4045 |
} |
| 4046 |
|
| 4047 |
/*:1250*/ |
| 4048 |
#line 1571 "./marpa.w" |
| 4049 |
|
| 4050 |
/*1232:*/ |
| 4051 |
#line 14875 "./marpa.w" |
| 4052 |
|
| 4053 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 4054 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 4055 |
return failure_indicator; |
| 4056 |
} |
| 4057 |
/*:1232*/ |
| 4058 |
#line 1572 "./marpa.w" |
| 4059 |
|
| 4060 |
/*1233:*/ |
| 4061 |
#line 14880 "./marpa.w" |
| 4062 |
|
| 4063 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 4064 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 4065 |
return failure_indicator; |
| 4066 |
} |
| 4067 |
/*:1233*/ |
| 4068 |
#line 1573 "./marpa.w" |
| 4069 |
|
| 4070 |
/*1234:*/ |
| 4071 |
#line 14887 "./marpa.w" |
| 4072 |
|
| 4073 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 4074 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4075 |
return-1; |
| 4076 |
} |
| 4077 |
/*:1234*/ |
| 4078 |
#line 1574 "./marpa.w" |
| 4079 |
|
| 4080 |
return XSY_is_Productive(XSY_by_ID(xsy_id)); |
| 4081 |
} |
| 4082 |
|
| 4083 |
/*:185*//*188:*/ |
| 4084 |
#line 1589 "./marpa.w" |
| 4085 |
|
| 4086 |
int marpa_g_symbol_is_completion_event(Marpa_Grammar g, |
| 4087 |
Marpa_Symbol_ID xsy_id) |
| 4088 |
{ |
| 4089 |
/*1230:*/ |
| 4090 |
#line 14864 "./marpa.w" |
| 4091 |
const int failure_indicator= -2; |
| 4092 |
|
| 4093 |
/*:1230*/ |
| 4094 |
#line 1593 "./marpa.w" |
| 4095 |
|
| 4096 |
/*1250:*/ |
| 4097 |
#line 14997 "./marpa.w" |
| 4098 |
|
| 4099 |
if(HEADER_VERSION_MISMATCH){ |
| 4100 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4101 |
return failure_indicator; |
| 4102 |
} |
| 4103 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4104 |
MARPA_ERROR(g->t_error); |
| 4105 |
return failure_indicator; |
| 4106 |
} |
| 4107 |
|
| 4108 |
/*:1250*/ |
| 4109 |
#line 1594 "./marpa.w" |
| 4110 |
|
| 4111 |
/*1233:*/ |
| 4112 |
#line 14880 "./marpa.w" |
| 4113 |
|
| 4114 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 4115 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 4116 |
return failure_indicator; |
| 4117 |
} |
| 4118 |
/*:1233*/ |
| 4119 |
#line 1595 "./marpa.w" |
| 4120 |
|
| 4121 |
/*1234:*/ |
| 4122 |
#line 14887 "./marpa.w" |
| 4123 |
|
| 4124 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 4125 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4126 |
return-1; |
| 4127 |
} |
| 4128 |
/*:1234*/ |
| 4129 |
#line 1596 "./marpa.w" |
| 4130 |
|
| 4131 |
return XSYID_is_Completion_Event(xsy_id); |
| 4132 |
} |
| 4133 |
/*:188*//*189:*/ |
| 4134 |
#line 1599 "./marpa.w" |
| 4135 |
|
| 4136 |
int marpa_g_symbol_is_completion_event_set( |
| 4137 |
Marpa_Grammar g,Marpa_Symbol_ID xsy_id,int value) |
| 4138 |
{ |
| 4139 |
XSY xsy; |
| 4140 |
/*1230:*/ |
| 4141 |
#line 14864 "./marpa.w" |
| 4142 |
const int failure_indicator= -2; |
| 4143 |
|
| 4144 |
/*:1230*/ |
| 4145 |
#line 1604 "./marpa.w" |
| 4146 |
|
| 4147 |
/*1250:*/ |
| 4148 |
#line 14997 "./marpa.w" |
| 4149 |
|
| 4150 |
if(HEADER_VERSION_MISMATCH){ |
| 4151 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4152 |
return failure_indicator; |
| 4153 |
} |
| 4154 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4155 |
MARPA_ERROR(g->t_error); |
| 4156 |
return failure_indicator; |
| 4157 |
} |
| 4158 |
|
| 4159 |
/*:1250*/ |
| 4160 |
#line 1605 "./marpa.w" |
| 4161 |
|
| 4162 |
/*1231:*/ |
| 4163 |
#line 14869 "./marpa.w" |
| 4164 |
|
| 4165 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 4166 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 4167 |
return failure_indicator; |
| 4168 |
} |
| 4169 |
|
| 4170 |
/*:1231*/ |
| 4171 |
#line 1606 "./marpa.w" |
| 4172 |
|
| 4173 |
/*1233:*/ |
| 4174 |
#line 14880 "./marpa.w" |
| 4175 |
|
| 4176 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 4177 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 4178 |
return failure_indicator; |
| 4179 |
} |
| 4180 |
/*:1233*/ |
| 4181 |
#line 1607 "./marpa.w" |
| 4182 |
|
| 4183 |
/*1234:*/ |
| 4184 |
#line 14887 "./marpa.w" |
| 4185 |
|
| 4186 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 4187 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4188 |
return-1; |
| 4189 |
} |
| 4190 |
/*:1234*/ |
| 4191 |
#line 1608 "./marpa.w" |
| 4192 |
|
| 4193 |
xsy= XSY_by_ID(xsy_id); |
| 4194 |
switch(value){ |
| 4195 |
case 0:case 1: |
| 4196 |
XSY_Completion_Event_Starts_Active(xsy)= Boolean(value); |
| 4197 |
return XSY_is_Completion_Event(xsy)= Boolean(value); |
| 4198 |
} |
| 4199 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 4200 |
return failure_indicator; |
| 4201 |
} |
| 4202 |
/*:189*//*190:*/ |
| 4203 |
#line 1618 "./marpa.w" |
| 4204 |
|
| 4205 |
int |
| 4206 |
marpa_g_completion_symbol_activate(Marpa_Grammar g, |
| 4207 |
Marpa_Symbol_ID xsy_id, |
| 4208 |
int reactivate) |
| 4209 |
{ |
| 4210 |
/*1230:*/ |
| 4211 |
#line 14864 "./marpa.w" |
| 4212 |
const int failure_indicator= -2; |
| 4213 |
|
| 4214 |
/*:1230*/ |
| 4215 |
#line 1624 "./marpa.w" |
| 4216 |
|
| 4217 |
/*1250:*/ |
| 4218 |
#line 14997 "./marpa.w" |
| 4219 |
|
| 4220 |
if(HEADER_VERSION_MISMATCH){ |
| 4221 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4222 |
return failure_indicator; |
| 4223 |
} |
| 4224 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4225 |
MARPA_ERROR(g->t_error); |
| 4226 |
return failure_indicator; |
| 4227 |
} |
| 4228 |
|
| 4229 |
/*:1250*/ |
| 4230 |
#line 1625 "./marpa.w" |
| 4231 |
|
| 4232 |
/*1231:*/ |
| 4233 |
#line 14869 "./marpa.w" |
| 4234 |
|
| 4235 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 4236 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 4237 |
return failure_indicator; |
| 4238 |
} |
| 4239 |
|
| 4240 |
/*:1231*/ |
| 4241 |
#line 1626 "./marpa.w" |
| 4242 |
|
| 4243 |
/*1233:*/ |
| 4244 |
#line 14880 "./marpa.w" |
| 4245 |
|
| 4246 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 4247 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 4248 |
return failure_indicator; |
| 4249 |
} |
| 4250 |
/*:1233*/ |
| 4251 |
#line 1627 "./marpa.w" |
| 4252 |
|
| 4253 |
/*1234:*/ |
| 4254 |
#line 14887 "./marpa.w" |
| 4255 |
|
| 4256 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 4257 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4258 |
return-1; |
| 4259 |
} |
| 4260 |
/*:1234*/ |
| 4261 |
#line 1628 "./marpa.w" |
| 4262 |
|
| 4263 |
switch(reactivate){ |
| 4264 |
case 0: |
| 4265 |
XSYID_Completion_Event_Starts_Active(xsy_id) |
| 4266 |
= Boolean(reactivate); |
| 4267 |
return 0; |
| 4268 |
case 1: |
| 4269 |
if(!XSYID_is_Completion_Event(xsy_id)){ |
| 4270 |
|
| 4271 |
|
| 4272 |
MARPA_ERROR(MARPA_ERR_SYMBOL_IS_NOT_COMPLETION_EVENT); |
| 4273 |
} |
| 4274 |
XSYID_Completion_Event_Starts_Active(xsy_id) |
| 4275 |
= Boolean(reactivate); |
| 4276 |
return 1; |
| 4277 |
} |
| 4278 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 4279 |
return failure_indicator; |
| 4280 |
} |
| 4281 |
|
| 4282 |
/*:190*//*193:*/ |
| 4283 |
#line 1659 "./marpa.w" |
| 4284 |
|
| 4285 |
int marpa_g_symbol_is_nulled_event(Marpa_Grammar g, |
| 4286 |
Marpa_Symbol_ID xsy_id) |
| 4287 |
{ |
| 4288 |
/*1230:*/ |
| 4289 |
#line 14864 "./marpa.w" |
| 4290 |
const int failure_indicator= -2; |
| 4291 |
|
| 4292 |
/*:1230*/ |
| 4293 |
#line 1663 "./marpa.w" |
| 4294 |
|
| 4295 |
/*1250:*/ |
| 4296 |
#line 14997 "./marpa.w" |
| 4297 |
|
| 4298 |
if(HEADER_VERSION_MISMATCH){ |
| 4299 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4300 |
return failure_indicator; |
| 4301 |
} |
| 4302 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4303 |
MARPA_ERROR(g->t_error); |
| 4304 |
return failure_indicator; |
| 4305 |
} |
| 4306 |
|
| 4307 |
/*:1250*/ |
| 4308 |
#line 1664 "./marpa.w" |
| 4309 |
|
| 4310 |
/*1233:*/ |
| 4311 |
#line 14880 "./marpa.w" |
| 4312 |
|
| 4313 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 4314 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 4315 |
return failure_indicator; |
| 4316 |
} |
| 4317 |
/*:1233*/ |
| 4318 |
#line 1665 "./marpa.w" |
| 4319 |
|
| 4320 |
/*1234:*/ |
| 4321 |
#line 14887 "./marpa.w" |
| 4322 |
|
| 4323 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 4324 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4325 |
return-1; |
| 4326 |
} |
| 4327 |
/*:1234*/ |
| 4328 |
#line 1666 "./marpa.w" |
| 4329 |
|
| 4330 |
return XSYID_is_Nulled_Event(xsy_id); |
| 4331 |
} |
| 4332 |
|
| 4333 |
/*:193*//*194:*/ |
| 4334 |
#line 1672 "./marpa.w" |
| 4335 |
|
| 4336 |
int marpa_g_symbol_is_nulled_event_set( |
| 4337 |
Marpa_Grammar g,Marpa_Symbol_ID xsy_id,int value) |
| 4338 |
{ |
| 4339 |
XSY xsy; |
| 4340 |
/*1230:*/ |
| 4341 |
#line 14864 "./marpa.w" |
| 4342 |
const int failure_indicator= -2; |
| 4343 |
|
| 4344 |
/*:1230*/ |
| 4345 |
#line 1677 "./marpa.w" |
| 4346 |
|
| 4347 |
/*1250:*/ |
| 4348 |
#line 14997 "./marpa.w" |
| 4349 |
|
| 4350 |
if(HEADER_VERSION_MISMATCH){ |
| 4351 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4352 |
return failure_indicator; |
| 4353 |
} |
| 4354 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4355 |
MARPA_ERROR(g->t_error); |
| 4356 |
return failure_indicator; |
| 4357 |
} |
| 4358 |
|
| 4359 |
/*:1250*/ |
| 4360 |
#line 1678 "./marpa.w" |
| 4361 |
|
| 4362 |
/*1231:*/ |
| 4363 |
#line 14869 "./marpa.w" |
| 4364 |
|
| 4365 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 4366 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 4367 |
return failure_indicator; |
| 4368 |
} |
| 4369 |
|
| 4370 |
/*:1231*/ |
| 4371 |
#line 1679 "./marpa.w" |
| 4372 |
|
| 4373 |
/*1233:*/ |
| 4374 |
#line 14880 "./marpa.w" |
| 4375 |
|
| 4376 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 4377 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 4378 |
return failure_indicator; |
| 4379 |
} |
| 4380 |
/*:1233*/ |
| 4381 |
#line 1680 "./marpa.w" |
| 4382 |
|
| 4383 |
/*1234:*/ |
| 4384 |
#line 14887 "./marpa.w" |
| 4385 |
|
| 4386 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 4387 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4388 |
return-1; |
| 4389 |
} |
| 4390 |
/*:1234*/ |
| 4391 |
#line 1681 "./marpa.w" |
| 4392 |
|
| 4393 |
xsy= XSY_by_ID(xsy_id); |
| 4394 |
switch(value){ |
| 4395 |
case 0:case 1: |
| 4396 |
XSY_Nulled_Event_Starts_Active(xsy)= Boolean(value); |
| 4397 |
return XSY_is_Nulled_Event(xsy)= Boolean(value); |
| 4398 |
} |
| 4399 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 4400 |
return failure_indicator; |
| 4401 |
} |
| 4402 |
/*:194*//*195:*/ |
| 4403 |
#line 1691 "./marpa.w" |
| 4404 |
|
| 4405 |
int |
| 4406 |
marpa_g_nulled_symbol_activate(Marpa_Grammar g, |
| 4407 |
Marpa_Symbol_ID xsy_id, |
| 4408 |
int reactivate) |
| 4409 |
{ |
| 4410 |
/*1230:*/ |
| 4411 |
#line 14864 "./marpa.w" |
| 4412 |
const int failure_indicator= -2; |
| 4413 |
|
| 4414 |
/*:1230*/ |
| 4415 |
#line 1697 "./marpa.w" |
| 4416 |
|
| 4417 |
/*1250:*/ |
| 4418 |
#line 14997 "./marpa.w" |
| 4419 |
|
| 4420 |
if(HEADER_VERSION_MISMATCH){ |
| 4421 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4422 |
return failure_indicator; |
| 4423 |
} |
| 4424 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4425 |
MARPA_ERROR(g->t_error); |
| 4426 |
return failure_indicator; |
| 4427 |
} |
| 4428 |
|
| 4429 |
/*:1250*/ |
| 4430 |
#line 1698 "./marpa.w" |
| 4431 |
|
| 4432 |
/*1231:*/ |
| 4433 |
#line 14869 "./marpa.w" |
| 4434 |
|
| 4435 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 4436 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 4437 |
return failure_indicator; |
| 4438 |
} |
| 4439 |
|
| 4440 |
/*:1231*/ |
| 4441 |
#line 1699 "./marpa.w" |
| 4442 |
|
| 4443 |
/*1233:*/ |
| 4444 |
#line 14880 "./marpa.w" |
| 4445 |
|
| 4446 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 4447 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 4448 |
return failure_indicator; |
| 4449 |
} |
| 4450 |
/*:1233*/ |
| 4451 |
#line 1700 "./marpa.w" |
| 4452 |
|
| 4453 |
/*1234:*/ |
| 4454 |
#line 14887 "./marpa.w" |
| 4455 |
|
| 4456 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 4457 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4458 |
return-1; |
| 4459 |
} |
| 4460 |
/*:1234*/ |
| 4461 |
#line 1701 "./marpa.w" |
| 4462 |
|
| 4463 |
switch(reactivate){ |
| 4464 |
case 0: |
| 4465 |
XSYID_Nulled_Event_Starts_Active(xsy_id) |
| 4466 |
= Boolean(reactivate); |
| 4467 |
return 0; |
| 4468 |
case 1: |
| 4469 |
if(!XSYID_is_Nulled_Event(xsy_id)){ |
| 4470 |
|
| 4471 |
|
| 4472 |
MARPA_ERROR(MARPA_ERR_SYMBOL_IS_NOT_COMPLETION_EVENT); |
| 4473 |
} |
| 4474 |
XSYID_Nulled_Event_Starts_Active(xsy_id) |
| 4475 |
= Boolean(reactivate); |
| 4476 |
return 1; |
| 4477 |
} |
| 4478 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 4479 |
return failure_indicator; |
| 4480 |
} |
| 4481 |
|
| 4482 |
/*:195*//*198:*/ |
| 4483 |
#line 1732 "./marpa.w" |
| 4484 |
|
| 4485 |
int marpa_g_symbol_is_prediction_event(Marpa_Grammar g, |
| 4486 |
Marpa_Symbol_ID xsy_id) |
| 4487 |
{ |
| 4488 |
/*1230:*/ |
| 4489 |
#line 14864 "./marpa.w" |
| 4490 |
const int failure_indicator= -2; |
| 4491 |
|
| 4492 |
/*:1230*/ |
| 4493 |
#line 1736 "./marpa.w" |
| 4494 |
|
| 4495 |
/*1250:*/ |
| 4496 |
#line 14997 "./marpa.w" |
| 4497 |
|
| 4498 |
if(HEADER_VERSION_MISMATCH){ |
| 4499 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4500 |
return failure_indicator; |
| 4501 |
} |
| 4502 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4503 |
MARPA_ERROR(g->t_error); |
| 4504 |
return failure_indicator; |
| 4505 |
} |
| 4506 |
|
| 4507 |
/*:1250*/ |
| 4508 |
#line 1737 "./marpa.w" |
| 4509 |
|
| 4510 |
/*1233:*/ |
| 4511 |
#line 14880 "./marpa.w" |
| 4512 |
|
| 4513 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 4514 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 4515 |
return failure_indicator; |
| 4516 |
} |
| 4517 |
/*:1233*/ |
| 4518 |
#line 1738 "./marpa.w" |
| 4519 |
|
| 4520 |
/*1234:*/ |
| 4521 |
#line 14887 "./marpa.w" |
| 4522 |
|
| 4523 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 4524 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4525 |
return-1; |
| 4526 |
} |
| 4527 |
/*:1234*/ |
| 4528 |
#line 1739 "./marpa.w" |
| 4529 |
|
| 4530 |
return XSYID_is_Prediction_Event(xsy_id); |
| 4531 |
} |
| 4532 |
/*:198*//*199:*/ |
| 4533 |
#line 1742 "./marpa.w" |
| 4534 |
|
| 4535 |
int marpa_g_symbol_is_prediction_event_set( |
| 4536 |
Marpa_Grammar g,Marpa_Symbol_ID xsy_id,int value) |
| 4537 |
{ |
| 4538 |
XSY xsy; |
| 4539 |
/*1230:*/ |
| 4540 |
#line 14864 "./marpa.w" |
| 4541 |
const int failure_indicator= -2; |
| 4542 |
|
| 4543 |
/*:1230*/ |
| 4544 |
#line 1747 "./marpa.w" |
| 4545 |
|
| 4546 |
/*1250:*/ |
| 4547 |
#line 14997 "./marpa.w" |
| 4548 |
|
| 4549 |
if(HEADER_VERSION_MISMATCH){ |
| 4550 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4551 |
return failure_indicator; |
| 4552 |
} |
| 4553 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4554 |
MARPA_ERROR(g->t_error); |
| 4555 |
return failure_indicator; |
| 4556 |
} |
| 4557 |
|
| 4558 |
/*:1250*/ |
| 4559 |
#line 1748 "./marpa.w" |
| 4560 |
|
| 4561 |
/*1231:*/ |
| 4562 |
#line 14869 "./marpa.w" |
| 4563 |
|
| 4564 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 4565 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 4566 |
return failure_indicator; |
| 4567 |
} |
| 4568 |
|
| 4569 |
/*:1231*/ |
| 4570 |
#line 1749 "./marpa.w" |
| 4571 |
|
| 4572 |
/*1233:*/ |
| 4573 |
#line 14880 "./marpa.w" |
| 4574 |
|
| 4575 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 4576 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 4577 |
return failure_indicator; |
| 4578 |
} |
| 4579 |
/*:1233*/ |
| 4580 |
#line 1750 "./marpa.w" |
| 4581 |
|
| 4582 |
/*1234:*/ |
| 4583 |
#line 14887 "./marpa.w" |
| 4584 |
|
| 4585 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 4586 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4587 |
return-1; |
| 4588 |
} |
| 4589 |
/*:1234*/ |
| 4590 |
#line 1751 "./marpa.w" |
| 4591 |
|
| 4592 |
xsy= XSY_by_ID(xsy_id); |
| 4593 |
switch(value){ |
| 4594 |
case 0:case 1: |
| 4595 |
XSY_Prediction_Event_Starts_Active(xsy)= Boolean(value); |
| 4596 |
return XSY_is_Prediction_Event(xsy)= Boolean(value); |
| 4597 |
} |
| 4598 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 4599 |
return failure_indicator; |
| 4600 |
} |
| 4601 |
/*:199*//*200:*/ |
| 4602 |
#line 1761 "./marpa.w" |
| 4603 |
|
| 4604 |
int |
| 4605 |
marpa_g_prediction_symbol_activate(Marpa_Grammar g, |
| 4606 |
Marpa_Symbol_ID xsy_id, |
| 4607 |
int reactivate) |
| 4608 |
{ |
| 4609 |
/*1230:*/ |
| 4610 |
#line 14864 "./marpa.w" |
| 4611 |
const int failure_indicator= -2; |
| 4612 |
|
| 4613 |
/*:1230*/ |
| 4614 |
#line 1767 "./marpa.w" |
| 4615 |
|
| 4616 |
/*1250:*/ |
| 4617 |
#line 14997 "./marpa.w" |
| 4618 |
|
| 4619 |
if(HEADER_VERSION_MISMATCH){ |
| 4620 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4621 |
return failure_indicator; |
| 4622 |
} |
| 4623 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4624 |
MARPA_ERROR(g->t_error); |
| 4625 |
return failure_indicator; |
| 4626 |
} |
| 4627 |
|
| 4628 |
/*:1250*/ |
| 4629 |
#line 1768 "./marpa.w" |
| 4630 |
|
| 4631 |
/*1231:*/ |
| 4632 |
#line 14869 "./marpa.w" |
| 4633 |
|
| 4634 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 4635 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 4636 |
return failure_indicator; |
| 4637 |
} |
| 4638 |
|
| 4639 |
/*:1231*/ |
| 4640 |
#line 1769 "./marpa.w" |
| 4641 |
|
| 4642 |
/*1233:*/ |
| 4643 |
#line 14880 "./marpa.w" |
| 4644 |
|
| 4645 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 4646 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 4647 |
return failure_indicator; |
| 4648 |
} |
| 4649 |
/*:1233*/ |
| 4650 |
#line 1770 "./marpa.w" |
| 4651 |
|
| 4652 |
/*1234:*/ |
| 4653 |
#line 14887 "./marpa.w" |
| 4654 |
|
| 4655 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 4656 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4657 |
return-1; |
| 4658 |
} |
| 4659 |
/*:1234*/ |
| 4660 |
#line 1771 "./marpa.w" |
| 4661 |
|
| 4662 |
switch(reactivate){ |
| 4663 |
case 0: |
| 4664 |
XSYID_Prediction_Event_Starts_Active(xsy_id) |
| 4665 |
= Boolean(reactivate); |
| 4666 |
return 0; |
| 4667 |
case 1: |
| 4668 |
if(!XSYID_is_Prediction_Event(xsy_id)){ |
| 4669 |
|
| 4670 |
|
| 4671 |
MARPA_ERROR(MARPA_ERR_SYMBOL_IS_NOT_COMPLETION_EVENT); |
| 4672 |
} |
| 4673 |
XSYID_Prediction_Event_Starts_Active(xsy_id) |
| 4674 |
= Boolean(reactivate); |
| 4675 |
return 1; |
| 4676 |
} |
| 4677 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 4678 |
return failure_indicator; |
| 4679 |
} |
| 4680 |
|
| 4681 |
/*:200*//*201:*/ |
| 4682 |
#line 1791 "./marpa.w" |
| 4683 |
|
| 4684 |
/*:201*//*207:*/ |
| 4685 |
#line 1825 "./marpa.w" |
| 4686 |
|
| 4687 |
Marpa_NSY_ID _marpa_g_xsy_nsy( |
| 4688 |
Marpa_Grammar g, |
| 4689 |
Marpa_Symbol_ID xsy_id) |
| 4690 |
{ |
| 4691 |
XSY xsy; |
| 4692 |
NSY nsy; |
| 4693 |
/*1230:*/ |
| 4694 |
#line 14864 "./marpa.w" |
| 4695 |
const int failure_indicator= -2; |
| 4696 |
|
| 4697 |
/*:1230*/ |
| 4698 |
#line 1832 "./marpa.w" |
| 4699 |
|
| 4700 |
/*1233:*/ |
| 4701 |
#line 14880 "./marpa.w" |
| 4702 |
|
| 4703 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 4704 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 4705 |
return failure_indicator; |
| 4706 |
} |
| 4707 |
/*:1233*/ |
| 4708 |
#line 1833 "./marpa.w" |
| 4709 |
|
| 4710 |
/*1234:*/ |
| 4711 |
#line 14887 "./marpa.w" |
| 4712 |
|
| 4713 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 4714 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4715 |
return-1; |
| 4716 |
} |
| 4717 |
/*:1234*/ |
| 4718 |
#line 1834 "./marpa.w" |
| 4719 |
|
| 4720 |
xsy= XSY_by_ID(xsy_id); |
| 4721 |
nsy= NSY_of_XSY(xsy); |
| 4722 |
return nsy?ID_of_NSY(nsy):-1; |
| 4723 |
} |
| 4724 |
|
| 4725 |
/*:207*//*211:*/ |
| 4726 |
#line 1857 "./marpa.w" |
| 4727 |
|
| 4728 |
Marpa_NSY_ID _marpa_g_xsy_nulling_nsy( |
| 4729 |
Marpa_Grammar g, |
| 4730 |
Marpa_Symbol_ID xsy_id) |
| 4731 |
{ |
| 4732 |
XSY xsy; |
| 4733 |
NSY nsy; |
| 4734 |
/*1230:*/ |
| 4735 |
#line 14864 "./marpa.w" |
| 4736 |
const int failure_indicator= -2; |
| 4737 |
|
| 4738 |
/*:1230*/ |
| 4739 |
#line 1864 "./marpa.w" |
| 4740 |
|
| 4741 |
/*1233:*/ |
| 4742 |
#line 14880 "./marpa.w" |
| 4743 |
|
| 4744 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 4745 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 4746 |
return failure_indicator; |
| 4747 |
} |
| 4748 |
/*:1233*/ |
| 4749 |
#line 1865 "./marpa.w" |
| 4750 |
|
| 4751 |
/*1234:*/ |
| 4752 |
#line 14887 "./marpa.w" |
| 4753 |
|
| 4754 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 4755 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 4756 |
return-1; |
| 4757 |
} |
| 4758 |
/*:1234*/ |
| 4759 |
#line 1866 "./marpa.w" |
| 4760 |
|
| 4761 |
xsy= XSY_by_ID(xsy_id); |
| 4762 |
nsy= Nulling_NSY_of_XSY(xsy); |
| 4763 |
return nsy?ID_of_NSY(nsy):-1; |
| 4764 |
} |
| 4765 |
|
| 4766 |
/*:211*//*213:*/ |
| 4767 |
#line 1878 "./marpa.w" |
| 4768 |
|
| 4769 |
PRIVATE |
| 4770 |
NSY symbol_alias_create(GRAMMAR g,XSY symbol) |
| 4771 |
{ |
| 4772 |
NSY alias_nsy= semantic_nsy_new(g,symbol); |
| 4773 |
XSY_is_Nulling(symbol)= 0; |
| 4774 |
XSY_is_Nullable(symbol)= 1; |
| 4775 |
NSY_is_Nulling(alias_nsy)= 1; |
| 4776 |
return alias_nsy; |
| 4777 |
} |
| 4778 |
|
| 4779 |
/*:213*//*220:*/ |
| 4780 |
#line 1936 "./marpa.w" |
| 4781 |
|
| 4782 |
PRIVATE NSY |
| 4783 |
nsy_start(GRAMMAR g) |
| 4784 |
{ |
| 4785 |
const NSY nsy= marpa_obs_new(g->t_obs,struct s_nsy,1); |
| 4786 |
ID_of_NSY(nsy)= MARPA_DSTACK_LENGTH((g)->t_nsy_stack); |
| 4787 |
*MARPA_DSTACK_PUSH((g)->t_nsy_stack,NSY)= nsy; |
| 4788 |
/*218:*/ |
| 4789 |
#line 1928 "./marpa.w" |
| 4790 |
|
| 4791 |
nsy->t_nulling_or_node.t_or_node_type= NULLING_TOKEN_OR_NODE; |
| 4792 |
|
| 4793 |
nsy->t_unvalued_or_node.t_or_node_type= UNVALUED_TOKEN_OR_NODE; |
| 4794 |
nsy->t_unvalued_or_node.t_nsyid= ID_of_NSY(nsy); |
| 4795 |
|
| 4796 |
/*:218*//*228:*/ |
| 4797 |
#line 2004 "./marpa.w" |
| 4798 |
NSY_is_Start(nsy)= 0; |
| 4799 |
/*:228*//*231:*/ |
| 4800 |
#line 2018 "./marpa.w" |
| 4801 |
NSY_is_LHS(nsy)= 0; |
| 4802 |
/*:231*//*234:*/ |
| 4803 |
#line 2032 "./marpa.w" |
| 4804 |
NSY_is_Nulling(nsy)= 0; |
| 4805 |
/*:234*//*237:*/ |
| 4806 |
#line 2049 "./marpa.w" |
| 4807 |
LHS_CIL_of_NSY(nsy)= NULL; |
| 4808 |
|
| 4809 |
/*:237*//*239:*/ |
| 4810 |
#line 2057 "./marpa.w" |
| 4811 |
NSY_is_Semantic(nsy)= 0; |
| 4812 |
/*:239*//*242:*/ |
| 4813 |
#line 2080 "./marpa.w" |
| 4814 |
Source_XSY_of_NSY(nsy)= NULL; |
| 4815 |
/*:242*//*246:*/ |
| 4816 |
#line 2105 "./marpa.w" |
| 4817 |
|
| 4818 |
LHS_XRL_of_NSY(nsy)= NULL; |
| 4819 |
XRL_Offset_of_NSY(nsy)= -1; |
| 4820 |
|
| 4821 |
/*:246*//*251:*/ |
| 4822 |
#line 2156 "./marpa.w" |
| 4823 |
|
| 4824 |
Rank_of_NSY(nsy)= Default_Rank_of_G(g)*EXTERNAL_RANK_FACTOR+MAXIMUM_CHAF_RANK; |
| 4825 |
/*:251*/ |
| 4826 |
#line 1943 "./marpa.w" |
| 4827 |
|
| 4828 |
return nsy; |
| 4829 |
} |
| 4830 |
|
| 4831 |
/*:220*//*221:*/ |
| 4832 |
#line 1949 "./marpa.w" |
| 4833 |
|
| 4834 |
PRIVATE NSY |
| 4835 |
nsy_new(GRAMMAR g,XSY source) |
| 4836 |
{ |
| 4837 |
const NSY new_nsy= nsy_start(g); |
| 4838 |
Source_XSY_of_NSY(new_nsy)= source; |
| 4839 |
Rank_of_NSY(new_nsy)= NSY_Rank_by_XSY(source); |
| 4840 |
return new_nsy; |
| 4841 |
} |
| 4842 |
|
| 4843 |
/*:221*//*222:*/ |
| 4844 |
#line 1961 "./marpa.w" |
| 4845 |
|
| 4846 |
PRIVATE NSY |
| 4847 |
semantic_nsy_new(GRAMMAR g,XSY source) |
| 4848 |
{ |
| 4849 |
const NSY new_nsy= nsy_new(g,source); |
| 4850 |
NSY_is_Semantic(new_nsy)= 1; |
| 4851 |
return new_nsy; |
| 4852 |
} |
| 4853 |
|
| 4854 |
/*:222*//*223:*/ |
| 4855 |
#line 1972 "./marpa.w" |
| 4856 |
|
| 4857 |
PRIVATE NSY |
| 4858 |
nsy_clone(GRAMMAR g,XSY xsy) |
| 4859 |
{ |
| 4860 |
const NSY new_nsy= nsy_start(g); |
| 4861 |
Source_XSY_of_NSY(new_nsy)= xsy; |
| 4862 |
NSY_is_Semantic(new_nsy)= 1; |
| 4863 |
Rank_of_NSY(new_nsy)= NSY_Rank_by_XSY(xsy); |
| 4864 |
NSY_is_Nulling(new_nsy)= XSY_is_Nulling(xsy); |
| 4865 |
return new_nsy; |
| 4866 |
} |
| 4867 |
|
| 4868 |
/*:223*//*226:*/ |
| 4869 |
#line 1994 "./marpa.w" |
| 4870 |
|
| 4871 |
int _marpa_g_nsy_count(Marpa_Grammar g){ |
| 4872 |
/*1230:*/ |
| 4873 |
#line 14864 "./marpa.w" |
| 4874 |
const int failure_indicator= -2; |
| 4875 |
|
| 4876 |
/*:1230*/ |
| 4877 |
#line 1996 "./marpa.w" |
| 4878 |
|
| 4879 |
/*1250:*/ |
| 4880 |
#line 14997 "./marpa.w" |
| 4881 |
|
| 4882 |
if(HEADER_VERSION_MISMATCH){ |
| 4883 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4884 |
return failure_indicator; |
| 4885 |
} |
| 4886 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4887 |
MARPA_ERROR(g->t_error); |
| 4888 |
return failure_indicator; |
| 4889 |
} |
| 4890 |
|
| 4891 |
/*:1250*/ |
| 4892 |
#line 1997 "./marpa.w" |
| 4893 |
|
| 4894 |
return NSY_Count_of_G(g); |
| 4895 |
} |
| 4896 |
|
| 4897 |
/*:226*//*229:*/ |
| 4898 |
#line 2005 "./marpa.w" |
| 4899 |
|
| 4900 |
int _marpa_g_nsy_is_start(Marpa_Grammar g,Marpa_NSY_ID nsy_id) |
| 4901 |
{ |
| 4902 |
/*1230:*/ |
| 4903 |
#line 14864 "./marpa.w" |
| 4904 |
const int failure_indicator= -2; |
| 4905 |
|
| 4906 |
/*:1230*/ |
| 4907 |
#line 2008 "./marpa.w" |
| 4908 |
|
| 4909 |
/*1250:*/ |
| 4910 |
#line 14997 "./marpa.w" |
| 4911 |
|
| 4912 |
if(HEADER_VERSION_MISMATCH){ |
| 4913 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4914 |
return failure_indicator; |
| 4915 |
} |
| 4916 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4917 |
MARPA_ERROR(g->t_error); |
| 4918 |
return failure_indicator; |
| 4919 |
} |
| 4920 |
|
| 4921 |
/*:1250*/ |
| 4922 |
#line 2009 "./marpa.w" |
| 4923 |
|
| 4924 |
/*1232:*/ |
| 4925 |
#line 14875 "./marpa.w" |
| 4926 |
|
| 4927 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 4928 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 4929 |
return failure_indicator; |
| 4930 |
} |
| 4931 |
/*:1232*/ |
| 4932 |
#line 2010 "./marpa.w" |
| 4933 |
|
| 4934 |
/*1236:*/ |
| 4935 |
#line 14898 "./marpa.w" |
| 4936 |
|
| 4937 |
if(_MARPA_UNLIKELY(!nsy_is_valid(g,nsy_id))){ |
| 4938 |
MARPA_ERROR(MARPA_ERR_INVALID_NSYID); |
| 4939 |
return failure_indicator; |
| 4940 |
} |
| 4941 |
/*:1236*/ |
| 4942 |
#line 2011 "./marpa.w" |
| 4943 |
|
| 4944 |
return NSY_is_Start(NSY_by_ID(nsy_id)); |
| 4945 |
} |
| 4946 |
|
| 4947 |
/*:229*//*232:*/ |
| 4948 |
#line 2019 "./marpa.w" |
| 4949 |
|
| 4950 |
int _marpa_g_nsy_is_lhs(Marpa_Grammar g,Marpa_NSY_ID nsy_id) |
| 4951 |
{ |
| 4952 |
/*1230:*/ |
| 4953 |
#line 14864 "./marpa.w" |
| 4954 |
const int failure_indicator= -2; |
| 4955 |
|
| 4956 |
/*:1230*/ |
| 4957 |
#line 2022 "./marpa.w" |
| 4958 |
|
| 4959 |
/*1250:*/ |
| 4960 |
#line 14997 "./marpa.w" |
| 4961 |
|
| 4962 |
if(HEADER_VERSION_MISMATCH){ |
| 4963 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 4964 |
return failure_indicator; |
| 4965 |
} |
| 4966 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 4967 |
MARPA_ERROR(g->t_error); |
| 4968 |
return failure_indicator; |
| 4969 |
} |
| 4970 |
|
| 4971 |
/*:1250*/ |
| 4972 |
#line 2023 "./marpa.w" |
| 4973 |
|
| 4974 |
/*1232:*/ |
| 4975 |
#line 14875 "./marpa.w" |
| 4976 |
|
| 4977 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 4978 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 4979 |
return failure_indicator; |
| 4980 |
} |
| 4981 |
/*:1232*/ |
| 4982 |
#line 2024 "./marpa.w" |
| 4983 |
|
| 4984 |
/*1236:*/ |
| 4985 |
#line 14898 "./marpa.w" |
| 4986 |
|
| 4987 |
if(_MARPA_UNLIKELY(!nsy_is_valid(g,nsy_id))){ |
| 4988 |
MARPA_ERROR(MARPA_ERR_INVALID_NSYID); |
| 4989 |
return failure_indicator; |
| 4990 |
} |
| 4991 |
/*:1236*/ |
| 4992 |
#line 2025 "./marpa.w" |
| 4993 |
|
| 4994 |
return NSY_is_LHS(NSY_by_ID(nsy_id)); |
| 4995 |
} |
| 4996 |
|
| 4997 |
/*:232*//*235:*/ |
| 4998 |
#line 2033 "./marpa.w" |
| 4999 |
|
| 5000 |
int _marpa_g_nsy_is_nulling(Marpa_Grammar g,Marpa_NSY_ID nsy_id) |
| 5001 |
{ |
| 5002 |
/*1230:*/ |
| 5003 |
#line 14864 "./marpa.w" |
| 5004 |
const int failure_indicator= -2; |
| 5005 |
|
| 5006 |
/*:1230*/ |
| 5007 |
#line 2036 "./marpa.w" |
| 5008 |
|
| 5009 |
/*1250:*/ |
| 5010 |
#line 14997 "./marpa.w" |
| 5011 |
|
| 5012 |
if(HEADER_VERSION_MISMATCH){ |
| 5013 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 5014 |
return failure_indicator; |
| 5015 |
} |
| 5016 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 5017 |
MARPA_ERROR(g->t_error); |
| 5018 |
return failure_indicator; |
| 5019 |
} |
| 5020 |
|
| 5021 |
/*:1250*/ |
| 5022 |
#line 2037 "./marpa.w" |
| 5023 |
|
| 5024 |
/*1232:*/ |
| 5025 |
#line 14875 "./marpa.w" |
| 5026 |
|
| 5027 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 5028 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 5029 |
return failure_indicator; |
| 5030 |
} |
| 5031 |
/*:1232*/ |
| 5032 |
#line 2038 "./marpa.w" |
| 5033 |
|
| 5034 |
/*1236:*/ |
| 5035 |
#line 14898 "./marpa.w" |
| 5036 |
|
| 5037 |
if(_MARPA_UNLIKELY(!nsy_is_valid(g,nsy_id))){ |
| 5038 |
MARPA_ERROR(MARPA_ERR_INVALID_NSYID); |
| 5039 |
return failure_indicator; |
| 5040 |
} |
| 5041 |
/*:1236*/ |
| 5042 |
#line 2039 "./marpa.w" |
| 5043 |
|
| 5044 |
return NSY_is_Nulling(NSY_by_ID(nsy_id)); |
| 5045 |
} |
| 5046 |
|
| 5047 |
/*:235*//*240:*/ |
| 5048 |
#line 2058 "./marpa.w" |
| 5049 |
|
| 5050 |
int _marpa_g_nsy_is_semantic( |
| 5051 |
Marpa_Grammar g, |
| 5052 |
Marpa_IRL_ID nsy_id) |
| 5053 |
{ |
| 5054 |
/*1230:*/ |
| 5055 |
#line 14864 "./marpa.w" |
| 5056 |
const int failure_indicator= -2; |
| 5057 |
|
| 5058 |
/*:1230*/ |
| 5059 |
#line 2063 "./marpa.w" |
| 5060 |
|
| 5061 |
/*1236:*/ |
| 5062 |
#line 14898 "./marpa.w" |
| 5063 |
|
| 5064 |
if(_MARPA_UNLIKELY(!nsy_is_valid(g,nsy_id))){ |
| 5065 |
MARPA_ERROR(MARPA_ERR_INVALID_NSYID); |
| 5066 |
return failure_indicator; |
| 5067 |
} |
| 5068 |
/*:1236*/ |
| 5069 |
#line 2064 "./marpa.w" |
| 5070 |
|
| 5071 |
return NSYID_is_Semantic(nsy_id); |
| 5072 |
} |
| 5073 |
|
| 5074 |
/*:240*//*243:*/ |
| 5075 |
#line 2081 "./marpa.w" |
| 5076 |
|
| 5077 |
Marpa_Rule_ID _marpa_g_source_xsy( |
| 5078 |
Marpa_Grammar g, |
| 5079 |
Marpa_IRL_ID nsy_id) |
| 5080 |
{ |
| 5081 |
XSY source_xsy; |
| 5082 |
/*1230:*/ |
| 5083 |
#line 14864 "./marpa.w" |
| 5084 |
const int failure_indicator= -2; |
| 5085 |
|
| 5086 |
/*:1230*/ |
| 5087 |
#line 2087 "./marpa.w" |
| 5088 |
|
| 5089 |
/*1236:*/ |
| 5090 |
#line 14898 "./marpa.w" |
| 5091 |
|
| 5092 |
if(_MARPA_UNLIKELY(!nsy_is_valid(g,nsy_id))){ |
| 5093 |
MARPA_ERROR(MARPA_ERR_INVALID_NSYID); |
| 5094 |
return failure_indicator; |
| 5095 |
} |
| 5096 |
/*:1236*/ |
| 5097 |
#line 2088 "./marpa.w" |
| 5098 |
|
| 5099 |
source_xsy= Source_XSY_of_NSYID(nsy_id); |
| 5100 |
return ID_of_XSY(source_xsy); |
| 5101 |
} |
| 5102 |
|
| 5103 |
/*:243*//*248:*/ |
| 5104 |
#line 2116 "./marpa.w" |
| 5105 |
|
| 5106 |
Marpa_Rule_ID _marpa_g_nsy_lhs_xrl(Marpa_Grammar g,Marpa_NSY_ID nsy_id) |
| 5107 |
{ |
| 5108 |
/*1230:*/ |
| 5109 |
#line 14864 "./marpa.w" |
| 5110 |
const int failure_indicator= -2; |
| 5111 |
|
| 5112 |
/*:1230*/ |
| 5113 |
#line 2119 "./marpa.w" |
| 5114 |
|
| 5115 |
/*1236:*/ |
| 5116 |
#line 14898 "./marpa.w" |
| 5117 |
|
| 5118 |
if(_MARPA_UNLIKELY(!nsy_is_valid(g,nsy_id))){ |
| 5119 |
MARPA_ERROR(MARPA_ERR_INVALID_NSYID); |
| 5120 |
return failure_indicator; |
| 5121 |
} |
| 5122 |
/*:1236*/ |
| 5123 |
#line 2120 "./marpa.w" |
| 5124 |
|
| 5125 |
{ |
| 5126 |
const NSY nsy= NSY_by_ID(nsy_id); |
| 5127 |
const XRL lhs_xrl= LHS_XRL_of_NSY(nsy); |
| 5128 |
if(lhs_xrl) |
| 5129 |
return ID_of_XRL(lhs_xrl); |
| 5130 |
} |
| 5131 |
return-1; |
| 5132 |
} |
| 5133 |
|
| 5134 |
/*:248*//*249:*/ |
| 5135 |
#line 2140 "./marpa.w" |
| 5136 |
|
| 5137 |
int _marpa_g_nsy_xrl_offset(Marpa_Grammar g,Marpa_NSY_ID nsy_id) |
| 5138 |
{ |
| 5139 |
/*1230:*/ |
| 5140 |
#line 14864 "./marpa.w" |
| 5141 |
const int failure_indicator= -2; |
| 5142 |
|
| 5143 |
/*:1230*/ |
| 5144 |
#line 2143 "./marpa.w" |
| 5145 |
|
| 5146 |
NSY nsy; |
| 5147 |
/*1236:*/ |
| 5148 |
#line 14898 "./marpa.w" |
| 5149 |
|
| 5150 |
if(_MARPA_UNLIKELY(!nsy_is_valid(g,nsy_id))){ |
| 5151 |
MARPA_ERROR(MARPA_ERR_INVALID_NSYID); |
| 5152 |
return failure_indicator; |
| 5153 |
} |
| 5154 |
/*:1236*/ |
| 5155 |
#line 2145 "./marpa.w" |
| 5156 |
|
| 5157 |
nsy= NSY_by_ID(nsy_id); |
| 5158 |
return XRL_Offset_of_NSY(nsy); |
| 5159 |
} |
| 5160 |
|
| 5161 |
/*:249*//*252:*/ |
| 5162 |
#line 2158 "./marpa.w" |
| 5163 |
|
| 5164 |
Marpa_Rank _marpa_g_nsy_rank( |
| 5165 |
Marpa_Grammar g, |
| 5166 |
Marpa_NSY_ID nsy_id) |
| 5167 |
{ |
| 5168 |
/*1230:*/ |
| 5169 |
#line 14864 "./marpa.w" |
| 5170 |
const int failure_indicator= -2; |
| 5171 |
|
| 5172 |
/*:1230*/ |
| 5173 |
#line 2163 "./marpa.w" |
| 5174 |
|
| 5175 |
/*1236:*/ |
| 5176 |
#line 14898 "./marpa.w" |
| 5177 |
|
| 5178 |
if(_MARPA_UNLIKELY(!nsy_is_valid(g,nsy_id))){ |
| 5179 |
MARPA_ERROR(MARPA_ERR_INVALID_NSYID); |
| 5180 |
return failure_indicator; |
| 5181 |
} |
| 5182 |
/*:1236*/ |
| 5183 |
#line 2164 "./marpa.w" |
| 5184 |
|
| 5185 |
return Rank_of_NSY(NSY_by_ID(nsy_id)); |
| 5186 |
} |
| 5187 |
|
| 5188 |
/*:252*//*258:*/ |
| 5189 |
#line 2199 "./marpa.w" |
| 5190 |
|
| 5191 |
PRIVATE |
| 5192 |
XRL xrl_start(GRAMMAR g,const XSYID lhs,const XSYID*rhs,int length) |
| 5193 |
{ |
| 5194 |
XRL xrl; |
| 5195 |
const size_t sizeof_xrl= offsetof(struct s_xrl,t_symbols)+ |
| 5196 |
((size_t)length+1)*sizeof(xrl->t_symbols[0]); |
| 5197 |
xrl= marpa_obs_start(g->t_xrl_obs,sizeof_xrl,ALIGNOF(XRL)); |
| 5198 |
Length_of_XRL(xrl)= length; |
| 5199 |
xrl->t_symbols[0]= lhs; |
| 5200 |
XSY_is_LHS(XSY_by_ID(lhs))= 1; |
| 5201 |
{ |
| 5202 |
int i; |
| 5203 |
for(i= 0;i<length;i++) |
| 5204 |
{ |
| 5205 |
xrl->t_symbols[i+1]= rhs[i]; |
| 5206 |
} |
| 5207 |
} |
| 5208 |
return xrl; |
| 5209 |
} |
| 5210 |
|
| 5211 |
PRIVATE |
| 5212 |
XRL xrl_finish(GRAMMAR g,XRL rule) |
| 5213 |
{ |
| 5214 |
/*277:*/ |
| 5215 |
#line 2545 "./marpa.w" |
| 5216 |
|
| 5217 |
rule->t_rank= Default_Rank_of_G(g); |
| 5218 |
/*:277*//*281:*/ |
| 5219 |
#line 2594 "./marpa.w" |
| 5220 |
|
| 5221 |
rule->t_null_ranks_high= 0; |
| 5222 |
/*:281*//*285:*/ |
| 5223 |
#line 2634 "./marpa.w" |
| 5224 |
|
| 5225 |
rule->t_is_bnf= 0; |
| 5226 |
|
| 5227 |
/*:285*//*287:*/ |
| 5228 |
#line 2640 "./marpa.w" |
| 5229 |
|
| 5230 |
rule->t_is_sequence= 0; |
| 5231 |
|
| 5232 |
/*:287*//*289:*/ |
| 5233 |
#line 2654 "./marpa.w" |
| 5234 |
|
| 5235 |
rule->t_minimum= -1; |
| 5236 |
/*:289*//*292:*/ |
| 5237 |
#line 2680 "./marpa.w" |
| 5238 |
|
| 5239 |
Separator_of_XRL(rule)= -1; |
| 5240 |
/*:292*//*297:*/ |
| 5241 |
#line 2717 "./marpa.w" |
| 5242 |
|
| 5243 |
rule->t_is_discard= 0; |
| 5244 |
/*:297*//*301:*/ |
| 5245 |
#line 2753 "./marpa.w" |
| 5246 |
|
| 5247 |
rule->t_is_proper_separation= 0; |
| 5248 |
/*:301*//*305:*/ |
| 5249 |
#line 2774 "./marpa.w" |
| 5250 |
|
| 5251 |
rule->t_is_loop= 0; |
| 5252 |
/*:305*//*308:*/ |
| 5253 |
#line 2792 "./marpa.w" |
| 5254 |
|
| 5255 |
XRL_is_Nulling(rule)= 0; |
| 5256 |
/*:308*//*311:*/ |
| 5257 |
#line 2811 "./marpa.w" |
| 5258 |
|
| 5259 |
XRL_is_Nullable(rule)= 0; |
| 5260 |
/*:311*//*315:*/ |
| 5261 |
#line 2830 "./marpa.w" |
| 5262 |
|
| 5263 |
XRL_is_Accessible(rule)= 1; |
| 5264 |
/*:315*//*318:*/ |
| 5265 |
#line 2849 "./marpa.w" |
| 5266 |
|
| 5267 |
XRL_is_Productive(rule)= 1; |
| 5268 |
/*:318*//*321:*/ |
| 5269 |
#line 2868 "./marpa.w" |
| 5270 |
|
| 5271 |
XRL_is_Used(rule)= 0; |
| 5272 |
/*:321*/ |
| 5273 |
#line 2223 "./marpa.w" |
| 5274 |
|
| 5275 |
rule_add(g,rule); |
| 5276 |
return rule; |
| 5277 |
} |
| 5278 |
|
| 5279 |
PRIVATE_NOT_INLINE |
| 5280 |
RULE rule_new(GRAMMAR g, |
| 5281 |
const XSYID lhs,const XSYID*rhs,int length) |
| 5282 |
{ |
| 5283 |
RULE rule= xrl_start(g,lhs,rhs,length); |
| 5284 |
xrl_finish(g,rule); |
| 5285 |
rule= marpa_obs_finish(g->t_xrl_obs); |
| 5286 |
return rule; |
| 5287 |
} |
| 5288 |
|
| 5289 |
/*:258*//*259:*/ |
| 5290 |
#line 2239 "./marpa.w" |
| 5291 |
|
| 5292 |
PRIVATE IRL |
| 5293 |
irl_start(GRAMMAR g,int length) |
| 5294 |
{ |
| 5295 |
IRL irl; |
| 5296 |
const size_t sizeof_irl= offsetof(struct s_irl,t_nsyid_array)+ |
| 5297 |
((size_t)length+1)*sizeof(irl->t_nsyid_array[0]); |
| 5298 |
|
| 5299 |
|
| 5300 |
irl= marpa__obs_alloc(g->t_obs,sizeof_irl,ALIGNOF(IRL_Object)); |
| 5301 |
|
| 5302 |
ID_of_IRL(irl)= MARPA_DSTACK_LENGTH((g)->t_irl_stack); |
| 5303 |
Length_of_IRL(irl)= length; |
| 5304 |
/*342:*/ |
| 5305 |
#line 3005 "./marpa.w" |
| 5306 |
|
| 5307 |
IRL_has_Virtual_LHS(irl)= 0; |
| 5308 |
/*:342*//*345:*/ |
| 5309 |
#line 3021 "./marpa.w" |
| 5310 |
|
| 5311 |
IRL_has_Virtual_RHS(irl)= 0; |
| 5312 |
/*:345*//*348:*/ |
| 5313 |
#line 3040 "./marpa.w" |
| 5314 |
|
| 5315 |
IRL_is_Right_Recursive(irl)= 0; |
| 5316 |
|
| 5317 |
/*:348*//*351:*/ |
| 5318 |
#line 3051 "./marpa.w" |
| 5319 |
Real_SYM_Count_of_IRL(irl)= 0; |
| 5320 |
/*:351*//*354:*/ |
| 5321 |
#line 3069 "./marpa.w" |
| 5322 |
irl->t_virtual_start= -1; |
| 5323 |
/*:354*//*357:*/ |
| 5324 |
#line 3089 "./marpa.w" |
| 5325 |
irl->t_virtual_end= -1; |
| 5326 |
/*:357*//*360:*/ |
| 5327 |
#line 3111 "./marpa.w" |
| 5328 |
Source_XRL_of_IRL(irl)= NULL; |
| 5329 |
/*:360*//*363:*/ |
| 5330 |
#line 3138 "./marpa.w" |
| 5331 |
|
| 5332 |
Rank_of_IRL(irl)= Default_Rank_of_G(g)*EXTERNAL_RANK_FACTOR+MAXIMUM_CHAF_RANK; |
| 5333 |
/*:363*//*366:*/ |
| 5334 |
#line 3160 "./marpa.w" |
| 5335 |
|
| 5336 |
First_AHM_of_IRL(irl)= NULL; |
| 5337 |
|
| 5338 |
/*:366*//*410:*/ |
| 5339 |
#line 4058 "./marpa.w" |
| 5340 |
|
| 5341 |
IRL_is_CHAF(irl)= 0; |
| 5342 |
/*:410*//*473:*/ |
| 5343 |
#line 4973 "./marpa.w" |
| 5344 |
|
| 5345 |
Last_Proper_SYMI_of_IRL(irl)= -1; |
| 5346 |
|
| 5347 |
/*:473*/ |
| 5348 |
#line 2252 "./marpa.w" |
| 5349 |
|
| 5350 |
*MARPA_DSTACK_PUSH((g)->t_irl_stack,IRL)= irl; |
| 5351 |
return irl; |
| 5352 |
} |
| 5353 |
|
| 5354 |
PRIVATE void |
| 5355 |
irl_finish(GRAMMAR g,IRL irl) |
| 5356 |
{ |
| 5357 |
const NSY lhs_nsy= LHS_of_IRL(irl); |
| 5358 |
NSY_is_LHS(lhs_nsy)= 1; |
| 5359 |
} |
| 5360 |
|
| 5361 |
/*:259*//*261:*/ |
| 5362 |
#line 2278 "./marpa.w" |
| 5363 |
|
| 5364 |
Marpa_Rule_ID |
| 5365 |
marpa_g_rule_new(Marpa_Grammar g, |
| 5366 |
Marpa_Symbol_ID lhs_id,Marpa_Symbol_ID*rhs_ids,int length) |
| 5367 |
{ |
| 5368 |
/*1230:*/ |
| 5369 |
#line 14864 "./marpa.w" |
| 5370 |
const int failure_indicator= -2; |
| 5371 |
|
| 5372 |
/*:1230*/ |
| 5373 |
#line 2283 "./marpa.w" |
| 5374 |
|
| 5375 |
Marpa_Rule_ID rule_id; |
| 5376 |
RULE rule; |
| 5377 |
/*1250:*/ |
| 5378 |
#line 14997 "./marpa.w" |
| 5379 |
|
| 5380 |
if(HEADER_VERSION_MISMATCH){ |
| 5381 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 5382 |
return failure_indicator; |
| 5383 |
} |
| 5384 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 5385 |
MARPA_ERROR(g->t_error); |
| 5386 |
return failure_indicator; |
| 5387 |
} |
| 5388 |
|
| 5389 |
/*:1250*/ |
| 5390 |
#line 2286 "./marpa.w" |
| 5391 |
|
| 5392 |
/*1231:*/ |
| 5393 |
#line 14869 "./marpa.w" |
| 5394 |
|
| 5395 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 5396 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 5397 |
return failure_indicator; |
| 5398 |
} |
| 5399 |
|
| 5400 |
/*:1231*/ |
| 5401 |
#line 2287 "./marpa.w" |
| 5402 |
|
| 5403 |
if(_MARPA_UNLIKELY(length> MAX_RHS_LENGTH)) |
| 5404 |
{ |
| 5405 |
MARPA_ERROR(MARPA_ERR_RHS_TOO_LONG); |
| 5406 |
return failure_indicator; |
| 5407 |
} |
| 5408 |
if(_MARPA_UNLIKELY(!xsy_id_is_valid(g,lhs_id))) |
| 5409 |
{ |
| 5410 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 5411 |
return failure_indicator; |
| 5412 |
} |
| 5413 |
{ |
| 5414 |
int rh_index; |
| 5415 |
for(rh_index= 0;rh_index<length;rh_index++) |
| 5416 |
{ |
| 5417 |
const XSYID rhs_id= rhs_ids[rh_index]; |
| 5418 |
if(_MARPA_UNLIKELY(!xsy_id_is_valid(g,rhs_id))) |
| 5419 |
{ |
| 5420 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 5421 |
return failure_indicator; |
| 5422 |
} |
| 5423 |
} |
| 5424 |
} |
| 5425 |
{ |
| 5426 |
const XSY lhs= XSY_by_ID(lhs_id); |
| 5427 |
if(_MARPA_UNLIKELY(XSY_is_Sequence_LHS(lhs))) |
| 5428 |
{ |
| 5429 |
MARPA_ERROR(MARPA_ERR_SEQUENCE_LHS_NOT_UNIQUE); |
| 5430 |
return failure_indicator; |
| 5431 |
} |
| 5432 |
} |
| 5433 |
rule= xrl_start(g,lhs_id,rhs_ids,length); |
| 5434 |
if(_MARPA_UNLIKELY(_marpa_avl_insert(g->t_xrl_tree,rule)!=NULL)) |
| 5435 |
{ |
| 5436 |
MARPA_ERROR(MARPA_ERR_DUPLICATE_RULE); |
| 5437 |
marpa_obs_reject(g->t_xrl_obs); |
| 5438 |
return failure_indicator; |
| 5439 |
} |
| 5440 |
rule= xrl_finish(g,rule); |
| 5441 |
rule= marpa_obs_finish(g->t_xrl_obs); |
| 5442 |
XRL_is_BNF(rule)= 1; |
| 5443 |
rule_id= rule->t_id; |
| 5444 |
return rule_id; |
| 5445 |
} |
| 5446 |
|
| 5447 |
/*:261*//*262:*/ |
| 5448 |
#line 2332 "./marpa.w" |
| 5449 |
|
| 5450 |
Marpa_Rule_ID marpa_g_sequence_new(Marpa_Grammar g, |
| 5451 |
Marpa_Symbol_ID lhs_id,Marpa_Symbol_ID rhs_id,Marpa_Symbol_ID separator_id, |
| 5452 |
int min,int flags) |
| 5453 |
{ |
| 5454 |
RULE original_rule; |
| 5455 |
RULEID original_rule_id= -2; |
| 5456 |
/*1230:*/ |
| 5457 |
#line 14864 "./marpa.w" |
| 5458 |
const int failure_indicator= -2; |
| 5459 |
|
| 5460 |
/*:1230*/ |
| 5461 |
#line 2339 "./marpa.w" |
| 5462 |
|
| 5463 |
/*1250:*/ |
| 5464 |
#line 14997 "./marpa.w" |
| 5465 |
|
| 5466 |
if(HEADER_VERSION_MISMATCH){ |
| 5467 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 5468 |
return failure_indicator; |
| 5469 |
} |
| 5470 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 5471 |
MARPA_ERROR(g->t_error); |
| 5472 |
return failure_indicator; |
| 5473 |
} |
| 5474 |
|
| 5475 |
/*:1250*/ |
| 5476 |
#line 2340 "./marpa.w" |
| 5477 |
|
| 5478 |
/*1231:*/ |
| 5479 |
#line 14869 "./marpa.w" |
| 5480 |
|
| 5481 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 5482 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 5483 |
return failure_indicator; |
| 5484 |
} |
| 5485 |
|
| 5486 |
/*:1231*/ |
| 5487 |
#line 2341 "./marpa.w" |
| 5488 |
|
| 5489 |
/*264:*/ |
| 5490 |
#line 2372 "./marpa.w" |
| 5491 |
|
| 5492 |
{ |
| 5493 |
if(separator_id!=-1) |
| 5494 |
{ |
| 5495 |
if(_MARPA_UNLIKELY(!xsy_id_is_valid(g,separator_id))) |
| 5496 |
{ |
| 5497 |
MARPA_ERROR(MARPA_ERR_BAD_SEPARATOR); |
| 5498 |
goto FAILURE; |
| 5499 |
} |
| 5500 |
} |
| 5501 |
if(_MARPA_UNLIKELY(!xsy_id_is_valid(g,lhs_id))) |
| 5502 |
{ |
| 5503 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 5504 |
goto FAILURE; |
| 5505 |
} |
| 5506 |
{ |
| 5507 |
const XSY lhs= XSY_by_ID(lhs_id); |
| 5508 |
if(_MARPA_UNLIKELY(XSY_is_LHS(lhs))) |
| 5509 |
{ |
| 5510 |
MARPA_ERROR(MARPA_ERR_SEQUENCE_LHS_NOT_UNIQUE); |
| 5511 |
goto FAILURE; |
| 5512 |
} |
| 5513 |
} |
| 5514 |
if(_MARPA_UNLIKELY(!xsy_id_is_valid(g,rhs_id))) |
| 5515 |
{ |
| 5516 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 5517 |
goto FAILURE; |
| 5518 |
} |
| 5519 |
} |
| 5520 |
|
| 5521 |
/*:264*/ |
| 5522 |
#line 2342 "./marpa.w" |
| 5523 |
|
| 5524 |
/*263:*/ |
| 5525 |
#line 2350 "./marpa.w" |
| 5526 |
|
| 5527 |
{ |
| 5528 |
original_rule= rule_new(g,lhs_id,&rhs_id,1); |
| 5529 |
original_rule_id= original_rule->t_id; |
| 5530 |
if(separator_id>=0) |
| 5531 |
Separator_of_XRL(original_rule)= separator_id; |
| 5532 |
Minimum_of_XRL(original_rule)= min; |
| 5533 |
XRL_is_Sequence(original_rule)= 1; |
| 5534 |
original_rule->t_is_discard= !(flags&MARPA_KEEP_SEPARATION) |
| 5535 |
&&separator_id>=0; |
| 5536 |
if(flags&MARPA_PROPER_SEPARATION) |
| 5537 |
{ |
| 5538 |
XRL_is_Proper_Separation(original_rule)= 1; |
| 5539 |
} |
| 5540 |
XSY_is_Sequence_LHS(XSY_by_ID(lhs_id))= 1; |
| 5541 |
XSY_by_ID(rhs_id)->t_is_counted= 1; |
| 5542 |
if(separator_id>=0) |
| 5543 |
{ |
| 5544 |
XSY_by_ID(separator_id)->t_is_counted= 1; |
| 5545 |
} |
| 5546 |
} |
| 5547 |
|
| 5548 |
/*:263*/ |
| 5549 |
#line 2343 "./marpa.w" |
| 5550 |
|
| 5551 |
return original_rule_id; |
| 5552 |
FAILURE: |
| 5553 |
return failure_indicator; |
| 5554 |
} |
| 5555 |
|
| 5556 |
/*:262*//*266:*/ |
| 5557 |
#line 2425 "./marpa.w" |
| 5558 |
|
| 5559 |
PRIVATE_NOT_INLINE int |
| 5560 |
duplicate_rule_cmp(const void*ap,const void*bp,void*param UNUSED) |
| 5561 |
{ |
| 5562 |
XRL xrl1= (XRL)ap; |
| 5563 |
XRL xrl2= (XRL)bp; |
| 5564 |
int diff= LHS_ID_of_XRL(xrl2)-LHS_ID_of_XRL(xrl1); |
| 5565 |
if(diff) |
| 5566 |
return diff; |
| 5567 |
{ |
| 5568 |
|
| 5569 |
|
| 5570 |
|
| 5571 |
|
| 5572 |
int ix; |
| 5573 |
const int length= Length_of_XRL(xrl1); |
| 5574 |
diff= Length_of_XRL(xrl2)-length; |
| 5575 |
if(diff) |
| 5576 |
return diff; |
| 5577 |
for(ix= 0;ix<length;ix++) |
| 5578 |
{ |
| 5579 |
diff= RHS_ID_of_XRL(xrl2,ix)-RHS_ID_of_XRL(xrl1,ix); |
| 5580 |
if(diff) |
| 5581 |
return diff; |
| 5582 |
} |
| 5583 |
} |
| 5584 |
return 0; |
| 5585 |
} |
| 5586 |
|
| 5587 |
/*:266*//*269:*/ |
| 5588 |
#line 2481 "./marpa.w" |
| 5589 |
|
| 5590 |
PRIVATE Marpa_Symbol_ID rule_lhs_get(RULE rule) |
| 5591 |
{ |
| 5592 |
return rule->t_symbols[0];} |
| 5593 |
/*:269*//*270:*/ |
| 5594 |
#line 2485 "./marpa.w" |
| 5595 |
|
| 5596 |
Marpa_Symbol_ID marpa_g_rule_lhs(Marpa_Grammar g,Marpa_Rule_ID xrl_id){ |
| 5597 |
/*1230:*/ |
| 5598 |
#line 14864 "./marpa.w" |
| 5599 |
const int failure_indicator= -2; |
| 5600 |
|
| 5601 |
/*:1230*/ |
| 5602 |
#line 2487 "./marpa.w" |
| 5603 |
|
| 5604 |
/*1250:*/ |
| 5605 |
#line 14997 "./marpa.w" |
| 5606 |
|
| 5607 |
if(HEADER_VERSION_MISMATCH){ |
| 5608 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 5609 |
return failure_indicator; |
| 5610 |
} |
| 5611 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 5612 |
MARPA_ERROR(g->t_error); |
| 5613 |
return failure_indicator; |
| 5614 |
} |
| 5615 |
|
| 5616 |
/*:1250*/ |
| 5617 |
#line 2488 "./marpa.w" |
| 5618 |
|
| 5619 |
/*1242:*/ |
| 5620 |
#line 14936 "./marpa.w" |
| 5621 |
|
| 5622 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 5623 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 5624 |
return failure_indicator; |
| 5625 |
} |
| 5626 |
|
| 5627 |
/*:1242*/ |
| 5628 |
#line 2489 "./marpa.w" |
| 5629 |
|
| 5630 |
/*1240:*/ |
| 5631 |
#line 14924 "./marpa.w" |
| 5632 |
|
| 5633 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 5634 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 5635 |
return-1; |
| 5636 |
} |
| 5637 |
|
| 5638 |
/*:1240*/ |
| 5639 |
#line 2490 "./marpa.w" |
| 5640 |
|
| 5641 |
return rule_lhs_get(XRL_by_ID(xrl_id)); |
| 5642 |
} |
| 5643 |
/*:270*//*271:*/ |
| 5644 |
#line 2493 "./marpa.w" |
| 5645 |
|
| 5646 |
PRIVATE Marpa_Symbol_ID*rule_rhs_get(RULE rule) |
| 5647 |
{ |
| 5648 |
return rule->t_symbols+1;} |
| 5649 |
/*:271*//*272:*/ |
| 5650 |
#line 2497 "./marpa.w" |
| 5651 |
|
| 5652 |
Marpa_Symbol_ID marpa_g_rule_rhs(Marpa_Grammar g,Marpa_Rule_ID xrl_id,int ix){ |
| 5653 |
RULE rule; |
| 5654 |
/*1230:*/ |
| 5655 |
#line 14864 "./marpa.w" |
| 5656 |
const int failure_indicator= -2; |
| 5657 |
|
| 5658 |
/*:1230*/ |
| 5659 |
#line 2500 "./marpa.w" |
| 5660 |
|
| 5661 |
/*1250:*/ |
| 5662 |
#line 14997 "./marpa.w" |
| 5663 |
|
| 5664 |
if(HEADER_VERSION_MISMATCH){ |
| 5665 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 5666 |
return failure_indicator; |
| 5667 |
} |
| 5668 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 5669 |
MARPA_ERROR(g->t_error); |
| 5670 |
return failure_indicator; |
| 5671 |
} |
| 5672 |
|
| 5673 |
/*:1250*/ |
| 5674 |
#line 2501 "./marpa.w" |
| 5675 |
|
| 5676 |
/*1242:*/ |
| 5677 |
#line 14936 "./marpa.w" |
| 5678 |
|
| 5679 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 5680 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 5681 |
return failure_indicator; |
| 5682 |
} |
| 5683 |
|
| 5684 |
/*:1242*/ |
| 5685 |
#line 2502 "./marpa.w" |
| 5686 |
|
| 5687 |
/*1240:*/ |
| 5688 |
#line 14924 "./marpa.w" |
| 5689 |
|
| 5690 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 5691 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 5692 |
return-1; |
| 5693 |
} |
| 5694 |
|
| 5695 |
/*:1240*/ |
| 5696 |
#line 2503 "./marpa.w" |
| 5697 |
|
| 5698 |
rule= XRL_by_ID(xrl_id); |
| 5699 |
if(ix<0){ |
| 5700 |
MARPA_ERROR(MARPA_ERR_RHS_IX_NEGATIVE); |
| 5701 |
return failure_indicator; |
| 5702 |
} |
| 5703 |
if(Length_of_XRL(rule)<=ix){ |
| 5704 |
MARPA_ERROR(MARPA_ERR_RHS_IX_OOB); |
| 5705 |
return failure_indicator; |
| 5706 |
} |
| 5707 |
return RHS_ID_of_RULE(rule,ix); |
| 5708 |
} |
| 5709 |
|
| 5710 |
/*:272*//*273:*/ |
| 5711 |
#line 2516 "./marpa.w" |
| 5712 |
|
| 5713 |
int marpa_g_rule_length(Marpa_Grammar g,Marpa_Rule_ID xrl_id){ |
| 5714 |
/*1230:*/ |
| 5715 |
#line 14864 "./marpa.w" |
| 5716 |
const int failure_indicator= -2; |
| 5717 |
|
| 5718 |
/*:1230*/ |
| 5719 |
#line 2518 "./marpa.w" |
| 5720 |
|
| 5721 |
/*1250:*/ |
| 5722 |
#line 14997 "./marpa.w" |
| 5723 |
|
| 5724 |
if(HEADER_VERSION_MISMATCH){ |
| 5725 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 5726 |
return failure_indicator; |
| 5727 |
} |
| 5728 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 5729 |
MARPA_ERROR(g->t_error); |
| 5730 |
return failure_indicator; |
| 5731 |
} |
| 5732 |
|
| 5733 |
/*:1250*/ |
| 5734 |
#line 2519 "./marpa.w" |
| 5735 |
|
| 5736 |
/*1242:*/ |
| 5737 |
#line 14936 "./marpa.w" |
| 5738 |
|
| 5739 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 5740 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 5741 |
return failure_indicator; |
| 5742 |
} |
| 5743 |
|
| 5744 |
/*:1242*/ |
| 5745 |
#line 2520 "./marpa.w" |
| 5746 |
|
| 5747 |
/*1240:*/ |
| 5748 |
#line 14924 "./marpa.w" |
| 5749 |
|
| 5750 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 5751 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 5752 |
return-1; |
| 5753 |
} |
| 5754 |
|
| 5755 |
/*:1240*/ |
| 5756 |
#line 2521 "./marpa.w" |
| 5757 |
|
| 5758 |
return Length_of_XRL(XRL_by_ID(xrl_id)); |
| 5759 |
} |
| 5760 |
|
| 5761 |
/*:273*//*278:*/ |
| 5762 |
#line 2548 "./marpa.w" |
| 5763 |
|
| 5764 |
int marpa_g_rule_rank(Marpa_Grammar g, |
| 5765 |
Marpa_Rule_ID xrl_id) |
| 5766 |
{ |
| 5767 |
XRL xrl; |
| 5768 |
/*1230:*/ |
| 5769 |
#line 14864 "./marpa.w" |
| 5770 |
const int failure_indicator= -2; |
| 5771 |
|
| 5772 |
/*:1230*/ |
| 5773 |
#line 2553 "./marpa.w" |
| 5774 |
|
| 5775 |
clear_error(g); |
| 5776 |
/*1250:*/ |
| 5777 |
#line 14997 "./marpa.w" |
| 5778 |
|
| 5779 |
if(HEADER_VERSION_MISMATCH){ |
| 5780 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 5781 |
return failure_indicator; |
| 5782 |
} |
| 5783 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 5784 |
MARPA_ERROR(g->t_error); |
| 5785 |
return failure_indicator; |
| 5786 |
} |
| 5787 |
|
| 5788 |
/*:1250*/ |
| 5789 |
#line 2555 "./marpa.w" |
| 5790 |
|
| 5791 |
/*1242:*/ |
| 5792 |
#line 14936 "./marpa.w" |
| 5793 |
|
| 5794 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 5795 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 5796 |
return failure_indicator; |
| 5797 |
} |
| 5798 |
|
| 5799 |
/*:1242*/ |
| 5800 |
#line 2556 "./marpa.w" |
| 5801 |
|
| 5802 |
/*1241:*/ |
| 5803 |
#line 14930 "./marpa.w" |
| 5804 |
|
| 5805 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 5806 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 5807 |
return failure_indicator; |
| 5808 |
} |
| 5809 |
/*:1241*/ |
| 5810 |
#line 2557 "./marpa.w" |
| 5811 |
|
| 5812 |
clear_error(g); |
| 5813 |
xrl= XRL_by_ID(xrl_id); |
| 5814 |
return Rank_of_XRL(xrl); |
| 5815 |
} |
| 5816 |
/*:278*//*279:*/ |
| 5817 |
#line 2562 "./marpa.w" |
| 5818 |
|
| 5819 |
int marpa_g_rule_rank_set( |
| 5820 |
Marpa_Grammar g,Marpa_Rule_ID xrl_id,Marpa_Rank rank) |
| 5821 |
{ |
| 5822 |
XRL xrl; |
| 5823 |
/*1230:*/ |
| 5824 |
#line 14864 "./marpa.w" |
| 5825 |
const int failure_indicator= -2; |
| 5826 |
|
| 5827 |
/*:1230*/ |
| 5828 |
#line 2567 "./marpa.w" |
| 5829 |
|
| 5830 |
clear_error(g); |
| 5831 |
/*1250:*/ |
| 5832 |
#line 14997 "./marpa.w" |
| 5833 |
|
| 5834 |
if(HEADER_VERSION_MISMATCH){ |
| 5835 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 5836 |
return failure_indicator; |
| 5837 |
} |
| 5838 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 5839 |
MARPA_ERROR(g->t_error); |
| 5840 |
return failure_indicator; |
| 5841 |
} |
| 5842 |
|
| 5843 |
/*:1250*/ |
| 5844 |
#line 2569 "./marpa.w" |
| 5845 |
|
| 5846 |
/*1231:*/ |
| 5847 |
#line 14869 "./marpa.w" |
| 5848 |
|
| 5849 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 5850 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 5851 |
return failure_indicator; |
| 5852 |
} |
| 5853 |
|
| 5854 |
/*:1231*/ |
| 5855 |
#line 2570 "./marpa.w" |
| 5856 |
|
| 5857 |
/*1242:*/ |
| 5858 |
#line 14936 "./marpa.w" |
| 5859 |
|
| 5860 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 5861 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 5862 |
return failure_indicator; |
| 5863 |
} |
| 5864 |
|
| 5865 |
/*:1242*/ |
| 5866 |
#line 2571 "./marpa.w" |
| 5867 |
|
| 5868 |
/*1241:*/ |
| 5869 |
#line 14930 "./marpa.w" |
| 5870 |
|
| 5871 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 5872 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 5873 |
return failure_indicator; |
| 5874 |
} |
| 5875 |
/*:1241*/ |
| 5876 |
#line 2572 "./marpa.w" |
| 5877 |
|
| 5878 |
xrl= XRL_by_ID(xrl_id); |
| 5879 |
if(_MARPA_UNLIKELY(rank<MINIMUM_RANK)) |
| 5880 |
{ |
| 5881 |
MARPA_ERROR(MARPA_ERR_RANK_TOO_LOW); |
| 5882 |
return failure_indicator; |
| 5883 |
} |
| 5884 |
if(_MARPA_UNLIKELY(rank> MAXIMUM_RANK)) |
| 5885 |
{ |
| 5886 |
MARPA_ERROR(MARPA_ERR_RANK_TOO_HIGH); |
| 5887 |
return failure_indicator; |
| 5888 |
} |
| 5889 |
return Rank_of_XRL(xrl)= rank; |
| 5890 |
} |
| 5891 |
|
| 5892 |
/*:279*//*282:*/ |
| 5893 |
#line 2598 "./marpa.w" |
| 5894 |
|
| 5895 |
int marpa_g_rule_null_high(Marpa_Grammar g, |
| 5896 |
Marpa_Rule_ID xrl_id) |
| 5897 |
{ |
| 5898 |
XRL xrl; |
| 5899 |
/*1230:*/ |
| 5900 |
#line 14864 "./marpa.w" |
| 5901 |
const int failure_indicator= -2; |
| 5902 |
|
| 5903 |
/*:1230*/ |
| 5904 |
#line 2603 "./marpa.w" |
| 5905 |
|
| 5906 |
/*1250:*/ |
| 5907 |
#line 14997 "./marpa.w" |
| 5908 |
|
| 5909 |
if(HEADER_VERSION_MISMATCH){ |
| 5910 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 5911 |
return failure_indicator; |
| 5912 |
} |
| 5913 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 5914 |
MARPA_ERROR(g->t_error); |
| 5915 |
return failure_indicator; |
| 5916 |
} |
| 5917 |
|
| 5918 |
/*:1250*/ |
| 5919 |
#line 2604 "./marpa.w" |
| 5920 |
|
| 5921 |
/*1242:*/ |
| 5922 |
#line 14936 "./marpa.w" |
| 5923 |
|
| 5924 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 5925 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 5926 |
return failure_indicator; |
| 5927 |
} |
| 5928 |
|
| 5929 |
/*:1242*/ |
| 5930 |
#line 2605 "./marpa.w" |
| 5931 |
|
| 5932 |
/*1240:*/ |
| 5933 |
#line 14924 "./marpa.w" |
| 5934 |
|
| 5935 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 5936 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 5937 |
return-1; |
| 5938 |
} |
| 5939 |
|
| 5940 |
/*:1240*/ |
| 5941 |
#line 2606 "./marpa.w" |
| 5942 |
|
| 5943 |
xrl= XRL_by_ID(xrl_id); |
| 5944 |
return Null_Ranks_High_of_RULE(xrl); |
| 5945 |
} |
| 5946 |
/*:282*//*283:*/ |
| 5947 |
#line 2610 "./marpa.w" |
| 5948 |
|
| 5949 |
int marpa_g_rule_null_high_set( |
| 5950 |
Marpa_Grammar g,Marpa_Rule_ID xrl_id,int flag) |
| 5951 |
{ |
| 5952 |
XRL xrl; |
| 5953 |
/*1230:*/ |
| 5954 |
#line 14864 "./marpa.w" |
| 5955 |
const int failure_indicator= -2; |
| 5956 |
|
| 5957 |
/*:1230*/ |
| 5958 |
#line 2615 "./marpa.w" |
| 5959 |
|
| 5960 |
/*1250:*/ |
| 5961 |
#line 14997 "./marpa.w" |
| 5962 |
|
| 5963 |
if(HEADER_VERSION_MISMATCH){ |
| 5964 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 5965 |
return failure_indicator; |
| 5966 |
} |
| 5967 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 5968 |
MARPA_ERROR(g->t_error); |
| 5969 |
return failure_indicator; |
| 5970 |
} |
| 5971 |
|
| 5972 |
/*:1250*/ |
| 5973 |
#line 2616 "./marpa.w" |
| 5974 |
|
| 5975 |
/*1231:*/ |
| 5976 |
#line 14869 "./marpa.w" |
| 5977 |
|
| 5978 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 5979 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 5980 |
return failure_indicator; |
| 5981 |
} |
| 5982 |
|
| 5983 |
/*:1231*/ |
| 5984 |
#line 2617 "./marpa.w" |
| 5985 |
|
| 5986 |
/*1242:*/ |
| 5987 |
#line 14936 "./marpa.w" |
| 5988 |
|
| 5989 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 5990 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 5991 |
return failure_indicator; |
| 5992 |
} |
| 5993 |
|
| 5994 |
/*:1242*/ |
| 5995 |
#line 2618 "./marpa.w" |
| 5996 |
|
| 5997 |
/*1240:*/ |
| 5998 |
#line 14924 "./marpa.w" |
| 5999 |
|
| 6000 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 6001 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 6002 |
return-1; |
| 6003 |
} |
| 6004 |
|
| 6005 |
/*:1240*/ |
| 6006 |
#line 2619 "./marpa.w" |
| 6007 |
|
| 6008 |
xrl= XRL_by_ID(xrl_id); |
| 6009 |
if(_MARPA_UNLIKELY(flag<0||flag> 1)) |
| 6010 |
{ |
| 6011 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 6012 |
return failure_indicator; |
| 6013 |
} |
| 6014 |
return Null_Ranks_High_of_RULE(xrl)= Boolean(flag); |
| 6015 |
} |
| 6016 |
|
| 6017 |
/*:283*//*290:*/ |
| 6018 |
#line 2656 "./marpa.w" |
| 6019 |
|
| 6020 |
int marpa_g_sequence_min( |
| 6021 |
Marpa_Grammar g, |
| 6022 |
Marpa_Rule_ID xrl_id) |
| 6023 |
{ |
| 6024 |
/*1230:*/ |
| 6025 |
#line 14864 "./marpa.w" |
| 6026 |
const int failure_indicator= -2; |
| 6027 |
|
| 6028 |
/*:1230*/ |
| 6029 |
#line 2661 "./marpa.w" |
| 6030 |
|
| 6031 |
XRL xrl; |
| 6032 |
/*1250:*/ |
| 6033 |
#line 14997 "./marpa.w" |
| 6034 |
|
| 6035 |
if(HEADER_VERSION_MISMATCH){ |
| 6036 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 6037 |
return failure_indicator; |
| 6038 |
} |
| 6039 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 6040 |
MARPA_ERROR(g->t_error); |
| 6041 |
return failure_indicator; |
| 6042 |
} |
| 6043 |
|
| 6044 |
/*:1250*/ |
| 6045 |
#line 2663 "./marpa.w" |
| 6046 |
|
| 6047 |
/*1242:*/ |
| 6048 |
#line 14936 "./marpa.w" |
| 6049 |
|
| 6050 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 6051 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 6052 |
return failure_indicator; |
| 6053 |
} |
| 6054 |
|
| 6055 |
/*:1242*/ |
| 6056 |
#line 2664 "./marpa.w" |
| 6057 |
|
| 6058 |
/*1241:*/ |
| 6059 |
#line 14930 "./marpa.w" |
| 6060 |
|
| 6061 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 6062 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 6063 |
return failure_indicator; |
| 6064 |
} |
| 6065 |
/*:1241*/ |
| 6066 |
#line 2665 "./marpa.w" |
| 6067 |
|
| 6068 |
xrl= XRL_by_ID(xrl_id); |
| 6069 |
if(!XRL_is_Sequence(xrl)) |
| 6070 |
{ |
| 6071 |
MARPA_ERROR(MARPA_ERR_NOT_A_SEQUENCE); |
| 6072 |
return-1; |
| 6073 |
} |
| 6074 |
return Minimum_of_XRL(xrl); |
| 6075 |
} |
| 6076 |
|
| 6077 |
/*:290*//*293:*/ |
| 6078 |
#line 2682 "./marpa.w" |
| 6079 |
|
| 6080 |
Marpa_Symbol_ID marpa_g_sequence_separator( |
| 6081 |
Marpa_Grammar g, |
| 6082 |
Marpa_Rule_ID xrl_id) |
| 6083 |
{ |
| 6084 |
/*1230:*/ |
| 6085 |
#line 14864 "./marpa.w" |
| 6086 |
const int failure_indicator= -2; |
| 6087 |
|
| 6088 |
/*:1230*/ |
| 6089 |
#line 2687 "./marpa.w" |
| 6090 |
|
| 6091 |
XRL xrl; |
| 6092 |
/*1250:*/ |
| 6093 |
#line 14997 "./marpa.w" |
| 6094 |
|
| 6095 |
if(HEADER_VERSION_MISMATCH){ |
| 6096 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 6097 |
return failure_indicator; |
| 6098 |
} |
| 6099 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 6100 |
MARPA_ERROR(g->t_error); |
| 6101 |
return failure_indicator; |
| 6102 |
} |
| 6103 |
|
| 6104 |
/*:1250*/ |
| 6105 |
#line 2689 "./marpa.w" |
| 6106 |
|
| 6107 |
/*1242:*/ |
| 6108 |
#line 14936 "./marpa.w" |
| 6109 |
|
| 6110 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 6111 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 6112 |
return failure_indicator; |
| 6113 |
} |
| 6114 |
|
| 6115 |
/*:1242*/ |
| 6116 |
#line 2690 "./marpa.w" |
| 6117 |
|
| 6118 |
/*1241:*/ |
| 6119 |
#line 14930 "./marpa.w" |
| 6120 |
|
| 6121 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 6122 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 6123 |
return failure_indicator; |
| 6124 |
} |
| 6125 |
/*:1241*/ |
| 6126 |
#line 2691 "./marpa.w" |
| 6127 |
|
| 6128 |
xrl= XRL_by_ID(xrl_id); |
| 6129 |
if(!XRL_is_Sequence(xrl)) |
| 6130 |
{ |
| 6131 |
MARPA_ERROR(MARPA_ERR_NOT_A_SEQUENCE); |
| 6132 |
return failure_indicator; |
| 6133 |
} |
| 6134 |
return Separator_of_XRL(xrl); |
| 6135 |
} |
| 6136 |
|
| 6137 |
/*:293*//*298:*/ |
| 6138 |
#line 2719 "./marpa.w" |
| 6139 |
|
| 6140 |
int _marpa_g_rule_is_keep_separation( |
| 6141 |
Marpa_Grammar g, |
| 6142 |
Marpa_Rule_ID xrl_id) |
| 6143 |
{ |
| 6144 |
/*1230:*/ |
| 6145 |
#line 14864 "./marpa.w" |
| 6146 |
const int failure_indicator= -2; |
| 6147 |
|
| 6148 |
/*:1230*/ |
| 6149 |
#line 2724 "./marpa.w" |
| 6150 |
|
| 6151 |
/*1250:*/ |
| 6152 |
#line 14997 "./marpa.w" |
| 6153 |
|
| 6154 |
if(HEADER_VERSION_MISMATCH){ |
| 6155 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 6156 |
return failure_indicator; |
| 6157 |
} |
| 6158 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 6159 |
MARPA_ERROR(g->t_error); |
| 6160 |
return failure_indicator; |
| 6161 |
} |
| 6162 |
|
| 6163 |
/*:1250*/ |
| 6164 |
#line 2725 "./marpa.w" |
| 6165 |
|
| 6166 |
/*1242:*/ |
| 6167 |
#line 14936 "./marpa.w" |
| 6168 |
|
| 6169 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 6170 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 6171 |
return failure_indicator; |
| 6172 |
} |
| 6173 |
|
| 6174 |
/*:1242*/ |
| 6175 |
#line 2726 "./marpa.w" |
| 6176 |
|
| 6177 |
/*1240:*/ |
| 6178 |
#line 14924 "./marpa.w" |
| 6179 |
|
| 6180 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 6181 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 6182 |
return-1; |
| 6183 |
} |
| 6184 |
|
| 6185 |
/*:1240*/ |
| 6186 |
#line 2727 "./marpa.w" |
| 6187 |
|
| 6188 |
return!XRL_by_ID(xrl_id)->t_is_discard; |
| 6189 |
} |
| 6190 |
|
| 6191 |
/*:298*//*302:*/ |
| 6192 |
#line 2755 "./marpa.w" |
| 6193 |
|
| 6194 |
int marpa_g_rule_is_proper_separation( |
| 6195 |
Marpa_Grammar g, |
| 6196 |
Marpa_Rule_ID xrl_id) |
| 6197 |
{ |
| 6198 |
/*1230:*/ |
| 6199 |
#line 14864 "./marpa.w" |
| 6200 |
const int failure_indicator= -2; |
| 6201 |
|
| 6202 |
/*:1230*/ |
| 6203 |
#line 2760 "./marpa.w" |
| 6204 |
|
| 6205 |
/*1250:*/ |
| 6206 |
#line 14997 "./marpa.w" |
| 6207 |
|
| 6208 |
if(HEADER_VERSION_MISMATCH){ |
| 6209 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 6210 |
return failure_indicator; |
| 6211 |
} |
| 6212 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 6213 |
MARPA_ERROR(g->t_error); |
| 6214 |
return failure_indicator; |
| 6215 |
} |
| 6216 |
|
| 6217 |
/*:1250*/ |
| 6218 |
#line 2761 "./marpa.w" |
| 6219 |
|
| 6220 |
/*1242:*/ |
| 6221 |
#line 14936 "./marpa.w" |
| 6222 |
|
| 6223 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 6224 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 6225 |
return failure_indicator; |
| 6226 |
} |
| 6227 |
|
| 6228 |
/*:1242*/ |
| 6229 |
#line 2762 "./marpa.w" |
| 6230 |
|
| 6231 |
/*1240:*/ |
| 6232 |
#line 14924 "./marpa.w" |
| 6233 |
|
| 6234 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 6235 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 6236 |
return-1; |
| 6237 |
} |
| 6238 |
|
| 6239 |
/*:1240*/ |
| 6240 |
#line 2763 "./marpa.w" |
| 6241 |
|
| 6242 |
return XRL_is_Proper_Separation(XRL_by_ID(xrl_id)); |
| 6243 |
} |
| 6244 |
|
| 6245 |
/*:302*//*306:*/ |
| 6246 |
#line 2776 "./marpa.w" |
| 6247 |
|
| 6248 |
int marpa_g_rule_is_loop(Marpa_Grammar g,Marpa_Rule_ID xrl_id) |
| 6249 |
{ |
| 6250 |
/*1230:*/ |
| 6251 |
#line 14864 "./marpa.w" |
| 6252 |
const int failure_indicator= -2; |
| 6253 |
|
| 6254 |
/*:1230*/ |
| 6255 |
#line 2779 "./marpa.w" |
| 6256 |
|
| 6257 |
/*1250:*/ |
| 6258 |
#line 14997 "./marpa.w" |
| 6259 |
|
| 6260 |
if(HEADER_VERSION_MISMATCH){ |
| 6261 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 6262 |
return failure_indicator; |
| 6263 |
} |
| 6264 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 6265 |
MARPA_ERROR(g->t_error); |
| 6266 |
return failure_indicator; |
| 6267 |
} |
| 6268 |
|
| 6269 |
/*:1250*/ |
| 6270 |
#line 2780 "./marpa.w" |
| 6271 |
|
| 6272 |
/*1232:*/ |
| 6273 |
#line 14875 "./marpa.w" |
| 6274 |
|
| 6275 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6276 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6277 |
return failure_indicator; |
| 6278 |
} |
| 6279 |
/*:1232*/ |
| 6280 |
#line 2781 "./marpa.w" |
| 6281 |
|
| 6282 |
/*1242:*/ |
| 6283 |
#line 14936 "./marpa.w" |
| 6284 |
|
| 6285 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 6286 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 6287 |
return failure_indicator; |
| 6288 |
} |
| 6289 |
|
| 6290 |
/*:1242*/ |
| 6291 |
#line 2782 "./marpa.w" |
| 6292 |
|
| 6293 |
/*1240:*/ |
| 6294 |
#line 14924 "./marpa.w" |
| 6295 |
|
| 6296 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 6297 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 6298 |
return-1; |
| 6299 |
} |
| 6300 |
|
| 6301 |
/*:1240*/ |
| 6302 |
#line 2783 "./marpa.w" |
| 6303 |
|
| 6304 |
/*1232:*/ |
| 6305 |
#line 14875 "./marpa.w" |
| 6306 |
|
| 6307 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6308 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6309 |
return failure_indicator; |
| 6310 |
} |
| 6311 |
/*:1232*/ |
| 6312 |
#line 2784 "./marpa.w" |
| 6313 |
|
| 6314 |
return XRL_by_ID(xrl_id)->t_is_loop; |
| 6315 |
} |
| 6316 |
|
| 6317 |
/*:306*//*309:*/ |
| 6318 |
#line 2794 "./marpa.w" |
| 6319 |
|
| 6320 |
int marpa_g_rule_is_nulling(Marpa_Grammar g,Marpa_Rule_ID xrl_id) |
| 6321 |
{ |
| 6322 |
/*1230:*/ |
| 6323 |
#line 14864 "./marpa.w" |
| 6324 |
const int failure_indicator= -2; |
| 6325 |
|
| 6326 |
/*:1230*/ |
| 6327 |
#line 2797 "./marpa.w" |
| 6328 |
|
| 6329 |
XRL xrl; |
| 6330 |
/*1250:*/ |
| 6331 |
#line 14997 "./marpa.w" |
| 6332 |
|
| 6333 |
if(HEADER_VERSION_MISMATCH){ |
| 6334 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 6335 |
return failure_indicator; |
| 6336 |
} |
| 6337 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 6338 |
MARPA_ERROR(g->t_error); |
| 6339 |
return failure_indicator; |
| 6340 |
} |
| 6341 |
|
| 6342 |
/*:1250*/ |
| 6343 |
#line 2799 "./marpa.w" |
| 6344 |
|
| 6345 |
/*1232:*/ |
| 6346 |
#line 14875 "./marpa.w" |
| 6347 |
|
| 6348 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6349 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6350 |
return failure_indicator; |
| 6351 |
} |
| 6352 |
/*:1232*/ |
| 6353 |
#line 2800 "./marpa.w" |
| 6354 |
|
| 6355 |
/*1242:*/ |
| 6356 |
#line 14936 "./marpa.w" |
| 6357 |
|
| 6358 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 6359 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 6360 |
return failure_indicator; |
| 6361 |
} |
| 6362 |
|
| 6363 |
/*:1242*/ |
| 6364 |
#line 2801 "./marpa.w" |
| 6365 |
|
| 6366 |
/*1240:*/ |
| 6367 |
#line 14924 "./marpa.w" |
| 6368 |
|
| 6369 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 6370 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 6371 |
return-1; |
| 6372 |
} |
| 6373 |
|
| 6374 |
/*:1240*/ |
| 6375 |
#line 2802 "./marpa.w" |
| 6376 |
|
| 6377 |
xrl= XRL_by_ID(xrl_id); |
| 6378 |
return XRL_is_Nulling(xrl); |
| 6379 |
} |
| 6380 |
|
| 6381 |
/*:309*//*312:*/ |
| 6382 |
#line 2813 "./marpa.w" |
| 6383 |
|
| 6384 |
int marpa_g_rule_is_nullable(Marpa_Grammar g,Marpa_Rule_ID xrl_id) |
| 6385 |
{ |
| 6386 |
/*1230:*/ |
| 6387 |
#line 14864 "./marpa.w" |
| 6388 |
const int failure_indicator= -2; |
| 6389 |
|
| 6390 |
/*:1230*/ |
| 6391 |
#line 2816 "./marpa.w" |
| 6392 |
|
| 6393 |
XRL xrl; |
| 6394 |
/*1250:*/ |
| 6395 |
#line 14997 "./marpa.w" |
| 6396 |
|
| 6397 |
if(HEADER_VERSION_MISMATCH){ |
| 6398 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 6399 |
return failure_indicator; |
| 6400 |
} |
| 6401 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 6402 |
MARPA_ERROR(g->t_error); |
| 6403 |
return failure_indicator; |
| 6404 |
} |
| 6405 |
|
| 6406 |
/*:1250*/ |
| 6407 |
#line 2818 "./marpa.w" |
| 6408 |
|
| 6409 |
/*1232:*/ |
| 6410 |
#line 14875 "./marpa.w" |
| 6411 |
|
| 6412 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6413 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6414 |
return failure_indicator; |
| 6415 |
} |
| 6416 |
/*:1232*/ |
| 6417 |
#line 2819 "./marpa.w" |
| 6418 |
|
| 6419 |
/*1242:*/ |
| 6420 |
#line 14936 "./marpa.w" |
| 6421 |
|
| 6422 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 6423 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 6424 |
return failure_indicator; |
| 6425 |
} |
| 6426 |
|
| 6427 |
/*:1242*/ |
| 6428 |
#line 2820 "./marpa.w" |
| 6429 |
|
| 6430 |
/*1240:*/ |
| 6431 |
#line 14924 "./marpa.w" |
| 6432 |
|
| 6433 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 6434 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 6435 |
return-1; |
| 6436 |
} |
| 6437 |
|
| 6438 |
/*:1240*/ |
| 6439 |
#line 2821 "./marpa.w" |
| 6440 |
|
| 6441 |
xrl= XRL_by_ID(xrl_id); |
| 6442 |
return XRL_is_Nullable(xrl); |
| 6443 |
} |
| 6444 |
|
| 6445 |
/*:312*//*316:*/ |
| 6446 |
#line 2832 "./marpa.w" |
| 6447 |
|
| 6448 |
int marpa_g_rule_is_accessible(Marpa_Grammar g,Marpa_Rule_ID xrl_id) |
| 6449 |
{ |
| 6450 |
/*1230:*/ |
| 6451 |
#line 14864 "./marpa.w" |
| 6452 |
const int failure_indicator= -2; |
| 6453 |
|
| 6454 |
/*:1230*/ |
| 6455 |
#line 2835 "./marpa.w" |
| 6456 |
|
| 6457 |
XRL xrl; |
| 6458 |
/*1250:*/ |
| 6459 |
#line 14997 "./marpa.w" |
| 6460 |
|
| 6461 |
if(HEADER_VERSION_MISMATCH){ |
| 6462 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 6463 |
return failure_indicator; |
| 6464 |
} |
| 6465 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 6466 |
MARPA_ERROR(g->t_error); |
| 6467 |
return failure_indicator; |
| 6468 |
} |
| 6469 |
|
| 6470 |
/*:1250*/ |
| 6471 |
#line 2837 "./marpa.w" |
| 6472 |
|
| 6473 |
/*1232:*/ |
| 6474 |
#line 14875 "./marpa.w" |
| 6475 |
|
| 6476 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6477 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6478 |
return failure_indicator; |
| 6479 |
} |
| 6480 |
/*:1232*/ |
| 6481 |
#line 2838 "./marpa.w" |
| 6482 |
|
| 6483 |
/*1242:*/ |
| 6484 |
#line 14936 "./marpa.w" |
| 6485 |
|
| 6486 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 6487 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 6488 |
return failure_indicator; |
| 6489 |
} |
| 6490 |
|
| 6491 |
/*:1242*/ |
| 6492 |
#line 2839 "./marpa.w" |
| 6493 |
|
| 6494 |
/*1240:*/ |
| 6495 |
#line 14924 "./marpa.w" |
| 6496 |
|
| 6497 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 6498 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 6499 |
return-1; |
| 6500 |
} |
| 6501 |
|
| 6502 |
/*:1240*/ |
| 6503 |
#line 2840 "./marpa.w" |
| 6504 |
|
| 6505 |
xrl= XRL_by_ID(xrl_id); |
| 6506 |
return XRL_is_Accessible(xrl); |
| 6507 |
} |
| 6508 |
|
| 6509 |
/*:316*//*319:*/ |
| 6510 |
#line 2851 "./marpa.w" |
| 6511 |
|
| 6512 |
int marpa_g_rule_is_productive(Marpa_Grammar g,Marpa_Rule_ID xrl_id) |
| 6513 |
{ |
| 6514 |
/*1230:*/ |
| 6515 |
#line 14864 "./marpa.w" |
| 6516 |
const int failure_indicator= -2; |
| 6517 |
|
| 6518 |
/*:1230*/ |
| 6519 |
#line 2854 "./marpa.w" |
| 6520 |
|
| 6521 |
XRL xrl; |
| 6522 |
/*1250:*/ |
| 6523 |
#line 14997 "./marpa.w" |
| 6524 |
|
| 6525 |
if(HEADER_VERSION_MISMATCH){ |
| 6526 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 6527 |
return failure_indicator; |
| 6528 |
} |
| 6529 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 6530 |
MARPA_ERROR(g->t_error); |
| 6531 |
return failure_indicator; |
| 6532 |
} |
| 6533 |
|
| 6534 |
/*:1250*/ |
| 6535 |
#line 2856 "./marpa.w" |
| 6536 |
|
| 6537 |
/*1232:*/ |
| 6538 |
#line 14875 "./marpa.w" |
| 6539 |
|
| 6540 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6541 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6542 |
return failure_indicator; |
| 6543 |
} |
| 6544 |
/*:1232*/ |
| 6545 |
#line 2857 "./marpa.w" |
| 6546 |
|
| 6547 |
/*1242:*/ |
| 6548 |
#line 14936 "./marpa.w" |
| 6549 |
|
| 6550 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 6551 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 6552 |
return failure_indicator; |
| 6553 |
} |
| 6554 |
|
| 6555 |
/*:1242*/ |
| 6556 |
#line 2858 "./marpa.w" |
| 6557 |
|
| 6558 |
/*1240:*/ |
| 6559 |
#line 14924 "./marpa.w" |
| 6560 |
|
| 6561 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 6562 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 6563 |
return-1; |
| 6564 |
} |
| 6565 |
|
| 6566 |
/*:1240*/ |
| 6567 |
#line 2859 "./marpa.w" |
| 6568 |
|
| 6569 |
xrl= XRL_by_ID(xrl_id); |
| 6570 |
return XRL_is_Productive(xrl); |
| 6571 |
} |
| 6572 |
|
| 6573 |
/*:319*//*322:*/ |
| 6574 |
#line 2870 "./marpa.w" |
| 6575 |
|
| 6576 |
int |
| 6577 |
_marpa_g_rule_is_used(Marpa_Grammar g,Marpa_Rule_ID xrl_id) |
| 6578 |
{ |
| 6579 |
/*1230:*/ |
| 6580 |
#line 14864 "./marpa.w" |
| 6581 |
const int failure_indicator= -2; |
| 6582 |
|
| 6583 |
/*:1230*/ |
| 6584 |
#line 2874 "./marpa.w" |
| 6585 |
|
| 6586 |
/*1242:*/ |
| 6587 |
#line 14936 "./marpa.w" |
| 6588 |
|
| 6589 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 6590 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 6591 |
return failure_indicator; |
| 6592 |
} |
| 6593 |
|
| 6594 |
/*:1242*/ |
| 6595 |
#line 2875 "./marpa.w" |
| 6596 |
|
| 6597 |
/*1240:*/ |
| 6598 |
#line 14924 "./marpa.w" |
| 6599 |
|
| 6600 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 6601 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 6602 |
return-1; |
| 6603 |
} |
| 6604 |
|
| 6605 |
/*:1240*/ |
| 6606 |
#line 2876 "./marpa.w" |
| 6607 |
|
| 6608 |
return XRL_is_Used(XRL_by_ID(xrl_id)); |
| 6609 |
} |
| 6610 |
|
| 6611 |
/*:322*//*324:*/ |
| 6612 |
#line 2883 "./marpa.w" |
| 6613 |
|
| 6614 |
Marpa_Rule_ID |
| 6615 |
_marpa_g_irl_semantic_equivalent(Marpa_Grammar g,Marpa_IRL_ID irl_id) |
| 6616 |
{ |
| 6617 |
IRL irl; |
| 6618 |
/*1230:*/ |
| 6619 |
#line 14864 "./marpa.w" |
| 6620 |
const int failure_indicator= -2; |
| 6621 |
|
| 6622 |
/*:1230*/ |
| 6623 |
#line 2888 "./marpa.w" |
| 6624 |
|
| 6625 |
/*1239:*/ |
| 6626 |
#line 14916 "./marpa.w" |
| 6627 |
|
| 6628 |
if(_MARPA_UNLIKELY(!IRLID_of_G_is_Valid(irl_id))){ |
| 6629 |
MARPA_ERROR(MARPA_ERR_INVALID_IRLID); |
| 6630 |
return failure_indicator; |
| 6631 |
} |
| 6632 |
/*:1239*/ |
| 6633 |
#line 2889 "./marpa.w" |
| 6634 |
|
| 6635 |
irl= IRL_by_ID(irl_id); |
| 6636 |
if(IRL_has_Virtual_LHS(irl))return-1; |
| 6637 |
return ID_of_XRL(Source_XRL_of_IRL(irl)); |
| 6638 |
} |
| 6639 |
|
| 6640 |
/*:324*//*333:*/ |
| 6641 |
#line 2930 "./marpa.w" |
| 6642 |
|
| 6643 |
Marpa_NSY_ID _marpa_g_irl_lhs(Marpa_Grammar g,Marpa_IRL_ID irl_id){ |
| 6644 |
IRL irl; |
| 6645 |
/*1230:*/ |
| 6646 |
#line 14864 "./marpa.w" |
| 6647 |
const int failure_indicator= -2; |
| 6648 |
|
| 6649 |
/*:1230*/ |
| 6650 |
#line 2933 "./marpa.w" |
| 6651 |
|
| 6652 |
/*1250:*/ |
| 6653 |
#line 14997 "./marpa.w" |
| 6654 |
|
| 6655 |
if(HEADER_VERSION_MISMATCH){ |
| 6656 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 6657 |
return failure_indicator; |
| 6658 |
} |
| 6659 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 6660 |
MARPA_ERROR(g->t_error); |
| 6661 |
return failure_indicator; |
| 6662 |
} |
| 6663 |
|
| 6664 |
/*:1250*/ |
| 6665 |
#line 2934 "./marpa.w" |
| 6666 |
|
| 6667 |
/*1232:*/ |
| 6668 |
#line 14875 "./marpa.w" |
| 6669 |
|
| 6670 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6671 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6672 |
return failure_indicator; |
| 6673 |
} |
| 6674 |
/*:1232*/ |
| 6675 |
#line 2935 "./marpa.w" |
| 6676 |
|
| 6677 |
/*1239:*/ |
| 6678 |
#line 14916 "./marpa.w" |
| 6679 |
|
| 6680 |
if(_MARPA_UNLIKELY(!IRLID_of_G_is_Valid(irl_id))){ |
| 6681 |
MARPA_ERROR(MARPA_ERR_INVALID_IRLID); |
| 6682 |
return failure_indicator; |
| 6683 |
} |
| 6684 |
/*:1239*/ |
| 6685 |
#line 2936 "./marpa.w" |
| 6686 |
|
| 6687 |
irl= IRL_by_ID(irl_id); |
| 6688 |
return LHSID_of_IRL(irl); |
| 6689 |
} |
| 6690 |
|
| 6691 |
/*:333*//*335:*/ |
| 6692 |
#line 2943 "./marpa.w" |
| 6693 |
|
| 6694 |
Marpa_NSY_ID _marpa_g_irl_rhs(Marpa_Grammar g,Marpa_IRL_ID irl_id,int ix){ |
| 6695 |
IRL irl; |
| 6696 |
/*1230:*/ |
| 6697 |
#line 14864 "./marpa.w" |
| 6698 |
const int failure_indicator= -2; |
| 6699 |
|
| 6700 |
/*:1230*/ |
| 6701 |
#line 2946 "./marpa.w" |
| 6702 |
|
| 6703 |
/*1250:*/ |
| 6704 |
#line 14997 "./marpa.w" |
| 6705 |
|
| 6706 |
if(HEADER_VERSION_MISMATCH){ |
| 6707 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 6708 |
return failure_indicator; |
| 6709 |
} |
| 6710 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 6711 |
MARPA_ERROR(g->t_error); |
| 6712 |
return failure_indicator; |
| 6713 |
} |
| 6714 |
|
| 6715 |
/*:1250*/ |
| 6716 |
#line 2947 "./marpa.w" |
| 6717 |
|
| 6718 |
/*1232:*/ |
| 6719 |
#line 14875 "./marpa.w" |
| 6720 |
|
| 6721 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6722 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6723 |
return failure_indicator; |
| 6724 |
} |
| 6725 |
/*:1232*/ |
| 6726 |
#line 2948 "./marpa.w" |
| 6727 |
|
| 6728 |
/*1239:*/ |
| 6729 |
#line 14916 "./marpa.w" |
| 6730 |
|
| 6731 |
if(_MARPA_UNLIKELY(!IRLID_of_G_is_Valid(irl_id))){ |
| 6732 |
MARPA_ERROR(MARPA_ERR_INVALID_IRLID); |
| 6733 |
return failure_indicator; |
| 6734 |
} |
| 6735 |
/*:1239*/ |
| 6736 |
#line 2949 "./marpa.w" |
| 6737 |
|
| 6738 |
irl= IRL_by_ID(irl_id); |
| 6739 |
if(Length_of_IRL(irl)<=ix)return-1; |
| 6740 |
return RHSID_of_IRL(irl,ix); |
| 6741 |
} |
| 6742 |
|
| 6743 |
/*:335*//*337:*/ |
| 6744 |
#line 2957 "./marpa.w" |
| 6745 |
|
| 6746 |
int _marpa_g_irl_length(Marpa_Grammar g,Marpa_IRL_ID irl_id){ |
| 6747 |
/*1230:*/ |
| 6748 |
#line 14864 "./marpa.w" |
| 6749 |
const int failure_indicator= -2; |
| 6750 |
|
| 6751 |
/*:1230*/ |
| 6752 |
#line 2959 "./marpa.w" |
| 6753 |
|
| 6754 |
/*1250:*/ |
| 6755 |
#line 14997 "./marpa.w" |
| 6756 |
|
| 6757 |
if(HEADER_VERSION_MISMATCH){ |
| 6758 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 6759 |
return failure_indicator; |
| 6760 |
} |
| 6761 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 6762 |
MARPA_ERROR(g->t_error); |
| 6763 |
return failure_indicator; |
| 6764 |
} |
| 6765 |
|
| 6766 |
/*:1250*/ |
| 6767 |
#line 2960 "./marpa.w" |
| 6768 |
|
| 6769 |
/*1232:*/ |
| 6770 |
#line 14875 "./marpa.w" |
| 6771 |
|
| 6772 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6773 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6774 |
return failure_indicator; |
| 6775 |
} |
| 6776 |
/*:1232*/ |
| 6777 |
#line 2961 "./marpa.w" |
| 6778 |
|
| 6779 |
/*1239:*/ |
| 6780 |
#line 14916 "./marpa.w" |
| 6781 |
|
| 6782 |
if(_MARPA_UNLIKELY(!IRLID_of_G_is_Valid(irl_id))){ |
| 6783 |
MARPA_ERROR(MARPA_ERR_INVALID_IRLID); |
| 6784 |
return failure_indicator; |
| 6785 |
} |
| 6786 |
/*:1239*/ |
| 6787 |
#line 2962 "./marpa.w" |
| 6788 |
|
| 6789 |
return Length_of_IRL(IRL_by_ID(irl_id)); |
| 6790 |
} |
| 6791 |
|
| 6792 |
/*:337*//*343:*/ |
| 6793 |
#line 3007 "./marpa.w" |
| 6794 |
|
| 6795 |
int _marpa_g_irl_is_virtual_lhs( |
| 6796 |
Marpa_Grammar g, |
| 6797 |
Marpa_IRL_ID irl_id) |
| 6798 |
{ |
| 6799 |
/*1230:*/ |
| 6800 |
#line 14864 "./marpa.w" |
| 6801 |
const int failure_indicator= -2; |
| 6802 |
|
| 6803 |
/*:1230*/ |
| 6804 |
#line 3012 "./marpa.w" |
| 6805 |
|
| 6806 |
/*1232:*/ |
| 6807 |
#line 14875 "./marpa.w" |
| 6808 |
|
| 6809 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6810 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6811 |
return failure_indicator; |
| 6812 |
} |
| 6813 |
/*:1232*/ |
| 6814 |
#line 3013 "./marpa.w" |
| 6815 |
|
| 6816 |
/*1239:*/ |
| 6817 |
#line 14916 "./marpa.w" |
| 6818 |
|
| 6819 |
if(_MARPA_UNLIKELY(!IRLID_of_G_is_Valid(irl_id))){ |
| 6820 |
MARPA_ERROR(MARPA_ERR_INVALID_IRLID); |
| 6821 |
return failure_indicator; |
| 6822 |
} |
| 6823 |
/*:1239*/ |
| 6824 |
#line 3014 "./marpa.w" |
| 6825 |
|
| 6826 |
return IRL_has_Virtual_LHS(IRL_by_ID(irl_id)); |
| 6827 |
} |
| 6828 |
|
| 6829 |
/*:343*//*346:*/ |
| 6830 |
#line 3023 "./marpa.w" |
| 6831 |
|
| 6832 |
int _marpa_g_irl_is_virtual_rhs( |
| 6833 |
Marpa_Grammar g, |
| 6834 |
Marpa_IRL_ID irl_id) |
| 6835 |
{ |
| 6836 |
/*1230:*/ |
| 6837 |
#line 14864 "./marpa.w" |
| 6838 |
const int failure_indicator= -2; |
| 6839 |
|
| 6840 |
/*:1230*/ |
| 6841 |
#line 3028 "./marpa.w" |
| 6842 |
|
| 6843 |
/*1232:*/ |
| 6844 |
#line 14875 "./marpa.w" |
| 6845 |
|
| 6846 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6847 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6848 |
return failure_indicator; |
| 6849 |
} |
| 6850 |
/*:1232*/ |
| 6851 |
#line 3029 "./marpa.w" |
| 6852 |
|
| 6853 |
/*1239:*/ |
| 6854 |
#line 14916 "./marpa.w" |
| 6855 |
|
| 6856 |
if(_MARPA_UNLIKELY(!IRLID_of_G_is_Valid(irl_id))){ |
| 6857 |
MARPA_ERROR(MARPA_ERR_INVALID_IRLID); |
| 6858 |
return failure_indicator; |
| 6859 |
} |
| 6860 |
/*:1239*/ |
| 6861 |
#line 3030 "./marpa.w" |
| 6862 |
|
| 6863 |
return IRL_has_Virtual_RHS(IRL_by_ID(irl_id)); |
| 6864 |
} |
| 6865 |
|
| 6866 |
/*:346*//*352:*/ |
| 6867 |
#line 3052 "./marpa.w" |
| 6868 |
|
| 6869 |
int _marpa_g_real_symbol_count( |
| 6870 |
Marpa_Grammar g, |
| 6871 |
Marpa_IRL_ID irl_id) |
| 6872 |
{ |
| 6873 |
/*1230:*/ |
| 6874 |
#line 14864 "./marpa.w" |
| 6875 |
const int failure_indicator= -2; |
| 6876 |
|
| 6877 |
/*:1230*/ |
| 6878 |
#line 3057 "./marpa.w" |
| 6879 |
|
| 6880 |
/*1232:*/ |
| 6881 |
#line 14875 "./marpa.w" |
| 6882 |
|
| 6883 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6884 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6885 |
return failure_indicator; |
| 6886 |
} |
| 6887 |
/*:1232*/ |
| 6888 |
#line 3058 "./marpa.w" |
| 6889 |
|
| 6890 |
/*1239:*/ |
| 6891 |
#line 14916 "./marpa.w" |
| 6892 |
|
| 6893 |
if(_MARPA_UNLIKELY(!IRLID_of_G_is_Valid(irl_id))){ |
| 6894 |
MARPA_ERROR(MARPA_ERR_INVALID_IRLID); |
| 6895 |
return failure_indicator; |
| 6896 |
} |
| 6897 |
/*:1239*/ |
| 6898 |
#line 3059 "./marpa.w" |
| 6899 |
|
| 6900 |
return Real_SYM_Count_of_IRL(IRL_by_ID(irl_id)); |
| 6901 |
} |
| 6902 |
|
| 6903 |
/*:352*//*355:*/ |
| 6904 |
#line 3070 "./marpa.w" |
| 6905 |
|
| 6906 |
int _marpa_g_virtual_start( |
| 6907 |
Marpa_Grammar g, |
| 6908 |
Marpa_IRL_ID irl_id) |
| 6909 |
{ |
| 6910 |
IRL irl; |
| 6911 |
/*1230:*/ |
| 6912 |
#line 14864 "./marpa.w" |
| 6913 |
const int failure_indicator= -2; |
| 6914 |
|
| 6915 |
/*:1230*/ |
| 6916 |
#line 3076 "./marpa.w" |
| 6917 |
|
| 6918 |
/*1232:*/ |
| 6919 |
#line 14875 "./marpa.w" |
| 6920 |
|
| 6921 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6922 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6923 |
return failure_indicator; |
| 6924 |
} |
| 6925 |
/*:1232*/ |
| 6926 |
#line 3077 "./marpa.w" |
| 6927 |
|
| 6928 |
/*1239:*/ |
| 6929 |
#line 14916 "./marpa.w" |
| 6930 |
|
| 6931 |
if(_MARPA_UNLIKELY(!IRLID_of_G_is_Valid(irl_id))){ |
| 6932 |
MARPA_ERROR(MARPA_ERR_INVALID_IRLID); |
| 6933 |
return failure_indicator; |
| 6934 |
} |
| 6935 |
/*:1239*/ |
| 6936 |
#line 3078 "./marpa.w" |
| 6937 |
|
| 6938 |
irl= IRL_by_ID(irl_id); |
| 6939 |
return Virtual_Start_of_IRL(irl); |
| 6940 |
} |
| 6941 |
|
| 6942 |
/*:355*//*358:*/ |
| 6943 |
#line 3090 "./marpa.w" |
| 6944 |
|
| 6945 |
int _marpa_g_virtual_end( |
| 6946 |
Marpa_Grammar g, |
| 6947 |
Marpa_IRL_ID irl_id) |
| 6948 |
{ |
| 6949 |
IRL irl; |
| 6950 |
/*1230:*/ |
| 6951 |
#line 14864 "./marpa.w" |
| 6952 |
const int failure_indicator= -2; |
| 6953 |
|
| 6954 |
/*:1230*/ |
| 6955 |
#line 3096 "./marpa.w" |
| 6956 |
|
| 6957 |
/*1232:*/ |
| 6958 |
#line 14875 "./marpa.w" |
| 6959 |
|
| 6960 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 6961 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 6962 |
return failure_indicator; |
| 6963 |
} |
| 6964 |
/*:1232*/ |
| 6965 |
#line 3097 "./marpa.w" |
| 6966 |
|
| 6967 |
/*1239:*/ |
| 6968 |
#line 14916 "./marpa.w" |
| 6969 |
|
| 6970 |
if(_MARPA_UNLIKELY(!IRLID_of_G_is_Valid(irl_id))){ |
| 6971 |
MARPA_ERROR(MARPA_ERR_INVALID_IRLID); |
| 6972 |
return failure_indicator; |
| 6973 |
} |
| 6974 |
/*:1239*/ |
| 6975 |
#line 3098 "./marpa.w" |
| 6976 |
|
| 6977 |
irl= IRL_by_ID(irl_id); |
| 6978 |
return Virtual_End_of_IRL(irl); |
| 6979 |
} |
| 6980 |
|
| 6981 |
/*:358*//*361:*/ |
| 6982 |
#line 3112 "./marpa.w" |
| 6983 |
|
| 6984 |
Marpa_Rule_ID _marpa_g_source_xrl( |
| 6985 |
Marpa_Grammar g, |
| 6986 |
Marpa_IRL_ID irl_id) |
| 6987 |
{ |
| 6988 |
XRL source_xrl; |
| 6989 |
/*1230:*/ |
| 6990 |
#line 14864 "./marpa.w" |
| 6991 |
const int failure_indicator= -2; |
| 6992 |
|
| 6993 |
/*:1230*/ |
| 6994 |
#line 3118 "./marpa.w" |
| 6995 |
|
| 6996 |
/*1239:*/ |
| 6997 |
#line 14916 "./marpa.w" |
| 6998 |
|
| 6999 |
if(_MARPA_UNLIKELY(!IRLID_of_G_is_Valid(irl_id))){ |
| 7000 |
MARPA_ERROR(MARPA_ERR_INVALID_IRLID); |
| 7001 |
return failure_indicator; |
| 7002 |
} |
| 7003 |
/*:1239*/ |
| 7004 |
#line 3119 "./marpa.w" |
| 7005 |
|
| 7006 |
source_xrl= Source_XRL_of_IRL(IRL_by_ID(irl_id)); |
| 7007 |
return source_xrl?ID_of_XRL(source_xrl):-1; |
| 7008 |
} |
| 7009 |
|
| 7010 |
/*:361*//*364:*/ |
| 7011 |
#line 3140 "./marpa.w" |
| 7012 |
|
| 7013 |
Marpa_Rank _marpa_g_irl_rank( |
| 7014 |
Marpa_Grammar g, |
| 7015 |
Marpa_IRL_ID irl_id) |
| 7016 |
{ |
| 7017 |
/*1230:*/ |
| 7018 |
#line 14864 "./marpa.w" |
| 7019 |
const int failure_indicator= -2; |
| 7020 |
|
| 7021 |
/*:1230*/ |
| 7022 |
#line 3145 "./marpa.w" |
| 7023 |
|
| 7024 |
/*1239:*/ |
| 7025 |
#line 14916 "./marpa.w" |
| 7026 |
|
| 7027 |
if(_MARPA_UNLIKELY(!IRLID_of_G_is_Valid(irl_id))){ |
| 7028 |
MARPA_ERROR(MARPA_ERR_INVALID_IRLID); |
| 7029 |
return failure_indicator; |
| 7030 |
} |
| 7031 |
/*:1239*/ |
| 7032 |
#line 3146 "./marpa.w" |
| 7033 |
|
| 7034 |
return Rank_of_IRL(IRL_by_ID(irl_id)); |
| 7035 |
} |
| 7036 |
|
| 7037 |
/*:364*//*368:*/ |
| 7038 |
#line 3180 "./marpa.w" |
| 7039 |
|
| 7040 |
int marpa_g_precompute(Marpa_Grammar g) |
| 7041 |
{ |
| 7042 |
/*1230:*/ |
| 7043 |
#line 14864 "./marpa.w" |
| 7044 |
const int failure_indicator= -2; |
| 7045 |
|
| 7046 |
/*:1230*/ |
| 7047 |
#line 3183 "./marpa.w" |
| 7048 |
|
| 7049 |
int return_value= failure_indicator; |
| 7050 |
struct marpa_obstack*obs_precompute= marpa_obs_init; |
| 7051 |
/*373:*/ |
| 7052 |
#line 3307 "./marpa.w" |
| 7053 |
|
| 7054 |
XRLID xrl_count= XRL_Count_of_G(g); |
| 7055 |
XSYID pre_census_xsy_count= XSY_Count_of_G(g); |
| 7056 |
XSYID post_census_xsy_count= -1; |
| 7057 |
|
| 7058 |
/*:373*//*377:*/ |
| 7059 |
#line 3341 "./marpa.w" |
| 7060 |
|
| 7061 |
XSYID start_xsy_id= g->t_start_xsy_id; |
| 7062 |
|
| 7063 |
/*:377*//*390:*/ |
| 7064 |
#line 3644 "./marpa.w" |
| 7065 |
|
| 7066 |
Bit_Matrix reach_matrix= NULL; |
| 7067 |
|
| 7068 |
/*:390*/ |
| 7069 |
#line 3186 "./marpa.w" |
| 7070 |
|
| 7071 |
/*1250:*/ |
| 7072 |
#line 14997 "./marpa.w" |
| 7073 |
|
| 7074 |
if(HEADER_VERSION_MISMATCH){ |
| 7075 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 7076 |
return failure_indicator; |
| 7077 |
} |
| 7078 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 7079 |
MARPA_ERROR(g->t_error); |
| 7080 |
return failure_indicator; |
| 7081 |
} |
| 7082 |
|
| 7083 |
/*:1250*/ |
| 7084 |
#line 3187 "./marpa.w" |
| 7085 |
|
| 7086 |
G_EVENTS_CLEAR(g); |
| 7087 |
/*374:*/ |
| 7088 |
#line 3312 "./marpa.w" |
| 7089 |
|
| 7090 |
if(_MARPA_UNLIKELY(xrl_count<=0)){ |
| 7091 |
MARPA_ERROR(MARPA_ERR_NO_RULES); |
| 7092 |
goto FAILURE; |
| 7093 |
} |
| 7094 |
|
| 7095 |
/*:374*/ |
| 7096 |
#line 3189 "./marpa.w" |
| 7097 |
|
| 7098 |
/*1231:*/ |
| 7099 |
#line 14869 "./marpa.w" |
| 7100 |
|
| 7101 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 7102 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 7103 |
return failure_indicator; |
| 7104 |
} |
| 7105 |
|
| 7106 |
/*:1231*/ |
| 7107 |
#line 3190 "./marpa.w" |
| 7108 |
|
| 7109 |
/*376:*/ |
| 7110 |
#line 3322 "./marpa.w" |
| 7111 |
|
| 7112 |
{ |
| 7113 |
if(_MARPA_UNLIKELY(start_xsy_id<0)) |
| 7114 |
{ |
| 7115 |
MARPA_ERROR(MARPA_ERR_NO_START_SYMBOL); |
| 7116 |
goto FAILURE; |
| 7117 |
} |
| 7118 |
if(_MARPA_UNLIKELY(!xsy_id_is_valid(g,start_xsy_id))) |
| 7119 |
{ |
| 7120 |
MARPA_ERROR(MARPA_ERR_INVALID_START_SYMBOL); |
| 7121 |
goto FAILURE; |
| 7122 |
} |
| 7123 |
if(_MARPA_UNLIKELY(!XSY_is_LHS(XSY_by_ID(start_xsy_id)))) |
| 7124 |
{ |
| 7125 |
MARPA_ERROR(MARPA_ERR_START_NOT_LHS); |
| 7126 |
goto FAILURE; |
| 7127 |
} |
| 7128 |
} |
| 7129 |
|
| 7130 |
/*:376*/ |
| 7131 |
#line 3191 "./marpa.w" |
| 7132 |
|
| 7133 |
|
| 7134 |
|
| 7135 |
|
| 7136 |
|
| 7137 |
/*122:*/ |
| 7138 |
#line 1126 "./marpa.w" |
| 7139 |
|
| 7140 |
{ |
| 7141 |
_marpa_avl_destroy((g)->t_xrl_tree); |
| 7142 |
(g)->t_xrl_tree= NULL; |
| 7143 |
} |
| 7144 |
/*:122*/ |
| 7145 |
#line 3196 "./marpa.w" |
| 7146 |
|
| 7147 |
|
| 7148 |
|
| 7149 |
|
| 7150 |
{ |
| 7151 |
/*382:*/ |
| 7152 |
#line 3523 "./marpa.w" |
| 7153 |
|
| 7154 |
Bit_Vector terminal_v= NULL; |
| 7155 |
|
| 7156 |
/*:382*//*383:*/ |
| 7157 |
#line 3526 "./marpa.w" |
| 7158 |
|
| 7159 |
Bit_Vector lhs_v= NULL; |
| 7160 |
Bit_Vector empty_lhs_v= NULL; |
| 7161 |
|
| 7162 |
/*:383*//*384:*/ |
| 7163 |
#line 3531 "./marpa.w" |
| 7164 |
|
| 7165 |
RULEID**xrl_list_x_rh_sym= NULL; |
| 7166 |
RULEID**xrl_list_x_lh_sym= NULL; |
| 7167 |
|
| 7168 |
/*:384*//*388:*/ |
| 7169 |
#line 3590 "./marpa.w" |
| 7170 |
|
| 7171 |
Bit_Vector productive_v= NULL; |
| 7172 |
Bit_Vector nullable_v= NULL; |
| 7173 |
|
| 7174 |
/*:388*/ |
| 7175 |
#line 3201 "./marpa.w" |
| 7176 |
|
| 7177 |
/*372:*/ |
| 7178 |
#line 3292 "./marpa.w" |
| 7179 |
|
| 7180 |
{ |
| 7181 |
/*380:*/ |
| 7182 |
#line 3365 "./marpa.w" |
| 7183 |
|
| 7184 |
{ |
| 7185 |
Marpa_Rule_ID rule_id; |
| 7186 |
|
| 7187 |
|
| 7188 |
|
| 7189 |
const MARPA_AVL_TREE rhs_avl_tree= _marpa_avl_create(sym_rule_cmp,NULL); |
| 7190 |
|
| 7191 |
|
| 7192 |
struct sym_rule_pair*const p_rh_sym_rule_pair_base= |
| 7193 |
marpa_obs_new(MARPA_AVL_OBSTACK(rhs_avl_tree),struct sym_rule_pair, |
| 7194 |
(size_t)External_Size_of_G(g)); |
| 7195 |
struct sym_rule_pair*p_rh_sym_rule_pairs= p_rh_sym_rule_pair_base; |
| 7196 |
|
| 7197 |
|
| 7198 |
|
| 7199 |
const MARPA_AVL_TREE lhs_avl_tree= _marpa_avl_create(sym_rule_cmp,NULL); |
| 7200 |
struct sym_rule_pair*const p_lh_sym_rule_pair_base= |
| 7201 |
marpa_obs_new(MARPA_AVL_OBSTACK(lhs_avl_tree),struct sym_rule_pair, |
| 7202 |
(size_t)xrl_count); |
| 7203 |
struct sym_rule_pair*p_lh_sym_rule_pairs= p_lh_sym_rule_pair_base; |
| 7204 |
|
| 7205 |
lhs_v= bv_obs_create(obs_precompute,pre_census_xsy_count); |
| 7206 |
empty_lhs_v= bv_obs_shadow(obs_precompute,lhs_v); |
| 7207 |
for(rule_id= 0;rule_id<xrl_count;rule_id++) |
| 7208 |
{ |
| 7209 |
const XRL rule= XRL_by_ID(rule_id); |
| 7210 |
const Marpa_Symbol_ID lhs_id= LHS_ID_of_RULE(rule); |
| 7211 |
const int rule_length= Length_of_XRL(rule); |
| 7212 |
const int is_sequence= XRL_is_Sequence(rule); |
| 7213 |
|
| 7214 |
bv_bit_set(lhs_v,lhs_id); |
| 7215 |
|
| 7216 |
|
| 7217 |
|
| 7218 |
p_lh_sym_rule_pairs->t_symid= lhs_id; |
| 7219 |
p_lh_sym_rule_pairs->t_ruleid= rule_id; |
| 7220 |
_marpa_avl_insert(lhs_avl_tree,p_lh_sym_rule_pairs); |
| 7221 |
p_lh_sym_rule_pairs++; |
| 7222 |
|
| 7223 |
if(is_sequence) |
| 7224 |
{ |
| 7225 |
const XSYID separator_id= Separator_of_XRL(rule); |
| 7226 |
if(Minimum_of_XRL(rule)<=0) |
| 7227 |
{ |
| 7228 |
bv_bit_set(empty_lhs_v,lhs_id); |
| 7229 |
} |
| 7230 |
if(separator_id>=0){ |
| 7231 |
p_rh_sym_rule_pairs->t_symid= separator_id; |
| 7232 |
p_rh_sym_rule_pairs->t_ruleid= rule_id; |
| 7233 |
_marpa_avl_insert(rhs_avl_tree,p_rh_sym_rule_pairs); |
| 7234 |
p_rh_sym_rule_pairs++; |
| 7235 |
} |
| 7236 |
} |
| 7237 |
|
| 7238 |
if(rule_length<=0) |
| 7239 |
{ |
| 7240 |
bv_bit_set(empty_lhs_v,lhs_id); |
| 7241 |
} |
| 7242 |
else |
| 7243 |
{ |
| 7244 |
int rhs_ix; |
| 7245 |
for(rhs_ix= 0;rhs_ix<rule_length;rhs_ix++) |
| 7246 |
{ |
| 7247 |
p_rh_sym_rule_pairs->t_symid= RHS_ID_of_RULE(rule,rhs_ix); |
| 7248 |
p_rh_sym_rule_pairs->t_ruleid= rule_id; |
| 7249 |
_marpa_avl_insert(rhs_avl_tree,p_rh_sym_rule_pairs); |
| 7250 |
p_rh_sym_rule_pairs++; |
| 7251 |
} |
| 7252 |
} |
| 7253 |
} |
| 7254 |
{ |
| 7255 |
MARPA_AVL_TRAV traverser; |
| 7256 |
struct sym_rule_pair*pair; |
| 7257 |
XSYID seen_symid= -1; |
| 7258 |
RULEID*const rule_data_base= |
| 7259 |
marpa_obs_new(obs_precompute,RULEID,(size_t)External_Size_of_G(g)); |
| 7260 |
RULEID*p_rule_data= rule_data_base; |
| 7261 |
traverser= _marpa_avl_t_init(rhs_avl_tree); |
| 7262 |
|
| 7263 |
|
| 7264 |
|
| 7265 |
xrl_list_x_rh_sym= |
| 7266 |
marpa_obs_new(obs_precompute,RULEID*,(size_t)pre_census_xsy_count+1); |
| 7267 |
for(pair= _marpa_avl_t_first(traverser);pair; |
| 7268 |
pair= (struct sym_rule_pair*)_marpa_avl_t_next(traverser)) |
| 7269 |
{ |
| 7270 |
const XSYID current_symid= pair->t_symid; |
| 7271 |
while(seen_symid<current_symid) |
| 7272 |
xrl_list_x_rh_sym[++seen_symid]= p_rule_data; |
| 7273 |
*p_rule_data++= pair->t_ruleid; |
| 7274 |
} |
| 7275 |
while(++seen_symid<=pre_census_xsy_count) |
| 7276 |
xrl_list_x_rh_sym[seen_symid]= p_rule_data; |
| 7277 |
_marpa_avl_destroy(rhs_avl_tree); |
| 7278 |
} |
| 7279 |
|
| 7280 |
{ |
| 7281 |
MARPA_AVL_TRAV traverser; |
| 7282 |
struct sym_rule_pair*pair; |
| 7283 |
XSYID seen_symid= -1; |
| 7284 |
RULEID*const rule_data_base= |
| 7285 |
marpa_obs_new(obs_precompute,RULEID,(size_t)xrl_count); |
| 7286 |
RULEID*p_rule_data= rule_data_base; |
| 7287 |
traverser= _marpa_avl_t_init(lhs_avl_tree); |
| 7288 |
|
| 7289 |
|
| 7290 |
xrl_list_x_lh_sym= |
| 7291 |
marpa_obs_new(obs_precompute,RULEID*,(size_t)pre_census_xsy_count+1); |
| 7292 |
for(pair= _marpa_avl_t_first(traverser);pair; |
| 7293 |
pair= (struct sym_rule_pair*)_marpa_avl_t_next(traverser)) |
| 7294 |
{ |
| 7295 |
const XSYID current_symid= pair->t_symid; |
| 7296 |
while(seen_symid<current_symid) |
| 7297 |
xrl_list_x_lh_sym[++seen_symid]= p_rule_data; |
| 7298 |
*p_rule_data++= pair->t_ruleid; |
| 7299 |
} |
| 7300 |
while(++seen_symid<=pre_census_xsy_count) |
| 7301 |
xrl_list_x_lh_sym[seen_symid]= p_rule_data; |
| 7302 |
_marpa_avl_destroy(lhs_avl_tree); |
| 7303 |
} |
| 7304 |
|
| 7305 |
} |
| 7306 |
|
| 7307 |
/*:380*/ |
| 7308 |
#line 3294 "./marpa.w" |
| 7309 |
|
| 7310 |
/*381:*/ |
| 7311 |
#line 3492 "./marpa.w" |
| 7312 |
|
| 7313 |
{ |
| 7314 |
XSYID symid; |
| 7315 |
terminal_v= bv_obs_create(obs_precompute,pre_census_xsy_count); |
| 7316 |
bv_not(terminal_v,lhs_v); |
| 7317 |
for(symid= 0;symid<pre_census_xsy_count;symid++) |
| 7318 |
{ |
| 7319 |
XSY symbol= XSY_by_ID(symid); |
| 7320 |
|
| 7321 |
|
| 7322 |
|
| 7323 |
if(XSY_is_Locked_Terminal(symbol)) |
| 7324 |
{ |
| 7325 |
if(XSY_is_Terminal(symbol)) |
| 7326 |
{ |
| 7327 |
bv_bit_set(terminal_v,symid); |
| 7328 |
continue; |
| 7329 |
} |
| 7330 |
bv_bit_clear(terminal_v,symid); |
| 7331 |
continue; |
| 7332 |
} |
| 7333 |
|
| 7334 |
|
| 7335 |
|
| 7336 |
|
| 7337 |
if(bv_bit_test(terminal_v,symid)) |
| 7338 |
XSY_is_Terminal(symbol)= 1; |
| 7339 |
} |
| 7340 |
} |
| 7341 |
|
| 7342 |
/*:381*/ |
| 7343 |
#line 3295 "./marpa.w" |
| 7344 |
|
| 7345 |
/*389:*/ |
| 7346 |
#line 3612 "./marpa.w" |
| 7347 |
|
| 7348 |
{ |
| 7349 |
XRLID rule_id; |
| 7350 |
reach_matrix= |
| 7351 |
matrix_obs_create(obs_precompute,pre_census_xsy_count, |
| 7352 |
pre_census_xsy_count); |
| 7353 |
for(rule_id= 0;rule_id<xrl_count;rule_id++) |
| 7354 |
{ |
| 7355 |
XRL rule= XRL_by_ID(rule_id); |
| 7356 |
XSYID lhs_id= LHS_ID_of_RULE(rule); |
| 7357 |
int rhs_ix; |
| 7358 |
int rule_length= Length_of_XRL(rule); |
| 7359 |
for(rhs_ix= 0;rhs_ix<rule_length;rhs_ix++) |
| 7360 |
{ |
| 7361 |
matrix_bit_set(reach_matrix, |
| 7362 |
lhs_id, |
| 7363 |
RHS_ID_of_RULE(rule,rhs_ix)); |
| 7364 |
} |
| 7365 |
if(XRL_is_Sequence(rule)) |
| 7366 |
{ |
| 7367 |
const XSYID separator_id= Separator_of_XRL(rule); |
| 7368 |
if(separator_id>=0) |
| 7369 |
{ |
| 7370 |
matrix_bit_set(reach_matrix, |
| 7371 |
lhs_id, |
| 7372 |
separator_id); |
| 7373 |
} |
| 7374 |
} |
| 7375 |
} |
| 7376 |
transitive_closure(reach_matrix); |
| 7377 |
} |
| 7378 |
|
| 7379 |
/*:389*/ |
| 7380 |
#line 3296 "./marpa.w" |
| 7381 |
|
| 7382 |
/*385:*/ |
| 7383 |
#line 3535 "./marpa.w" |
| 7384 |
|
| 7385 |
{ |
| 7386 |
int min,max,start; |
| 7387 |
XSYID xsy_id; |
| 7388 |
int counted_nullables= 0; |
| 7389 |
nullable_v= bv_obs_clone(obs_precompute,empty_lhs_v); |
| 7390 |
rhs_closure(g,nullable_v,xrl_list_x_rh_sym); |
| 7391 |
for(start= 0;bv_scan(nullable_v,start,&min,&max);start= max+2) |
| 7392 |
{ |
| 7393 |
for(xsy_id= min;xsy_id<=max; |
| 7394 |
xsy_id++) |
| 7395 |
{ |
| 7396 |
XSY xsy= XSY_by_ID(xsy_id); |
| 7397 |
XSY_is_Nullable(xsy)= 1; |
| 7398 |
if(_MARPA_UNLIKELY(xsy->t_is_counted)) |
| 7399 |
{ |
| 7400 |
counted_nullables++; |
| 7401 |
int_event_new(g,MARPA_EVENT_COUNTED_NULLABLE,xsy_id); |
| 7402 |
} |
| 7403 |
} |
| 7404 |
} |
| 7405 |
if(_MARPA_UNLIKELY(counted_nullables)) |
| 7406 |
{ |
| 7407 |
MARPA_ERROR(MARPA_ERR_COUNTED_NULLABLE); |
| 7408 |
goto FAILURE; |
| 7409 |
} |
| 7410 |
} |
| 7411 |
|
| 7412 |
/*:385*/ |
| 7413 |
#line 3297 "./marpa.w" |
| 7414 |
|
| 7415 |
/*386:*/ |
| 7416 |
#line 3563 "./marpa.w" |
| 7417 |
|
| 7418 |
{ |
| 7419 |
productive_v= bv_obs_shadow(obs_precompute,nullable_v); |
| 7420 |
bv_or(productive_v,nullable_v,terminal_v); |
| 7421 |
rhs_closure(g,productive_v,xrl_list_x_rh_sym); |
| 7422 |
{ |
| 7423 |
int min,max,start; |
| 7424 |
XSYID symid; |
| 7425 |
for(start= 0;bv_scan(productive_v,start,&min,&max); |
| 7426 |
start= max+2) |
| 7427 |
{ |
| 7428 |
for(symid= min; |
| 7429 |
symid<=max;symid++) |
| 7430 |
{ |
| 7431 |
XSY symbol= XSY_by_ID(symid); |
| 7432 |
symbol->t_is_productive= 1; |
| 7433 |
} |
| 7434 |
} |
| 7435 |
} |
| 7436 |
} |
| 7437 |
|
| 7438 |
/*:386*/ |
| 7439 |
#line 3298 "./marpa.w" |
| 7440 |
|
| 7441 |
/*387:*/ |
| 7442 |
#line 3584 "./marpa.w" |
| 7443 |
|
| 7444 |
if(_MARPA_UNLIKELY(!bv_bit_test(productive_v,start_xsy_id))) |
| 7445 |
{ |
| 7446 |
MARPA_ERROR(MARPA_ERR_UNPRODUCTIVE_START); |
| 7447 |
goto FAILURE; |
| 7448 |
} |
| 7449 |
/*:387*/ |
| 7450 |
#line 3299 "./marpa.w" |
| 7451 |
|
| 7452 |
/*391:*/ |
| 7453 |
#line 3649 "./marpa.w" |
| 7454 |
|
| 7455 |
{ |
| 7456 |
Bit_Vector accessible_v= |
| 7457 |
matrix_row(reach_matrix,start_xsy_id); |
| 7458 |
int min,max,start; |
| 7459 |
XSYID symid; |
| 7460 |
for(start= 0;bv_scan(accessible_v,start,&min,&max);start= max+2) |
| 7461 |
{ |
| 7462 |
for(symid= min; |
| 7463 |
symid<=max;symid++) |
| 7464 |
{ |
| 7465 |
XSY symbol= XSY_by_ID(symid); |
| 7466 |
symbol->t_is_accessible= 1; |
| 7467 |
} |
| 7468 |
} |
| 7469 |
XSY_by_ID(start_xsy_id)->t_is_accessible= 1; |
| 7470 |
} |
| 7471 |
|
| 7472 |
/*:391*/ |
| 7473 |
#line 3300 "./marpa.w" |
| 7474 |
|
| 7475 |
/*392:*/ |
| 7476 |
#line 3669 "./marpa.w" |
| 7477 |
|
| 7478 |
{ |
| 7479 |
Bit_Vector reaches_terminal_v= bv_shadow(terminal_v); |
| 7480 |
int nulling_terminal_found= 0; |
| 7481 |
int min,max,start; |
| 7482 |
for(start= 0;bv_scan(lhs_v,start,&min,&max);start= max+2) |
| 7483 |
{ |
| 7484 |
XSYID productive_id; |
| 7485 |
for(productive_id= min; |
| 7486 |
productive_id<=max;productive_id++) |
| 7487 |
{ |
| 7488 |
bv_and(reaches_terminal_v,terminal_v, |
| 7489 |
matrix_row(reach_matrix,productive_id)); |
| 7490 |
if(bv_is_empty(reaches_terminal_v)) |
| 7491 |
{ |
| 7492 |
const XSY symbol= XSY_by_ID(productive_id); |
| 7493 |
XSY_is_Nulling(symbol)= 1; |
| 7494 |
if(_MARPA_UNLIKELY(XSY_is_Terminal(symbol))) |
| 7495 |
{ |
| 7496 |
nulling_terminal_found= 1; |
| 7497 |
int_event_new(g,MARPA_EVENT_NULLING_TERMINAL, |
| 7498 |
productive_id); |
| 7499 |
} |
| 7500 |
} |
| 7501 |
} |
| 7502 |
} |
| 7503 |
bv_free(reaches_terminal_v); |
| 7504 |
if(_MARPA_UNLIKELY(nulling_terminal_found)) |
| 7505 |
{ |
| 7506 |
MARPA_ERROR(MARPA_ERR_NULLING_TERMINAL); |
| 7507 |
goto FAILURE; |
| 7508 |
} |
| 7509 |
} |
| 7510 |
|
| 7511 |
/*:392*/ |
| 7512 |
#line 3301 "./marpa.w" |
| 7513 |
|
| 7514 |
/*393:*/ |
| 7515 |
#line 3708 "./marpa.w" |
| 7516 |
|
| 7517 |
{ |
| 7518 |
XRLID xrl_id; |
| 7519 |
for(xrl_id= 0;xrl_id<xrl_count;xrl_id++) |
| 7520 |
{ |
| 7521 |
const XRL xrl= XRL_by_ID(xrl_id); |
| 7522 |
const XSYID lhs_id= LHS_ID_of_XRL(xrl); |
| 7523 |
const XSY lhs= XSY_by_ID(lhs_id); |
| 7524 |
XRL_is_Accessible(xrl)= XSY_is_Accessible(lhs); |
| 7525 |
if(XRL_is_Sequence(xrl)) |
| 7526 |
{ |
| 7527 |
/*395:*/ |
| 7528 |
#line 3759 "./marpa.w" |
| 7529 |
|
| 7530 |
{ |
| 7531 |
const XSYID rhs_id= RHS_ID_of_XRL(xrl,0); |
| 7532 |
const XSY rh_xsy= XSY_by_ID(rhs_id); |
| 7533 |
const XSYID separator_id= Separator_of_XRL(xrl); |
| 7534 |
|
| 7535 |
|
| 7536 |
|
| 7537 |
|
| 7538 |
XRL_is_Nullable(xrl)= Minimum_of_XRL(xrl)<=0 |
| 7539 |
||XSY_is_Nullable(rh_xsy); |
| 7540 |
|
| 7541 |
|
| 7542 |
|
| 7543 |
XRL_is_Nulling(xrl)= XSY_is_Nulling(rh_xsy); |
| 7544 |
|
| 7545 |
|
| 7546 |
|
| 7547 |
|
| 7548 |
XRL_is_Productive(xrl)= XRL_is_Nullable(xrl)||XSY_is_Productive(rh_xsy); |
| 7549 |
|
| 7550 |
|
| 7551 |
|
| 7552 |
XRL_is_Used(xrl)= XRL_is_Accessible(xrl)&&XSY_is_Productive(rh_xsy); |
| 7553 |
|
| 7554 |
|
| 7555 |
|
| 7556 |
if(separator_id>=0) |
| 7557 |
{ |
| 7558 |
const XSY separator_xsy= XSY_by_ID(separator_id); |
| 7559 |
|
| 7560 |
|
| 7561 |
|
| 7562 |
if(!XSY_is_Nulling(separator_xsy)) |
| 7563 |
{ |
| 7564 |
XRL_is_Nulling(xrl)= 0; |
| 7565 |
} |
| 7566 |
|
| 7567 |
|
| 7568 |
|
| 7569 |
|
| 7570 |
if(_MARPA_UNLIKELY(!XSY_is_Productive(separator_xsy))) |
| 7571 |
{ |
| 7572 |
XRL_is_Productive(xrl)= XRL_is_Nullable(xrl); |
| 7573 |
|
| 7574 |
|
| 7575 |
|
| 7576 |
XRL_is_Used(xrl)= 0; |
| 7577 |
} |
| 7578 |
} |
| 7579 |
|
| 7580 |
|
| 7581 |
|
| 7582 |
if(XRL_is_Nulling(xrl))XRL_is_Used(xrl)= 0; |
| 7583 |
} |
| 7584 |
|
| 7585 |
/*:395*/ |
| 7586 |
#line 3719 "./marpa.w" |
| 7587 |
|
| 7588 |
continue; |
| 7589 |
} |
| 7590 |
/*394:*/ |
| 7591 |
#line 3728 "./marpa.w" |
| 7592 |
|
| 7593 |
{ |
| 7594 |
int rh_ix; |
| 7595 |
int is_nulling= 1; |
| 7596 |
int is_nullable= 1; |
| 7597 |
int is_productive= 1; |
| 7598 |
for(rh_ix= 0;rh_ix<Length_of_XRL(xrl);rh_ix++) |
| 7599 |
{ |
| 7600 |
const XSYID rhs_id= RHS_ID_of_XRL(xrl,rh_ix); |
| 7601 |
const XSY rh_xsy= XSY_by_ID(rhs_id); |
| 7602 |
if(_MARPA_LIKELY(!XSY_is_Nulling(rh_xsy))) |
| 7603 |
is_nulling= 0; |
| 7604 |
if(_MARPA_LIKELY(!XSY_is_Nullable(rh_xsy))) |
| 7605 |
is_nullable= 0; |
| 7606 |
if(_MARPA_UNLIKELY(!XSY_is_Productive(rh_xsy))) |
| 7607 |
is_productive= 0; |
| 7608 |
} |
| 7609 |
XRL_is_Nulling(xrl)= Boolean(is_nulling); |
| 7610 |
XRL_is_Nullable(xrl)= Boolean(is_nullable); |
| 7611 |
XRL_is_Productive(xrl)= Boolean(is_productive); |
| 7612 |
XRL_is_Used(xrl)= XRL_is_Accessible(xrl)&&XRL_is_Productive(xrl) |
| 7613 |
&&!XRL_is_Nulling(xrl); |
| 7614 |
} |
| 7615 |
|
| 7616 |
/*:394*/ |
| 7617 |
#line 3722 "./marpa.w" |
| 7618 |
|
| 7619 |
} |
| 7620 |
} |
| 7621 |
|
| 7622 |
/*:393*/ |
| 7623 |
#line 3302 "./marpa.w" |
| 7624 |
|
| 7625 |
/*396:*/ |
| 7626 |
#line 3824 "./marpa.w" |
| 7627 |
|
| 7628 |
if(0) |
| 7629 |
{ |
| 7630 |
|
| 7631 |
|
| 7632 |
|
| 7633 |
|
| 7634 |
XSYID xsy_id; |
| 7635 |
for(xsy_id= 0;xsy_id<pre_census_xsy_count;xsy_id++) |
| 7636 |
{ |
| 7637 |
if(bv_bit_test(terminal_v,xsy_id)&&bv_bit_test(lhs_v,xsy_id)) |
| 7638 |
{ |
| 7639 |
const XSY xsy= XSY_by_ID(xsy_id); |
| 7640 |
if(XSY_is_Valued_Locked(xsy)) |
| 7641 |
continue; |
| 7642 |
XSY_is_Valued(xsy)= 1; |
| 7643 |
XSY_is_Valued_Locked(xsy)= 1; |
| 7644 |
} |
| 7645 |
} |
| 7646 |
} |
| 7647 |
|
| 7648 |
/*:396*/ |
| 7649 |
#line 3303 "./marpa.w" |
| 7650 |
|
| 7651 |
/*397:*/ |
| 7652 |
#line 3853 "./marpa.w" |
| 7653 |
|
| 7654 |
{ |
| 7655 |
XSYID xsyid; |
| 7656 |
XRLID xrlid; |
| 7657 |
|
| 7658 |
|
| 7659 |
int nullable_xsy_count= 0; |
| 7660 |
|
| 7661 |
|
| 7662 |
|
| 7663 |
|
| 7664 |
void*matrix_buffer= my_malloc(matrix_sizeof( |
| 7665 |
pre_census_xsy_count, |
| 7666 |
pre_census_xsy_count)); |
| 7667 |
Bit_Matrix nullification_matrix= |
| 7668 |
matrix_buffer_create(matrix_buffer,pre_census_xsy_count, |
| 7669 |
pre_census_xsy_count); |
| 7670 |
|
| 7671 |
for(xsyid= 0;xsyid<pre_census_xsy_count;xsyid++) |
| 7672 |
{ |
| 7673 |
if(!XSYID_is_Nullable(xsyid)) |
| 7674 |
continue; |
| 7675 |
nullable_xsy_count++; |
| 7676 |
matrix_bit_set(nullification_matrix,xsyid, |
| 7677 |
xsyid); |
| 7678 |
} |
| 7679 |
for(xrlid= 0;xrlid<xrl_count;xrlid++) |
| 7680 |
{ |
| 7681 |
int rh_ix; |
| 7682 |
XRL xrl= XRL_by_ID(xrlid); |
| 7683 |
const XSYID lhs_id= LHS_ID_of_XRL(xrl); |
| 7684 |
if(XRL_is_Nullable(xrl)) |
| 7685 |
{ |
| 7686 |
for(rh_ix= 0;rh_ix<Length_of_XRL(xrl);rh_ix++) |
| 7687 |
{ |
| 7688 |
const XSYID rhs_id= RHS_ID_of_XRL(xrl,rh_ix); |
| 7689 |
matrix_bit_set(nullification_matrix,lhs_id, |
| 7690 |
rhs_id); |
| 7691 |
} |
| 7692 |
} |
| 7693 |
} |
| 7694 |
transitive_closure(nullification_matrix); |
| 7695 |
for(xsyid= 0;xsyid<pre_census_xsy_count;xsyid++) |
| 7696 |
{ |
| 7697 |
Bit_Vector bv_nullifications_by_to_xsy= |
| 7698 |
matrix_row(nullification_matrix,xsyid); |
| 7699 |
Nulled_XSYIDs_of_XSYID(xsyid)= |
| 7700 |
cil_bv_add(&g->t_cilar,bv_nullifications_by_to_xsy); |
| 7701 |
} |
| 7702 |
my_free(matrix_buffer); |
| 7703 |
} |
| 7704 |
|
| 7705 |
/*:397*/ |
| 7706 |
#line 3304 "./marpa.w" |
| 7707 |
|
| 7708 |
} |
| 7709 |
|
| 7710 |
/*:372*/ |
| 7711 |
#line 3202 "./marpa.w" |
| 7712 |
|
| 7713 |
/*448:*/ |
| 7714 |
#line 4728 "./marpa.w" |
| 7715 |
|
| 7716 |
{ |
| 7717 |
int loop_rule_count= 0; |
| 7718 |
Bit_Matrix unit_transition_matrix= |
| 7719 |
matrix_obs_create(obs_precompute,xrl_count, |
| 7720 |
xrl_count); |
| 7721 |
/*449:*/ |
| 7722 |
#line 4749 "./marpa.w" |
| 7723 |
|
| 7724 |
{ |
| 7725 |
Marpa_Rule_ID rule_id; |
| 7726 |
for(rule_id= 0;rule_id<xrl_count;rule_id++) |
| 7727 |
{ |
| 7728 |
XRL rule= XRL_by_ID(rule_id); |
| 7729 |
XSYID nonnullable_id= -1; |
| 7730 |
int nonnullable_count= 0; |
| 7731 |
int rhs_ix,rule_length; |
| 7732 |
rule_length= Length_of_XRL(rule); |
| 7733 |
|
| 7734 |
|
| 7735 |
|
| 7736 |
for(rhs_ix= 0;rhs_ix<rule_length;rhs_ix++) |
| 7737 |
{ |
| 7738 |
XSYID xsy_id= RHS_ID_of_RULE(rule,rhs_ix); |
| 7739 |
if(bv_bit_test(nullable_v,xsy_id)) |
| 7740 |
continue; |
| 7741 |
nonnullable_id= xsy_id; |
| 7742 |
nonnullable_count++; |
| 7743 |
} |
| 7744 |
|
| 7745 |
if(nonnullable_count==1) |
| 7746 |
{ |
| 7747 |
|
| 7748 |
|
| 7749 |
|
| 7750 |
/*450:*/ |
| 7751 |
#line 4804 "./marpa.w" |
| 7752 |
|
| 7753 |
{ |
| 7754 |
RULEID*p_xrl= xrl_list_x_lh_sym[nonnullable_id]; |
| 7755 |
const RULEID*p_one_past_rules= xrl_list_x_lh_sym[nonnullable_id+1]; |
| 7756 |
for(;p_xrl<p_one_past_rules;p_xrl++) |
| 7757 |
{ |
| 7758 |
|
| 7759 |
|
| 7760 |
const RULEID to_rule_id= *p_xrl; |
| 7761 |
matrix_bit_set(unit_transition_matrix,rule_id, |
| 7762 |
to_rule_id); |
| 7763 |
} |
| 7764 |
} |
| 7765 |
|
| 7766 |
/*:450*/ |
| 7767 |
#line 4777 "./marpa.w" |
| 7768 |
|
| 7769 |
} |
| 7770 |
else if(nonnullable_count==0) |
| 7771 |
{ |
| 7772 |
for(rhs_ix= 0;rhs_ix<rule_length;rhs_ix++) |
| 7773 |
{ |
| 7774 |
|
| 7775 |
|
| 7776 |
|
| 7777 |
|
| 7778 |
nonnullable_id= RHS_ID_of_RULE(rule,rhs_ix); |
| 7779 |
|
| 7780 |
if(XSY_is_Nulling(XSY_by_ID(nonnullable_id))) |
| 7781 |
continue; |
| 7782 |
|
| 7783 |
|
| 7784 |
|
| 7785 |
/*450:*/ |
| 7786 |
#line 4804 "./marpa.w" |
| 7787 |
|
| 7788 |
{ |
| 7789 |
RULEID*p_xrl= xrl_list_x_lh_sym[nonnullable_id]; |
| 7790 |
const RULEID*p_one_past_rules= xrl_list_x_lh_sym[nonnullable_id+1]; |
| 7791 |
for(;p_xrl<p_one_past_rules;p_xrl++) |
| 7792 |
{ |
| 7793 |
|
| 7794 |
|
| 7795 |
const RULEID to_rule_id= *p_xrl; |
| 7796 |
matrix_bit_set(unit_transition_matrix,rule_id, |
| 7797 |
to_rule_id); |
| 7798 |
} |
| 7799 |
} |
| 7800 |
|
| 7801 |
/*:450*/ |
| 7802 |
#line 4795 "./marpa.w" |
| 7803 |
|
| 7804 |
} |
| 7805 |
} |
| 7806 |
} |
| 7807 |
} |
| 7808 |
|
| 7809 |
/*:449*/ |
| 7810 |
#line 4734 "./marpa.w" |
| 7811 |
|
| 7812 |
transitive_closure(unit_transition_matrix); |
| 7813 |
/*451:*/ |
| 7814 |
#line 4818 "./marpa.w" |
| 7815 |
|
| 7816 |
{ |
| 7817 |
XRLID rule_id; |
| 7818 |
for(rule_id= 0;rule_id<xrl_count;rule_id++) |
| 7819 |
{ |
| 7820 |
XRL rule; |
| 7821 |
if(!matrix_bit_test |
| 7822 |
(unit_transition_matrix,rule_id, |
| 7823 |
rule_id)) |
| 7824 |
continue; |
| 7825 |
loop_rule_count++; |
| 7826 |
rule= XRL_by_ID(rule_id); |
| 7827 |
rule->t_is_loop= 1; |
| 7828 |
} |
| 7829 |
} |
| 7830 |
|
| 7831 |
/*:451*/ |
| 7832 |
#line 4736 "./marpa.w" |
| 7833 |
|
| 7834 |
if(loop_rule_count) |
| 7835 |
{ |
| 7836 |
g->t_has_cycle= 1; |
| 7837 |
int_event_new(g,MARPA_EVENT_LOOP_RULES,loop_rule_count); |
| 7838 |
} |
| 7839 |
} |
| 7840 |
|
| 7841 |
/*:448*/ |
| 7842 |
#line 3203 "./marpa.w" |
| 7843 |
|
| 7844 |
} |
| 7845 |
|
| 7846 |
|
| 7847 |
|
| 7848 |
/*512:*/ |
| 7849 |
#line 5405 "./marpa.w" |
| 7850 |
|
| 7851 |
MARPA_DSTACK_INIT(g->t_irl_stack,IRL,2*MARPA_DSTACK_CAPACITY(g->t_xrl_stack)); |
| 7852 |
|
| 7853 |
/*:512*/ |
| 7854 |
#line 3208 "./marpa.w" |
| 7855 |
|
| 7856 |
/*513:*/ |
| 7857 |
#line 5413 "./marpa.w" |
| 7858 |
|
| 7859 |
{ |
| 7860 |
MARPA_DSTACK_INIT(g->t_nsy_stack,NSY,2*MARPA_DSTACK_CAPACITY(g->t_xsy_stack)); |
| 7861 |
} |
| 7862 |
|
| 7863 |
/*:513*/ |
| 7864 |
#line 3209 "./marpa.w" |
| 7865 |
|
| 7866 |
/*413:*/ |
| 7867 |
#line 4075 "./marpa.w" |
| 7868 |
|
| 7869 |
{ |
| 7870 |
/*414:*/ |
| 7871 |
#line 4106 "./marpa.w" |
| 7872 |
|
| 7873 |
Marpa_Rule_ID rule_id; |
| 7874 |
int pre_chaf_rule_count; |
| 7875 |
|
| 7876 |
/*:414*//*417:*/ |
| 7877 |
#line 4164 "./marpa.w" |
| 7878 |
|
| 7879 |
int factor_count; |
| 7880 |
int*factor_positions; |
| 7881 |
/*:417*/ |
| 7882 |
#line 4077 "./marpa.w" |
| 7883 |
|
| 7884 |
/*418:*/ |
| 7885 |
#line 4167 "./marpa.w" |
| 7886 |
|
| 7887 |
factor_positions= marpa_obs_new(obs_precompute,int,g->t_max_rule_length); |
| 7888 |
|
| 7889 |
/*:418*/ |
| 7890 |
#line 4078 "./marpa.w" |
| 7891 |
|
| 7892 |
/*415:*/ |
| 7893 |
#line 4112 "./marpa.w" |
| 7894 |
|
| 7895 |
{ |
| 7896 |
XSYID xsy_id; |
| 7897 |
for(xsy_id= 0;xsy_id<pre_census_xsy_count;xsy_id++) |
| 7898 |
{ |
| 7899 |
const XSY xsy_to_clone= XSY_by_ID(xsy_id); |
| 7900 |
if(_MARPA_UNLIKELY(!xsy_to_clone->t_is_accessible)) |
| 7901 |
continue; |
| 7902 |
if(_MARPA_UNLIKELY(!xsy_to_clone->t_is_productive)) |
| 7903 |
continue; |
| 7904 |
NSY_of_XSY(xsy_to_clone)= nsy_clone(g,xsy_to_clone); |
| 7905 |
if(XSY_is_Nulling(xsy_to_clone)) |
| 7906 |
{ |
| 7907 |
Nulling_NSY_of_XSY(xsy_to_clone)= NSY_of_XSY(xsy_to_clone); |
| 7908 |
continue; |
| 7909 |
} |
| 7910 |
if(XSY_is_Nullable(xsy_to_clone)) |
| 7911 |
{ |
| 7912 |
Nulling_NSY_of_XSY(xsy_to_clone)= symbol_alias_create(g,xsy_to_clone); |
| 7913 |
} |
| 7914 |
} |
| 7915 |
} |
| 7916 |
|
| 7917 |
/*:415*/ |
| 7918 |
#line 4079 "./marpa.w" |
| 7919 |
|
| 7920 |
pre_chaf_rule_count= XRL_Count_of_G(g); |
| 7921 |
for(rule_id= 0;rule_id<pre_chaf_rule_count;rule_id++) |
| 7922 |
{ |
| 7923 |
|
| 7924 |
XRL rule= XRL_by_ID(rule_id); |
| 7925 |
XRL rewrite_xrl= rule; |
| 7926 |
const int rewrite_xrl_length= Length_of_XRL(rewrite_xrl); |
| 7927 |
int nullable_suffix_ix= 0; |
| 7928 |
if(!XRL_is_Used(rule)) |
| 7929 |
continue; |
| 7930 |
if(XRL_is_Sequence(rule)) |
| 7931 |
{ |
| 7932 |
/*398:*/ |
| 7933 |
#line 3906 "./marpa.w" |
| 7934 |
|
| 7935 |
{ |
| 7936 |
const XSYID lhs_id= LHS_ID_of_RULE(rule); |
| 7937 |
const NSY lhs_nsy= NSY_by_XSYID(lhs_id); |
| 7938 |
const NSYID lhs_nsyid= ID_of_NSY(lhs_nsy); |
| 7939 |
|
| 7940 |
const NSY internal_lhs_nsy= nsy_new(g,XSY_by_ID(lhs_id)); |
| 7941 |
const NSYID internal_lhs_nsyid= ID_of_NSY(internal_lhs_nsy); |
| 7942 |
|
| 7943 |
const XSYID rhs_id= RHS_ID_of_RULE(rule,0); |
| 7944 |
const NSY rhs_nsy= NSY_by_XSYID(rhs_id); |
| 7945 |
const NSYID rhs_nsyid= ID_of_NSY(rhs_nsy); |
| 7946 |
|
| 7947 |
const XSYID separator_id= Separator_of_XRL(rule); |
| 7948 |
NSYID separator_nsyid= -1; |
| 7949 |
if(separator_id>=0){ |
| 7950 |
const NSY separator_nsy= NSY_by_XSYID(separator_id); |
| 7951 |
separator_nsyid= ID_of_NSY(separator_nsy); |
| 7952 |
} |
| 7953 |
|
| 7954 |
LHS_XRL_of_NSY(internal_lhs_nsy)= rule; |
| 7955 |
/*399:*/ |
| 7956 |
#line 3935 "./marpa.w" |
| 7957 |
|
| 7958 |
{ |
| 7959 |
IRL rewrite_irl= irl_start(g,1); |
| 7960 |
LHSID_of_IRL(rewrite_irl)= lhs_nsyid; |
| 7961 |
RHSID_of_IRL(rewrite_irl,0)= internal_lhs_nsyid; |
| 7962 |
irl_finish(g,rewrite_irl); |
| 7963 |
Source_XRL_of_IRL(rewrite_irl)= rule; |
| 7964 |
Rank_of_IRL(rewrite_irl)= IRL_Rank_by_XRL(rule); |
| 7965 |
|
| 7966 |
IRL_has_Virtual_RHS(rewrite_irl)= 1; |
| 7967 |
} |
| 7968 |
|
| 7969 |
/*:399*/ |
| 7970 |
#line 3927 "./marpa.w" |
| 7971 |
|
| 7972 |
if(separator_nsyid>=0&&!XRL_is_Proper_Separation(rule)){ |
| 7973 |
/*400:*/ |
| 7974 |
#line 3948 "./marpa.w" |
| 7975 |
|
| 7976 |
{ |
| 7977 |
IRL rewrite_irl; |
| 7978 |
rewrite_irl= irl_start(g,2); |
| 7979 |
LHSID_of_IRL(rewrite_irl)= lhs_nsyid; |
| 7980 |
RHSID_of_IRL(rewrite_irl,0)= internal_lhs_nsyid; |
| 7981 |
RHSID_of_IRL(rewrite_irl,1)= separator_nsyid; |
| 7982 |
irl_finish(g,rewrite_irl); |
| 7983 |
Source_XRL_of_IRL(rewrite_irl)= rule; |
| 7984 |
Rank_of_IRL(rewrite_irl)= IRL_Rank_by_XRL(rule); |
| 7985 |
IRL_has_Virtual_RHS(rewrite_irl)= 1; |
| 7986 |
Real_SYM_Count_of_IRL(rewrite_irl)= 1; |
| 7987 |
} |
| 7988 |
|
| 7989 |
/*:400*/ |
| 7990 |
#line 3929 "./marpa.w" |
| 7991 |
|
| 7992 |
} |
| 7993 |
/*401:*/ |
| 7994 |
#line 3965 "./marpa.w" |
| 7995 |
|
| 7996 |
{ |
| 7997 |
const IRL rewrite_irl= irl_start(g,1); |
| 7998 |
LHSID_of_IRL(rewrite_irl)= internal_lhs_nsyid; |
| 7999 |
RHSID_of_IRL(rewrite_irl,0)= rhs_nsyid; |
| 8000 |
irl_finish(g,rewrite_irl); |
| 8001 |
Source_XRL_of_IRL(rewrite_irl)= rule; |
| 8002 |
Rank_of_IRL(rewrite_irl)= IRL_Rank_by_XRL(rule); |
| 8003 |
IRL_has_Virtual_LHS(rewrite_irl)= 1; |
| 8004 |
Real_SYM_Count_of_IRL(rewrite_irl)= 1; |
| 8005 |
} |
| 8006 |
/*:401*/ |
| 8007 |
#line 3931 "./marpa.w" |
| 8008 |
|
| 8009 |
/*402:*/ |
| 8010 |
#line 3976 "./marpa.w" |
| 8011 |
|
| 8012 |
{ |
| 8013 |
IRL rewrite_irl; |
| 8014 |
int rhs_ix= 0; |
| 8015 |
const int length= separator_nsyid>=0?3:2; |
| 8016 |
rewrite_irl= irl_start(g,length); |
| 8017 |
LHSID_of_IRL(rewrite_irl)= internal_lhs_nsyid; |
| 8018 |
RHSID_of_IRL(rewrite_irl,rhs_ix++)= internal_lhs_nsyid; |
| 8019 |
if(separator_nsyid>=0) |
| 8020 |
RHSID_of_IRL(rewrite_irl,rhs_ix++)= separator_nsyid; |
| 8021 |
RHSID_of_IRL(rewrite_irl,rhs_ix)= rhs_nsyid; |
| 8022 |
irl_finish(g,rewrite_irl); |
| 8023 |
Source_XRL_of_IRL(rewrite_irl)= rule; |
| 8024 |
Rank_of_IRL(rewrite_irl)= IRL_Rank_by_XRL(rule); |
| 8025 |
IRL_has_Virtual_LHS(rewrite_irl)= 1; |
| 8026 |
IRL_has_Virtual_RHS(rewrite_irl)= 1; |
| 8027 |
Real_SYM_Count_of_IRL(rewrite_irl)= length-1; |
| 8028 |
} |
| 8029 |
|
| 8030 |
/*:402*/ |
| 8031 |
#line 3932 "./marpa.w" |
| 8032 |
|
| 8033 |
} |
| 8034 |
|
| 8035 |
/*:398*/ |
| 8036 |
#line 4092 "./marpa.w" |
| 8037 |
|
| 8038 |
continue; |
| 8039 |
} |
| 8040 |
/*416:*/ |
| 8041 |
#line 4143 "./marpa.w" |
| 8042 |
|
| 8043 |
{ |
| 8044 |
int rhs_ix; |
| 8045 |
factor_count= 0; |
| 8046 |
for(rhs_ix= 0;rhs_ix<rewrite_xrl_length;rhs_ix++) |
| 8047 |
{ |
| 8048 |
Marpa_Symbol_ID symid= RHS_ID_of_RULE(rule,rhs_ix); |
| 8049 |
XSY symbol= XSY_by_ID(symid); |
| 8050 |
if(XSY_is_Nulling(symbol)) |
| 8051 |
continue; |
| 8052 |
if(XSY_is_Nullable(symbol)) |
| 8053 |
{ |
| 8054 |
|
| 8055 |
factor_positions[factor_count++]= rhs_ix; |
| 8056 |
continue; |
| 8057 |
} |
| 8058 |
nullable_suffix_ix= rhs_ix+1; |
| 8059 |
|
| 8060 |
|
| 8061 |
} |
| 8062 |
} |
| 8063 |
/*:416*/ |
| 8064 |
#line 4095 "./marpa.w" |
| 8065 |
|
| 8066 |
|
| 8067 |
if(factor_count> 0) |
| 8068 |
{ |
| 8069 |
/*419:*/ |
| 8070 |
#line 4171 "./marpa.w" |
| 8071 |
|
| 8072 |
{ |
| 8073 |
const XRL chaf_xrl= rule; |
| 8074 |
|
| 8075 |
|
| 8076 |
int unprocessed_factor_count; |
| 8077 |
|
| 8078 |
int factor_position_ix= 0; |
| 8079 |
NSY current_lhs_nsy= NSY_by_XSYID(LHS_ID_of_RULE(rule)); |
| 8080 |
NSYID current_lhs_nsyid= ID_of_NSY(current_lhs_nsy); |
| 8081 |
|
| 8082 |
|
| 8083 |
int piece_end,piece_start= 0; |
| 8084 |
|
| 8085 |
for(unprocessed_factor_count= factor_count-factor_position_ix; |
| 8086 |
unprocessed_factor_count>=3; |
| 8087 |
unprocessed_factor_count= factor_count-factor_position_ix){ |
| 8088 |
/*422:*/ |
| 8089 |
#line 4207 "./marpa.w" |
| 8090 |
|
| 8091 |
NSY chaf_virtual_nsy; |
| 8092 |
NSYID chaf_virtual_nsyid; |
| 8093 |
int first_factor_position= factor_positions[factor_position_ix]; |
| 8094 |
int second_factor_position= factor_positions[factor_position_ix+1]; |
| 8095 |
if(second_factor_position>=nullable_suffix_ix){ |
| 8096 |
piece_end= second_factor_position-1; |
| 8097 |
|
| 8098 |
|
| 8099 |
|
| 8100 |
/*420:*/ |
| 8101 |
#line 4197 "./marpa.w" |
| 8102 |
|
| 8103 |
{ |
| 8104 |
const XSYID chaf_xrl_lhs_id= LHS_ID_of_XRL(chaf_xrl); |
| 8105 |
chaf_virtual_nsy= nsy_new(g,XSY_by_ID(chaf_xrl_lhs_id)); |
| 8106 |
chaf_virtual_nsyid= ID_of_NSY(chaf_virtual_nsy); |
| 8107 |
} |
| 8108 |
|
| 8109 |
/*:420*/ |
| 8110 |
#line 4217 "./marpa.w" |
| 8111 |
|
| 8112 |
/*423:*/ |
| 8113 |
#line 4236 "./marpa.w" |
| 8114 |
|
| 8115 |
{ |
| 8116 |
{ |
| 8117 |
const int real_symbol_count= piece_end-piece_start+1; |
| 8118 |
/*428:*/ |
| 8119 |
#line 4334 "./marpa.w" |
| 8120 |
|
| 8121 |
{ |
| 8122 |
int piece_ix; |
| 8123 |
const int chaf_irl_length= (piece_end-piece_start)+2; |
| 8124 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8125 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8126 |
for(piece_ix= 0;piece_ix<chaf_irl_length-1;piece_ix++) |
| 8127 |
{ |
| 8128 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8129 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8130 |
} |
| 8131 |
RHSID_of_IRL(chaf_irl,chaf_irl_length-1)= chaf_virtual_nsyid; |
| 8132 |
irl_finish(g,chaf_irl); |
| 8133 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,3); |
| 8134 |
/*440:*/ |
| 8135 |
#line 4637 "./marpa.w" |
| 8136 |
|
| 8137 |
{ |
| 8138 |
const int is_virtual_lhs= (piece_start> 0); |
| 8139 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8140 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8141 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8142 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8143 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8144 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8145 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8146 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8147 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8148 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8149 |
} |
| 8150 |
|
| 8151 |
/*:440*/ |
| 8152 |
#line 4348 "./marpa.w" |
| 8153 |
|
| 8154 |
} |
| 8155 |
|
| 8156 |
/*:428*/ |
| 8157 |
#line 4240 "./marpa.w" |
| 8158 |
; |
| 8159 |
} |
| 8160 |
/*424:*/ |
| 8161 |
#line 4250 "./marpa.w" |
| 8162 |
|
| 8163 |
{ |
| 8164 |
int piece_ix; |
| 8165 |
const int second_nulling_piece_ix= second_factor_position-piece_start; |
| 8166 |
const int chaf_irl_length= rewrite_xrl_length-piece_start; |
| 8167 |
const int real_symbol_count= chaf_irl_length; |
| 8168 |
|
| 8169 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8170 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8171 |
for(piece_ix= 0;piece_ix<second_nulling_piece_ix;piece_ix++) |
| 8172 |
{ |
| 8173 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8174 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8175 |
} |
| 8176 |
for(piece_ix= second_nulling_piece_ix;piece_ix<chaf_irl_length; |
| 8177 |
piece_ix++) |
| 8178 |
{ |
| 8179 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8180 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8181 |
} |
| 8182 |
irl_finish(g,chaf_irl); |
| 8183 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,2); |
| 8184 |
/*440:*/ |
| 8185 |
#line 4637 "./marpa.w" |
| 8186 |
|
| 8187 |
{ |
| 8188 |
const int is_virtual_lhs= (piece_start> 0); |
| 8189 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8190 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8191 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8192 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8193 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8194 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8195 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8196 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8197 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8198 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8199 |
} |
| 8200 |
|
| 8201 |
/*:440*/ |
| 8202 |
#line 4272 "./marpa.w" |
| 8203 |
|
| 8204 |
} |
| 8205 |
|
| 8206 |
/*:424*/ |
| 8207 |
#line 4242 "./marpa.w" |
| 8208 |
; |
| 8209 |
{ |
| 8210 |
const int real_symbol_count= piece_end-piece_start+1; |
| 8211 |
/*430:*/ |
| 8212 |
#line 4380 "./marpa.w" |
| 8213 |
|
| 8214 |
{ |
| 8215 |
int piece_ix; |
| 8216 |
const int first_nulling_piece_ix= first_factor_position-piece_start; |
| 8217 |
const int chaf_irl_length= (piece_end-piece_start)+2; |
| 8218 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8219 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8220 |
for(piece_ix= 0;piece_ix<first_nulling_piece_ix;piece_ix++) |
| 8221 |
{ |
| 8222 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8223 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8224 |
} |
| 8225 |
RHSID_of_IRL(chaf_irl,first_nulling_piece_ix)= |
| 8226 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE |
| 8227 |
(rule,piece_start+first_nulling_piece_ix)); |
| 8228 |
for(piece_ix= first_nulling_piece_ix+1; |
| 8229 |
piece_ix<chaf_irl_length-1;piece_ix++) |
| 8230 |
{ |
| 8231 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8232 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8233 |
} |
| 8234 |
RHSID_of_IRL(chaf_irl,chaf_irl_length-1)= chaf_virtual_nsyid; |
| 8235 |
irl_finish(g,chaf_irl); |
| 8236 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,1); |
| 8237 |
/*440:*/ |
| 8238 |
#line 4637 "./marpa.w" |
| 8239 |
|
| 8240 |
{ |
| 8241 |
const int is_virtual_lhs= (piece_start> 0); |
| 8242 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8243 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8244 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8245 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8246 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8247 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8248 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8249 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8250 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8251 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8252 |
} |
| 8253 |
|
| 8254 |
/*:440*/ |
| 8255 |
#line 4404 "./marpa.w" |
| 8256 |
|
| 8257 |
} |
| 8258 |
|
| 8259 |
/*:430*/ |
| 8260 |
#line 4245 "./marpa.w" |
| 8261 |
; |
| 8262 |
} |
| 8263 |
/*425:*/ |
| 8264 |
#line 4280 "./marpa.w" |
| 8265 |
|
| 8266 |
{ |
| 8267 |
if(piece_start<nullable_suffix_ix) |
| 8268 |
{ |
| 8269 |
int piece_ix; |
| 8270 |
const int first_nulling_piece_ix= first_factor_position-piece_start; |
| 8271 |
const int second_nulling_piece_ix= |
| 8272 |
second_factor_position-piece_start; |
| 8273 |
const int chaf_irl_length= rewrite_xrl_length-piece_start; |
| 8274 |
const int real_symbol_count= chaf_irl_length; |
| 8275 |
|
| 8276 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8277 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8278 |
for(piece_ix= 0;piece_ix<first_nulling_piece_ix;piece_ix++) |
| 8279 |
{ |
| 8280 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8281 |
NSYID_by_XSYID(RHS_ID_of_RULE |
| 8282 |
(rule,piece_start+piece_ix)); |
| 8283 |
} |
| 8284 |
RHSID_of_IRL(chaf_irl,first_nulling_piece_ix)= |
| 8285 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE |
| 8286 |
(rule,piece_start+first_nulling_piece_ix)); |
| 8287 |
for(piece_ix= first_nulling_piece_ix+1; |
| 8288 |
piece_ix<second_nulling_piece_ix;piece_ix++) |
| 8289 |
{ |
| 8290 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8291 |
NSYID_by_XSYID(RHS_ID_of_RULE |
| 8292 |
(rule,piece_start+piece_ix)); |
| 8293 |
} |
| 8294 |
for(piece_ix= second_nulling_piece_ix;piece_ix<chaf_irl_length; |
| 8295 |
piece_ix++) |
| 8296 |
{ |
| 8297 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8298 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE |
| 8299 |
(rule,piece_start+piece_ix)); |
| 8300 |
} |
| 8301 |
irl_finish(g,chaf_irl); |
| 8302 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,0); |
| 8303 |
/*440:*/ |
| 8304 |
#line 4637 "./marpa.w" |
| 8305 |
|
| 8306 |
{ |
| 8307 |
const int is_virtual_lhs= (piece_start> 0); |
| 8308 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8309 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8310 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8311 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8312 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8313 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8314 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8315 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8316 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8317 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8318 |
} |
| 8319 |
|
| 8320 |
/*:440*/ |
| 8321 |
#line 4318 "./marpa.w" |
| 8322 |
|
| 8323 |
} |
| 8324 |
} |
| 8325 |
|
| 8326 |
/*:425*/ |
| 8327 |
#line 4247 "./marpa.w" |
| 8328 |
; |
| 8329 |
} |
| 8330 |
|
| 8331 |
/*:423*/ |
| 8332 |
#line 4218 "./marpa.w" |
| 8333 |
|
| 8334 |
factor_position_ix++; |
| 8335 |
}else{ |
| 8336 |
piece_end= second_factor_position; |
| 8337 |
/*420:*/ |
| 8338 |
#line 4197 "./marpa.w" |
| 8339 |
|
| 8340 |
{ |
| 8341 |
const XSYID chaf_xrl_lhs_id= LHS_ID_of_XRL(chaf_xrl); |
| 8342 |
chaf_virtual_nsy= nsy_new(g,XSY_by_ID(chaf_xrl_lhs_id)); |
| 8343 |
chaf_virtual_nsyid= ID_of_NSY(chaf_virtual_nsy); |
| 8344 |
} |
| 8345 |
|
| 8346 |
/*:420*/ |
| 8347 |
#line 4222 "./marpa.w" |
| 8348 |
|
| 8349 |
/*427:*/ |
| 8350 |
#line 4324 "./marpa.w" |
| 8351 |
|
| 8352 |
{ |
| 8353 |
const int real_symbol_count= piece_end-piece_start+1; |
| 8354 |
/*428:*/ |
| 8355 |
#line 4334 "./marpa.w" |
| 8356 |
|
| 8357 |
{ |
| 8358 |
int piece_ix; |
| 8359 |
const int chaf_irl_length= (piece_end-piece_start)+2; |
| 8360 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8361 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8362 |
for(piece_ix= 0;piece_ix<chaf_irl_length-1;piece_ix++) |
| 8363 |
{ |
| 8364 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8365 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8366 |
} |
| 8367 |
RHSID_of_IRL(chaf_irl,chaf_irl_length-1)= chaf_virtual_nsyid; |
| 8368 |
irl_finish(g,chaf_irl); |
| 8369 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,3); |
| 8370 |
/*440:*/ |
| 8371 |
#line 4637 "./marpa.w" |
| 8372 |
|
| 8373 |
{ |
| 8374 |
const int is_virtual_lhs= (piece_start> 0); |
| 8375 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8376 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8377 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8378 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8379 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8380 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8381 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8382 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8383 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8384 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8385 |
} |
| 8386 |
|
| 8387 |
/*:440*/ |
| 8388 |
#line 4348 "./marpa.w" |
| 8389 |
|
| 8390 |
} |
| 8391 |
|
| 8392 |
/*:428*/ |
| 8393 |
#line 4327 "./marpa.w" |
| 8394 |
|
| 8395 |
/*429:*/ |
| 8396 |
#line 4352 "./marpa.w" |
| 8397 |
|
| 8398 |
{ |
| 8399 |
int piece_ix; |
| 8400 |
const int second_nulling_piece_ix= second_factor_position-piece_start; |
| 8401 |
const int chaf_irl_length= (piece_end-piece_start)+2; |
| 8402 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8403 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8404 |
for(piece_ix= 0;piece_ix<second_nulling_piece_ix;piece_ix++) |
| 8405 |
{ |
| 8406 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8407 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8408 |
} |
| 8409 |
RHSID_of_IRL(chaf_irl,second_nulling_piece_ix)= |
| 8410 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE |
| 8411 |
(rule,piece_start+second_nulling_piece_ix)); |
| 8412 |
for(piece_ix= second_nulling_piece_ix+1; |
| 8413 |
piece_ix<chaf_irl_length-1;piece_ix++) |
| 8414 |
{ |
| 8415 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8416 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8417 |
} |
| 8418 |
RHSID_of_IRL(chaf_irl,chaf_irl_length-1)= chaf_virtual_nsyid; |
| 8419 |
irl_finish(g,chaf_irl); |
| 8420 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,2); |
| 8421 |
/*440:*/ |
| 8422 |
#line 4637 "./marpa.w" |
| 8423 |
|
| 8424 |
{ |
| 8425 |
const int is_virtual_lhs= (piece_start> 0); |
| 8426 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8427 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8428 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8429 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8430 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8431 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8432 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8433 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8434 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8435 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8436 |
} |
| 8437 |
|
| 8438 |
/*:440*/ |
| 8439 |
#line 4376 "./marpa.w" |
| 8440 |
|
| 8441 |
} |
| 8442 |
|
| 8443 |
/*:429*/ |
| 8444 |
#line 4328 "./marpa.w" |
| 8445 |
|
| 8446 |
/*430:*/ |
| 8447 |
#line 4380 "./marpa.w" |
| 8448 |
|
| 8449 |
{ |
| 8450 |
int piece_ix; |
| 8451 |
const int first_nulling_piece_ix= first_factor_position-piece_start; |
| 8452 |
const int chaf_irl_length= (piece_end-piece_start)+2; |
| 8453 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8454 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8455 |
for(piece_ix= 0;piece_ix<first_nulling_piece_ix;piece_ix++) |
| 8456 |
{ |
| 8457 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8458 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8459 |
} |
| 8460 |
RHSID_of_IRL(chaf_irl,first_nulling_piece_ix)= |
| 8461 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE |
| 8462 |
(rule,piece_start+first_nulling_piece_ix)); |
| 8463 |
for(piece_ix= first_nulling_piece_ix+1; |
| 8464 |
piece_ix<chaf_irl_length-1;piece_ix++) |
| 8465 |
{ |
| 8466 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8467 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8468 |
} |
| 8469 |
RHSID_of_IRL(chaf_irl,chaf_irl_length-1)= chaf_virtual_nsyid; |
| 8470 |
irl_finish(g,chaf_irl); |
| 8471 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,1); |
| 8472 |
/*440:*/ |
| 8473 |
#line 4637 "./marpa.w" |
| 8474 |
|
| 8475 |
{ |
| 8476 |
const int is_virtual_lhs= (piece_start> 0); |
| 8477 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8478 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8479 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8480 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8481 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8482 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8483 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8484 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8485 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8486 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8487 |
} |
| 8488 |
|
| 8489 |
/*:440*/ |
| 8490 |
#line 4404 "./marpa.w" |
| 8491 |
|
| 8492 |
} |
| 8493 |
|
| 8494 |
/*:430*/ |
| 8495 |
#line 4329 "./marpa.w" |
| 8496 |
|
| 8497 |
/*431:*/ |
| 8498 |
#line 4408 "./marpa.w" |
| 8499 |
|
| 8500 |
{ |
| 8501 |
int piece_ix; |
| 8502 |
const int first_nulling_piece_ix= first_factor_position-piece_start; |
| 8503 |
const int second_nulling_piece_ix= second_factor_position-piece_start; |
| 8504 |
const int chaf_irl_length= (piece_end-piece_start)+2; |
| 8505 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8506 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8507 |
for(piece_ix= 0;piece_ix<first_nulling_piece_ix;piece_ix++) |
| 8508 |
{ |
| 8509 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8510 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8511 |
} |
| 8512 |
RHSID_of_IRL(chaf_irl,first_nulling_piece_ix)= |
| 8513 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE |
| 8514 |
(rule,piece_start+first_nulling_piece_ix)); |
| 8515 |
for(piece_ix= first_nulling_piece_ix+1; |
| 8516 |
piece_ix<second_nulling_piece_ix;piece_ix++) |
| 8517 |
{ |
| 8518 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8519 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8520 |
} |
| 8521 |
RHSID_of_IRL(chaf_irl,second_nulling_piece_ix)= |
| 8522 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE |
| 8523 |
(rule,piece_start+second_nulling_piece_ix)); |
| 8524 |
for(piece_ix= second_nulling_piece_ix+1;piece_ix<chaf_irl_length-1; |
| 8525 |
piece_ix++) |
| 8526 |
{ |
| 8527 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8528 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8529 |
} |
| 8530 |
RHSID_of_IRL(chaf_irl,chaf_irl_length-1)= chaf_virtual_nsyid; |
| 8531 |
irl_finish(g,chaf_irl); |
| 8532 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,0); |
| 8533 |
/*440:*/ |
| 8534 |
#line 4637 "./marpa.w" |
| 8535 |
|
| 8536 |
{ |
| 8537 |
const int is_virtual_lhs= (piece_start> 0); |
| 8538 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8539 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8540 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8541 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8542 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8543 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8544 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8545 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8546 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8547 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8548 |
} |
| 8549 |
|
| 8550 |
/*:440*/ |
| 8551 |
#line 4442 "./marpa.w" |
| 8552 |
|
| 8553 |
} |
| 8554 |
|
| 8555 |
/*:431*/ |
| 8556 |
#line 4330 "./marpa.w" |
| 8557 |
|
| 8558 |
} |
| 8559 |
|
| 8560 |
/*:427*/ |
| 8561 |
#line 4223 "./marpa.w" |
| 8562 |
|
| 8563 |
factor_position_ix+= 2; |
| 8564 |
} |
| 8565 |
current_lhs_nsy= chaf_virtual_nsy; |
| 8566 |
current_lhs_nsyid= chaf_virtual_nsyid; |
| 8567 |
piece_start= piece_end+1; |
| 8568 |
|
| 8569 |
/*:422*/ |
| 8570 |
#line 4188 "./marpa.w" |
| 8571 |
|
| 8572 |
} |
| 8573 |
if(unprocessed_factor_count==2){ |
| 8574 |
/*432:*/ |
| 8575 |
#line 4447 "./marpa.w" |
| 8576 |
|
| 8577 |
{ |
| 8578 |
const int first_factor_position= factor_positions[factor_position_ix]; |
| 8579 |
const int second_factor_position= factor_positions[factor_position_ix+1]; |
| 8580 |
const int real_symbol_count= Length_of_XRL(rule)-piece_start; |
| 8581 |
piece_end= Length_of_XRL(rule)-1; |
| 8582 |
/*433:*/ |
| 8583 |
#line 4460 "./marpa.w" |
| 8584 |
|
| 8585 |
{ |
| 8586 |
int piece_ix; |
| 8587 |
const int chaf_irl_length= (piece_end-piece_start)+1; |
| 8588 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8589 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8590 |
for(piece_ix= 0;piece_ix<chaf_irl_length;piece_ix++) |
| 8591 |
{ |
| 8592 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8593 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8594 |
} |
| 8595 |
irl_finish(g,chaf_irl); |
| 8596 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,3); |
| 8597 |
/*440:*/ |
| 8598 |
#line 4637 "./marpa.w" |
| 8599 |
|
| 8600 |
{ |
| 8601 |
const int is_virtual_lhs= (piece_start> 0); |
| 8602 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8603 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8604 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8605 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8606 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8607 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8608 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8609 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8610 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8611 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8612 |
} |
| 8613 |
|
| 8614 |
/*:440*/ |
| 8615 |
#line 4473 "./marpa.w" |
| 8616 |
|
| 8617 |
} |
| 8618 |
|
| 8619 |
/*:433*/ |
| 8620 |
#line 4453 "./marpa.w" |
| 8621 |
|
| 8622 |
/*434:*/ |
| 8623 |
#line 4477 "./marpa.w" |
| 8624 |
|
| 8625 |
{ |
| 8626 |
int piece_ix; |
| 8627 |
const int second_nulling_piece_ix= second_factor_position-piece_start; |
| 8628 |
const int chaf_irl_length= (piece_end-piece_start)+1; |
| 8629 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8630 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8631 |
for(piece_ix= 0;piece_ix<second_nulling_piece_ix;piece_ix++) |
| 8632 |
{ |
| 8633 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8634 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8635 |
} |
| 8636 |
RHSID_of_IRL(chaf_irl,second_nulling_piece_ix)= |
| 8637 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE |
| 8638 |
(rule,piece_start+second_nulling_piece_ix)); |
| 8639 |
for(piece_ix= second_nulling_piece_ix+1;piece_ix<chaf_irl_length; |
| 8640 |
piece_ix++) |
| 8641 |
{ |
| 8642 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8643 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8644 |
} |
| 8645 |
irl_finish(g,chaf_irl); |
| 8646 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,2); |
| 8647 |
/*440:*/ |
| 8648 |
#line 4637 "./marpa.w" |
| 8649 |
|
| 8650 |
{ |
| 8651 |
const int is_virtual_lhs= (piece_start> 0); |
| 8652 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8653 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8654 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8655 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8656 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8657 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8658 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8659 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8660 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8661 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8662 |
} |
| 8663 |
|
| 8664 |
/*:440*/ |
| 8665 |
#line 4500 "./marpa.w" |
| 8666 |
|
| 8667 |
} |
| 8668 |
|
| 8669 |
/*:434*/ |
| 8670 |
#line 4454 "./marpa.w" |
| 8671 |
|
| 8672 |
/*435:*/ |
| 8673 |
#line 4504 "./marpa.w" |
| 8674 |
|
| 8675 |
{ |
| 8676 |
int piece_ix; |
| 8677 |
const int first_nulling_piece_ix= first_factor_position-piece_start; |
| 8678 |
const int chaf_irl_length= (piece_end-piece_start)+1; |
| 8679 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8680 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8681 |
for(piece_ix= 0;piece_ix<first_nulling_piece_ix;piece_ix++) |
| 8682 |
{ |
| 8683 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8684 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8685 |
} |
| 8686 |
RHSID_of_IRL(chaf_irl,first_nulling_piece_ix)= |
| 8687 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE |
| 8688 |
(rule,piece_start+first_nulling_piece_ix)); |
| 8689 |
for(piece_ix= first_nulling_piece_ix+1;piece_ix<chaf_irl_length; |
| 8690 |
piece_ix++) |
| 8691 |
{ |
| 8692 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8693 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8694 |
} |
| 8695 |
irl_finish(g,chaf_irl); |
| 8696 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,1); |
| 8697 |
/*440:*/ |
| 8698 |
#line 4637 "./marpa.w" |
| 8699 |
|
| 8700 |
{ |
| 8701 |
const int is_virtual_lhs= (piece_start> 0); |
| 8702 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8703 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8704 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8705 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8706 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8707 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8708 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8709 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8710 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8711 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8712 |
} |
| 8713 |
|
| 8714 |
/*:440*/ |
| 8715 |
#line 4527 "./marpa.w" |
| 8716 |
|
| 8717 |
} |
| 8718 |
|
| 8719 |
/*:435*/ |
| 8720 |
#line 4455 "./marpa.w" |
| 8721 |
|
| 8722 |
/*436:*/ |
| 8723 |
#line 4532 "./marpa.w" |
| 8724 |
|
| 8725 |
{ |
| 8726 |
if(piece_start<nullable_suffix_ix){ |
| 8727 |
int piece_ix; |
| 8728 |
const int first_nulling_piece_ix= first_factor_position-piece_start; |
| 8729 |
const int second_nulling_piece_ix= second_factor_position-piece_start; |
| 8730 |
const int chaf_irl_length= (piece_end-piece_start)+1; |
| 8731 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8732 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8733 |
for(piece_ix= 0;piece_ix<first_nulling_piece_ix;piece_ix++) |
| 8734 |
{ |
| 8735 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8736 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8737 |
} |
| 8738 |
|
| 8739 |
RHSID_of_IRL(chaf_irl,first_nulling_piece_ix)= |
| 8740 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE |
| 8741 |
(rule,piece_start+first_nulling_piece_ix)); |
| 8742 |
for(piece_ix= first_nulling_piece_ix+1; |
| 8743 |
piece_ix<second_nulling_piece_ix;piece_ix++) |
| 8744 |
{ |
| 8745 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8746 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8747 |
} |
| 8748 |
|
| 8749 |
RHSID_of_IRL(chaf_irl,second_nulling_piece_ix)= |
| 8750 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE |
| 8751 |
(rule,piece_start+second_nulling_piece_ix)); |
| 8752 |
for(piece_ix= second_nulling_piece_ix+1;piece_ix<chaf_irl_length; |
| 8753 |
piece_ix++) |
| 8754 |
{ |
| 8755 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8756 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8757 |
} |
| 8758 |
|
| 8759 |
irl_finish(g,chaf_irl); |
| 8760 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,0); |
| 8761 |
/*440:*/ |
| 8762 |
#line 4637 "./marpa.w" |
| 8763 |
|
| 8764 |
{ |
| 8765 |
const int is_virtual_lhs= (piece_start> 0); |
| 8766 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8767 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8768 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8769 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8770 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8771 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8772 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8773 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8774 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8775 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8776 |
} |
| 8777 |
|
| 8778 |
/*:440*/ |
| 8779 |
#line 4569 "./marpa.w" |
| 8780 |
|
| 8781 |
} |
| 8782 |
} |
| 8783 |
|
| 8784 |
/*:436*/ |
| 8785 |
#line 4456 "./marpa.w" |
| 8786 |
|
| 8787 |
} |
| 8788 |
|
| 8789 |
/*:432*/ |
| 8790 |
#line 4191 "./marpa.w" |
| 8791 |
|
| 8792 |
}else{ |
| 8793 |
/*437:*/ |
| 8794 |
#line 4574 "./marpa.w" |
| 8795 |
|
| 8796 |
{ |
| 8797 |
int real_symbol_count; |
| 8798 |
const int first_factor_position= factor_positions[factor_position_ix]; |
| 8799 |
piece_end= Length_of_XRL(rule)-1; |
| 8800 |
real_symbol_count= piece_end-piece_start+1; |
| 8801 |
/*438:*/ |
| 8802 |
#line 4585 "./marpa.w" |
| 8803 |
|
| 8804 |
{ |
| 8805 |
int piece_ix; |
| 8806 |
const int chaf_irl_length= (piece_end-piece_start)+1; |
| 8807 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8808 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8809 |
for(piece_ix= 0;piece_ix<chaf_irl_length;piece_ix++) |
| 8810 |
{ |
| 8811 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8812 |
NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+piece_ix)); |
| 8813 |
} |
| 8814 |
irl_finish(g,chaf_irl); |
| 8815 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,3); |
| 8816 |
/*440:*/ |
| 8817 |
#line 4637 "./marpa.w" |
| 8818 |
|
| 8819 |
{ |
| 8820 |
const int is_virtual_lhs= (piece_start> 0); |
| 8821 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8822 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8823 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8824 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8825 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8826 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8827 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8828 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8829 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8830 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8831 |
} |
| 8832 |
|
| 8833 |
/*:440*/ |
| 8834 |
#line 4598 "./marpa.w" |
| 8835 |
|
| 8836 |
} |
| 8837 |
|
| 8838 |
/*:438*/ |
| 8839 |
#line 4580 "./marpa.w" |
| 8840 |
|
| 8841 |
/*439:*/ |
| 8842 |
#line 4603 "./marpa.w" |
| 8843 |
|
| 8844 |
{ |
| 8845 |
if(piece_start<nullable_suffix_ix) |
| 8846 |
{ |
| 8847 |
int piece_ix; |
| 8848 |
const int nulling_piece_ix= first_factor_position-piece_start; |
| 8849 |
const int chaf_irl_length= (piece_end-piece_start)+1; |
| 8850 |
IRL chaf_irl= irl_start(g,chaf_irl_length); |
| 8851 |
LHSID_of_IRL(chaf_irl)= current_lhs_nsyid; |
| 8852 |
for(piece_ix= 0;piece_ix<nulling_piece_ix;piece_ix++) |
| 8853 |
{ |
| 8854 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8855 |
NSYID_by_XSYID(RHS_ID_of_RULE |
| 8856 |
(rule,piece_start+piece_ix)); |
| 8857 |
} |
| 8858 |
RHSID_of_IRL(chaf_irl,nulling_piece_ix)= |
| 8859 |
Nulling_NSYID_by_XSYID(RHS_ID_of_RULE(rule,piece_start+nulling_piece_ix)); |
| 8860 |
for(piece_ix= nulling_piece_ix+1;piece_ix<chaf_irl_length; |
| 8861 |
piece_ix++) |
| 8862 |
{ |
| 8863 |
RHSID_of_IRL(chaf_irl,piece_ix)= |
| 8864 |
NSYID_by_XSYID(RHS_ID_of_RULE |
| 8865 |
(rule,piece_start+piece_ix)); |
| 8866 |
} |
| 8867 |
irl_finish(g,chaf_irl); |
| 8868 |
Rank_of_IRL(chaf_irl)= IRL_CHAF_Rank_by_XRL(rule,0); |
| 8869 |
/*440:*/ |
| 8870 |
#line 4637 "./marpa.w" |
| 8871 |
|
| 8872 |
{ |
| 8873 |
const int is_virtual_lhs= (piece_start> 0); |
| 8874 |
IRL_is_CHAF(chaf_irl)= 1; |
| 8875 |
Source_XRL_of_IRL(chaf_irl)= rule; |
| 8876 |
IRL_has_Virtual_LHS(chaf_irl)= Boolean(is_virtual_lhs); |
| 8877 |
IRL_has_Virtual_RHS(chaf_irl)= |
| 8878 |
Length_of_IRL(chaf_irl)> real_symbol_count; |
| 8879 |
Virtual_Start_of_IRL(chaf_irl)= piece_start; |
| 8880 |
Virtual_End_of_IRL(chaf_irl)= piece_start+real_symbol_count-1; |
| 8881 |
Real_SYM_Count_of_IRL(chaf_irl)= real_symbol_count; |
| 8882 |
LHS_XRL_of_NSY(current_lhs_nsy)= chaf_xrl; |
| 8883 |
XRL_Offset_of_NSY(current_lhs_nsy)= piece_start; |
| 8884 |
} |
| 8885 |
|
| 8886 |
/*:440*/ |
| 8887 |
#line 4629 "./marpa.w" |
| 8888 |
|
| 8889 |
} |
| 8890 |
} |
| 8891 |
|
| 8892 |
/*:439*/ |
| 8893 |
#line 4581 "./marpa.w" |
| 8894 |
|
| 8895 |
} |
| 8896 |
|
| 8897 |
/*:437*/ |
| 8898 |
#line 4193 "./marpa.w" |
| 8899 |
|
| 8900 |
} |
| 8901 |
} |
| 8902 |
|
| 8903 |
/*:419*/ |
| 8904 |
#line 4099 "./marpa.w" |
| 8905 |
|
| 8906 |
continue; |
| 8907 |
} |
| 8908 |
/*260:*/ |
| 8909 |
#line 2264 "./marpa.w" |
| 8910 |
|
| 8911 |
{ |
| 8912 |
int symbol_ix; |
| 8913 |
const IRL new_irl= irl_start(g,rewrite_xrl_length); |
| 8914 |
Source_XRL_of_IRL(new_irl)= rule; |
| 8915 |
Rank_of_IRL(new_irl)= IRL_Rank_by_XRL(rule); |
| 8916 |
for(symbol_ix= 0;symbol_ix<=rewrite_xrl_length;symbol_ix++) |
| 8917 |
{ |
| 8918 |
new_irl->t_nsyid_array[symbol_ix]= |
| 8919 |
NSYID_by_XSYID(rule->t_symbols[symbol_ix]); |
| 8920 |
} |
| 8921 |
irl_finish(g,new_irl); |
| 8922 |
} |
| 8923 |
|
| 8924 |
/*:260*/ |
| 8925 |
#line 4102 "./marpa.w" |
| 8926 |
|
| 8927 |
} |
| 8928 |
} |
| 8929 |
|
| 8930 |
/*:413*/ |
| 8931 |
#line 3210 "./marpa.w" |
| 8932 |
|
| 8933 |
/*442:*/ |
| 8934 |
#line 4655 "./marpa.w" |
| 8935 |
|
| 8936 |
{ |
| 8937 |
const XSY start_xsy= XSY_by_ID(start_xsy_id); |
| 8938 |
if(_MARPA_LIKELY(!XSY_is_Nulling(start_xsy))){ |
| 8939 |
/*443:*/ |
| 8940 |
#line 4663 "./marpa.w" |
| 8941 |
{ |
| 8942 |
IRL new_start_irl; |
| 8943 |
|
| 8944 |
const NSY new_start_nsy= nsy_new(g,start_xsy); |
| 8945 |
NSY_is_Start(new_start_nsy)= 1; |
| 8946 |
|
| 8947 |
new_start_irl= irl_start(g,1); |
| 8948 |
LHSID_of_IRL(new_start_irl)= ID_of_NSY(new_start_nsy); |
| 8949 |
RHSID_of_IRL(new_start_irl,0)= NSYID_of_XSY(start_xsy); |
| 8950 |
irl_finish(g,new_start_irl); |
| 8951 |
IRL_has_Virtual_LHS(new_start_irl)= 1; |
| 8952 |
Real_SYM_Count_of_IRL(new_start_irl)= 1; |
| 8953 |
g->t_start_irl= new_start_irl; |
| 8954 |
|
| 8955 |
} |
| 8956 |
|
| 8957 |
/*:443*/ |
| 8958 |
#line 4659 "./marpa.w" |
| 8959 |
|
| 8960 |
} |
| 8961 |
} |
| 8962 |
|
| 8963 |
/*:442*/ |
| 8964 |
#line 3211 "./marpa.w" |
| 8965 |
|
| 8966 |
post_census_xsy_count= XSY_Count_of_G(g); |
| 8967 |
/*524:*/ |
| 8968 |
#line 5602 "./marpa.w" |
| 8969 |
|
| 8970 |
{ |
| 8971 |
int xsyid; |
| 8972 |
g->t_lbv_xsyid_is_completion_event= |
| 8973 |
bv_obs_create(g->t_obs,post_census_xsy_count); |
| 8974 |
g->t_lbv_xsyid_completion_event_starts_active= |
| 8975 |
bv_obs_create(g->t_obs,post_census_xsy_count); |
| 8976 |
g->t_lbv_xsyid_is_nulled_event= |
| 8977 |
bv_obs_create(g->t_obs,post_census_xsy_count); |
| 8978 |
g->t_lbv_xsyid_nulled_event_starts_active= |
| 8979 |
bv_obs_create(g->t_obs,post_census_xsy_count); |
| 8980 |
g->t_lbv_xsyid_is_prediction_event= |
| 8981 |
bv_obs_create(g->t_obs,post_census_xsy_count); |
| 8982 |
g->t_lbv_xsyid_prediction_event_starts_active= |
| 8983 |
bv_obs_create(g->t_obs,post_census_xsy_count); |
| 8984 |
for(xsyid= 0;xsyid<post_census_xsy_count;xsyid++) |
| 8985 |
{ |
| 8986 |
if(XSYID_is_Completion_Event(xsyid)) |
| 8987 |
{ |
| 8988 |
lbv_bit_set(g->t_lbv_xsyid_is_completion_event,xsyid); |
| 8989 |
} |
| 8990 |
if(XSYID_Completion_Event_Starts_Active(xsyid)) |
| 8991 |
{ |
| 8992 |
lbv_bit_set(g->t_lbv_xsyid_completion_event_starts_active,xsyid); |
| 8993 |
} |
| 8994 |
if(XSYID_is_Nulled_Event(xsyid)) |
| 8995 |
{ |
| 8996 |
lbv_bit_set(g->t_lbv_xsyid_is_nulled_event,xsyid); |
| 8997 |
} |
| 8998 |
if(XSYID_Nulled_Event_Starts_Active(xsyid)) |
| 8999 |
{ |
| 9000 |
lbv_bit_set(g->t_lbv_xsyid_nulled_event_starts_active,xsyid); |
| 9001 |
} |
| 9002 |
if(XSYID_is_Prediction_Event(xsyid)) |
| 9003 |
{ |
| 9004 |
lbv_bit_set(g->t_lbv_xsyid_is_prediction_event,xsyid); |
| 9005 |
} |
| 9006 |
if(XSYID_Prediction_Event_Starts_Active(xsyid)) |
| 9007 |
{ |
| 9008 |
lbv_bit_set(g->t_lbv_xsyid_prediction_event_starts_active,xsyid); |
| 9009 |
} |
| 9010 |
} |
| 9011 |
} |
| 9012 |
|
| 9013 |
/*:524*/ |
| 9014 |
#line 3213 "./marpa.w" |
| 9015 |
|
| 9016 |
|
| 9017 |
|
| 9018 |
|
| 9019 |
if(!G_is_Trivial(g)){ |
| 9020 |
/*511:*/ |
| 9021 |
#line 5396 "./marpa.w" |
| 9022 |
|
| 9023 |
const RULEID irl_count= IRL_Count_of_G(g); |
| 9024 |
const NSYID nsy_count= NSY_Count_of_G(g); |
| 9025 |
Bit_Matrix nsy_by_right_nsy_matrix; |
| 9026 |
Bit_Matrix prediction_nsy_by_irl_matrix; |
| 9027 |
|
| 9028 |
/*:511*/ |
| 9029 |
#line 3219 "./marpa.w" |
| 9030 |
|
| 9031 |
/*514:*/ |
| 9032 |
#line 5418 "./marpa.w" |
| 9033 |
|
| 9034 |
{ |
| 9035 |
NSYID lhsid; |
| 9036 |
|
| 9037 |
|
| 9038 |
|
| 9039 |
|
| 9040 |
void*matrix_buffer= my_malloc(matrix_sizeof( |
| 9041 |
nsy_count,irl_count)); |
| 9042 |
Bit_Matrix irl_by_lhs_matrix= |
| 9043 |
matrix_buffer_create(matrix_buffer,nsy_count,irl_count); |
| 9044 |
|
| 9045 |
IRLID irl_id; |
| 9046 |
for(irl_id= 0;irl_id<irl_count;irl_id++) |
| 9047 |
{ |
| 9048 |
const IRL irl= IRL_by_ID(irl_id); |
| 9049 |
const NSYID lhs_nsyid= LHSID_of_IRL(irl); |
| 9050 |
matrix_bit_set(irl_by_lhs_matrix,lhs_nsyid,irl_id); |
| 9051 |
} |
| 9052 |
|
| 9053 |
|
| 9054 |
|
| 9055 |
|
| 9056 |
for(lhsid= 0;lhsid<nsy_count;lhsid++) |
| 9057 |
{ |
| 9058 |
IRLID irlid; |
| 9059 |
int min,max,start; |
| 9060 |
cil_buffer_clear(&g->t_cilar); |
| 9061 |
for(start= 0; |
| 9062 |
bv_scan(matrix_row |
| 9063 |
(irl_by_lhs_matrix,lhsid), |
| 9064 |
start,&min,&max);start= max+2) |
| 9065 |
{ |
| 9066 |
for(irlid= min;irlid<=max;irlid++) |
| 9067 |
{ |
| 9068 |
cil_buffer_push(&g->t_cilar,irlid); |
| 9069 |
} |
| 9070 |
} |
| 9071 |
LHS_CIL_of_NSYID(lhsid)= cil_buffer_add(&g->t_cilar); |
| 9072 |
} |
| 9073 |
|
| 9074 |
my_free(matrix_buffer); |
| 9075 |
|
| 9076 |
} |
| 9077 |
|
| 9078 |
/*:514*/ |
| 9079 |
#line 3220 "./marpa.w" |
| 9080 |
|
| 9081 |
/*485:*/ |
| 9082 |
#line 5043 "./marpa.w" |
| 9083 |
|
| 9084 |
{ |
| 9085 |
IRLID irl_id; |
| 9086 |
int ahm_count= 0; |
| 9087 |
AHM base_item; |
| 9088 |
AHM current_item; |
| 9089 |
int symbol_instance_of_next_rule= 0; |
| 9090 |
for(irl_id= 0;irl_id<irl_count;irl_id++){ |
| 9091 |
const IRL irl= IRL_by_ID(irl_id); |
| 9092 |
/*487:*/ |
| 9093 |
#line 5095 "./marpa.w" |
| 9094 |
|
| 9095 |
{ |
| 9096 |
int rhs_ix; |
| 9097 |
for(rhs_ix= 0;rhs_ix<Length_of_IRL(irl);rhs_ix++) |
| 9098 |
{ |
| 9099 |
const NSYID rh_nsyid= RHSID_of_IRL(irl,rhs_ix); |
| 9100 |
const NSY nsy= NSY_by_ID(rh_nsyid); |
| 9101 |
if(!NSY_is_Nulling(nsy))ahm_count++; |
| 9102 |
} |
| 9103 |
ahm_count++; |
| 9104 |
} |
| 9105 |
|
| 9106 |
/*:487*/ |
| 9107 |
#line 5052 "./marpa.w" |
| 9108 |
|
| 9109 |
} |
| 9110 |
current_item= base_item= marpa_new(struct s_ahm,ahm_count); |
| 9111 |
for(irl_id= 0;irl_id<irl_count;irl_id++){ |
| 9112 |
const IRL irl= IRL_by_ID(irl_id); |
| 9113 |
SYMI_of_IRL(irl)= symbol_instance_of_next_rule; |
| 9114 |
/*486:*/ |
| 9115 |
#line 5070 "./marpa.w" |
| 9116 |
|
| 9117 |
{ |
| 9118 |
int leading_nulls= 0; |
| 9119 |
int rhs_ix; |
| 9120 |
const AHM first_ahm_of_irl= current_item; |
| 9121 |
for(rhs_ix= 0;rhs_ix<Length_of_IRL(irl);rhs_ix++) |
| 9122 |
{ |
| 9123 |
NSYID rh_nsyid= RHSID_of_IRL(irl,rhs_ix); |
| 9124 |
if(!NSY_is_Nulling(NSY_by_ID(rh_nsyid))) |
| 9125 |
{ |
| 9126 |
Last_Proper_SYMI_of_IRL(irl)= symbol_instance_of_next_rule+rhs_ix; |
| 9127 |
/*488:*/ |
| 9128 |
#line 5107 "./marpa.w" |
| 9129 |
|
| 9130 |
{ |
| 9131 |
/*490:*/ |
| 9132 |
#line 5130 "./marpa.w" |
| 9133 |
|
| 9134 |
{ |
| 9135 |
IRL_of_AHM(current_item)= irl; |
| 9136 |
Null_Count_of_AHM(current_item)= leading_nulls; |
| 9137 |
Quasi_Position_of_AHM(current_item)= (int)(current_item-first_ahm_of_irl); |
| 9138 |
if(Quasi_Position_of_AHM(current_item)==0){ |
| 9139 |
if(ID_of_IRL(irl)==ID_of_IRL(g->t_start_irl)) |
| 9140 |
{ |
| 9141 |
AHM_was_Predicted(current_item)= 0; |
| 9142 |
AHM_is_Initial(current_item)= 1; |
| 9143 |
}else{ |
| 9144 |
AHM_was_Predicted(current_item)= 1; |
| 9145 |
AHM_is_Initial(current_item)= 0; |
| 9146 |
} |
| 9147 |
}else{ |
| 9148 |
AHM_was_Predicted(current_item)= 0; |
| 9149 |
AHM_is_Initial(current_item)= 0; |
| 9150 |
} |
| 9151 |
/*505:*/ |
| 9152 |
#line 5293 "./marpa.w" |
| 9153 |
|
| 9154 |
Event_AHMIDs_of_AHM(current_item)= NULL; |
| 9155 |
Event_Group_Size_of_AHM(current_item)= 0; |
| 9156 |
|
| 9157 |
/*:505*/ |
| 9158 |
#line 5148 "./marpa.w" |
| 9159 |
|
| 9160 |
} |
| 9161 |
|
| 9162 |
/*:490*/ |
| 9163 |
#line 5109 "./marpa.w" |
| 9164 |
|
| 9165 |
AHM_predicts_ZWA(current_item)= 0; |
| 9166 |
|
| 9167 |
Postdot_NSYID_of_AHM(current_item)= rh_nsyid; |
| 9168 |
Position_of_AHM(current_item)= rhs_ix; |
| 9169 |
SYMI_of_AHM(current_item) |
| 9170 |
= AHM_is_Prediction(current_item) |
| 9171 |
?-1 |
| 9172 |
:SYMI_of_IRL(irl)+Position_of_AHM(current_item-1); |
| 9173 |
memoize_xrl_data_for_AHM(current_item,irl); |
| 9174 |
} |
| 9175 |
|
| 9176 |
/*:488*/ |
| 9177 |
#line 5081 "./marpa.w" |
| 9178 |
|
| 9179 |
current_item++; |
| 9180 |
leading_nulls= 0; |
| 9181 |
} |
| 9182 |
else |
| 9183 |
{ |
| 9184 |
leading_nulls++; |
| 9185 |
} |
| 9186 |
} |
| 9187 |
/*489:*/ |
| 9188 |
#line 5121 "./marpa.w" |
| 9189 |
|
| 9190 |
{ |
| 9191 |
/*490:*/ |
| 9192 |
#line 5130 "./marpa.w" |
| 9193 |
|
| 9194 |
{ |
| 9195 |
IRL_of_AHM(current_item)= irl; |
| 9196 |
Null_Count_of_AHM(current_item)= leading_nulls; |
| 9197 |
Quasi_Position_of_AHM(current_item)= (int)(current_item-first_ahm_of_irl); |
| 9198 |
if(Quasi_Position_of_AHM(current_item)==0){ |
| 9199 |
if(ID_of_IRL(irl)==ID_of_IRL(g->t_start_irl)) |
| 9200 |
{ |
| 9201 |
AHM_was_Predicted(current_item)= 0; |
| 9202 |
AHM_is_Initial(current_item)= 1; |
| 9203 |
}else{ |
| 9204 |
AHM_was_Predicted(current_item)= 1; |
| 9205 |
AHM_is_Initial(current_item)= 0; |
| 9206 |
} |
| 9207 |
}else{ |
| 9208 |
AHM_was_Predicted(current_item)= 0; |
| 9209 |
AHM_is_Initial(current_item)= 0; |
| 9210 |
} |
| 9211 |
/*505:*/ |
| 9212 |
#line 5293 "./marpa.w" |
| 9213 |
|
| 9214 |
Event_AHMIDs_of_AHM(current_item)= NULL; |
| 9215 |
Event_Group_Size_of_AHM(current_item)= 0; |
| 9216 |
|
| 9217 |
/*:505*/ |
| 9218 |
#line 5148 "./marpa.w" |
| 9219 |
|
| 9220 |
} |
| 9221 |
|
| 9222 |
/*:490*/ |
| 9223 |
#line 5123 "./marpa.w" |
| 9224 |
|
| 9225 |
Postdot_NSYID_of_AHM(current_item)= -1; |
| 9226 |
Position_of_AHM(current_item)= -1; |
| 9227 |
SYMI_of_AHM(current_item)= SYMI_of_IRL(irl)+Position_of_AHM(current_item-1); |
| 9228 |
memoize_xrl_data_for_AHM(current_item,irl); |
| 9229 |
} |
| 9230 |
|
| 9231 |
/*:489*/ |
| 9232 |
#line 5090 "./marpa.w" |
| 9233 |
|
| 9234 |
current_item++; |
| 9235 |
AHM_Count_of_IRL(irl)= (int)(current_item-first_ahm_of_irl); |
| 9236 |
} |
| 9237 |
|
| 9238 |
/*:486*/ |
| 9239 |
#line 5058 "./marpa.w" |
| 9240 |
|
| 9241 |
{ |
| 9242 |
symbol_instance_of_next_rule+= Length_of_IRL(irl); |
| 9243 |
} |
| 9244 |
} |
| 9245 |
SYMI_Count_of_G(g)= symbol_instance_of_next_rule; |
| 9246 |
MARPA_ASSERT(ahm_count==current_item-base_item); |
| 9247 |
AHM_Count_of_G(g)= ahm_count; |
| 9248 |
g->t_ahms= marpa_renew(struct s_ahm,base_item,ahm_count); |
| 9249 |
/*493:*/ |
| 9250 |
#line 5201 "./marpa.w" |
| 9251 |
|
| 9252 |
{ |
| 9253 |
AHM items= g->t_ahms; |
| 9254 |
AHMID item_id= (AHMID)ahm_count; |
| 9255 |
for(item_id--;item_id>=0;item_id--) |
| 9256 |
{ |
| 9257 |
AHM item= items+item_id; |
| 9258 |
IRL irl= IRL_of_AHM(item); |
| 9259 |
First_AHM_of_IRL(irl)= item; |
| 9260 |
} |
| 9261 |
} |
| 9262 |
|
| 9263 |
/*:493*/ |
| 9264 |
#line 5067 "./marpa.w" |
| 9265 |
|
| 9266 |
} |
| 9267 |
|
| 9268 |
/*:485*/ |
| 9269 |
#line 3221 "./marpa.w" |
| 9270 |
|
| 9271 |
/*517:*/ |
| 9272 |
#line 5471 "./marpa.w" |
| 9273 |
{ |
| 9274 |
Bit_Matrix prediction_nsy_by_nsy_matrix= |
| 9275 |
matrix_obs_create(obs_precompute,nsy_count,nsy_count); |
| 9276 |
/*518:*/ |
| 9277 |
#line 5479 "./marpa.w" |
| 9278 |
|
| 9279 |
{ |
| 9280 |
IRLID irl_id; |
| 9281 |
NSYID nsyid; |
| 9282 |
for(nsyid= 0;nsyid<nsy_count;nsyid++) |
| 9283 |
{ |
| 9284 |
|
| 9285 |
NSY nsy= NSY_by_ID(nsyid); |
| 9286 |
if(!NSY_is_LHS(nsy))continue; |
| 9287 |
matrix_bit_set(prediction_nsy_by_nsy_matrix,nsyid, |
| 9288 |
nsyid); |
| 9289 |
} |
| 9290 |
for(irl_id= 0;irl_id<irl_count;irl_id++) |
| 9291 |
{ |
| 9292 |
NSYID from_nsyid,to_nsyid; |
| 9293 |
const IRL irl= IRL_by_ID(irl_id); |
| 9294 |
|
| 9295 |
const AHM item= First_AHM_of_IRL(irl); |
| 9296 |
to_nsyid= Postdot_NSYID_of_AHM(item); |
| 9297 |
|
| 9298 |
if(to_nsyid<0) |
| 9299 |
continue; |
| 9300 |
|
| 9301 |
from_nsyid= LHS_NSYID_of_AHM(item); |
| 9302 |
matrix_bit_set(prediction_nsy_by_nsy_matrix, |
| 9303 |
from_nsyid, |
| 9304 |
to_nsyid); |
| 9305 |
} |
| 9306 |
} |
| 9307 |
|
| 9308 |
/*:518*/ |
| 9309 |
#line 5474 "./marpa.w" |
| 9310 |
|
| 9311 |
transitive_closure(prediction_nsy_by_nsy_matrix); |
| 9312 |
/*519:*/ |
| 9313 |
#line 5516 "./marpa.w" |
| 9314 |
{ |
| 9315 |
/*520:*/ |
| 9316 |
#line 5520 "./marpa.w" |
| 9317 |
|
| 9318 |
{ |
| 9319 |
NSYID from_nsyid; |
| 9320 |
prediction_nsy_by_irl_matrix= |
| 9321 |
matrix_obs_create(obs_precompute,nsy_count, |
| 9322 |
irl_count); |
| 9323 |
for(from_nsyid= 0;from_nsyid<nsy_count;from_nsyid++) |
| 9324 |
{ |
| 9325 |
|
| 9326 |
|
| 9327 |
int min,max,start; |
| 9328 |
for(start= 0; |
| 9329 |
bv_scan(matrix_row |
| 9330 |
(prediction_nsy_by_nsy_matrix,from_nsyid), |
| 9331 |
start,&min,&max);start= max+2) |
| 9332 |
{ |
| 9333 |
NSYID to_nsyid; |
| 9334 |
|
| 9335 |
|
| 9336 |
|
| 9337 |
for(to_nsyid= min;to_nsyid<=max;to_nsyid++) |
| 9338 |
{ |
| 9339 |
int cil_ix; |
| 9340 |
const CIL lhs_cil= LHS_CIL_of_NSYID(to_nsyid); |
| 9341 |
const int cil_count= Count_of_CIL(lhs_cil); |
| 9342 |
for(cil_ix= 0;cil_ix<cil_count;cil_ix++) |
| 9343 |
{ |
| 9344 |
const IRLID irlid= Item_of_CIL(lhs_cil,cil_ix); |
| 9345 |
matrix_bit_set(prediction_nsy_by_irl_matrix, |
| 9346 |
from_nsyid,irlid); |
| 9347 |
} |
| 9348 |
} |
| 9349 |
} |
| 9350 |
} |
| 9351 |
} |
| 9352 |
|
| 9353 |
/*:520*/ |
| 9354 |
#line 5517 "./marpa.w" |
| 9355 |
|
| 9356 |
} |
| 9357 |
|
| 9358 |
/*:519*/ |
| 9359 |
#line 5476 "./marpa.w" |
| 9360 |
|
| 9361 |
} |
| 9362 |
|
| 9363 |
/*:517*/ |
| 9364 |
#line 3222 "./marpa.w" |
| 9365 |
|
| 9366 |
/*507:*/ |
| 9367 |
#line 5306 "./marpa.w" |
| 9368 |
{ |
| 9369 |
nsy_by_right_nsy_matrix= |
| 9370 |
matrix_obs_create(obs_precompute,nsy_count,nsy_count); |
| 9371 |
/*508:*/ |
| 9372 |
#line 5317 "./marpa.w" |
| 9373 |
|
| 9374 |
{ |
| 9375 |
IRLID irl_id; |
| 9376 |
for(irl_id= 0;irl_id<irl_count;irl_id++) |
| 9377 |
{ |
| 9378 |
const IRL irl= IRL_by_ID(irl_id); |
| 9379 |
int rhs_ix; |
| 9380 |
for(rhs_ix= Length_of_IRL(irl)-1; |
| 9381 |
rhs_ix>=0; |
| 9382 |
rhs_ix--) |
| 9383 |
{ |
| 9384 |
|
| 9385 |
|
| 9386 |
const NSYID rh_nsyid= RHSID_of_IRL(irl,rhs_ix); |
| 9387 |
if(!NSY_is_Nulling(NSY_by_ID(rh_nsyid))) |
| 9388 |
{ |
| 9389 |
matrix_bit_set(nsy_by_right_nsy_matrix, |
| 9390 |
LHSID_of_IRL(irl), |
| 9391 |
rh_nsyid); |
| 9392 |
break; |
| 9393 |
} |
| 9394 |
} |
| 9395 |
} |
| 9396 |
} |
| 9397 |
|
| 9398 |
/*:508*/ |
| 9399 |
#line 5309 "./marpa.w" |
| 9400 |
|
| 9401 |
transitive_closure(nsy_by_right_nsy_matrix); |
| 9402 |
/*509:*/ |
| 9403 |
#line 5342 "./marpa.w" |
| 9404 |
|
| 9405 |
{ |
| 9406 |
IRLID irl_id; |
| 9407 |
for(irl_id= 0;irl_id<irl_count;irl_id++) |
| 9408 |
{ |
| 9409 |
const IRL irl= IRL_by_ID(irl_id); |
| 9410 |
int rhs_ix; |
| 9411 |
for(rhs_ix= Length_of_IRL(irl)-1;rhs_ix>=0;rhs_ix--) |
| 9412 |
{ |
| 9413 |
const NSYID rh_nsyid= RHSID_of_IRL(irl,rhs_ix); |
| 9414 |
if(!NSY_is_Nulling(NSY_by_ID(rh_nsyid))) |
| 9415 |
{ |
| 9416 |
|
| 9417 |
|
| 9418 |
|
| 9419 |
if(matrix_bit_test(nsy_by_right_nsy_matrix, |
| 9420 |
rh_nsyid, |
| 9421 |
LHSID_of_IRL(irl))) |
| 9422 |
{ |
| 9423 |
IRL_is_Right_Recursive(irl)= 1; |
| 9424 |
} |
| 9425 |
break; |
| 9426 |
} |
| 9427 |
} |
| 9428 |
} |
| 9429 |
} |
| 9430 |
|
| 9431 |
/*:509*/ |
| 9432 |
#line 5311 "./marpa.w" |
| 9433 |
|
| 9434 |
matrix_clear(nsy_by_right_nsy_matrix); |
| 9435 |
/*510:*/ |
| 9436 |
#line 5369 "./marpa.w" |
| 9437 |
|
| 9438 |
{ |
| 9439 |
IRLID irl_id; |
| 9440 |
for(irl_id= 0;irl_id<irl_count;irl_id++) |
| 9441 |
{ |
| 9442 |
int rhs_ix; |
| 9443 |
const IRL irl= IRL_by_ID(irl_id); |
| 9444 |
if(!IRL_is_Right_Recursive(irl)){continue;} |
| 9445 |
for(rhs_ix= Length_of_IRL(irl)-1; |
| 9446 |
rhs_ix>=0; |
| 9447 |
rhs_ix--) |
| 9448 |
{ |
| 9449 |
|
| 9450 |
|
| 9451 |
const NSYID rh_nsyid= RHSID_of_IRL(irl,rhs_ix); |
| 9452 |
if(!NSY_is_Nulling(NSY_by_ID(rh_nsyid))) |
| 9453 |
{ |
| 9454 |
matrix_bit_set(nsy_by_right_nsy_matrix, |
| 9455 |
LHSID_of_IRL(irl), |
| 9456 |
rh_nsyid); |
| 9457 |
break; |
| 9458 |
} |
| 9459 |
} |
| 9460 |
} |
| 9461 |
} |
| 9462 |
|
| 9463 |
/*:510*/ |
| 9464 |
#line 5313 "./marpa.w" |
| 9465 |
|
| 9466 |
transitive_closure(nsy_by_right_nsy_matrix); |
| 9467 |
} |
| 9468 |
|
| 9469 |
/*:507*/ |
| 9470 |
#line 3223 "./marpa.w" |
| 9471 |
|
| 9472 |
/*522:*/ |
| 9473 |
#line 5557 "./marpa.w" |
| 9474 |
|
| 9475 |
{ |
| 9476 |
AHMID ahm_id; |
| 9477 |
const int ahm_count= AHM_Count_of_G(g); |
| 9478 |
for(ahm_id= 0;ahm_id<ahm_count;ahm_id++) |
| 9479 |
{ |
| 9480 |
const AHM ahm= AHM_by_ID(ahm_id); |
| 9481 |
const NSYID postdot_nsyid= Postdot_NSYID_of_AHM(ahm); |
| 9482 |
if(postdot_nsyid<0) |
| 9483 |
{ |
| 9484 |
Predicted_IRL_CIL_of_AHM(ahm)= cil_empty(&g->t_cilar); |
| 9485 |
LHS_CIL_of_AHM(ahm)= cil_empty(&g->t_cilar); |
| 9486 |
} |
| 9487 |
else |
| 9488 |
{ |
| 9489 |
Predicted_IRL_CIL_of_AHM(ahm)= |
| 9490 |
cil_bv_add(&g->t_cilar, |
| 9491 |
matrix_row(prediction_nsy_by_irl_matrix,postdot_nsyid)); |
| 9492 |
LHS_CIL_of_AHM(ahm)= LHS_CIL_of_NSYID(postdot_nsyid); |
| 9493 |
} |
| 9494 |
} |
| 9495 |
} |
| 9496 |
|
| 9497 |
/*:522*/ |
| 9498 |
#line 3224 "./marpa.w" |
| 9499 |
|
| 9500 |
/*523:*/ |
| 9501 |
#line 5581 "./marpa.w" |
| 9502 |
|
| 9503 |
{ |
| 9504 |
int xsy_id; |
| 9505 |
g->t_bv_nsyid_is_terminal= bv_obs_create(g->t_obs,nsy_count); |
| 9506 |
for(xsy_id= 0;xsy_id<post_census_xsy_count;xsy_id++) |
| 9507 |
{ |
| 9508 |
if(XSYID_is_Terminal(xsy_id)) |
| 9509 |
{ |
| 9510 |
|
| 9511 |
|
| 9512 |
const NSY nsy= NSY_of_XSY(XSY_by_ID(xsy_id)); |
| 9513 |
if(nsy) |
| 9514 |
{ |
| 9515 |
bv_bit_set(g->t_bv_nsyid_is_terminal, |
| 9516 |
ID_of_NSY(nsy)); |
| 9517 |
} |
| 9518 |
} |
| 9519 |
} |
| 9520 |
} |
| 9521 |
|
| 9522 |
/*:523*/ |
| 9523 |
#line 3225 "./marpa.w" |
| 9524 |
|
| 9525 |
/*525:*/ |
| 9526 |
#line 5646 "./marpa.w" |
| 9527 |
|
| 9528 |
{ |
| 9529 |
AHMID ahm_id; |
| 9530 |
const int ahm_count_of_g= AHM_Count_of_G(g); |
| 9531 |
const LBV bv_completion_xsyid= bv_create(post_census_xsy_count); |
| 9532 |
const LBV bv_prediction_xsyid= bv_create(post_census_xsy_count); |
| 9533 |
const LBV bv_nulled_xsyid= bv_create(post_census_xsy_count); |
| 9534 |
const CILAR cilar= &g->t_cilar; |
| 9535 |
for(ahm_id= 0;ahm_id<ahm_count_of_g;ahm_id++) |
| 9536 |
{ |
| 9537 |
const AHM ahm= AHM_by_ID(ahm_id); |
| 9538 |
const NSYID postdot_nsyid= Postdot_NSYID_of_AHM(ahm); |
| 9539 |
const IRL irl= IRL_of_AHM(ahm); |
| 9540 |
bv_clear(bv_completion_xsyid); |
| 9541 |
bv_clear(bv_prediction_xsyid); |
| 9542 |
bv_clear(bv_nulled_xsyid); |
| 9543 |
{ |
| 9544 |
int rhs_ix; |
| 9545 |
int raw_position= Position_of_AHM(ahm); |
| 9546 |
if(raw_position<0) |
| 9547 |
{ |
| 9548 |
raw_position= Length_of_IRL(irl); |
| 9549 |
if(!IRL_has_Virtual_LHS(irl)) |
| 9550 |
{ |
| 9551 |
const NSY lhs= LHS_of_IRL(irl); |
| 9552 |
const XSY xsy= Source_XSY_of_NSY(lhs); |
| 9553 |
if(XSY_is_Completion_Event(xsy)) |
| 9554 |
{ |
| 9555 |
const XSYID xsyid= ID_of_XSY(xsy); |
| 9556 |
bv_bit_set(bv_completion_xsyid,xsyid); |
| 9557 |
} |
| 9558 |
} |
| 9559 |
} |
| 9560 |
if(postdot_nsyid>=0) |
| 9561 |
{ |
| 9562 |
const XSY xsy= Source_XSY_of_NSYID(postdot_nsyid); |
| 9563 |
const XSYID xsyid= ID_of_XSY(xsy); |
| 9564 |
bv_bit_set(bv_prediction_xsyid,xsyid); |
| 9565 |
} |
| 9566 |
for(rhs_ix= raw_position-Null_Count_of_AHM(ahm); |
| 9567 |
rhs_ix<raw_position;rhs_ix++) |
| 9568 |
{ |
| 9569 |
int cil_ix; |
| 9570 |
const NSYID rhs_nsyid= RHSID_of_IRL(irl,rhs_ix); |
| 9571 |
const XSY xsy= Source_XSY_of_NSYID(rhs_nsyid); |
| 9572 |
const CIL nulled_xsyids= Nulled_XSYIDs_of_XSY(xsy); |
| 9573 |
const int cil_count= Count_of_CIL(nulled_xsyids); |
| 9574 |
for(cil_ix= 0;cil_ix<cil_count;cil_ix++) |
| 9575 |
{ |
| 9576 |
const XSYID nulled_xsyid= |
| 9577 |
Item_of_CIL(nulled_xsyids,cil_ix); |
| 9578 |
bv_bit_set(bv_nulled_xsyid,nulled_xsyid); |
| 9579 |
} |
| 9580 |
} |
| 9581 |
} |
| 9582 |
Completion_XSYIDs_of_AHM(ahm)= |
| 9583 |
cil_bv_add(cilar,bv_completion_xsyid); |
| 9584 |
Nulled_XSYIDs_of_AHM(ahm)= cil_bv_add(cilar,bv_nulled_xsyid); |
| 9585 |
Prediction_XSYIDs_of_AHM(ahm)= |
| 9586 |
cil_bv_add(cilar,bv_prediction_xsyid); |
| 9587 |
} |
| 9588 |
bv_free(bv_completion_xsyid); |
| 9589 |
bv_free(bv_prediction_xsyid); |
| 9590 |
bv_free(bv_nulled_xsyid); |
| 9591 |
} |
| 9592 |
|
| 9593 |
/*:525*/ |
| 9594 |
#line 3227 "./marpa.w" |
| 9595 |
|
| 9596 |
/*526:*/ |
| 9597 |
#line 5712 "./marpa.w" |
| 9598 |
|
| 9599 |
{ |
| 9600 |
AHMID ahm_id; |
| 9601 |
for(ahm_id= 0;ahm_id<AHM_Count_of_G(g);ahm_id++) |
| 9602 |
{ |
| 9603 |
const CILAR cilar= &g->t_cilar; |
| 9604 |
const AHM ahm= AHM_by_ID(ahm_id); |
| 9605 |
const int ahm_is_event= |
| 9606 |
Count_of_CIL(Completion_XSYIDs_of_AHM(ahm)) |
| 9607 |
||Count_of_CIL(Nulled_XSYIDs_of_AHM(ahm)) |
| 9608 |
||Count_of_CIL(Prediction_XSYIDs_of_AHM(ahm)); |
| 9609 |
Event_AHMIDs_of_AHM(ahm)= |
| 9610 |
ahm_is_event?cil_singleton(cilar,ahm_id):cil_empty(cilar); |
| 9611 |
} |
| 9612 |
} |
| 9613 |
|
| 9614 |
/*:526*/ |
| 9615 |
#line 3228 "./marpa.w" |
| 9616 |
|
| 9617 |
/*527:*/ |
| 9618 |
#line 5728 "./marpa.w" |
| 9619 |
|
| 9620 |
{ |
| 9621 |
const int ahm_count_of_g= AHM_Count_of_G(g); |
| 9622 |
AHMID outer_ahm_id; |
| 9623 |
for(outer_ahm_id= 0;outer_ahm_id<ahm_count_of_g;outer_ahm_id++) |
| 9624 |
{ |
| 9625 |
AHMID inner_ahm_id; |
| 9626 |
const AHM outer_ahm= AHM_by_ID(outer_ahm_id); |
| 9627 |
|
| 9628 |
|
| 9629 |
|
| 9630 |
|
| 9631 |
NSYID outer_nsyid; |
| 9632 |
if(!AHM_is_Leo_Completion(outer_ahm)){ |
| 9633 |
if(AHM_has_Event(outer_ahm)){ |
| 9634 |
Event_Group_Size_of_AHM(outer_ahm)= 1; |
| 9635 |
} |
| 9636 |
continue; |
| 9637 |
|
| 9638 |
} |
| 9639 |
outer_nsyid= LHSID_of_AHM(outer_ahm); |
| 9640 |
for(inner_ahm_id= 0;inner_ahm_id<ahm_count_of_g; |
| 9641 |
inner_ahm_id++) |
| 9642 |
{ |
| 9643 |
NSYID inner_nsyid; |
| 9644 |
const AHM inner_ahm= AHM_by_ID(inner_ahm_id); |
| 9645 |
if(!AHM_has_Event(inner_ahm)) |
| 9646 |
continue; |
| 9647 |
|
| 9648 |
if(!AHM_is_Leo_Completion(inner_ahm)) |
| 9649 |
continue; |
| 9650 |
|
| 9651 |
inner_nsyid= LHSID_of_AHM(inner_ahm); |
| 9652 |
if(matrix_bit_test(nsy_by_right_nsy_matrix, |
| 9653 |
outer_nsyid, |
| 9654 |
inner_nsyid)) |
| 9655 |
{ |
| 9656 |
|
| 9657 |
|
| 9658 |
|
| 9659 |
Event_Group_Size_of_AHM(outer_ahm)++; |
| 9660 |
} |
| 9661 |
} |
| 9662 |
} |
| 9663 |
} |
| 9664 |
|
| 9665 |
/*:527*/ |
| 9666 |
#line 3229 "./marpa.w" |
| 9667 |
|
| 9668 |
/*546:*/ |
| 9669 |
#line 5933 "./marpa.w" |
| 9670 |
|
| 9671 |
{ |
| 9672 |
AHMID ahm_id; |
| 9673 |
const int ahm_count_of_g= AHM_Count_of_G(g); |
| 9674 |
for(ahm_id= 0;ahm_id<ahm_count_of_g;ahm_id++) |
| 9675 |
{ |
| 9676 |
ZWP_Object sought_zwp_object; |
| 9677 |
ZWP sought_zwp= &sought_zwp_object; |
| 9678 |
ZWP found_zwp; |
| 9679 |
MARPA_AVL_TRAV traverser; |
| 9680 |
const AHM ahm= AHM_by_ID(ahm_id); |
| 9681 |
const XRL ahm_xrl= XRL_of_AHM(ahm); |
| 9682 |
cil_buffer_clear(&g->t_cilar); |
| 9683 |
if(ahm_xrl) |
| 9684 |
{ |
| 9685 |
const int xrl_dot_end= Raw_XRL_Position_of_AHM(ahm); |
| 9686 |
const int xrl_dot_start= xrl_dot_end-Null_Count_of_AHM(ahm); |
| 9687 |
|
| 9688 |
|
| 9689 |
const XRLID sought_xrlid= ID_of_XRL(ahm_xrl); |
| 9690 |
XRLID_of_ZWP(sought_zwp)= sought_xrlid; |
| 9691 |
Dot_of_ZWP(sought_zwp)= xrl_dot_start; |
| 9692 |
ZWAID_of_ZWP(sought_zwp)= 0; |
| 9693 |
traverser= _marpa_avl_t_init((g)->t_zwp_tree); |
| 9694 |
found_zwp= _marpa_avl_t_at_or_after(traverser,sought_zwp); |
| 9695 |
|
| 9696 |
|
| 9697 |
|
| 9698 |
while( |
| 9699 |
found_zwp |
| 9700 |
&&XRLID_of_ZWP(found_zwp)==sought_xrlid |
| 9701 |
&&Dot_of_ZWP(found_zwp)<=xrl_dot_end) |
| 9702 |
{ |
| 9703 |
cil_buffer_push(&g->t_cilar,ZWAID_of_ZWP(found_zwp)); |
| 9704 |
found_zwp= _marpa_avl_t_next(traverser); |
| 9705 |
} |
| 9706 |
} |
| 9707 |
ZWA_CIL_of_AHM(ahm)= cil_buffer_add(&g->t_cilar); |
| 9708 |
} |
| 9709 |
} |
| 9710 |
|
| 9711 |
/*:546*/ |
| 9712 |
#line 3230 "./marpa.w" |
| 9713 |
|
| 9714 |
/*547:*/ |
| 9715 |
#line 5978 "./marpa.w" |
| 9716 |
|
| 9717 |
{ |
| 9718 |
AHMID ahm_id; |
| 9719 |
const int ahm_count_of_g= AHM_Count_of_G(g); |
| 9720 |
for(ahm_id= 0;ahm_id<ahm_count_of_g;ahm_id++) |
| 9721 |
{ |
| 9722 |
const AHM ahm_to_populate= AHM_by_ID(ahm_id); |
| 9723 |
|
| 9724 |
|
| 9725 |
|
| 9726 |
|
| 9727 |
const CIL prediction_cil= Predicted_IRL_CIL_of_AHM(ahm_to_populate); |
| 9728 |
const int prediction_count= Count_of_CIL(prediction_cil); |
| 9729 |
|
| 9730 |
int cil_ix; |
| 9731 |
for(cil_ix= 0;cil_ix<prediction_count;cil_ix++) |
| 9732 |
{ |
| 9733 |
const IRLID prediction_irlid= Item_of_CIL(prediction_cil,cil_ix); |
| 9734 |
const AHM prediction_ahm_of_irl= First_AHM_of_IRLID(prediction_irlid); |
| 9735 |
const CIL zwaids_of_prediction= ZWA_CIL_of_AHM(prediction_ahm_of_irl); |
| 9736 |
if(Count_of_CIL(zwaids_of_prediction)> 0){ |
| 9737 |
AHM_predicts_ZWA(ahm_to_populate)= 1; |
| 9738 |
break; |
| 9739 |
} |
| 9740 |
} |
| 9741 |
} |
| 9742 |
} |
| 9743 |
|
| 9744 |
/*:547*/ |
| 9745 |
#line 3231 "./marpa.w" |
| 9746 |
|
| 9747 |
} |
| 9748 |
g->t_is_precomputed= 1; |
| 9749 |
if(g->t_has_cycle) |
| 9750 |
{ |
| 9751 |
MARPA_ERROR(MARPA_ERR_GRAMMAR_HAS_CYCLE); |
| 9752 |
goto FAILURE; |
| 9753 |
} |
| 9754 |
/*369:*/ |
| 9755 |
#line 3253 "./marpa.w" |
| 9756 |
|
| 9757 |
{cilar_buffer_reinit(&g->t_cilar);} |
| 9758 |
/*:369*/ |
| 9759 |
#line 3239 "./marpa.w" |
| 9760 |
|
| 9761 |
return_value= 0; |
| 9762 |
goto CLEANUP; |
| 9763 |
FAILURE:; |
| 9764 |
goto CLEANUP; |
| 9765 |
CLEANUP:; |
| 9766 |
marpa_obs_free(obs_precompute); |
| 9767 |
return return_value; |
| 9768 |
} |
| 9769 |
|
| 9770 |
/*:368*//*379:*/ |
| 9771 |
#line 3352 "./marpa.w" |
| 9772 |
|
| 9773 |
PRIVATE_NOT_INLINE int sym_rule_cmp( |
| 9774 |
const void*ap, |
| 9775 |
const void*bp, |
| 9776 |
void*param UNUSED) |
| 9777 |
{ |
| 9778 |
const struct sym_rule_pair*pair_a= (struct sym_rule_pair*)ap; |
| 9779 |
const struct sym_rule_pair*pair_b= (struct sym_rule_pair*)bp; |
| 9780 |
int result= pair_a->t_symid-pair_b->t_symid; |
| 9781 |
if(result)return result; |
| 9782 |
return pair_a->t_ruleid-pair_b->t_ruleid; |
| 9783 |
} |
| 9784 |
|
| 9785 |
/*:379*//*412:*/ |
| 9786 |
#line 4064 "./marpa.w" |
| 9787 |
|
| 9788 |
int _marpa_g_irl_is_chaf( |
| 9789 |
Marpa_Grammar g, |
| 9790 |
Marpa_IRL_ID irl_id) |
| 9791 |
{ |
| 9792 |
/*1230:*/ |
| 9793 |
#line 14864 "./marpa.w" |
| 9794 |
const int failure_indicator= -2; |
| 9795 |
|
| 9796 |
/*:1230*/ |
| 9797 |
#line 4069 "./marpa.w" |
| 9798 |
|
| 9799 |
/*1232:*/ |
| 9800 |
#line 14875 "./marpa.w" |
| 9801 |
|
| 9802 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 9803 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 9804 |
return failure_indicator; |
| 9805 |
} |
| 9806 |
/*:1232*/ |
| 9807 |
#line 4070 "./marpa.w" |
| 9808 |
|
| 9809 |
/*1239:*/ |
| 9810 |
#line 14916 "./marpa.w" |
| 9811 |
|
| 9812 |
if(_MARPA_UNLIKELY(!IRLID_of_G_is_Valid(irl_id))){ |
| 9813 |
MARPA_ERROR(MARPA_ERR_INVALID_IRLID); |
| 9814 |
return failure_indicator; |
| 9815 |
} |
| 9816 |
/*:1239*/ |
| 9817 |
#line 4071 "./marpa.w" |
| 9818 |
|
| 9819 |
return IRL_is_CHAF(IRL_by_ID(irl_id)); |
| 9820 |
} |
| 9821 |
|
| 9822 |
/*:412*//*461:*/ |
| 9823 |
#line 4880 "./marpa.w" |
| 9824 |
|
| 9825 |
PRIVATE int ahm_is_valid( |
| 9826 |
GRAMMAR g,AHMID item_id) |
| 9827 |
{ |
| 9828 |
return item_id<(AHMID)AHM_Count_of_G(g)&&item_id>=0; |
| 9829 |
} |
| 9830 |
|
| 9831 |
/*:461*//*478:*/ |
| 9832 |
#line 5006 "./marpa.w" |
| 9833 |
|
| 9834 |
int _marpa_g_ahm_count(Marpa_Grammar g){ |
| 9835 |
/*1230:*/ |
| 9836 |
#line 14864 "./marpa.w" |
| 9837 |
const int failure_indicator= -2; |
| 9838 |
|
| 9839 |
/*:1230*/ |
| 9840 |
#line 5008 "./marpa.w" |
| 9841 |
|
| 9842 |
/*1232:*/ |
| 9843 |
#line 14875 "./marpa.w" |
| 9844 |
|
| 9845 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 9846 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 9847 |
return failure_indicator; |
| 9848 |
} |
| 9849 |
/*:1232*/ |
| 9850 |
#line 5009 "./marpa.w" |
| 9851 |
|
| 9852 |
return AHM_Count_of_G(g); |
| 9853 |
} |
| 9854 |
|
| 9855 |
/*:478*//*479:*/ |
| 9856 |
#line 5013 "./marpa.w" |
| 9857 |
|
| 9858 |
Marpa_IRL_ID _marpa_g_ahm_irl(Marpa_Grammar g, |
| 9859 |
Marpa_AHM_ID item_id){ |
| 9860 |
/*1230:*/ |
| 9861 |
#line 14864 "./marpa.w" |
| 9862 |
const int failure_indicator= -2; |
| 9863 |
|
| 9864 |
/*:1230*/ |
| 9865 |
#line 5016 "./marpa.w" |
| 9866 |
|
| 9867 |
/*1232:*/ |
| 9868 |
#line 14875 "./marpa.w" |
| 9869 |
|
| 9870 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 9871 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 9872 |
return failure_indicator; |
| 9873 |
} |
| 9874 |
/*:1232*/ |
| 9875 |
#line 5017 "./marpa.w" |
| 9876 |
|
| 9877 |
/*1245:*/ |
| 9878 |
#line 14959 "./marpa.w" |
| 9879 |
|
| 9880 |
if(_MARPA_UNLIKELY(!ahm_is_valid(g,item_id))){ |
| 9881 |
MARPA_ERROR(MARPA_ERR_INVALID_AIMID); |
| 9882 |
return failure_indicator; |
| 9883 |
} |
| 9884 |
|
| 9885 |
/*:1245*/ |
| 9886 |
#line 5018 "./marpa.w" |
| 9887 |
|
| 9888 |
return IRLID_of_AHM(AHM_by_ID(item_id)); |
| 9889 |
} |
| 9890 |
|
| 9891 |
/*:479*//*481:*/ |
| 9892 |
#line 5023 "./marpa.w" |
| 9893 |
|
| 9894 |
int _marpa_g_ahm_position(Marpa_Grammar g, |
| 9895 |
Marpa_AHM_ID item_id){ |
| 9896 |
/*1230:*/ |
| 9897 |
#line 14864 "./marpa.w" |
| 9898 |
const int failure_indicator= -2; |
| 9899 |
|
| 9900 |
/*:1230*/ |
| 9901 |
#line 5026 "./marpa.w" |
| 9902 |
|
| 9903 |
/*1232:*/ |
| 9904 |
#line 14875 "./marpa.w" |
| 9905 |
|
| 9906 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 9907 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 9908 |
return failure_indicator; |
| 9909 |
} |
| 9910 |
/*:1232*/ |
| 9911 |
#line 5027 "./marpa.w" |
| 9912 |
|
| 9913 |
/*1245:*/ |
| 9914 |
#line 14959 "./marpa.w" |
| 9915 |
|
| 9916 |
if(_MARPA_UNLIKELY(!ahm_is_valid(g,item_id))){ |
| 9917 |
MARPA_ERROR(MARPA_ERR_INVALID_AIMID); |
| 9918 |
return failure_indicator; |
| 9919 |
} |
| 9920 |
|
| 9921 |
/*:1245*/ |
| 9922 |
#line 5028 "./marpa.w" |
| 9923 |
|
| 9924 |
return Position_of_AHM(AHM_by_ID(item_id)); |
| 9925 |
} |
| 9926 |
|
| 9927 |
/*:481*//*483:*/ |
| 9928 |
#line 5033 "./marpa.w" |
| 9929 |
|
| 9930 |
Marpa_Symbol_ID _marpa_g_ahm_postdot(Marpa_Grammar g, |
| 9931 |
Marpa_AHM_ID item_id){ |
| 9932 |
/*1230:*/ |
| 9933 |
#line 14864 "./marpa.w" |
| 9934 |
const int failure_indicator= -2; |
| 9935 |
|
| 9936 |
/*:1230*/ |
| 9937 |
#line 5036 "./marpa.w" |
| 9938 |
|
| 9939 |
/*1232:*/ |
| 9940 |
#line 14875 "./marpa.w" |
| 9941 |
|
| 9942 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 9943 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 9944 |
return failure_indicator; |
| 9945 |
} |
| 9946 |
/*:1232*/ |
| 9947 |
#line 5037 "./marpa.w" |
| 9948 |
|
| 9949 |
/*1245:*/ |
| 9950 |
#line 14959 "./marpa.w" |
| 9951 |
|
| 9952 |
if(_MARPA_UNLIKELY(!ahm_is_valid(g,item_id))){ |
| 9953 |
MARPA_ERROR(MARPA_ERR_INVALID_AIMID); |
| 9954 |
return failure_indicator; |
| 9955 |
} |
| 9956 |
|
| 9957 |
/*:1245*/ |
| 9958 |
#line 5038 "./marpa.w" |
| 9959 |
|
| 9960 |
return Postdot_NSYID_of_AHM(AHM_by_ID(item_id)); |
| 9961 |
} |
| 9962 |
|
| 9963 |
/*:483*//*491:*/ |
| 9964 |
#line 5151 "./marpa.w" |
| 9965 |
|
| 9966 |
PRIVATE void |
| 9967 |
memoize_xrl_data_for_AHM(AHM current_item,IRL irl) |
| 9968 |
{ |
| 9969 |
XRL source_xrl= Source_XRL_of_IRL(irl); |
| 9970 |
XRL_of_AHM(current_item)= source_xrl; |
| 9971 |
if(!source_xrl){ |
| 9972 |
|
| 9973 |
|
| 9974 |
XRL_Position_of_AHM(current_item)= -2; |
| 9975 |
return; |
| 9976 |
} |
| 9977 |
{ |
| 9978 |
const int virtual_start= Virtual_Start_of_IRL(irl); |
| 9979 |
const int irl_position= Position_of_AHM(current_item); |
| 9980 |
if(XRL_is_Sequence(source_xrl)) |
| 9981 |
{ |
| 9982 |
|
| 9983 |
|
| 9984 |
|
| 9985 |
|
| 9986 |
XRL_Position_of_AHM(current_item)= irl_position?-1:0; |
| 9987 |
return; |
| 9988 |
} |
| 9989 |
|
| 9990 |
|
| 9991 |
if(IRL_is_CHAF(irl)&& |
| 9992 |
(irl_position<0||irl_position>=Length_of_IRL(irl))) |
| 9993 |
{ |
| 9994 |
XRL_Position_of_AHM(current_item)= -1; |
| 9995 |
return; |
| 9996 |
} |
| 9997 |
if(virtual_start>=0) |
| 9998 |
{ |
| 9999 |
XRL_Position_of_AHM(current_item)= irl_position+virtual_start; |
| 10000 |
return; |
| 10001 |
} |
| 10002 |
XRL_Position_of_AHM(current_item)= irl_position; |
| 10003 |
} |
| 10004 |
return; |
| 10005 |
} |
| 10006 |
|
| 10007 |
/*:491*//*542:*/ |
| 10008 |
#line 5843 "./marpa.w" |
| 10009 |
|
| 10010 |
PRIVATE_NOT_INLINE int zwp_cmp( |
| 10011 |
const void*ap, |
| 10012 |
const void*bp, |
| 10013 |
void*param UNUSED) |
| 10014 |
{ |
| 10015 |
const ZWP_Const zwp_a= ap; |
| 10016 |
const ZWP_Const zwp_b= bp; |
| 10017 |
int subkey= XRLID_of_ZWP(zwp_a)-XRLID_of_ZWP(zwp_b); |
| 10018 |
if(subkey)return subkey; |
| 10019 |
subkey= Dot_of_ZWP(zwp_a)-Dot_of_ZWP(zwp_b); |
| 10020 |
if(subkey)return subkey; |
| 10021 |
return ZWAID_of_ZWP(zwp_a)-ZWAID_of_ZWP(zwp_b); |
| 10022 |
} |
| 10023 |
|
| 10024 |
/*:542*//*543:*/ |
| 10025 |
#line 5858 "./marpa.w" |
| 10026 |
|
| 10027 |
Marpa_Assertion_ID |
| 10028 |
marpa_g_zwa_new(Marpa_Grammar g,int default_value) |
| 10029 |
{ |
| 10030 |
/*1230:*/ |
| 10031 |
#line 14864 "./marpa.w" |
| 10032 |
const int failure_indicator= -2; |
| 10033 |
|
| 10034 |
/*:1230*/ |
| 10035 |
#line 5862 "./marpa.w" |
| 10036 |
|
| 10037 |
ZWAID zwa_id; |
| 10038 |
GZWA gzwa; |
| 10039 |
/*1250:*/ |
| 10040 |
#line 14997 "./marpa.w" |
| 10041 |
|
| 10042 |
if(HEADER_VERSION_MISMATCH){ |
| 10043 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 10044 |
return failure_indicator; |
| 10045 |
} |
| 10046 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 10047 |
MARPA_ERROR(g->t_error); |
| 10048 |
return failure_indicator; |
| 10049 |
} |
| 10050 |
|
| 10051 |
/*:1250*/ |
| 10052 |
#line 5865 "./marpa.w" |
| 10053 |
|
| 10054 |
/*1231:*/ |
| 10055 |
#line 14869 "./marpa.w" |
| 10056 |
|
| 10057 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 10058 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 10059 |
return failure_indicator; |
| 10060 |
} |
| 10061 |
|
| 10062 |
/*:1231*/ |
| 10063 |
#line 5866 "./marpa.w" |
| 10064 |
|
| 10065 |
if(_MARPA_UNLIKELY(default_value<0||default_value> 1)) |
| 10066 |
{ |
| 10067 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 10068 |
return failure_indicator; |
| 10069 |
} |
| 10070 |
gzwa= marpa_obs_new(g->t_obs,GZWA_Object,1); |
| 10071 |
zwa_id= MARPA_DSTACK_LENGTH((g)->t_gzwa_stack); |
| 10072 |
*MARPA_DSTACK_PUSH((g)->t_gzwa_stack,GZWA)= gzwa; |
| 10073 |
gzwa->t_id= zwa_id; |
| 10074 |
gzwa->t_default_value= default_value?1:0; |
| 10075 |
return zwa_id; |
| 10076 |
} |
| 10077 |
|
| 10078 |
/*:543*//*544:*/ |
| 10079 |
#line 5880 "./marpa.w" |
| 10080 |
|
| 10081 |
Marpa_Assertion_ID |
| 10082 |
marpa_g_highest_zwa_id(Marpa_Grammar g) |
| 10083 |
{ |
| 10084 |
/*1230:*/ |
| 10085 |
#line 14864 "./marpa.w" |
| 10086 |
const int failure_indicator= -2; |
| 10087 |
|
| 10088 |
/*:1230*/ |
| 10089 |
#line 5884 "./marpa.w" |
| 10090 |
|
| 10091 |
/*1250:*/ |
| 10092 |
#line 14997 "./marpa.w" |
| 10093 |
|
| 10094 |
if(HEADER_VERSION_MISMATCH){ |
| 10095 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 10096 |
return failure_indicator; |
| 10097 |
} |
| 10098 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 10099 |
MARPA_ERROR(g->t_error); |
| 10100 |
return failure_indicator; |
| 10101 |
} |
| 10102 |
|
| 10103 |
/*:1250*/ |
| 10104 |
#line 5885 "./marpa.w" |
| 10105 |
|
| 10106 |
return ZWA_Count_of_G(g)-1; |
| 10107 |
} |
| 10108 |
|
| 10109 |
/*:544*//*545:*/ |
| 10110 |
#line 5892 "./marpa.w" |
| 10111 |
|
| 10112 |
int |
| 10113 |
marpa_g_zwa_place(Marpa_Grammar g, |
| 10114 |
Marpa_Assertion_ID zwaid, |
| 10115 |
Marpa_Rule_ID xrl_id,int rhs_ix) |
| 10116 |
{ |
| 10117 |
/*1230:*/ |
| 10118 |
#line 14864 "./marpa.w" |
| 10119 |
const int failure_indicator= -2; |
| 10120 |
|
| 10121 |
/*:1230*/ |
| 10122 |
#line 5898 "./marpa.w" |
| 10123 |
|
| 10124 |
void*avl_insert_result; |
| 10125 |
ZWP zwp; |
| 10126 |
XRL xrl; |
| 10127 |
int xrl_length; |
| 10128 |
/*1250:*/ |
| 10129 |
#line 14997 "./marpa.w" |
| 10130 |
|
| 10131 |
if(HEADER_VERSION_MISMATCH){ |
| 10132 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 10133 |
return failure_indicator; |
| 10134 |
} |
| 10135 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 10136 |
MARPA_ERROR(g->t_error); |
| 10137 |
return failure_indicator; |
| 10138 |
} |
| 10139 |
|
| 10140 |
/*:1250*/ |
| 10141 |
#line 5903 "./marpa.w" |
| 10142 |
|
| 10143 |
/*1231:*/ |
| 10144 |
#line 14869 "./marpa.w" |
| 10145 |
|
| 10146 |
if(_MARPA_UNLIKELY(G_is_Precomputed(g))){ |
| 10147 |
MARPA_ERROR(MARPA_ERR_PRECOMPUTED); |
| 10148 |
return failure_indicator; |
| 10149 |
} |
| 10150 |
|
| 10151 |
/*:1231*/ |
| 10152 |
#line 5904 "./marpa.w" |
| 10153 |
|
| 10154 |
/*1242:*/ |
| 10155 |
#line 14936 "./marpa.w" |
| 10156 |
|
| 10157 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 10158 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 10159 |
return failure_indicator; |
| 10160 |
} |
| 10161 |
|
| 10162 |
/*:1242*/ |
| 10163 |
#line 5905 "./marpa.w" |
| 10164 |
|
| 10165 |
/*1240:*/ |
| 10166 |
#line 14924 "./marpa.w" |
| 10167 |
|
| 10168 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 10169 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 10170 |
return-1; |
| 10171 |
} |
| 10172 |
|
| 10173 |
/*:1240*/ |
| 10174 |
#line 5906 "./marpa.w" |
| 10175 |
|
| 10176 |
/*1244:*/ |
| 10177 |
#line 14948 "./marpa.w" |
| 10178 |
|
| 10179 |
if(_MARPA_UNLIKELY(ZWAID_is_Malformed(zwaid))){ |
| 10180 |
MARPA_ERROR(MARPA_ERR_INVALID_ASSERTION_ID); |
| 10181 |
return failure_indicator; |
| 10182 |
} |
| 10183 |
|
| 10184 |
/*:1244*/ |
| 10185 |
#line 5907 "./marpa.w" |
| 10186 |
|
| 10187 |
/*1243:*/ |
| 10188 |
#line 14942 "./marpa.w" |
| 10189 |
|
| 10190 |
if(_MARPA_UNLIKELY(!ZWAID_of_G_Exists(zwaid))){ |
| 10191 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_ASSERTION_ID); |
| 10192 |
return failure_indicator; |
| 10193 |
} |
| 10194 |
/*:1243*/ |
| 10195 |
#line 5908 "./marpa.w" |
| 10196 |
|
| 10197 |
xrl= XRL_by_ID(xrl_id); |
| 10198 |
if(rhs_ix<-1){ |
| 10199 |
MARPA_ERROR(MARPA_ERR_RHS_IX_NEGATIVE); |
| 10200 |
return failure_indicator; |
| 10201 |
} |
| 10202 |
xrl_length= Length_of_XRL(xrl); |
| 10203 |
if(xrl_length<=rhs_ix){ |
| 10204 |
MARPA_ERROR(MARPA_ERR_RHS_IX_OOB); |
| 10205 |
return failure_indicator; |
| 10206 |
} |
| 10207 |
if(rhs_ix==-1){ |
| 10208 |
rhs_ix= XRL_is_Sequence(xrl)?1:xrl_length; |
| 10209 |
} |
| 10210 |
zwp= marpa_obs_new(g->t_obs,ZWP_Object,1); |
| 10211 |
XRLID_of_ZWP(zwp)= xrl_id; |
| 10212 |
Dot_of_ZWP(zwp)= rhs_ix; |
| 10213 |
ZWAID_of_ZWP(zwp)= zwaid; |
| 10214 |
avl_insert_result= _marpa_avl_insert(g->t_zwp_tree,zwp); |
| 10215 |
return avl_insert_result?-1:0; |
| 10216 |
} |
| 10217 |
|
| 10218 |
/*:545*//*551:*/ |
| 10219 |
#line 6024 "./marpa.w" |
| 10220 |
|
| 10221 |
Marpa_Recognizer marpa_r_new(Marpa_Grammar g) |
| 10222 |
{ |
| 10223 |
RECCE r; |
| 10224 |
int nsy_count; |
| 10225 |
int irl_count; |
| 10226 |
/*1229:*/ |
| 10227 |
#line 14861 "./marpa.w" |
| 10228 |
void*const failure_indicator= NULL; |
| 10229 |
/*:1229*/ |
| 10230 |
#line 6030 "./marpa.w" |
| 10231 |
|
| 10232 |
/*1232:*/ |
| 10233 |
#line 14875 "./marpa.w" |
| 10234 |
|
| 10235 |
if(_MARPA_UNLIKELY(!G_is_Precomputed(g))){ |
| 10236 |
MARPA_ERROR(MARPA_ERR_NOT_PRECOMPUTED); |
| 10237 |
return failure_indicator; |
| 10238 |
} |
| 10239 |
/*:1232*/ |
| 10240 |
#line 6031 "./marpa.w" |
| 10241 |
|
| 10242 |
nsy_count= NSY_Count_of_G(g); |
| 10243 |
irl_count= IRL_Count_of_G(g); |
| 10244 |
r= my_malloc(sizeof(struct marpa_r)); |
| 10245 |
/*616:*/ |
| 10246 |
#line 6645 "./marpa.w" |
| 10247 |
r->t_obs= marpa_obs_init; |
| 10248 |
/*:616*/ |
| 10249 |
#line 6035 "./marpa.w" |
| 10250 |
|
| 10251 |
/*554:*/ |
| 10252 |
#line 6044 "./marpa.w" |
| 10253 |
|
| 10254 |
r->t_ref_count= 1; |
| 10255 |
|
| 10256 |
/*:554*//*559:*/ |
| 10257 |
#line 6095 "./marpa.w" |
| 10258 |
|
| 10259 |
{ |
| 10260 |
G_of_R(r)= g; |
| 10261 |
grammar_ref(g); |
| 10262 |
} |
| 10263 |
/*:559*//*564:*/ |
| 10264 |
#line 6114 "./marpa.w" |
| 10265 |
|
| 10266 |
Input_Phase_of_R(r)= R_BEFORE_INPUT; |
| 10267 |
|
| 10268 |
/*:564*//*566:*/ |
| 10269 |
#line 6124 "./marpa.w" |
| 10270 |
|
| 10271 |
r->t_first_earley_set= NULL; |
| 10272 |
r->t_latest_earley_set= NULL; |
| 10273 |
r->t_current_earleme= -1; |
| 10274 |
|
| 10275 |
/*:566*//*570:*/ |
| 10276 |
#line 6160 "./marpa.w" |
| 10277 |
|
| 10278 |
r->t_earley_item_warning_threshold= |
| 10279 |
MAX(DEFAULT_YIM_WARNING_THRESHOLD,AHM_Count_of_G(g)*3); |
| 10280 |
/*:570*//*574:*/ |
| 10281 |
#line 6190 "./marpa.w" |
| 10282 |
r->t_furthest_earleme= 0; |
| 10283 |
/*:574*//*581:*/ |
| 10284 |
#line 6237 "./marpa.w" |
| 10285 |
|
| 10286 |
r->t_bv_nsyid_is_expected= bv_obs_create(r->t_obs,nsy_count); |
| 10287 |
/*:581*//*585:*/ |
| 10288 |
#line 6314 "./marpa.w" |
| 10289 |
|
| 10290 |
r->t_nsy_expected_is_event= lbv_obs_new0(r->t_obs,nsy_count); |
| 10291 |
/*:585*//*603:*/ |
| 10292 |
#line 6560 "./marpa.w" |
| 10293 |
|
| 10294 |
r->t_use_leo_flag= 1; |
| 10295 |
r->t_is_using_leo= 0; |
| 10296 |
/*:603*//*607:*/ |
| 10297 |
#line 6593 "./marpa.w" |
| 10298 |
|
| 10299 |
r->t_bv_irl_seen= bv_obs_create(r->t_obs,irl_count); |
| 10300 |
MARPA_DSTACK_INIT2(r->t_irl_cil_stack,CIL); |
| 10301 |
/*:607*//*610:*/ |
| 10302 |
#line 6610 "./marpa.w" |
| 10303 |
r->t_is_exhausted= 0; |
| 10304 |
/*:610*//*614:*/ |
| 10305 |
#line 6638 "./marpa.w" |
| 10306 |
r->t_first_inconsistent_ys= -1; |
| 10307 |
|
| 10308 |
/*:614*//*620:*/ |
| 10309 |
#line 6667 "./marpa.w" |
| 10310 |
|
| 10311 |
{ |
| 10312 |
ZWAID zwaid; |
| 10313 |
const int zwa_count= ZWA_Count_of_R(r); |
| 10314 |
(r)->t_zwas= marpa_obs_new(r->t_obs,ZWA_Object,ZWA_Count_of_R(r)); |
| 10315 |
for(zwaid= 0;zwaid<zwa_count;zwaid++){ |
| 10316 |
const GZWA gzwa= GZWA_by_ID(zwaid); |
| 10317 |
const ZWA zwa= RZWA_by_ID(zwaid); |
| 10318 |
ID_of_ZWA(zwa)= ID_of_GZWA(gzwa); |
| 10319 |
Default_Value_of_ZWA(zwa)= Default_Value_of_GZWA(gzwa); |
| 10320 |
Memo_Value_of_ZWA(zwa)= Default_Value_of_GZWA(gzwa); |
| 10321 |
Memo_YSID_of_ZWA(zwa)= -1; |
| 10322 |
} |
| 10323 |
} |
| 10324 |
|
| 10325 |
/*:620*//*635:*/ |
| 10326 |
#line 6761 "./marpa.w" |
| 10327 |
|
| 10328 |
r->t_earley_set_count= 0; |
| 10329 |
|
| 10330 |
/*:635*//*701:*/ |
| 10331 |
#line 7562 "./marpa.w" |
| 10332 |
|
| 10333 |
MARPA_DSTACK_INIT2(r->t_alternatives,ALT_Object); |
| 10334 |
/*:701*//*726:*/ |
| 10335 |
#line 8060 "./marpa.w" |
| 10336 |
MARPA_DSTACK_SAFE(r->t_yim_work_stack); |
| 10337 |
/*:726*//*730:*/ |
| 10338 |
#line 8075 "./marpa.w" |
| 10339 |
MARPA_DSTACK_SAFE(r->t_completion_stack); |
| 10340 |
/*:730*//*734:*/ |
| 10341 |
#line 8086 "./marpa.w" |
| 10342 |
MARPA_DSTACK_SAFE(r->t_earley_set_stack); |
| 10343 |
/*:734*//*825:*/ |
| 10344 |
#line 9619 "./marpa.w" |
| 10345 |
|
| 10346 |
r->t_current_report_item= &progress_report_not_ready; |
| 10347 |
r->t_progress_report_traverser= NULL; |
| 10348 |
/*:825*//*859:*/ |
| 10349 |
#line 10057 "./marpa.w" |
| 10350 |
|
| 10351 |
ur_node_stack_init(URS_of_R(r)); |
| 10352 |
/*:859*//*1262:*/ |
| 10353 |
#line 15142 "./marpa.w" |
| 10354 |
|
| 10355 |
r->t_trace_earley_set= NULL; |
| 10356 |
|
| 10357 |
/*:1262*//*1269:*/ |
| 10358 |
#line 15218 "./marpa.w" |
| 10359 |
|
| 10360 |
r->t_trace_earley_item= NULL; |
| 10361 |
|
| 10362 |
/*:1269*//*1284:*/ |
| 10363 |
#line 15435 "./marpa.w" |
| 10364 |
|
| 10365 |
r->t_trace_pim_nsy_p= NULL; |
| 10366 |
r->t_trace_postdot_item= NULL; |
| 10367 |
/*:1284*//*1292:*/ |
| 10368 |
#line 15585 "./marpa.w" |
| 10369 |
|
| 10370 |
r->t_trace_source_link= NULL; |
| 10371 |
r->t_trace_source_type= NO_SOURCE; |
| 10372 |
|
| 10373 |
/*:1292*/ |
| 10374 |
#line 6036 "./marpa.w" |
| 10375 |
|
| 10376 |
/*1211:*/ |
| 10377 |
#line 14674 "./marpa.w" |
| 10378 |
|
| 10379 |
{ |
| 10380 |
if(G_is_Trivial(g)){ |
| 10381 |
psar_safe(Dot_PSAR_of_R(r)); |
| 10382 |
}else{ |
| 10383 |
psar_init(Dot_PSAR_of_R(r),AHM_Count_of_G(g)); |
| 10384 |
} |
| 10385 |
} |
| 10386 |
/*:1211*/ |
| 10387 |
#line 6037 "./marpa.w" |
| 10388 |
|
| 10389 |
/*579:*/ |
| 10390 |
#line 6217 "./marpa.w" |
| 10391 |
|
| 10392 |
{ |
| 10393 |
NSYID xsy_count= XSY_Count_of_G(g); |
| 10394 |
r->t_lbv_xsyid_completion_event_is_active= |
| 10395 |
lbv_clone(r->t_obs,g->t_lbv_xsyid_completion_event_starts_active,xsy_count); |
| 10396 |
r->t_lbv_xsyid_nulled_event_is_active= |
| 10397 |
lbv_clone(r->t_obs,g->t_lbv_xsyid_nulled_event_starts_active,xsy_count); |
| 10398 |
r->t_lbv_xsyid_prediction_event_is_active= |
| 10399 |
lbv_clone(r->t_obs,g->t_lbv_xsyid_prediction_event_starts_active,xsy_count); |
| 10400 |
r->t_active_event_count= |
| 10401 |
bv_count(g->t_lbv_xsyid_is_completion_event) |
| 10402 |
+bv_count(g->t_lbv_xsyid_is_nulled_event) |
| 10403 |
+bv_count(g->t_lbv_xsyid_is_prediction_event); |
| 10404 |
} |
| 10405 |
|
| 10406 |
/*:579*/ |
| 10407 |
#line 6038 "./marpa.w" |
| 10408 |
|
| 10409 |
return r; |
| 10410 |
} |
| 10411 |
|
| 10412 |
/*:551*//*555:*/ |
| 10413 |
#line 6048 "./marpa.w" |
| 10414 |
|
| 10415 |
PRIVATE void |
| 10416 |
recce_unref(RECCE r) |
| 10417 |
{ |
| 10418 |
MARPA_ASSERT(r->t_ref_count> 0) |
| 10419 |
r->t_ref_count--; |
| 10420 |
if(r->t_ref_count<=0) |
| 10421 |
{ |
| 10422 |
recce_free(r); |
| 10423 |
} |
| 10424 |
} |
| 10425 |
void |
| 10426 |
marpa_r_unref(Marpa_Recognizer r) |
| 10427 |
{ |
| 10428 |
recce_unref(r); |
| 10429 |
} |
| 10430 |
|
| 10431 |
/*:555*//*556:*/ |
| 10432 |
#line 6066 "./marpa.w" |
| 10433 |
|
| 10434 |
PRIVATE |
| 10435 |
RECCE recce_ref(RECCE r) |
| 10436 |
{ |
| 10437 |
MARPA_ASSERT(r->t_ref_count> 0) |
| 10438 |
r->t_ref_count++; |
| 10439 |
return r; |
| 10440 |
} |
| 10441 |
Marpa_Recognizer |
| 10442 |
marpa_r_ref(Marpa_Recognizer r) |
| 10443 |
{ |
| 10444 |
return recce_ref(r); |
| 10445 |
} |
| 10446 |
|
| 10447 |
/*:556*//*557:*/ |
| 10448 |
#line 6080 "./marpa.w" |
| 10449 |
|
| 10450 |
PRIVATE |
| 10451 |
void recce_free(struct marpa_r*r) |
| 10452 |
{ |
| 10453 |
/*560:*/ |
| 10454 |
#line 6100 "./marpa.w" |
| 10455 |
|
| 10456 |
const GRAMMAR g= G_of_R(r); |
| 10457 |
/*:560*/ |
| 10458 |
#line 6084 "./marpa.w" |
| 10459 |
|
| 10460 |
/*561:*/ |
| 10461 |
#line 6102 "./marpa.w" |
| 10462 |
grammar_unref(g); |
| 10463 |
|
| 10464 |
/*:561*//*608:*/ |
| 10465 |
#line 6596 "./marpa.w" |
| 10466 |
|
| 10467 |
MARPA_DSTACK_DESTROY(r->t_irl_cil_stack); |
| 10468 |
|
| 10469 |
/*:608*//*702:*/ |
| 10470 |
#line 7564 "./marpa.w" |
| 10471 |
MARPA_DSTACK_DESTROY(r->t_alternatives); |
| 10472 |
|
| 10473 |
/*:702*//*728:*/ |
| 10474 |
#line 8068 "./marpa.w" |
| 10475 |
MARPA_DSTACK_DESTROY(r->t_yim_work_stack); |
| 10476 |
|
| 10477 |
/*:728*//*732:*/ |
| 10478 |
#line 8083 "./marpa.w" |
| 10479 |
MARPA_DSTACK_DESTROY(r->t_completion_stack); |
| 10480 |
|
| 10481 |
/*:732*//*735:*/ |
| 10482 |
#line 8087 "./marpa.w" |
| 10483 |
MARPA_DSTACK_DESTROY(r->t_earley_set_stack); |
| 10484 |
|
| 10485 |
/*:735*//*827:*/ |
| 10486 |
#line 9628 "./marpa.w" |
| 10487 |
|
| 10488 |
/*826:*/ |
| 10489 |
#line 9622 "./marpa.w" |
| 10490 |
|
| 10491 |
r->t_current_report_item= &progress_report_not_ready; |
| 10492 |
if(r->t_progress_report_traverser){ |
| 10493 |
_marpa_avl_destroy(MARPA_TREE_OF_AVL_TRAV(r->t_progress_report_traverser)); |
| 10494 |
} |
| 10495 |
r->t_progress_report_traverser= NULL; |
| 10496 |
/*:826*/ |
| 10497 |
#line 9629 "./marpa.w" |
| 10498 |
; |
| 10499 |
/*:827*//*860:*/ |
| 10500 |
#line 10059 "./marpa.w" |
| 10501 |
|
| 10502 |
ur_node_stack_destroy(URS_of_R(r)); |
| 10503 |
|
| 10504 |
/*:860*//*1212:*/ |
| 10505 |
#line 14682 "./marpa.w" |
| 10506 |
|
| 10507 |
psar_destroy(Dot_PSAR_of_R(r)); |
| 10508 |
/*:1212*/ |
| 10509 |
#line 6085 "./marpa.w" |
| 10510 |
|
| 10511 |
/*617:*/ |
| 10512 |
#line 6646 "./marpa.w" |
| 10513 |
marpa_obs_free(r->t_obs); |
| 10514 |
|
| 10515 |
/*:617*/ |
| 10516 |
#line 6086 "./marpa.w" |
| 10517 |
|
| 10518 |
my_free(r); |
| 10519 |
} |
| 10520 |
|
| 10521 |
/*:557*//*567:*/ |
| 10522 |
#line 6132 "./marpa.w" |
| 10523 |
|
| 10524 |
Marpa_Earleme marpa_r_current_earleme(Marpa_Recognizer r) |
| 10525 |
{ |
| 10526 |
/*1230:*/ |
| 10527 |
#line 14864 "./marpa.w" |
| 10528 |
const int failure_indicator= -2; |
| 10529 |
|
| 10530 |
/*:1230*/ |
| 10531 |
#line 6135 "./marpa.w" |
| 10532 |
|
| 10533 |
/*560:*/ |
| 10534 |
#line 6100 "./marpa.w" |
| 10535 |
|
| 10536 |
const GRAMMAR g= G_of_R(r); |
| 10537 |
/*:560*/ |
| 10538 |
#line 6136 "./marpa.w" |
| 10539 |
|
| 10540 |
/*1250:*/ |
| 10541 |
#line 14997 "./marpa.w" |
| 10542 |
|
| 10543 |
if(HEADER_VERSION_MISMATCH){ |
| 10544 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 10545 |
return failure_indicator; |
| 10546 |
} |
| 10547 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 10548 |
MARPA_ERROR(g->t_error); |
| 10549 |
return failure_indicator; |
| 10550 |
} |
| 10551 |
|
| 10552 |
/*:1250*/ |
| 10553 |
#line 6137 "./marpa.w" |
| 10554 |
|
| 10555 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 10556 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 10557 |
return-1; |
| 10558 |
} |
| 10559 |
return Current_Earleme_of_R(r); |
| 10560 |
} |
| 10561 |
|
| 10562 |
/*:567*//*568:*/ |
| 10563 |
#line 6149 "./marpa.w" |
| 10564 |
|
| 10565 |
PRIVATE YS ys_at_current_earleme(RECCE r) |
| 10566 |
{ |
| 10567 |
const YS latest= Latest_YS_of_R(r); |
| 10568 |
if(Earleme_of_YS(latest)==Current_Earleme_of_R(r))return latest; |
| 10569 |
return NULL; |
| 10570 |
} |
| 10571 |
|
| 10572 |
/*:568*//*571:*/ |
| 10573 |
#line 6163 "./marpa.w" |
| 10574 |
|
| 10575 |
int |
| 10576 |
marpa_r_earley_item_warning_threshold(Marpa_Recognizer r) |
| 10577 |
{ |
| 10578 |
return r->t_earley_item_warning_threshold; |
| 10579 |
} |
| 10580 |
|
| 10581 |
/*:571*//*572:*/ |
| 10582 |
#line 6172 "./marpa.w" |
| 10583 |
|
| 10584 |
int |
| 10585 |
marpa_r_earley_item_warning_threshold_set(Marpa_Recognizer r,int threshold) |
| 10586 |
{ |
| 10587 |
const int new_threshold= threshold<=0?YIM_FATAL_THRESHOLD:threshold; |
| 10588 |
r->t_earley_item_warning_threshold= new_threshold; |
| 10589 |
return new_threshold; |
| 10590 |
} |
| 10591 |
|
| 10592 |
/*:572*//*575:*/ |
| 10593 |
#line 6196 "./marpa.w" |
| 10594 |
|
| 10595 |
unsigned int marpa_r_furthest_earleme(Marpa_Recognizer r) |
| 10596 |
{return(unsigned int)Furthest_Earleme_of_R(r);} |
| 10597 |
|
| 10598 |
/*:575*//*582:*/ |
| 10599 |
#line 6245 "./marpa.w" |
| 10600 |
|
| 10601 |
int marpa_r_terminals_expected(Marpa_Recognizer r,Marpa_Symbol_ID*buffer) |
| 10602 |
{ |
| 10603 |
/*1230:*/ |
| 10604 |
#line 14864 "./marpa.w" |
| 10605 |
const int failure_indicator= -2; |
| 10606 |
|
| 10607 |
/*:1230*/ |
| 10608 |
#line 6248 "./marpa.w" |
| 10609 |
|
| 10610 |
/*560:*/ |
| 10611 |
#line 6100 "./marpa.w" |
| 10612 |
|
| 10613 |
const GRAMMAR g= G_of_R(r); |
| 10614 |
/*:560*/ |
| 10615 |
#line 6249 "./marpa.w" |
| 10616 |
|
| 10617 |
NSYID xsy_count; |
| 10618 |
Bit_Vector bv_terminals; |
| 10619 |
int min,max,start; |
| 10620 |
int next_buffer_ix= 0; |
| 10621 |
|
| 10622 |
/*1250:*/ |
| 10623 |
#line 14997 "./marpa.w" |
| 10624 |
|
| 10625 |
if(HEADER_VERSION_MISMATCH){ |
| 10626 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 10627 |
return failure_indicator; |
| 10628 |
} |
| 10629 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 10630 |
MARPA_ERROR(g->t_error); |
| 10631 |
return failure_indicator; |
| 10632 |
} |
| 10633 |
|
| 10634 |
/*:1250*/ |
| 10635 |
#line 6255 "./marpa.w" |
| 10636 |
|
| 10637 |
/*1247:*/ |
| 10638 |
#line 14973 "./marpa.w" |
| 10639 |
|
| 10640 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 10641 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 10642 |
return failure_indicator; |
| 10643 |
} |
| 10644 |
/*:1247*/ |
| 10645 |
#line 6256 "./marpa.w" |
| 10646 |
|
| 10647 |
|
| 10648 |
xsy_count= XSY_Count_of_G(g); |
| 10649 |
bv_terminals= bv_create(xsy_count); |
| 10650 |
for(start= 0;bv_scan(r->t_bv_nsyid_is_expected,start,&min,&max); |
| 10651 |
start= max+2) |
| 10652 |
{ |
| 10653 |
NSYID nsyid; |
| 10654 |
for(nsyid= min;nsyid<=max;nsyid++) |
| 10655 |
{ |
| 10656 |
const XSY xsy= Source_XSY_of_NSYID(nsyid); |
| 10657 |
bv_bit_set(bv_terminals,ID_of_XSY(xsy)); |
| 10658 |
} |
| 10659 |
} |
| 10660 |
|
| 10661 |
for(start= 0;bv_scan(bv_terminals,start,&min,&max);start= max+2) |
| 10662 |
{ |
| 10663 |
XSYID xsyid; |
| 10664 |
for(xsyid= min;xsyid<=max;xsyid++) |
| 10665 |
{ |
| 10666 |
buffer[next_buffer_ix++]= xsyid; |
| 10667 |
} |
| 10668 |
} |
| 10669 |
bv_free(bv_terminals); |
| 10670 |
return next_buffer_ix; |
| 10671 |
} |
| 10672 |
|
| 10673 |
/*:582*//*583:*/ |
| 10674 |
#line 6283 "./marpa.w" |
| 10675 |
|
| 10676 |
int marpa_r_terminal_is_expected(Marpa_Recognizer r, |
| 10677 |
Marpa_Symbol_ID xsy_id) |
| 10678 |
{ |
| 10679 |
/*1230:*/ |
| 10680 |
#line 14864 "./marpa.w" |
| 10681 |
const int failure_indicator= -2; |
| 10682 |
|
| 10683 |
/*:1230*/ |
| 10684 |
#line 6287 "./marpa.w" |
| 10685 |
|
| 10686 |
/*560:*/ |
| 10687 |
#line 6100 "./marpa.w" |
| 10688 |
|
| 10689 |
const GRAMMAR g= G_of_R(r); |
| 10690 |
/*:560*/ |
| 10691 |
#line 6288 "./marpa.w" |
| 10692 |
|
| 10693 |
XSY xsy; |
| 10694 |
NSY nsy; |
| 10695 |
/*1250:*/ |
| 10696 |
#line 14997 "./marpa.w" |
| 10697 |
|
| 10698 |
if(HEADER_VERSION_MISMATCH){ |
| 10699 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 10700 |
return failure_indicator; |
| 10701 |
} |
| 10702 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 10703 |
MARPA_ERROR(g->t_error); |
| 10704 |
return failure_indicator; |
| 10705 |
} |
| 10706 |
|
| 10707 |
/*:1250*/ |
| 10708 |
#line 6291 "./marpa.w" |
| 10709 |
|
| 10710 |
/*1247:*/ |
| 10711 |
#line 14973 "./marpa.w" |
| 10712 |
|
| 10713 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 10714 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 10715 |
return failure_indicator; |
| 10716 |
} |
| 10717 |
/*:1247*/ |
| 10718 |
#line 6292 "./marpa.w" |
| 10719 |
|
| 10720 |
/*1233:*/ |
| 10721 |
#line 14880 "./marpa.w" |
| 10722 |
|
| 10723 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 10724 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 10725 |
return failure_indicator; |
| 10726 |
} |
| 10727 |
/*:1233*/ |
| 10728 |
#line 6293 "./marpa.w" |
| 10729 |
|
| 10730 |
/*1235:*/ |
| 10731 |
#line 14892 "./marpa.w" |
| 10732 |
|
| 10733 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 10734 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 10735 |
return failure_indicator; |
| 10736 |
} |
| 10737 |
|
| 10738 |
/*:1235*/ |
| 10739 |
#line 6294 "./marpa.w" |
| 10740 |
|
| 10741 |
xsy= XSY_by_ID(xsy_id); |
| 10742 |
if(_MARPA_UNLIKELY(!XSY_is_Terminal(xsy))){ |
| 10743 |
return 0; |
| 10744 |
} |
| 10745 |
nsy= NSY_of_XSY(xsy); |
| 10746 |
if(_MARPA_UNLIKELY(!nsy))return 0; |
| 10747 |
return bv_bit_test(r->t_bv_nsyid_is_expected,ID_of_NSY(nsy)); |
| 10748 |
} |
| 10749 |
|
| 10750 |
/*:583*//*586:*/ |
| 10751 |
#line 6320 "./marpa.w" |
| 10752 |
|
| 10753 |
int |
| 10754 |
marpa_r_expected_symbol_event_set(Marpa_Recognizer r,Marpa_Symbol_ID xsy_id, |
| 10755 |
int value) |
| 10756 |
{ |
| 10757 |
XSY xsy; |
| 10758 |
NSY nsy; |
| 10759 |
NSYID nsyid; |
| 10760 |
/*1230:*/ |
| 10761 |
#line 14864 "./marpa.w" |
| 10762 |
const int failure_indicator= -2; |
| 10763 |
|
| 10764 |
/*:1230*/ |
| 10765 |
#line 6328 "./marpa.w" |
| 10766 |
|
| 10767 |
/*560:*/ |
| 10768 |
#line 6100 "./marpa.w" |
| 10769 |
|
| 10770 |
const GRAMMAR g= G_of_R(r); |
| 10771 |
/*:560*/ |
| 10772 |
#line 6329 "./marpa.w" |
| 10773 |
|
| 10774 |
/*1250:*/ |
| 10775 |
#line 14997 "./marpa.w" |
| 10776 |
|
| 10777 |
if(HEADER_VERSION_MISMATCH){ |
| 10778 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 10779 |
return failure_indicator; |
| 10780 |
} |
| 10781 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 10782 |
MARPA_ERROR(g->t_error); |
| 10783 |
return failure_indicator; |
| 10784 |
} |
| 10785 |
|
| 10786 |
/*:1250*/ |
| 10787 |
#line 6330 "./marpa.w" |
| 10788 |
|
| 10789 |
/*1233:*/ |
| 10790 |
#line 14880 "./marpa.w" |
| 10791 |
|
| 10792 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 10793 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 10794 |
return failure_indicator; |
| 10795 |
} |
| 10796 |
/*:1233*/ |
| 10797 |
#line 6331 "./marpa.w" |
| 10798 |
|
| 10799 |
/*1234:*/ |
| 10800 |
#line 14887 "./marpa.w" |
| 10801 |
|
| 10802 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 10803 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 10804 |
return-1; |
| 10805 |
} |
| 10806 |
/*:1234*/ |
| 10807 |
#line 6332 "./marpa.w" |
| 10808 |
|
| 10809 |
if(_MARPA_UNLIKELY(value<0||value> 1)) |
| 10810 |
{ |
| 10811 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 10812 |
return failure_indicator; |
| 10813 |
} |
| 10814 |
xsy= XSY_by_ID(xsy_id); |
| 10815 |
if(_MARPA_UNLIKELY(XSY_is_Nulling(xsy))){ |
| 10816 |
MARPA_ERROR(MARPA_ERR_SYMBOL_IS_NULLING); |
| 10817 |
return-2; |
| 10818 |
} |
| 10819 |
nsy= NSY_of_XSY(xsy); |
| 10820 |
if(_MARPA_UNLIKELY(!nsy)){ |
| 10821 |
MARPA_ERROR(MARPA_ERR_SYMBOL_IS_UNUSED); |
| 10822 |
return-2; |
| 10823 |
} |
| 10824 |
nsyid= ID_of_NSY(nsy); |
| 10825 |
if(value){ |
| 10826 |
lbv_bit_set(r->t_nsy_expected_is_event,nsyid); |
| 10827 |
}else{ |
| 10828 |
lbv_bit_clear(r->t_nsy_expected_is_event,nsyid); |
| 10829 |
} |
| 10830 |
return value; |
| 10831 |
} |
| 10832 |
|
| 10833 |
/*:586*//*588:*/ |
| 10834 |
#line 6371 "./marpa.w" |
| 10835 |
|
| 10836 |
int |
| 10837 |
marpa_r_completion_symbol_activate(Marpa_Recognizer r, |
| 10838 |
Marpa_Symbol_ID xsy_id,int reactivate) |
| 10839 |
{ |
| 10840 |
/*1230:*/ |
| 10841 |
#line 14864 "./marpa.w" |
| 10842 |
const int failure_indicator= -2; |
| 10843 |
|
| 10844 |
/*:1230*/ |
| 10845 |
#line 6376 "./marpa.w" |
| 10846 |
|
| 10847 |
/*560:*/ |
| 10848 |
#line 6100 "./marpa.w" |
| 10849 |
|
| 10850 |
const GRAMMAR g= G_of_R(r); |
| 10851 |
/*:560*/ |
| 10852 |
#line 6377 "./marpa.w" |
| 10853 |
|
| 10854 |
/*1250:*/ |
| 10855 |
#line 14997 "./marpa.w" |
| 10856 |
|
| 10857 |
if(HEADER_VERSION_MISMATCH){ |
| 10858 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 10859 |
return failure_indicator; |
| 10860 |
} |
| 10861 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 10862 |
MARPA_ERROR(g->t_error); |
| 10863 |
return failure_indicator; |
| 10864 |
} |
| 10865 |
|
| 10866 |
/*:1250*/ |
| 10867 |
#line 6378 "./marpa.w" |
| 10868 |
|
| 10869 |
/*1233:*/ |
| 10870 |
#line 14880 "./marpa.w" |
| 10871 |
|
| 10872 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 10873 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 10874 |
return failure_indicator; |
| 10875 |
} |
| 10876 |
/*:1233*/ |
| 10877 |
#line 6379 "./marpa.w" |
| 10878 |
|
| 10879 |
/*1234:*/ |
| 10880 |
#line 14887 "./marpa.w" |
| 10881 |
|
| 10882 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 10883 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 10884 |
return-1; |
| 10885 |
} |
| 10886 |
/*:1234*/ |
| 10887 |
#line 6380 "./marpa.w" |
| 10888 |
|
| 10889 |
switch(reactivate){ |
| 10890 |
case 0: |
| 10891 |
if(lbv_bit_test(r->t_lbv_xsyid_completion_event_is_active,xsy_id)){ |
| 10892 |
lbv_bit_clear(r->t_lbv_xsyid_completion_event_is_active,xsy_id); |
| 10893 |
r->t_active_event_count--; |
| 10894 |
} |
| 10895 |
return 0; |
| 10896 |
case 1: |
| 10897 |
if(!lbv_bit_test(g->t_lbv_xsyid_is_completion_event,xsy_id)){ |
| 10898 |
|
| 10899 |
|
| 10900 |
MARPA_ERROR(MARPA_ERR_SYMBOL_IS_NOT_COMPLETION_EVENT); |
| 10901 |
} |
| 10902 |
if(!lbv_bit_test(r->t_lbv_xsyid_completion_event_is_active,xsy_id)){ |
| 10903 |
lbv_bit_set(r->t_lbv_xsyid_completion_event_is_active,xsy_id); |
| 10904 |
r->t_active_event_count++; |
| 10905 |
} |
| 10906 |
return 1; |
| 10907 |
} |
| 10908 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 10909 |
return failure_indicator; |
| 10910 |
} |
| 10911 |
|
| 10912 |
/*:588*//*590:*/ |
| 10913 |
#line 6418 "./marpa.w" |
| 10914 |
|
| 10915 |
int |
| 10916 |
marpa_r_nulled_symbol_activate(Marpa_Recognizer r,Marpa_Symbol_ID xsy_id, |
| 10917 |
int reactivate) |
| 10918 |
{ |
| 10919 |
/*1230:*/ |
| 10920 |
#line 14864 "./marpa.w" |
| 10921 |
const int failure_indicator= -2; |
| 10922 |
|
| 10923 |
/*:1230*/ |
| 10924 |
#line 6423 "./marpa.w" |
| 10925 |
|
| 10926 |
/*560:*/ |
| 10927 |
#line 6100 "./marpa.w" |
| 10928 |
|
| 10929 |
const GRAMMAR g= G_of_R(r); |
| 10930 |
/*:560*/ |
| 10931 |
#line 6424 "./marpa.w" |
| 10932 |
|
| 10933 |
/*1250:*/ |
| 10934 |
#line 14997 "./marpa.w" |
| 10935 |
|
| 10936 |
if(HEADER_VERSION_MISMATCH){ |
| 10937 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 10938 |
return failure_indicator; |
| 10939 |
} |
| 10940 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 10941 |
MARPA_ERROR(g->t_error); |
| 10942 |
return failure_indicator; |
| 10943 |
} |
| 10944 |
|
| 10945 |
/*:1250*/ |
| 10946 |
#line 6425 "./marpa.w" |
| 10947 |
|
| 10948 |
/*1233:*/ |
| 10949 |
#line 14880 "./marpa.w" |
| 10950 |
|
| 10951 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 10952 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 10953 |
return failure_indicator; |
| 10954 |
} |
| 10955 |
/*:1233*/ |
| 10956 |
#line 6426 "./marpa.w" |
| 10957 |
|
| 10958 |
/*1234:*/ |
| 10959 |
#line 14887 "./marpa.w" |
| 10960 |
|
| 10961 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 10962 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 10963 |
return-1; |
| 10964 |
} |
| 10965 |
/*:1234*/ |
| 10966 |
#line 6427 "./marpa.w" |
| 10967 |
|
| 10968 |
switch(reactivate){ |
| 10969 |
case 0: |
| 10970 |
if(lbv_bit_test(r->t_lbv_xsyid_nulled_event_is_active,xsy_id)){ |
| 10971 |
lbv_bit_clear(r->t_lbv_xsyid_nulled_event_is_active,xsy_id); |
| 10972 |
r->t_active_event_count--; |
| 10973 |
} |
| 10974 |
return 0; |
| 10975 |
case 1: |
| 10976 |
if(!lbv_bit_test(g->t_lbv_xsyid_is_nulled_event,xsy_id)){ |
| 10977 |
|
| 10978 |
|
| 10979 |
MARPA_ERROR(MARPA_ERR_SYMBOL_IS_NOT_NULLED_EVENT); |
| 10980 |
} |
| 10981 |
if(!lbv_bit_test(r->t_lbv_xsyid_nulled_event_is_active,xsy_id)){ |
| 10982 |
lbv_bit_set(r->t_lbv_xsyid_nulled_event_is_active,xsy_id); |
| 10983 |
r->t_active_event_count++; |
| 10984 |
} |
| 10985 |
return 1; |
| 10986 |
} |
| 10987 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 10988 |
return failure_indicator; |
| 10989 |
} |
| 10990 |
|
| 10991 |
/*:590*//*592:*/ |
| 10992 |
#line 6465 "./marpa.w" |
| 10993 |
|
| 10994 |
int |
| 10995 |
marpa_r_prediction_symbol_activate(Marpa_Recognizer r, |
| 10996 |
Marpa_Symbol_ID xsy_id,int reactivate) |
| 10997 |
{ |
| 10998 |
/*1230:*/ |
| 10999 |
#line 14864 "./marpa.w" |
| 11000 |
const int failure_indicator= -2; |
| 11001 |
|
| 11002 |
/*:1230*/ |
| 11003 |
#line 6470 "./marpa.w" |
| 11004 |
|
| 11005 |
/*560:*/ |
| 11006 |
#line 6100 "./marpa.w" |
| 11007 |
|
| 11008 |
const GRAMMAR g= G_of_R(r); |
| 11009 |
/*:560*/ |
| 11010 |
#line 6471 "./marpa.w" |
| 11011 |
|
| 11012 |
/*1250:*/ |
| 11013 |
#line 14997 "./marpa.w" |
| 11014 |
|
| 11015 |
if(HEADER_VERSION_MISMATCH){ |
| 11016 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 11017 |
return failure_indicator; |
| 11018 |
} |
| 11019 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 11020 |
MARPA_ERROR(g->t_error); |
| 11021 |
return failure_indicator; |
| 11022 |
} |
| 11023 |
|
| 11024 |
/*:1250*/ |
| 11025 |
#line 6472 "./marpa.w" |
| 11026 |
|
| 11027 |
/*1233:*/ |
| 11028 |
#line 14880 "./marpa.w" |
| 11029 |
|
| 11030 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 11031 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 11032 |
return failure_indicator; |
| 11033 |
} |
| 11034 |
/*:1233*/ |
| 11035 |
#line 6473 "./marpa.w" |
| 11036 |
|
| 11037 |
/*1234:*/ |
| 11038 |
#line 14887 "./marpa.w" |
| 11039 |
|
| 11040 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 11041 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 11042 |
return-1; |
| 11043 |
} |
| 11044 |
/*:1234*/ |
| 11045 |
#line 6474 "./marpa.w" |
| 11046 |
|
| 11047 |
switch(reactivate){ |
| 11048 |
case 0: |
| 11049 |
if(lbv_bit_test(r->t_lbv_xsyid_prediction_event_is_active,xsy_id)){ |
| 11050 |
lbv_bit_clear(r->t_lbv_xsyid_prediction_event_is_active,xsy_id); |
| 11051 |
r->t_active_event_count--; |
| 11052 |
} |
| 11053 |
return 0; |
| 11054 |
case 1: |
| 11055 |
if(!lbv_bit_test(g->t_lbv_xsyid_is_prediction_event,xsy_id)){ |
| 11056 |
|
| 11057 |
|
| 11058 |
MARPA_ERROR(MARPA_ERR_SYMBOL_IS_NOT_PREDICTION_EVENT); |
| 11059 |
} |
| 11060 |
if(!lbv_bit_test(r->t_lbv_xsyid_prediction_event_is_active,xsy_id)){ |
| 11061 |
lbv_bit_set(r->t_lbv_xsyid_prediction_event_is_active,xsy_id); |
| 11062 |
r->t_active_event_count++; |
| 11063 |
} |
| 11064 |
return 1; |
| 11065 |
} |
| 11066 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 11067 |
return failure_indicator; |
| 11068 |
} |
| 11069 |
|
| 11070 |
/*:592*//*604:*/ |
| 11071 |
#line 6566 "./marpa.w" |
| 11072 |
|
| 11073 |
int _marpa_r_is_use_leo(Marpa_Recognizer r) |
| 11074 |
{ |
| 11075 |
/*560:*/ |
| 11076 |
#line 6100 "./marpa.w" |
| 11077 |
|
| 11078 |
const GRAMMAR g= G_of_R(r); |
| 11079 |
/*:560*/ |
| 11080 |
#line 6569 "./marpa.w" |
| 11081 |
|
| 11082 |
/*1230:*/ |
| 11083 |
#line 14864 "./marpa.w" |
| 11084 |
const int failure_indicator= -2; |
| 11085 |
|
| 11086 |
/*:1230*/ |
| 11087 |
#line 6570 "./marpa.w" |
| 11088 |
|
| 11089 |
/*1250:*/ |
| 11090 |
#line 14997 "./marpa.w" |
| 11091 |
|
| 11092 |
if(HEADER_VERSION_MISMATCH){ |
| 11093 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 11094 |
return failure_indicator; |
| 11095 |
} |
| 11096 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 11097 |
MARPA_ERROR(g->t_error); |
| 11098 |
return failure_indicator; |
| 11099 |
} |
| 11100 |
|
| 11101 |
/*:1250*/ |
| 11102 |
#line 6571 "./marpa.w" |
| 11103 |
|
| 11104 |
return r->t_use_leo_flag; |
| 11105 |
} |
| 11106 |
/*:604*//*605:*/ |
| 11107 |
#line 6574 "./marpa.w" |
| 11108 |
|
| 11109 |
int _marpa_r_is_use_leo_set( |
| 11110 |
Marpa_Recognizer r,int value) |
| 11111 |
{ |
| 11112 |
/*560:*/ |
| 11113 |
#line 6100 "./marpa.w" |
| 11114 |
|
| 11115 |
const GRAMMAR g= G_of_R(r); |
| 11116 |
/*:560*/ |
| 11117 |
#line 6578 "./marpa.w" |
| 11118 |
|
| 11119 |
/*1230:*/ |
| 11120 |
#line 14864 "./marpa.w" |
| 11121 |
const int failure_indicator= -2; |
| 11122 |
|
| 11123 |
/*:1230*/ |
| 11124 |
#line 6579 "./marpa.w" |
| 11125 |
|
| 11126 |
/*1250:*/ |
| 11127 |
#line 14997 "./marpa.w" |
| 11128 |
|
| 11129 |
if(HEADER_VERSION_MISMATCH){ |
| 11130 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 11131 |
return failure_indicator; |
| 11132 |
} |
| 11133 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 11134 |
MARPA_ERROR(g->t_error); |
| 11135 |
return failure_indicator; |
| 11136 |
} |
| 11137 |
|
| 11138 |
/*:1250*/ |
| 11139 |
#line 6580 "./marpa.w" |
| 11140 |
|
| 11141 |
/*1246:*/ |
| 11142 |
#line 14968 "./marpa.w" |
| 11143 |
|
| 11144 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)!=R_BEFORE_INPUT)){ |
| 11145 |
MARPA_ERROR(MARPA_ERR_RECCE_STARTED); |
| 11146 |
return failure_indicator; |
| 11147 |
} |
| 11148 |
/*:1246*/ |
| 11149 |
#line 6581 "./marpa.w" |
| 11150 |
|
| 11151 |
return r->t_use_leo_flag= value?1:0; |
| 11152 |
} |
| 11153 |
|
| 11154 |
/*:605*//*612:*/ |
| 11155 |
#line 6621 "./marpa.w" |
| 11156 |
|
| 11157 |
int marpa_r_is_exhausted(Marpa_Recognizer r) |
| 11158 |
{ |
| 11159 |
/*560:*/ |
| 11160 |
#line 6100 "./marpa.w" |
| 11161 |
|
| 11162 |
const GRAMMAR g= G_of_R(r); |
| 11163 |
/*:560*/ |
| 11164 |
#line 6624 "./marpa.w" |
| 11165 |
|
| 11166 |
/*1230:*/ |
| 11167 |
#line 14864 "./marpa.w" |
| 11168 |
const int failure_indicator= -2; |
| 11169 |
|
| 11170 |
/*:1230*/ |
| 11171 |
#line 6625 "./marpa.w" |
| 11172 |
|
| 11173 |
/*1250:*/ |
| 11174 |
#line 14997 "./marpa.w" |
| 11175 |
|
| 11176 |
if(HEADER_VERSION_MISMATCH){ |
| 11177 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 11178 |
return failure_indicator; |
| 11179 |
} |
| 11180 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 11181 |
MARPA_ERROR(g->t_error); |
| 11182 |
return failure_indicator; |
| 11183 |
} |
| 11184 |
|
| 11185 |
/*:1250*/ |
| 11186 |
#line 6626 "./marpa.w" |
| 11187 |
|
| 11188 |
return R_is_Exhausted(r); |
| 11189 |
} |
| 11190 |
|
| 11191 |
/*:612*//*639:*/ |
| 11192 |
#line 6780 "./marpa.w" |
| 11193 |
|
| 11194 |
int marpa_r_earley_set_value(Marpa_Recognizer r,Marpa_Earley_Set_ID set_id) |
| 11195 |
{ |
| 11196 |
/*1230:*/ |
| 11197 |
#line 14864 "./marpa.w" |
| 11198 |
const int failure_indicator= -2; |
| 11199 |
|
| 11200 |
/*:1230*/ |
| 11201 |
#line 6783 "./marpa.w" |
| 11202 |
|
| 11203 |
YS earley_set; |
| 11204 |
/*560:*/ |
| 11205 |
#line 6100 "./marpa.w" |
| 11206 |
|
| 11207 |
const GRAMMAR g= G_of_R(r); |
| 11208 |
/*:560*/ |
| 11209 |
#line 6785 "./marpa.w" |
| 11210 |
|
| 11211 |
/*1250:*/ |
| 11212 |
#line 14997 "./marpa.w" |
| 11213 |
|
| 11214 |
if(HEADER_VERSION_MISMATCH){ |
| 11215 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 11216 |
return failure_indicator; |
| 11217 |
} |
| 11218 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 11219 |
MARPA_ERROR(g->t_error); |
| 11220 |
return failure_indicator; |
| 11221 |
} |
| 11222 |
|
| 11223 |
/*:1250*/ |
| 11224 |
#line 6786 "./marpa.w" |
| 11225 |
|
| 11226 |
/*1247:*/ |
| 11227 |
#line 14973 "./marpa.w" |
| 11228 |
|
| 11229 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 11230 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 11231 |
return failure_indicator; |
| 11232 |
} |
| 11233 |
/*:1247*/ |
| 11234 |
#line 6787 "./marpa.w" |
| 11235 |
|
| 11236 |
if(set_id<0) |
| 11237 |
{ |
| 11238 |
MARPA_ERROR(MARPA_ERR_INVALID_LOCATION); |
| 11239 |
return failure_indicator; |
| 11240 |
} |
| 11241 |
r_update_earley_sets(r); |
| 11242 |
if(!YS_Ord_is_Valid(r,set_id)) |
| 11243 |
{ |
| 11244 |
MARPA_ERROR(MARPA_ERR_NO_EARLEY_SET_AT_LOCATION); |
| 11245 |
return failure_indicator; |
| 11246 |
} |
| 11247 |
earley_set= YS_of_R_by_Ord(r,set_id); |
| 11248 |
MARPA_ERROR(MARPA_ERR_NONE); |
| 11249 |
return Value_of_YS(earley_set); |
| 11250 |
} |
| 11251 |
|
| 11252 |
/*:639*//*640:*/ |
| 11253 |
#line 6804 "./marpa.w" |
| 11254 |
|
| 11255 |
int |
| 11256 |
marpa_r_earley_set_values(Marpa_Recognizer r,Marpa_Earley_Set_ID set_id, |
| 11257 |
int*p_value,void**p_pvalue) |
| 11258 |
{ |
| 11259 |
/*1230:*/ |
| 11260 |
#line 14864 "./marpa.w" |
| 11261 |
const int failure_indicator= -2; |
| 11262 |
|
| 11263 |
/*:1230*/ |
| 11264 |
#line 6809 "./marpa.w" |
| 11265 |
|
| 11266 |
YS earley_set; |
| 11267 |
/*560:*/ |
| 11268 |
#line 6100 "./marpa.w" |
| 11269 |
|
| 11270 |
const GRAMMAR g= G_of_R(r); |
| 11271 |
/*:560*/ |
| 11272 |
#line 6811 "./marpa.w" |
| 11273 |
|
| 11274 |
/*1250:*/ |
| 11275 |
#line 14997 "./marpa.w" |
| 11276 |
|
| 11277 |
if(HEADER_VERSION_MISMATCH){ |
| 11278 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 11279 |
return failure_indicator; |
| 11280 |
} |
| 11281 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 11282 |
MARPA_ERROR(g->t_error); |
| 11283 |
return failure_indicator; |
| 11284 |
} |
| 11285 |
|
| 11286 |
/*:1250*/ |
| 11287 |
#line 6812 "./marpa.w" |
| 11288 |
|
| 11289 |
/*1247:*/ |
| 11290 |
#line 14973 "./marpa.w" |
| 11291 |
|
| 11292 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 11293 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 11294 |
return failure_indicator; |
| 11295 |
} |
| 11296 |
/*:1247*/ |
| 11297 |
#line 6813 "./marpa.w" |
| 11298 |
|
| 11299 |
if(set_id<0) |
| 11300 |
{ |
| 11301 |
MARPA_ERROR(MARPA_ERR_INVALID_LOCATION); |
| 11302 |
return failure_indicator; |
| 11303 |
} |
| 11304 |
r_update_earley_sets(r); |
| 11305 |
if(!YS_Ord_is_Valid(r,set_id)) |
| 11306 |
{ |
| 11307 |
MARPA_ERROR(MARPA_ERR_NO_EARLEY_SET_AT_LOCATION); |
| 11308 |
return failure_indicator; |
| 11309 |
} |
| 11310 |
earley_set= YS_of_R_by_Ord(r,set_id); |
| 11311 |
if(p_value)*p_value= Value_of_YS(earley_set); |
| 11312 |
if(p_pvalue)*p_pvalue= PValue_of_YS(earley_set); |
| 11313 |
return 1; |
| 11314 |
} |
| 11315 |
|
| 11316 |
/*:640*//*641:*/ |
| 11317 |
#line 6831 "./marpa.w" |
| 11318 |
|
| 11319 |
int marpa_r_latest_earley_set_value_set(Marpa_Recognizer r,int value) |
| 11320 |
{ |
| 11321 |
YS earley_set; |
| 11322 |
/*1230:*/ |
| 11323 |
#line 14864 "./marpa.w" |
| 11324 |
const int failure_indicator= -2; |
| 11325 |
|
| 11326 |
/*:1230*/ |
| 11327 |
#line 6835 "./marpa.w" |
| 11328 |
|
| 11329 |
/*560:*/ |
| 11330 |
#line 6100 "./marpa.w" |
| 11331 |
|
| 11332 |
const GRAMMAR g= G_of_R(r); |
| 11333 |
/*:560*/ |
| 11334 |
#line 6836 "./marpa.w" |
| 11335 |
|
| 11336 |
/*1249:*/ |
| 11337 |
#line 14989 "./marpa.w" |
| 11338 |
|
| 11339 |
/*1250:*/ |
| 11340 |
#line 14997 "./marpa.w" |
| 11341 |
|
| 11342 |
if(HEADER_VERSION_MISMATCH){ |
| 11343 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 11344 |
return failure_indicator; |
| 11345 |
} |
| 11346 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 11347 |
MARPA_ERROR(g->t_error); |
| 11348 |
return failure_indicator; |
| 11349 |
} |
| 11350 |
|
| 11351 |
/*:1250*/ |
| 11352 |
#line 14990 "./marpa.w" |
| 11353 |
|
| 11354 |
/*1247:*/ |
| 11355 |
#line 14973 "./marpa.w" |
| 11356 |
|
| 11357 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 11358 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 11359 |
return failure_indicator; |
| 11360 |
} |
| 11361 |
/*:1247*/ |
| 11362 |
#line 14991 "./marpa.w" |
| 11363 |
|
| 11364 |
|
| 11365 |
/*:1249*/ |
| 11366 |
#line 6837 "./marpa.w" |
| 11367 |
|
| 11368 |
earley_set= Latest_YS_of_R(r); |
| 11369 |
MARPA_ERROR(MARPA_ERR_NONE); |
| 11370 |
return Value_of_YS(earley_set)= value; |
| 11371 |
} |
| 11372 |
|
| 11373 |
/*:641*//*642:*/ |
| 11374 |
#line 6843 "./marpa.w" |
| 11375 |
|
| 11376 |
int marpa_r_latest_earley_set_values_set(Marpa_Recognizer r,int value, |
| 11377 |
void*pvalue) |
| 11378 |
{ |
| 11379 |
YS earley_set; |
| 11380 |
/*1230:*/ |
| 11381 |
#line 14864 "./marpa.w" |
| 11382 |
const int failure_indicator= -2; |
| 11383 |
|
| 11384 |
/*:1230*/ |
| 11385 |
#line 6848 "./marpa.w" |
| 11386 |
|
| 11387 |
/*560:*/ |
| 11388 |
#line 6100 "./marpa.w" |
| 11389 |
|
| 11390 |
const GRAMMAR g= G_of_R(r); |
| 11391 |
/*:560*/ |
| 11392 |
#line 6849 "./marpa.w" |
| 11393 |
|
| 11394 |
/*1249:*/ |
| 11395 |
#line 14989 "./marpa.w" |
| 11396 |
|
| 11397 |
/*1250:*/ |
| 11398 |
#line 14997 "./marpa.w" |
| 11399 |
|
| 11400 |
if(HEADER_VERSION_MISMATCH){ |
| 11401 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 11402 |
return failure_indicator; |
| 11403 |
} |
| 11404 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 11405 |
MARPA_ERROR(g->t_error); |
| 11406 |
return failure_indicator; |
| 11407 |
} |
| 11408 |
|
| 11409 |
/*:1250*/ |
| 11410 |
#line 14990 "./marpa.w" |
| 11411 |
|
| 11412 |
/*1247:*/ |
| 11413 |
#line 14973 "./marpa.w" |
| 11414 |
|
| 11415 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 11416 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 11417 |
return failure_indicator; |
| 11418 |
} |
| 11419 |
/*:1247*/ |
| 11420 |
#line 14991 "./marpa.w" |
| 11421 |
|
| 11422 |
|
| 11423 |
/*:1249*/ |
| 11424 |
#line 6850 "./marpa.w" |
| 11425 |
|
| 11426 |
earley_set= Latest_YS_of_R(r); |
| 11427 |
Value_of_YS(earley_set)= value; |
| 11428 |
PValue_of_YS(earley_set)= pvalue; |
| 11429 |
return 1; |
| 11430 |
} |
| 11431 |
|
| 11432 |
/*:642*//*643:*/ |
| 11433 |
#line 6858 "./marpa.w" |
| 11434 |
|
| 11435 |
PRIVATE YS |
| 11436 |
earley_set_new(RECCE r,JEARLEME id) |
| 11437 |
{ |
| 11438 |
YSK_Object key; |
| 11439 |
YS set; |
| 11440 |
set= marpa_obs_new(r->t_obs,YS_Object,1); |
| 11441 |
key.t_earleme= id; |
| 11442 |
set->t_key= key; |
| 11443 |
set->t_postdot_ary= NULL; |
| 11444 |
set->t_postdot_sym_count= 0; |
| 11445 |
YIM_Count_of_YS(set)= 0; |
| 11446 |
set->t_ordinal= r->t_earley_set_count++; |
| 11447 |
YIMs_of_YS(set)= NULL; |
| 11448 |
Next_YS_of_YS(set)= NULL; |
| 11449 |
/*638:*/ |
| 11450 |
#line 6776 "./marpa.w" |
| 11451 |
|
| 11452 |
Value_of_YS(set)= -1; |
| 11453 |
PValue_of_YS(set)= NULL; |
| 11454 |
|
| 11455 |
/*:638*//*1218:*/ |
| 11456 |
#line 14738 "./marpa.w" |
| 11457 |
|
| 11458 |
{set->t_dot_psl= NULL;} |
| 11459 |
|
| 11460 |
/*:1218*/ |
| 11461 |
#line 6873 "./marpa.w" |
| 11462 |
|
| 11463 |
return set; |
| 11464 |
} |
| 11465 |
|
| 11466 |
/*:643*//*653:*/ |
| 11467 |
#line 6983 "./marpa.w" |
| 11468 |
|
| 11469 |
PRIVATE YIM earley_item_create(const RECCE r, |
| 11470 |
const YIK_Object key) |
| 11471 |
{ |
| 11472 |
/*1229:*/ |
| 11473 |
#line 14861 "./marpa.w" |
| 11474 |
void*const failure_indicator= NULL; |
| 11475 |
/*:1229*/ |
| 11476 |
#line 6987 "./marpa.w" |
| 11477 |
|
| 11478 |
/*560:*/ |
| 11479 |
#line 6100 "./marpa.w" |
| 11480 |
|
| 11481 |
const GRAMMAR g= G_of_R(r); |
| 11482 |
/*:560*/ |
| 11483 |
#line 6988 "./marpa.w" |
| 11484 |
|
| 11485 |
YIM new_item; |
| 11486 |
YIM*end_of_work_stack; |
| 11487 |
const YS set= key.t_set; |
| 11488 |
const int count= ++YIM_Count_of_YS(set); |
| 11489 |
/*655:*/ |
| 11490 |
#line 7042 "./marpa.w" |
| 11491 |
|
| 11492 |
if(_MARPA_UNLIKELY(count>=YIM_FATAL_THRESHOLD)) |
| 11493 |
{ |
| 11494 |
MARPA_FATAL(MARPA_ERR_YIM_COUNT); |
| 11495 |
return failure_indicator; |
| 11496 |
} |
| 11497 |
|
| 11498 |
/*:655*/ |
| 11499 |
#line 6993 "./marpa.w" |
| 11500 |
|
| 11501 |
new_item= marpa_obs_new(r->t_obs,struct s_earley_item,1); |
| 11502 |
new_item->t_key= key; |
| 11503 |
new_item->t_source_type= NO_SOURCE; |
| 11504 |
YIM_is_Rejected(new_item)= 0; |
| 11505 |
YIM_is_Active(new_item)= 1; |
| 11506 |
{ |
| 11507 |
SRC unique_yim_src= SRC_of_YIM(new_item); |
| 11508 |
SRC_is_Rejected(unique_yim_src)= 0; |
| 11509 |
SRC_is_Active(unique_yim_src)= 1; |
| 11510 |
} |
| 11511 |
Ord_of_YIM(new_item)= YIM_ORDINAL_CLAMP((unsigned int)count-1); |
| 11512 |
end_of_work_stack= WORK_YIM_PUSH(r); |
| 11513 |
*end_of_work_stack= new_item; |
| 11514 |
return new_item; |
| 11515 |
} |
| 11516 |
|
| 11517 |
/*:653*//*654:*/ |
| 11518 |
#line 7010 "./marpa.w" |
| 11519 |
|
| 11520 |
PRIVATE YIM |
| 11521 |
earley_item_assign(const RECCE r,const YS set,const YS origin, |
| 11522 |
const AHM ahm) |
| 11523 |
{ |
| 11524 |
const GRAMMAR g= G_of_R(r); |
| 11525 |
YIK_Object key; |
| 11526 |
YIM yim; |
| 11527 |
PSL psl; |
| 11528 |
AHMID ahm_id= ID_of_AHM(ahm); |
| 11529 |
PSL*psl_owner= &Dot_PSL_of_YS(origin); |
| 11530 |
if(!*psl_owner) |
| 11531 |
{ |
| 11532 |
psl_claim(psl_owner,Dot_PSAR_of_R(r)); |
| 11533 |
} |
| 11534 |
psl= *psl_owner; |
| 11535 |
yim= PSL_Datum(psl,ahm_id); |
| 11536 |
if(yim |
| 11537 |
&&Earleme_of_YIM(yim)==Earleme_of_YS(set) |
| 11538 |
&&Earleme_of_YS(Origin_of_YIM(yim))==Earleme_of_YS(origin)) |
| 11539 |
{ |
| 11540 |
return yim; |
| 11541 |
} |
| 11542 |
key.t_origin= origin; |
| 11543 |
key.t_ahm= ahm; |
| 11544 |
key.t_set= set; |
| 11545 |
yim= earley_item_create(r,key); |
| 11546 |
PSL_Datum(psl,ahm_id)= yim; |
| 11547 |
return yim; |
| 11548 |
} |
| 11549 |
|
| 11550 |
/*:654*//*659:*/ |
| 11551 |
#line 7078 "./marpa.w" |
| 11552 |
|
| 11553 |
PRIVATE_NOT_INLINE Marpa_Error_Code invalid_source_type_code(unsigned int type) |
| 11554 |
{ |
| 11555 |
switch(type){ |
| 11556 |
case NO_SOURCE: |
| 11557 |
return MARPA_ERR_SOURCE_TYPE_IS_NONE; |
| 11558 |
case SOURCE_IS_TOKEN: |
| 11559 |
return MARPA_ERR_SOURCE_TYPE_IS_TOKEN; |
| 11560 |
case SOURCE_IS_COMPLETION: |
| 11561 |
return MARPA_ERR_SOURCE_TYPE_IS_COMPLETION; |
| 11562 |
case SOURCE_IS_LEO: |
| 11563 |
return MARPA_ERR_SOURCE_TYPE_IS_LEO; |
| 11564 |
case SOURCE_IS_AMBIGUOUS: |
| 11565 |
return MARPA_ERR_SOURCE_TYPE_IS_AMBIGUOUS; |
| 11566 |
} |
| 11567 |
return MARPA_ERR_SOURCE_TYPE_IS_UNKNOWN; |
| 11568 |
} |
| 11569 |
|
| 11570 |
/*:659*//*671:*/ |
| 11571 |
#line 7199 "./marpa.w" |
| 11572 |
|
| 11573 |
PRIVATE PIM* |
| 11574 |
pim_nsy_p_find(YS set,NSYID nsyid) |
| 11575 |
{ |
| 11576 |
int lo= 0; |
| 11577 |
int hi= Postdot_SYM_Count_of_YS(set)-1; |
| 11578 |
PIM*postdot_array= set->t_postdot_ary; |
| 11579 |
while(hi>=lo){ |
| 11580 |
int trial= lo+(hi-lo)/2; |
| 11581 |
PIM trial_pim= postdot_array[trial]; |
| 11582 |
NSYID trial_nsyid= Postdot_NSYID_of_PIM(trial_pim); |
| 11583 |
if(trial_nsyid==nsyid)return postdot_array+trial; |
| 11584 |
if(trial_nsyid<nsyid){ |
| 11585 |
lo= trial+1; |
| 11586 |
}else{ |
| 11587 |
hi= trial-1; |
| 11588 |
} |
| 11589 |
} |
| 11590 |
return NULL; |
| 11591 |
} |
| 11592 |
/*:671*//*672:*/ |
| 11593 |
#line 7219 "./marpa.w" |
| 11594 |
|
| 11595 |
PRIVATE PIM first_pim_of_ys_by_nsyid(YS set,NSYID nsyid) |
| 11596 |
{ |
| 11597 |
PIM*pim_nsy_p= pim_nsy_p_find(set,nsyid); |
| 11598 |
return pim_nsy_p?*pim_nsy_p:NULL; |
| 11599 |
} |
| 11600 |
|
| 11601 |
/*:672*//*689:*/ |
| 11602 |
#line 7374 "./marpa.w" |
| 11603 |
|
| 11604 |
PRIVATE |
| 11605 |
SRCL unique_srcl_new(struct marpa_obstack*t_obs) |
| 11606 |
{ |
| 11607 |
const SRCL new_srcl= marpa_obs_new(t_obs,SRCL_Object,1); |
| 11608 |
SRCL_is_Rejected(new_srcl)= 0; |
| 11609 |
SRCL_is_Active(new_srcl)= 1; |
| 11610 |
return new_srcl; |
| 11611 |
} |
| 11612 |
|
| 11613 |
/*:689*//*690:*/ |
| 11614 |
#line 7384 "./marpa.w" |
| 11615 |
PRIVATE |
| 11616 |
void |
| 11617 |
tkn_link_add(RECCE r, |
| 11618 |
YIM item, |
| 11619 |
YIM predecessor, |
| 11620 |
ALT alternative) |
| 11621 |
{ |
| 11622 |
SRCL new_link; |
| 11623 |
unsigned int previous_source_type= Source_Type_of_YIM(item); |
| 11624 |
if(previous_source_type==NO_SOURCE) |
| 11625 |
{ |
| 11626 |
const SRCL source_link= SRCL_of_YIM(item); |
| 11627 |
Source_Type_of_YIM(item)= SOURCE_IS_TOKEN; |
| 11628 |
Predecessor_of_SRCL(source_link)= predecessor; |
| 11629 |
NSYID_of_SRCL(source_link)= NSYID_of_ALT(alternative); |
| 11630 |
Value_of_SRCL(source_link)= Value_of_ALT(alternative); |
| 11631 |
Next_SRCL_of_SRCL(source_link)= NULL; |
| 11632 |
return; |
| 11633 |
} |
| 11634 |
if(previous_source_type!=SOURCE_IS_AMBIGUOUS) |
| 11635 |
{ |
| 11636 |
earley_item_ambiguate(r,item); |
| 11637 |
} |
| 11638 |
new_link= unique_srcl_new(r->t_obs); |
| 11639 |
new_link->t_next= LV_First_Token_SRCL_of_YIM(item); |
| 11640 |
new_link->t_source.t_predecessor= predecessor; |
| 11641 |
NSYID_of_Source(new_link->t_source)= NSYID_of_ALT(alternative); |
| 11642 |
Value_of_Source(new_link->t_source)= Value_of_ALT(alternative); |
| 11643 |
LV_First_Token_SRCL_of_YIM(item)= new_link; |
| 11644 |
} |
| 11645 |
|
| 11646 |
/*:690*//*691:*/ |
| 11647 |
#line 7415 "./marpa.w" |
| 11648 |
|
| 11649 |
PRIVATE |
| 11650 |
void |
| 11651 |
completion_link_add(RECCE r, |
| 11652 |
YIM item, |
| 11653 |
YIM predecessor, |
| 11654 |
YIM cause) |
| 11655 |
{ |
| 11656 |
SRCL new_link; |
| 11657 |
unsigned int previous_source_type= Source_Type_of_YIM(item); |
| 11658 |
if(previous_source_type==NO_SOURCE) |
| 11659 |
{ |
| 11660 |
const SRCL source_link= SRCL_of_YIM(item); |
| 11661 |
Source_Type_of_YIM(item)= SOURCE_IS_COMPLETION; |
| 11662 |
Predecessor_of_SRCL(source_link)= predecessor; |
| 11663 |
Cause_of_SRCL(source_link)= cause; |
| 11664 |
Next_SRCL_of_SRCL(source_link)= NULL; |
| 11665 |
return; |
| 11666 |
} |
| 11667 |
if(previous_source_type!=SOURCE_IS_AMBIGUOUS) |
| 11668 |
{ |
| 11669 |
earley_item_ambiguate(r,item); |
| 11670 |
} |
| 11671 |
new_link= unique_srcl_new(r->t_obs); |
| 11672 |
new_link->t_next= LV_First_Completion_SRCL_of_YIM(item); |
| 11673 |
new_link->t_source.t_predecessor= predecessor; |
| 11674 |
Cause_of_Source(new_link->t_source)= cause; |
| 11675 |
LV_First_Completion_SRCL_of_YIM(item)= new_link; |
| 11676 |
} |
| 11677 |
|
| 11678 |
/*:691*//*692:*/ |
| 11679 |
#line 7445 "./marpa.w" |
| 11680 |
|
| 11681 |
PRIVATE void |
| 11682 |
leo_link_add(RECCE r, |
| 11683 |
YIM item, |
| 11684 |
LIM predecessor, |
| 11685 |
YIM cause) |
| 11686 |
{ |
| 11687 |
SRCL new_link; |
| 11688 |
unsigned int previous_source_type= Source_Type_of_YIM(item); |
| 11689 |
if(previous_source_type==NO_SOURCE) |
| 11690 |
{ |
| 11691 |
const SRCL source_link= SRCL_of_YIM(item); |
| 11692 |
Source_Type_of_YIM(item)= SOURCE_IS_LEO; |
| 11693 |
Predecessor_of_SRCL(source_link)= predecessor; |
| 11694 |
Cause_of_SRCL(source_link)= cause; |
| 11695 |
Next_SRCL_of_SRCL(source_link)= NULL; |
| 11696 |
return; |
| 11697 |
} |
| 11698 |
if(previous_source_type!=SOURCE_IS_AMBIGUOUS) |
| 11699 |
{ |
| 11700 |
earley_item_ambiguate(r,item); |
| 11701 |
} |
| 11702 |
new_link= unique_srcl_new(r->t_obs); |
| 11703 |
new_link->t_next= LV_First_Leo_SRCL_of_YIM(item); |
| 11704 |
new_link->t_source.t_predecessor= predecessor; |
| 11705 |
Cause_of_Source(new_link->t_source)= cause; |
| 11706 |
LV_First_Leo_SRCL_of_YIM(item)= new_link; |
| 11707 |
} |
| 11708 |
|
| 11709 |
/*:692*//*694:*/ |
| 11710 |
#line 7494 "./marpa.w" |
| 11711 |
|
| 11712 |
PRIVATE_NOT_INLINE |
| 11713 |
void earley_item_ambiguate(struct marpa_r*r,YIM item) |
| 11714 |
{ |
| 11715 |
unsigned int previous_source_type= Source_Type_of_YIM(item); |
| 11716 |
Source_Type_of_YIM(item)= SOURCE_IS_AMBIGUOUS; |
| 11717 |
switch(previous_source_type) |
| 11718 |
{ |
| 11719 |
case SOURCE_IS_TOKEN:/*695:*/ |
| 11720 |
#line 7511 "./marpa.w" |
| 11721 |
{ |
| 11722 |
SRCL new_link= marpa_obs_new(r->t_obs,SRCL_Object,1); |
| 11723 |
*new_link= *SRCL_of_YIM(item); |
| 11724 |
LV_First_Leo_SRCL_of_YIM(item)= NULL; |
| 11725 |
LV_First_Completion_SRCL_of_YIM(item)= NULL; |
| 11726 |
LV_First_Token_SRCL_of_YIM(item)= new_link; |
| 11727 |
} |
| 11728 |
|
| 11729 |
/*:695*/ |
| 11730 |
#line 7502 "./marpa.w" |
| 11731 |
|
| 11732 |
return; |
| 11733 |
case SOURCE_IS_COMPLETION:/*696:*/ |
| 11734 |
#line 7519 "./marpa.w" |
| 11735 |
{ |
| 11736 |
SRCL new_link= marpa_obs_new(r->t_obs,SRCL_Object,1); |
| 11737 |
*new_link= *SRCL_of_YIM(item); |
| 11738 |
LV_First_Leo_SRCL_of_YIM(item)= NULL; |
| 11739 |
LV_First_Completion_SRCL_of_YIM(item)= new_link; |
| 11740 |
LV_First_Token_SRCL_of_YIM(item)= NULL; |
| 11741 |
} |
| 11742 |
|
| 11743 |
/*:696*/ |
| 11744 |
#line 7504 "./marpa.w" |
| 11745 |
|
| 11746 |
return; |
| 11747 |
case SOURCE_IS_LEO:/*697:*/ |
| 11748 |
#line 7527 "./marpa.w" |
| 11749 |
{ |
| 11750 |
SRCL new_link= marpa_obs_new(r->t_obs,SRCL_Object,1); |
| 11751 |
*new_link= *SRCL_of_YIM(item); |
| 11752 |
LV_First_Leo_SRCL_of_YIM(item)= new_link; |
| 11753 |
LV_First_Completion_SRCL_of_YIM(item)= NULL; |
| 11754 |
LV_First_Token_SRCL_of_YIM(item)= NULL; |
| 11755 |
} |
| 11756 |
|
| 11757 |
/*:697*/ |
| 11758 |
#line 7506 "./marpa.w" |
| 11759 |
|
| 11760 |
return; |
| 11761 |
} |
| 11762 |
} |
| 11763 |
|
| 11764 |
/*:694*//*704:*/ |
| 11765 |
#line 7570 "./marpa.w" |
| 11766 |
|
| 11767 |
PRIVATE int |
| 11768 |
alternative_insertion_point(RECCE r,ALT new_alternative) |
| 11769 |
{ |
| 11770 |
MARPA_DSTACK alternatives= &r->t_alternatives; |
| 11771 |
ALT alternative; |
| 11772 |
int hi= MARPA_DSTACK_LENGTH(*alternatives)-1; |
| 11773 |
int lo= 0; |
| 11774 |
int trial; |
| 11775 |
|
| 11776 |
if(hi<0) |
| 11777 |
return 0; |
| 11778 |
alternative= MARPA_DSTACK_BASE(*alternatives,ALT_Object); |
| 11779 |
for(;;) |
| 11780 |
{ |
| 11781 |
int outcome; |
| 11782 |
trial= lo+(hi-lo)/2; |
| 11783 |
outcome= alternative_cmp(new_alternative,alternative+trial); |
| 11784 |
if(outcome==0) |
| 11785 |
return-1; |
| 11786 |
if(outcome> 0) |
| 11787 |
{ |
| 11788 |
lo= trial+1; |
| 11789 |
} |
| 11790 |
else |
| 11791 |
{ |
| 11792 |
hi= trial-1; |
| 11793 |
} |
| 11794 |
if(hi<lo) |
| 11795 |
return outcome> 0?trial+1:trial; |
| 11796 |
} |
| 11797 |
} |
| 11798 |
|
| 11799 |
/*:704*//*706:*/ |
| 11800 |
#line 7614 "./marpa.w" |
| 11801 |
|
| 11802 |
PRIVATE int alternative_cmp(const ALT_Const a,const ALT_Const b) |
| 11803 |
{ |
| 11804 |
int subkey= End_Earleme_of_ALT(b)-End_Earleme_of_ALT(a); |
| 11805 |
if(subkey)return subkey; |
| 11806 |
subkey= NSYID_of_ALT(a)-NSYID_of_ALT(b); |
| 11807 |
if(subkey)return subkey; |
| 11808 |
return Start_Earleme_of_ALT(a)-Start_Earleme_of_ALT(b); |
| 11809 |
} |
| 11810 |
|
| 11811 |
/*:706*//*707:*/ |
| 11812 |
#line 7631 "./marpa.w" |
| 11813 |
|
| 11814 |
PRIVATE ALT alternative_pop(RECCE r,JEARLEME earleme) |
| 11815 |
{ |
| 11816 |
MARPA_DSTACK alternatives= &r->t_alternatives; |
| 11817 |
ALT end_of_stack= MARPA_DSTACK_TOP(*alternatives,ALT_Object); |
| 11818 |
|
| 11819 |
if(!end_of_stack)return NULL; |
| 11820 |
|
| 11821 |
|
| 11822 |
|
| 11823 |
|
| 11824 |
|
| 11825 |
|
| 11826 |
if(earleme<End_Earleme_of_ALT(end_of_stack)) |
| 11827 |
return NULL; |
| 11828 |
|
| 11829 |
return MARPA_DSTACK_POP(*alternatives,ALT_Object); |
| 11830 |
} |
| 11831 |
|
| 11832 |
/*:707*//*709:*/ |
| 11833 |
#line 7658 "./marpa.w" |
| 11834 |
|
| 11835 |
PRIVATE int alternative_insert(RECCE r,ALT new_alternative) |
| 11836 |
{ |
| 11837 |
ALT end_of_stack,base_of_stack; |
| 11838 |
MARPA_DSTACK alternatives= &r->t_alternatives; |
| 11839 |
int ix; |
| 11840 |
int insertion_point= alternative_insertion_point(r,new_alternative); |
| 11841 |
if(insertion_point<0) |
| 11842 |
return insertion_point; |
| 11843 |
|
| 11844 |
|
| 11845 |
end_of_stack= MARPA_DSTACK_PUSH(*alternatives,ALT_Object); |
| 11846 |
|
| 11847 |
|
| 11848 |
base_of_stack= MARPA_DSTACK_BASE(*alternatives,ALT_Object); |
| 11849 |
for(ix= (int)(end_of_stack-base_of_stack);ix> insertion_point;ix--){ |
| 11850 |
base_of_stack[ix]= base_of_stack[ix-1]; |
| 11851 |
} |
| 11852 |
base_of_stack[insertion_point]= *new_alternative; |
| 11853 |
return insertion_point; |
| 11854 |
} |
| 11855 |
|
| 11856 |
/*:709*//*710:*/ |
| 11857 |
#line 7681 "./marpa.w" |
| 11858 |
int marpa_r_start_input(Marpa_Recognizer r) |
| 11859 |
{ |
| 11860 |
int return_value= 1; |
| 11861 |
YS set0; |
| 11862 |
YIK_Object key; |
| 11863 |
|
| 11864 |
IRL start_irl; |
| 11865 |
AHM start_ahm; |
| 11866 |
|
| 11867 |
/*560:*/ |
| 11868 |
#line 6100 "./marpa.w" |
| 11869 |
|
| 11870 |
const GRAMMAR g= G_of_R(r); |
| 11871 |
/*:560*/ |
| 11872 |
#line 7690 "./marpa.w" |
| 11873 |
|
| 11874 |
/*1230:*/ |
| 11875 |
#line 14864 "./marpa.w" |
| 11876 |
const int failure_indicator= -2; |
| 11877 |
|
| 11878 |
/*:1230*/ |
| 11879 |
#line 7691 "./marpa.w" |
| 11880 |
|
| 11881 |
|
| 11882 |
/*1246:*/ |
| 11883 |
#line 14968 "./marpa.w" |
| 11884 |
|
| 11885 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)!=R_BEFORE_INPUT)){ |
| 11886 |
MARPA_ERROR(MARPA_ERR_RECCE_STARTED); |
| 11887 |
return failure_indicator; |
| 11888 |
} |
| 11889 |
/*:1246*/ |
| 11890 |
#line 7693 "./marpa.w" |
| 11891 |
|
| 11892 |
{ |
| 11893 |
/*712:*/ |
| 11894 |
#line 7811 "./marpa.w" |
| 11895 |
|
| 11896 |
const NSYID nsy_count= NSY_Count_of_G(g); |
| 11897 |
const NSYID xsy_count= XSY_Count_of_G(g); |
| 11898 |
Bit_Vector bv_ok_for_chain= bv_create(nsy_count); |
| 11899 |
/*:712*/ |
| 11900 |
#line 7695 "./marpa.w" |
| 11901 |
|
| 11902 |
Current_Earleme_of_R(r)= 0; |
| 11903 |
/*718:*/ |
| 11904 |
#line 7853 "./marpa.w" |
| 11905 |
|
| 11906 |
{ |
| 11907 |
XSYID xsy_id; |
| 11908 |
r->t_valued_terminal= lbv_obs_new0(r->t_obs,xsy_count); |
| 11909 |
r->t_unvalued_terminal= lbv_obs_new0(r->t_obs,xsy_count); |
| 11910 |
r->t_valued= lbv_obs_new0(r->t_obs,xsy_count); |
| 11911 |
r->t_unvalued= lbv_obs_new0(r->t_obs,xsy_count); |
| 11912 |
r->t_valued_locked= lbv_obs_new0(r->t_obs,xsy_count); |
| 11913 |
for(xsy_id= 0;xsy_id<xsy_count;xsy_id++) |
| 11914 |
{ |
| 11915 |
const XSY xsy= XSY_by_ID(xsy_id); |
| 11916 |
if(XSY_is_Valued_Locked(xsy)) |
| 11917 |
{ |
| 11918 |
lbv_bit_set(r->t_valued_locked,xsy_id); |
| 11919 |
} |
| 11920 |
if(XSY_is_Valued(xsy)) |
| 11921 |
{ |
| 11922 |
lbv_bit_set(r->t_valued,xsy_id); |
| 11923 |
if(XSY_is_Terminal(xsy)) |
| 11924 |
{ |
| 11925 |
lbv_bit_set(r->t_valued_terminal,xsy_id); |
| 11926 |
} |
| 11927 |
} |
| 11928 |
else |
| 11929 |
{ |
| 11930 |
lbv_bit_set(r->t_unvalued,xsy_id); |
| 11931 |
if(XSY_is_Terminal(xsy)) |
| 11932 |
{ |
| 11933 |
lbv_bit_set(r->t_unvalued_terminal,xsy_id); |
| 11934 |
} |
| 11935 |
} |
| 11936 |
} |
| 11937 |
} |
| 11938 |
|
| 11939 |
/*:718*/ |
| 11940 |
#line 7697 "./marpa.w" |
| 11941 |
|
| 11942 |
G_EVENTS_CLEAR(g); |
| 11943 |
|
| 11944 |
set0= earley_set_new(r,0); |
| 11945 |
Latest_YS_of_R(r)= set0; |
| 11946 |
First_YS_of_R(r)= set0; |
| 11947 |
|
| 11948 |
if(G_is_Trivial(g)){ |
| 11949 |
return_value+= trigger_trivial_events(r); |
| 11950 |
/*611:*/ |
| 11951 |
#line 6611 "./marpa.w" |
| 11952 |
|
| 11953 |
{ |
| 11954 |
R_is_Exhausted(r)= 1; |
| 11955 |
Input_Phase_of_R(r)= R_AFTER_INPUT; |
| 11956 |
event_new(g,MARPA_EVENT_EXHAUSTED); |
| 11957 |
} |
| 11958 |
|
| 11959 |
/*:611*/ |
| 11960 |
#line 7706 "./marpa.w" |
| 11961 |
|
| 11962 |
goto CLEANUP; |
| 11963 |
} |
| 11964 |
Input_Phase_of_R(r)= R_DURING_INPUT; |
| 11965 |
psar_reset(Dot_PSAR_of_R(r)); |
| 11966 |
/*771:*/ |
| 11967 |
#line 8719 "./marpa.w" |
| 11968 |
|
| 11969 |
r->t_bv_lim_symbols= bv_obs_create(r->t_obs,nsy_count); |
| 11970 |
r->t_bv_pim_symbols= bv_obs_create(r->t_obs,nsy_count); |
| 11971 |
r->t_pim_workarea= marpa_obs_new(r->t_obs,void*,nsy_count); |
| 11972 |
/*:771*//*790:*/ |
| 11973 |
#line 9001 "./marpa.w" |
| 11974 |
|
| 11975 |
r->t_lim_chain= marpa_obs_new(r->t_obs,void*,2*nsy_count); |
| 11976 |
/*:790*/ |
| 11977 |
#line 7711 "./marpa.w" |
| 11978 |
|
| 11979 |
/*727:*/ |
| 11980 |
#line 8061 "./marpa.w" |
| 11981 |
|
| 11982 |
{ |
| 11983 |
if(!MARPA_DSTACK_IS_INITIALIZED(r->t_yim_work_stack)) |
| 11984 |
{ |
| 11985 |
MARPA_DSTACK_INIT2(r->t_yim_work_stack,YIM); |
| 11986 |
} |
| 11987 |
} |
| 11988 |
/*:727*//*731:*/ |
| 11989 |
#line 8076 "./marpa.w" |
| 11990 |
|
| 11991 |
{ |
| 11992 |
if(!MARPA_DSTACK_IS_INITIALIZED(r->t_completion_stack)) |
| 11993 |
{ |
| 11994 |
MARPA_DSTACK_INIT2(r->t_completion_stack,YIM); |
| 11995 |
} |
| 11996 |
} |
| 11997 |
/*:731*/ |
| 11998 |
#line 7712 "./marpa.w" |
| 11999 |
|
| 12000 |
|
| 12001 |
start_irl= g->t_start_irl; |
| 12002 |
start_ahm= First_AHM_of_IRL(start_irl); |
| 12003 |
|
| 12004 |
|
| 12005 |
|
| 12006 |
key.t_origin= set0; |
| 12007 |
key.t_set= set0; |
| 12008 |
|
| 12009 |
key.t_ahm= start_ahm; |
| 12010 |
earley_item_create(r,key); |
| 12011 |
|
| 12012 |
bv_clear(r->t_bv_irl_seen); |
| 12013 |
bv_bit_set(r->t_bv_irl_seen,ID_of_IRL(start_irl)); |
| 12014 |
MARPA_DSTACK_CLEAR(r->t_irl_cil_stack); |
| 12015 |
*MARPA_DSTACK_PUSH(r->t_irl_cil_stack,CIL)= LHS_CIL_of_AHM(start_ahm); |
| 12016 |
|
| 12017 |
while(1) |
| 12018 |
{ |
| 12019 |
const CIL*const p_cil= MARPA_DSTACK_POP(r->t_irl_cil_stack,CIL); |
| 12020 |
if(!p_cil) |
| 12021 |
break; |
| 12022 |
{ |
| 12023 |
int cil_ix; |
| 12024 |
const CIL this_cil= *p_cil; |
| 12025 |
const int prediction_count= Count_of_CIL(this_cil); |
| 12026 |
for(cil_ix= 0;cil_ix<prediction_count;cil_ix++) |
| 12027 |
{ |
| 12028 |
const IRLID prediction_irlid= Item_of_CIL(this_cil,cil_ix); |
| 12029 |
if(!bv_bit_test_then_set(r->t_bv_irl_seen,prediction_irlid)) |
| 12030 |
{ |
| 12031 |
const IRL prediction_irl= IRL_by_ID(prediction_irlid); |
| 12032 |
const AHM prediction_ahm= First_AHM_of_IRL(prediction_irl); |
| 12033 |
|
| 12034 |
|
| 12035 |
|
| 12036 |
if(!evaluate_zwas(r,0,prediction_ahm))continue; |
| 12037 |
key.t_ahm= prediction_ahm; |
| 12038 |
earley_item_create(r,key); |
| 12039 |
*MARPA_DSTACK_PUSH(r->t_irl_cil_stack,CIL) |
| 12040 |
= LHS_CIL_of_AHM(prediction_ahm); |
| 12041 |
} |
| 12042 |
} |
| 12043 |
} |
| 12044 |
} |
| 12045 |
|
| 12046 |
postdot_items_create(r,bv_ok_for_chain,set0); |
| 12047 |
earley_set_update_items(r,set0); |
| 12048 |
r->t_is_using_leo= r->t_use_leo_flag; |
| 12049 |
trigger_events(r); |
| 12050 |
CLEANUP:; |
| 12051 |
/*713:*/ |
| 12052 |
#line 7815 "./marpa.w" |
| 12053 |
|
| 12054 |
bv_free(bv_ok_for_chain); |
| 12055 |
|
| 12056 |
/*:713*/ |
| 12057 |
#line 7764 "./marpa.w" |
| 12058 |
|
| 12059 |
} |
| 12060 |
return return_value; |
| 12061 |
} |
| 12062 |
|
| 12063 |
/*:710*//*711:*/ |
| 12064 |
#line 7769 "./marpa.w" |
| 12065 |
|
| 12066 |
PRIVATE |
| 12067 |
int evaluate_zwas(RECCE r,YSID ysid,AHM ahm) |
| 12068 |
{ |
| 12069 |
int cil_ix; |
| 12070 |
const CIL zwa_cil= ZWA_CIL_of_AHM(ahm); |
| 12071 |
const int cil_count= Count_of_CIL(zwa_cil); |
| 12072 |
for(cil_ix= 0;cil_ix<cil_count;cil_ix++) |
| 12073 |
{ |
| 12074 |
int value; |
| 12075 |
const ZWAID zwaid= Item_of_CIL(zwa_cil,cil_ix); |
| 12076 |
const ZWA zwa= RZWA_by_ID(zwaid); |
| 12077 |
|
| 12078 |
|
| 12079 |
MARPA_OFF_DEBUG3("At %s, evaluating assertion %ld",STRLOC,(long)zwaid) |
| 12080 |
if(Memo_YSID_of_ZWA(zwa)==ysid){ |
| 12081 |
if(Memo_Value_of_ZWA(zwa))continue; |
| 12082 |
MARPA_OFF_DEBUG3("At %s: returning 0 for assertion %ld",STRLOC,(long)zwaid) |
| 12083 |
return 0; |
| 12084 |
} |
| 12085 |
|
| 12086 |
|
| 12087 |
|
| 12088 |
|
| 12089 |
value= Memo_Value_of_ZWA(zwa)= Default_Value_of_ZWA(zwa); |
| 12090 |
Memo_YSID_of_ZWA(zwa)= ysid; |
| 12091 |
|
| 12092 |
|
| 12093 |
|
| 12094 |
|
| 12095 |
|
| 12096 |
if(!value){ |
| 12097 |
MARPA_OFF_DEBUG3("At %s: returning 0 for assertion %ld",STRLOC,(long)zwaid) |
| 12098 |
return 0; |
| 12099 |
} |
| 12100 |
|
| 12101 |
MARPA_OFF_DEBUG3("At %s: value is 1 for assertion %ld",STRLOC,(long)zwaid) |
| 12102 |
} |
| 12103 |
return 1; |
| 12104 |
} |
| 12105 |
|
| 12106 |
|
| 12107 |
/*:711*//*719:*/ |
| 12108 |
#line 7893 "./marpa.w" |
| 12109 |
|
| 12110 |
Marpa_Earleme marpa_r_alternative( |
| 12111 |
Marpa_Recognizer r, |
| 12112 |
Marpa_Symbol_ID tkn_xsy_id, |
| 12113 |
int value, |
| 12114 |
int length) |
| 12115 |
{ |
| 12116 |
/*560:*/ |
| 12117 |
#line 6100 "./marpa.w" |
| 12118 |
|
| 12119 |
const GRAMMAR g= G_of_R(r); |
| 12120 |
/*:560*/ |
| 12121 |
#line 7900 "./marpa.w" |
| 12122 |
|
| 12123 |
YS current_earley_set; |
| 12124 |
const JEARLEME current_earleme= Current_Earleme_of_R(r); |
| 12125 |
JEARLEME target_earleme; |
| 12126 |
NSYID tkn_nsyid; |
| 12127 |
if(_MARPA_UNLIKELY(!R_is_Consistent(r))) |
| 12128 |
{ |
| 12129 |
MARPA_ERROR(MARPA_ERR_RECCE_IS_INCONSISTENT); |
| 12130 |
return MARPA_ERR_RECCE_IS_INCONSISTENT; |
| 12131 |
} |
| 12132 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)!=R_DURING_INPUT)) |
| 12133 |
{ |
| 12134 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_ACCEPTING_INPUT); |
| 12135 |
return MARPA_ERR_RECCE_NOT_ACCEPTING_INPUT; |
| 12136 |
} |
| 12137 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(tkn_xsy_id))) |
| 12138 |
{ |
| 12139 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 12140 |
return MARPA_ERR_INVALID_SYMBOL_ID; |
| 12141 |
} |
| 12142 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(tkn_xsy_id))) |
| 12143 |
{ |
| 12144 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 12145 |
return MARPA_ERR_NO_SUCH_SYMBOL_ID; |
| 12146 |
} |
| 12147 |
/*720:*/ |
| 12148 |
#line 7932 "./marpa.w" |
| 12149 |
{ |
| 12150 |
const XSY_Const tkn= XSY_by_ID(tkn_xsy_id); |
| 12151 |
if(length<=0){ |
| 12152 |
MARPA_ERROR(MARPA_ERR_TOKEN_LENGTH_LE_ZERO); |
| 12153 |
return MARPA_ERR_TOKEN_LENGTH_LE_ZERO; |
| 12154 |
} |
| 12155 |
if(length>=JEARLEME_THRESHOLD){ |
| 12156 |
MARPA_ERROR(MARPA_ERR_TOKEN_TOO_LONG); |
| 12157 |
return MARPA_ERR_TOKEN_TOO_LONG; |
| 12158 |
} |
| 12159 |
if(value&&_MARPA_UNLIKELY(!lbv_bit_test(r->t_valued_terminal,tkn_xsy_id))) |
| 12160 |
{ |
| 12161 |
if(!XSY_is_Terminal(tkn)){ |
| 12162 |
MARPA_ERROR(MARPA_ERR_TOKEN_IS_NOT_TERMINAL); |
| 12163 |
return MARPA_ERR_TOKEN_IS_NOT_TERMINAL; |
| 12164 |
} |
| 12165 |
if(lbv_bit_test(r->t_valued_locked,tkn_xsy_id)){ |
| 12166 |
MARPA_ERROR(MARPA_ERR_SYMBOL_VALUED_CONFLICT); |
| 12167 |
return MARPA_ERR_SYMBOL_VALUED_CONFLICT; |
| 12168 |
} |
| 12169 |
lbv_bit_set(r->t_valued_locked,tkn_xsy_id); |
| 12170 |
lbv_bit_set(r->t_valued_terminal,tkn_xsy_id); |
| 12171 |
lbv_bit_set(r->t_valued,tkn_xsy_id); |
| 12172 |
} |
| 12173 |
if(!value&&_MARPA_UNLIKELY(!lbv_bit_test(r->t_unvalued_terminal,tkn_xsy_id))) |
| 12174 |
{ |
| 12175 |
if(!XSY_is_Terminal(tkn)){ |
| 12176 |
MARPA_ERROR(MARPA_ERR_TOKEN_IS_NOT_TERMINAL); |
| 12177 |
return MARPA_ERR_TOKEN_IS_NOT_TERMINAL; |
| 12178 |
} |
| 12179 |
if(lbv_bit_test(r->t_valued_locked,tkn_xsy_id)){ |
| 12180 |
MARPA_ERROR(MARPA_ERR_SYMBOL_VALUED_CONFLICT); |
| 12181 |
return MARPA_ERR_SYMBOL_VALUED_CONFLICT; |
| 12182 |
} |
| 12183 |
lbv_bit_set(r->t_valued_locked,tkn_xsy_id); |
| 12184 |
lbv_bit_set(r->t_unvalued_terminal,tkn_xsy_id); |
| 12185 |
lbv_bit_set(r->t_unvalued,tkn_xsy_id); |
| 12186 |
} |
| 12187 |
} |
| 12188 |
|
| 12189 |
/*:720*/ |
| 12190 |
#line 7925 "./marpa.w" |
| 12191 |
|
| 12192 |
/*723:*/ |
| 12193 |
#line 7992 "./marpa.w" |
| 12194 |
|
| 12195 |
{ |
| 12196 |
NSY tkn_nsy= NSY_by_XSYID(tkn_xsy_id); |
| 12197 |
if(_MARPA_UNLIKELY(!tkn_nsy)) |
| 12198 |
{ |
| 12199 |
MARPA_ERROR(MARPA_ERR_INACCESSIBLE_TOKEN); |
| 12200 |
return MARPA_ERR_INACCESSIBLE_TOKEN; |
| 12201 |
} |
| 12202 |
tkn_nsyid= ID_of_NSY(tkn_nsy); |
| 12203 |
current_earley_set= YS_at_Current_Earleme_of_R(r); |
| 12204 |
if(!current_earley_set) |
| 12205 |
{ |
| 12206 |
MARPA_ERROR(MARPA_ERR_NO_TOKEN_EXPECTED_HERE); |
| 12207 |
return MARPA_ERR_NO_TOKEN_EXPECTED_HERE; |
| 12208 |
} |
| 12209 |
if(!First_PIM_of_YS_by_NSYID(current_earley_set,tkn_nsyid)) |
| 12210 |
{ |
| 12211 |
MARPA_ERROR(MARPA_ERR_UNEXPECTED_TOKEN_ID); |
| 12212 |
return MARPA_ERR_UNEXPECTED_TOKEN_ID; |
| 12213 |
} |
| 12214 |
} |
| 12215 |
|
| 12216 |
/*:723*/ |
| 12217 |
#line 7926 "./marpa.w" |
| 12218 |
|
| 12219 |
/*721:*/ |
| 12220 |
#line 7972 "./marpa.w" |
| 12221 |
{ |
| 12222 |
target_earleme= current_earleme+length; |
| 12223 |
if(target_earleme>=JEARLEME_THRESHOLD){ |
| 12224 |
MARPA_ERROR(MARPA_ERR_PARSE_TOO_LONG); |
| 12225 |
return MARPA_ERR_PARSE_TOO_LONG; |
| 12226 |
} |
| 12227 |
} |
| 12228 |
|
| 12229 |
/*:721*/ |
| 12230 |
#line 7927 "./marpa.w" |
| 12231 |
|
| 12232 |
/*724:*/ |
| 12233 |
#line 8030 "./marpa.w" |
| 12234 |
|
| 12235 |
{ |
| 12236 |
ALT_Object alternative_object; |
| 12237 |
|
| 12238 |
|
| 12239 |
const ALT alternative= &alternative_object; |
| 12240 |
NSYID_of_ALT(alternative)= tkn_nsyid; |
| 12241 |
Value_of_ALT(alternative)= value; |
| 12242 |
ALT_is_Valued(alternative)= value?1:0; |
| 12243 |
if(Furthest_Earleme_of_R(r)<target_earleme) |
| 12244 |
Furthest_Earleme_of_R(r)= target_earleme; |
| 12245 |
alternative->t_start_earley_set= current_earley_set; |
| 12246 |
End_Earleme_of_ALT(alternative)= target_earleme; |
| 12247 |
if(alternative_insert(r,alternative)<0) |
| 12248 |
{ |
| 12249 |
MARPA_ERROR(MARPA_ERR_DUPLICATE_TOKEN); |
| 12250 |
return MARPA_ERR_DUPLICATE_TOKEN; |
| 12251 |
} |
| 12252 |
} |
| 12253 |
|
| 12254 |
/*:724*/ |
| 12255 |
#line 7928 "./marpa.w" |
| 12256 |
|
| 12257 |
return MARPA_ERR_NONE; |
| 12258 |
} |
| 12259 |
|
| 12260 |
/*:719*//*737:*/ |
| 12261 |
#line 8107 "./marpa.w" |
| 12262 |
|
| 12263 |
int |
| 12264 |
marpa_r_earleme_complete(Marpa_Recognizer r) |
| 12265 |
{ |
| 12266 |
/*1230:*/ |
| 12267 |
#line 14864 "./marpa.w" |
| 12268 |
const int failure_indicator= -2; |
| 12269 |
|
| 12270 |
/*:1230*/ |
| 12271 |
#line 8111 "./marpa.w" |
| 12272 |
|
| 12273 |
/*560:*/ |
| 12274 |
#line 6100 "./marpa.w" |
| 12275 |
|
| 12276 |
const GRAMMAR g= G_of_R(r); |
| 12277 |
/*:560*/ |
| 12278 |
#line 8112 "./marpa.w" |
| 12279 |
|
| 12280 |
YIM*cause_p; |
| 12281 |
YS current_earley_set; |
| 12282 |
JEARLEME current_earleme; |
| 12283 |
|
| 12284 |
|
| 12285 |
|
| 12286 |
|
| 12287 |
|
| 12288 |
JEARLEME return_value= -2; |
| 12289 |
|
| 12290 |
/*1248:*/ |
| 12291 |
#line 14978 "./marpa.w" |
| 12292 |
|
| 12293 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)!=R_DURING_INPUT)){ |
| 12294 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_ACCEPTING_INPUT); |
| 12295 |
return failure_indicator; |
| 12296 |
} |
| 12297 |
|
| 12298 |
if(_MARPA_UNLIKELY(!R_is_Consistent(r))){ |
| 12299 |
MARPA_ERROR(MARPA_ERR_RECCE_IS_INCONSISTENT); |
| 12300 |
return failure_indicator; |
| 12301 |
} |
| 12302 |
|
| 12303 |
/*:1248*/ |
| 12304 |
#line 8123 "./marpa.w" |
| 12305 |
|
| 12306 |
if(_MARPA_UNLIKELY(!R_is_Consistent(r))){ |
| 12307 |
MARPA_ERROR(MARPA_ERR_RECCE_IS_INCONSISTENT); |
| 12308 |
return failure_indicator; |
| 12309 |
} |
| 12310 |
|
| 12311 |
{ |
| 12312 |
int count_of_expected_terminals; |
| 12313 |
/*738:*/ |
| 12314 |
#line 8173 "./marpa.w" |
| 12315 |
|
| 12316 |
const NSYID nsy_count= NSY_Count_of_G(g); |
| 12317 |
Bit_Vector bv_ok_for_chain= bv_create(nsy_count); |
| 12318 |
struct marpa_obstack*const earleme_complete_obs= marpa_obs_init; |
| 12319 |
/*:738*/ |
| 12320 |
#line 8131 "./marpa.w" |
| 12321 |
|
| 12322 |
G_EVENTS_CLEAR(g); |
| 12323 |
psar_dealloc(Dot_PSAR_of_R(r)); |
| 12324 |
bv_clear(r->t_bv_nsyid_is_expected); |
| 12325 |
bv_clear(r->t_bv_irl_seen); |
| 12326 |
/*740:*/ |
| 12327 |
#line 8181 "./marpa.w" |
| 12328 |
{ |
| 12329 |
current_earleme= ++(Current_Earleme_of_R(r)); |
| 12330 |
if(current_earleme> Furthest_Earleme_of_R(r)) |
| 12331 |
{ |
| 12332 |
/*611:*/ |
| 12333 |
#line 6611 "./marpa.w" |
| 12334 |
|
| 12335 |
{ |
| 12336 |
R_is_Exhausted(r)= 1; |
| 12337 |
Input_Phase_of_R(r)= R_AFTER_INPUT; |
| 12338 |
event_new(g,MARPA_EVENT_EXHAUSTED); |
| 12339 |
} |
| 12340 |
|
| 12341 |
/*:611*/ |
| 12342 |
#line 8185 "./marpa.w" |
| 12343 |
|
| 12344 |
MARPA_ERROR(MARPA_ERR_PARSE_EXHAUSTED); |
| 12345 |
return_value= failure_indicator; |
| 12346 |
goto CLEANUP; |
| 12347 |
} |
| 12348 |
} |
| 12349 |
|
| 12350 |
/*:740*/ |
| 12351 |
#line 8136 "./marpa.w" |
| 12352 |
|
| 12353 |
/*742:*/ |
| 12354 |
#line 8204 "./marpa.w" |
| 12355 |
{ |
| 12356 |
ALT end_of_stack= MARPA_DSTACK_TOP(r->t_alternatives,ALT_Object); |
| 12357 |
if(!end_of_stack||current_earleme!=End_Earleme_of_ALT(end_of_stack)) |
| 12358 |
{ |
| 12359 |
return_value= 0; |
| 12360 |
goto CLEANUP; |
| 12361 |
} |
| 12362 |
} |
| 12363 |
|
| 12364 |
/*:742*/ |
| 12365 |
#line 8137 "./marpa.w" |
| 12366 |
|
| 12367 |
/*741:*/ |
| 12368 |
#line 8194 "./marpa.w" |
| 12369 |
{ |
| 12370 |
current_earley_set= earley_set_new(r,current_earleme); |
| 12371 |
Next_YS_of_YS(Latest_YS_of_R(r))= current_earley_set; |
| 12372 |
Latest_YS_of_R(r)= current_earley_set; |
| 12373 |
} |
| 12374 |
|
| 12375 |
/*:741*/ |
| 12376 |
#line 8138 "./marpa.w" |
| 12377 |
|
| 12378 |
/*743:*/ |
| 12379 |
#line 8213 "./marpa.w" |
| 12380 |
|
| 12381 |
{ |
| 12382 |
ALT alternative; |
| 12383 |
|
| 12384 |
|
| 12385 |
while((alternative= alternative_pop(r,current_earleme))) |
| 12386 |
/*745:*/ |
| 12387 |
#line 8232 "./marpa.w" |
| 12388 |
|
| 12389 |
{ |
| 12390 |
YS start_earley_set= Start_YS_of_ALT(alternative); |
| 12391 |
PIM pim= First_PIM_of_YS_by_NSYID(start_earley_set, |
| 12392 |
NSYID_of_ALT(alternative)); |
| 12393 |
for(;pim;pim= Next_PIM_of_PIM(pim)) |
| 12394 |
{ |
| 12395 |
|
| 12396 |
|
| 12397 |
const YIM predecessor= YIM_of_PIM(pim); |
| 12398 |
if(predecessor&&YIM_is_Active(predecessor)) |
| 12399 |
{ |
| 12400 |
const AHM predecessor_ahm= AHM_of_YIM(predecessor); |
| 12401 |
const AHM scanned_ahm= Next_AHM_of_AHM(predecessor_ahm); |
| 12402 |
/*746:*/ |
| 12403 |
#line 8251 "./marpa.w" |
| 12404 |
|
| 12405 |
{ |
| 12406 |
const YIM scanned_earley_item= earley_item_assign(r, |
| 12407 |
current_earley_set, |
| 12408 |
Origin_of_YIM |
| 12409 |
(predecessor), |
| 12410 |
scanned_ahm); |
| 12411 |
YIM_was_Scanned(scanned_earley_item)= 1; |
| 12412 |
tkn_link_add(r,scanned_earley_item,predecessor,alternative); |
| 12413 |
} |
| 12414 |
|
| 12415 |
/*:746*/ |
| 12416 |
#line 8246 "./marpa.w" |
| 12417 |
|
| 12418 |
} |
| 12419 |
} |
| 12420 |
} |
| 12421 |
|
| 12422 |
/*:745*/ |
| 12423 |
#line 8219 "./marpa.w" |
| 12424 |
|
| 12425 |
} |
| 12426 |
|
| 12427 |
/*:743*/ |
| 12428 |
#line 8139 "./marpa.w" |
| 12429 |
|
| 12430 |
/*747:*/ |
| 12431 |
#line 8267 "./marpa.w" |
| 12432 |
{ |
| 12433 |
|
| 12434 |
|
| 12435 |
YIM*work_earley_items= MARPA_DSTACK_BASE(r->t_yim_work_stack,YIM); |
| 12436 |
int no_of_work_earley_items= MARPA_DSTACK_LENGTH(r->t_yim_work_stack); |
| 12437 |
int ix; |
| 12438 |
MARPA_DSTACK_CLEAR(r->t_completion_stack); |
| 12439 |
for(ix= 0; |
| 12440 |
ix<no_of_work_earley_items; |
| 12441 |
ix++){ |
| 12442 |
YIM earley_item= work_earley_items[ix]; |
| 12443 |
YIM*end_of_stack; |
| 12444 |
if(!YIM_is_Completion(earley_item)) |
| 12445 |
continue; |
| 12446 |
end_of_stack= MARPA_DSTACK_PUSH(r->t_completion_stack,YIM); |
| 12447 |
*end_of_stack= earley_item; |
| 12448 |
} |
| 12449 |
} |
| 12450 |
|
| 12451 |
/*:747*/ |
| 12452 |
#line 8140 "./marpa.w" |
| 12453 |
|
| 12454 |
while((cause_p= MARPA_DSTACK_POP(r->t_completion_stack,YIM))){ |
| 12455 |
YIM cause= *cause_p; |
| 12456 |
/*748:*/ |
| 12457 |
#line 8288 "./marpa.w" |
| 12458 |
|
| 12459 |
{ |
| 12460 |
if(YIM_is_Active(cause)&&YIM_is_Completion(cause)) |
| 12461 |
{ |
| 12462 |
NSYID complete_nsyid= LHS_NSYID_of_YIM(cause); |
| 12463 |
const YS middle= Origin_of_YIM(cause); |
| 12464 |
/*749:*/ |
| 12465 |
#line 8298 "./marpa.w" |
| 12466 |
|
| 12467 |
{ |
| 12468 |
PIM postdot_item; |
| 12469 |
for(postdot_item= First_PIM_of_YS_by_NSYID(middle,complete_nsyid); |
| 12470 |
postdot_item;postdot_item= Next_PIM_of_PIM(postdot_item)) |
| 12471 |
{ |
| 12472 |
const YIM predecessor= YIM_of_PIM(postdot_item); |
| 12473 |
if(!predecessor){ |
| 12474 |
|
| 12475 |
|
| 12476 |
const LIM leo_item= LIM_of_PIM(postdot_item); |
| 12477 |
|
| 12478 |
|
| 12479 |
|
| 12480 |
|
| 12481 |
|
| 12482 |
|
| 12483 |
|
| 12484 |
|
| 12485 |
if(!LIM_is_Active(leo_item))goto NEXT_PIM; |
| 12486 |
|
| 12487 |
/*752:*/ |
| 12488 |
#line 8365 "./marpa.w" |
| 12489 |
{ |
| 12490 |
const YS origin= Origin_of_LIM(leo_item); |
| 12491 |
const AHM effect_ahm= Top_AHM_of_LIM(leo_item); |
| 12492 |
const YIM effect= earley_item_assign(r,current_earley_set, |
| 12493 |
origin,effect_ahm); |
| 12494 |
YIM_was_Fusion(effect)= 1; |
| 12495 |
if(Earley_Item_has_No_Source(effect)) |
| 12496 |
{ |
| 12497 |
|
| 12498 |
|
| 12499 |
/*751:*/ |
| 12500 |
#line 8359 "./marpa.w" |
| 12501 |
{ |
| 12502 |
YIM*end_of_stack= MARPA_DSTACK_PUSH(r->t_completion_stack,YIM); |
| 12503 |
*end_of_stack= effect; |
| 12504 |
} |
| 12505 |
|
| 12506 |
/*:751*/ |
| 12507 |
#line 8375 "./marpa.w" |
| 12508 |
|
| 12509 |
} |
| 12510 |
leo_link_add(r,effect,leo_item,cause); |
| 12511 |
} |
| 12512 |
|
| 12513 |
/*:752*/ |
| 12514 |
#line 8319 "./marpa.w" |
| 12515 |
|
| 12516 |
|
| 12517 |
|
| 12518 |
|
| 12519 |
|
| 12520 |
goto LAST_PIM; |
| 12521 |
}else{ |
| 12522 |
|
| 12523 |
|
| 12524 |
if(!YIM_is_Active(predecessor))continue; |
| 12525 |
|
| 12526 |
|
| 12527 |
|
| 12528 |
/*750:*/ |
| 12529 |
#line 8339 "./marpa.w" |
| 12530 |
|
| 12531 |
{ |
| 12532 |
const AHM predecessor_ahm= AHM_of_YIM(predecessor); |
| 12533 |
const AHM effect_ahm= Next_AHM_of_AHM(predecessor_ahm); |
| 12534 |
const YS origin= Origin_of_YIM(predecessor); |
| 12535 |
const YIM effect= earley_item_assign(r,current_earley_set, |
| 12536 |
origin,effect_ahm); |
| 12537 |
YIM_was_Fusion(effect)= 1; |
| 12538 |
if(Earley_Item_has_No_Source(effect)){ |
| 12539 |
|
| 12540 |
|
| 12541 |
if(YIM_is_Completion(effect)){ |
| 12542 |
/*751:*/ |
| 12543 |
#line 8359 "./marpa.w" |
| 12544 |
{ |
| 12545 |
YIM*end_of_stack= MARPA_DSTACK_PUSH(r->t_completion_stack,YIM); |
| 12546 |
*end_of_stack= effect; |
| 12547 |
} |
| 12548 |
|
| 12549 |
/*:751*/ |
| 12550 |
#line 8351 "./marpa.w" |
| 12551 |
|
| 12552 |
} |
| 12553 |
} |
| 12554 |
completion_link_add(r,effect,predecessor,cause); |
| 12555 |
} |
| 12556 |
|
| 12557 |
/*:750*/ |
| 12558 |
#line 8332 "./marpa.w" |
| 12559 |
|
| 12560 |
} |
| 12561 |
NEXT_PIM:; |
| 12562 |
} |
| 12563 |
LAST_PIM:; |
| 12564 |
} |
| 12565 |
|
| 12566 |
/*:749*/ |
| 12567 |
#line 8294 "./marpa.w" |
| 12568 |
|
| 12569 |
} |
| 12570 |
} |
| 12571 |
|
| 12572 |
/*:748*/ |
| 12573 |
#line 8143 "./marpa.w" |
| 12574 |
|
| 12575 |
} |
| 12576 |
/*753:*/ |
| 12577 |
#line 8380 "./marpa.w" |
| 12578 |
|
| 12579 |
{ |
| 12580 |
int ix; |
| 12581 |
const int no_of_work_earley_items= |
| 12582 |
MARPA_DSTACK_LENGTH(r->t_yim_work_stack); |
| 12583 |
for(ix= 0;ix<no_of_work_earley_items;ix++) |
| 12584 |
{ |
| 12585 |
YIM earley_item= WORK_YIM_ITEM(r,ix); |
| 12586 |
|
| 12587 |
int cil_ix; |
| 12588 |
const AHM ahm= AHM_of_YIM(earley_item); |
| 12589 |
const CIL prediction_cil= Predicted_IRL_CIL_of_AHM(ahm); |
| 12590 |
const int prediction_count= Count_of_CIL(prediction_cil); |
| 12591 |
for(cil_ix= 0;cil_ix<prediction_count;cil_ix++) |
| 12592 |
{ |
| 12593 |
const IRLID prediction_irlid= Item_of_CIL(prediction_cil,cil_ix); |
| 12594 |
const IRL prediction_irl= IRL_by_ID(prediction_irlid); |
| 12595 |
const AHM prediction_ahm= First_AHM_of_IRL(prediction_irl); |
| 12596 |
earley_item_assign(r,current_earley_set,current_earley_set, |
| 12597 |
prediction_ahm); |
| 12598 |
} |
| 12599 |
|
| 12600 |
} |
| 12601 |
} |
| 12602 |
|
| 12603 |
/*:753*/ |
| 12604 |
#line 8145 "./marpa.w" |
| 12605 |
|
| 12606 |
postdot_items_create(r,bv_ok_for_chain,current_earley_set); |
| 12607 |
|
| 12608 |
|
| 12609 |
|
| 12610 |
|
| 12611 |
|
| 12612 |
count_of_expected_terminals= bv_count(r->t_bv_nsyid_is_expected); |
| 12613 |
if(count_of_expected_terminals<=0 |
| 12614 |
&&MARPA_DSTACK_LENGTH(r->t_alternatives)<=0) |
| 12615 |
{ |
| 12616 |
/*611:*/ |
| 12617 |
#line 6611 "./marpa.w" |
| 12618 |
|
| 12619 |
{ |
| 12620 |
R_is_Exhausted(r)= 1; |
| 12621 |
Input_Phase_of_R(r)= R_AFTER_INPUT; |
| 12622 |
event_new(g,MARPA_EVENT_EXHAUSTED); |
| 12623 |
} |
| 12624 |
|
| 12625 |
/*:611*/ |
| 12626 |
#line 8156 "./marpa.w" |
| 12627 |
|
| 12628 |
} |
| 12629 |
earley_set_update_items(r,current_earley_set); |
| 12630 |
/*656:*/ |
| 12631 |
#line 7050 "./marpa.w" |
| 12632 |
|
| 12633 |
{ |
| 12634 |
const int yim_count= YIM_Count_of_YS(current_earley_set); |
| 12635 |
if(yim_count>=r->t_earley_item_warning_threshold) |
| 12636 |
{ |
| 12637 |
int_event_new(g,MARPA_EVENT_EARLEY_ITEM_THRESHOLD,yim_count); |
| 12638 |
} |
| 12639 |
} |
| 12640 |
|
| 12641 |
/*:656*/ |
| 12642 |
#line 8159 "./marpa.w" |
| 12643 |
|
| 12644 |
if(r->t_active_event_count> 0){ |
| 12645 |
trigger_events(r); |
| 12646 |
} |
| 12647 |
return_value= G_EVENT_COUNT(g); |
| 12648 |
CLEANUP:; |
| 12649 |
/*739:*/ |
| 12650 |
#line 8177 "./marpa.w" |
| 12651 |
|
| 12652 |
bv_free(bv_ok_for_chain); |
| 12653 |
marpa_obs_free(earleme_complete_obs); |
| 12654 |
|
| 12655 |
/*:739*/ |
| 12656 |
#line 8165 "./marpa.w" |
| 12657 |
|
| 12658 |
} |
| 12659 |
return return_value; |
| 12660 |
} |
| 12661 |
|
| 12662 |
/*:737*//*754:*/ |
| 12663 |
#line 8405 "./marpa.w" |
| 12664 |
|
| 12665 |
PRIVATE void trigger_events(RECCE r) |
| 12666 |
{ |
| 12667 |
const GRAMMAR g= G_of_R(r); |
| 12668 |
const YS current_earley_set= Latest_YS_of_R(r); |
| 12669 |
int min,max,start; |
| 12670 |
int yim_ix; |
| 12671 |
struct marpa_obstack*const trigger_events_obs= marpa_obs_init; |
| 12672 |
const YIM*yims= YIMs_of_YS(current_earley_set); |
| 12673 |
const XSYID xsy_count= XSY_Count_of_G(g); |
| 12674 |
const int ahm_count= AHM_Count_of_G(g); |
| 12675 |
Bit_Vector bv_completion_event_trigger= |
| 12676 |
bv_obs_create(trigger_events_obs,xsy_count); |
| 12677 |
Bit_Vector bv_nulled_event_trigger= |
| 12678 |
bv_obs_create(trigger_events_obs,xsy_count); |
| 12679 |
Bit_Vector bv_prediction_event_trigger= |
| 12680 |
bv_obs_create(trigger_events_obs,xsy_count); |
| 12681 |
Bit_Vector bv_ahm_event_trigger= |
| 12682 |
bv_obs_create(trigger_events_obs,ahm_count); |
| 12683 |
const int working_earley_item_count= YIM_Count_of_YS(current_earley_set); |
| 12684 |
for(yim_ix= 0;yim_ix<working_earley_item_count;yim_ix++) |
| 12685 |
{ |
| 12686 |
const YIM yim= yims[yim_ix]; |
| 12687 |
const AHM root_ahm= AHM_of_YIM(yim); |
| 12688 |
if(AHM_has_Event(root_ahm)) |
| 12689 |
{ |
| 12690 |
|
| 12691 |
bv_bit_set(bv_ahm_event_trigger,ID_of_AHM(root_ahm)); |
| 12692 |
} |
| 12693 |
{ |
| 12694 |
|
| 12695 |
const SRCL first_leo_source_link= First_Leo_SRCL_of_YIM(yim); |
| 12696 |
SRCL setup_source_link; |
| 12697 |
for(setup_source_link= first_leo_source_link;setup_source_link; |
| 12698 |
setup_source_link= Next_SRCL_of_SRCL(setup_source_link)) |
| 12699 |
{ |
| 12700 |
int cil_ix; |
| 12701 |
const LIM lim= LIM_of_SRCL(setup_source_link); |
| 12702 |
const CIL event_ahmids= CIL_of_LIM(lim); |
| 12703 |
const int event_ahm_count= Count_of_CIL(event_ahmids); |
| 12704 |
for(cil_ix= 0;cil_ix<event_ahm_count;cil_ix++) |
| 12705 |
{ |
| 12706 |
const NSYID leo_path_ahmid= |
| 12707 |
Item_of_CIL(event_ahmids,cil_ix); |
| 12708 |
bv_bit_set(bv_ahm_event_trigger,leo_path_ahmid); |
| 12709 |
|
| 12710 |
|
| 12711 |
} |
| 12712 |
} |
| 12713 |
} |
| 12714 |
} |
| 12715 |
|
| 12716 |
for(start= 0;bv_scan(bv_ahm_event_trigger,start,&min,&max); |
| 12717 |
start= max+2) |
| 12718 |
{ |
| 12719 |
XSYID event_ahmid; |
| 12720 |
for(event_ahmid= (NSYID)min;event_ahmid<=(NSYID)max; |
| 12721 |
event_ahmid++) |
| 12722 |
{ |
| 12723 |
int cil_ix; |
| 12724 |
const AHM event_ahm= AHM_by_ID(event_ahmid); |
| 12725 |
{ |
| 12726 |
const CIL completion_xsyids= |
| 12727 |
Completion_XSYIDs_of_AHM(event_ahm); |
| 12728 |
const int event_xsy_count= Count_of_CIL(completion_xsyids); |
| 12729 |
for(cil_ix= 0;cil_ix<event_xsy_count;cil_ix++) |
| 12730 |
{ |
| 12731 |
XSYID event_xsyid= Item_of_CIL(completion_xsyids,cil_ix); |
| 12732 |
bv_bit_set(bv_completion_event_trigger,event_xsyid); |
| 12733 |
} |
| 12734 |
} |
| 12735 |
{ |
| 12736 |
const CIL nulled_xsyids= Nulled_XSYIDs_of_AHM(event_ahm); |
| 12737 |
const int event_xsy_count= Count_of_CIL(nulled_xsyids); |
| 12738 |
for(cil_ix= 0;cil_ix<event_xsy_count;cil_ix++) |
| 12739 |
{ |
| 12740 |
XSYID event_xsyid= Item_of_CIL(nulled_xsyids,cil_ix); |
| 12741 |
bv_bit_set(bv_nulled_event_trigger,event_xsyid); |
| 12742 |
} |
| 12743 |
} |
| 12744 |
{ |
| 12745 |
const CIL prediction_xsyids= |
| 12746 |
Prediction_XSYIDs_of_AHM(event_ahm); |
| 12747 |
const int event_xsy_count= Count_of_CIL(prediction_xsyids); |
| 12748 |
for(cil_ix= 0;cil_ix<event_xsy_count;cil_ix++) |
| 12749 |
{ |
| 12750 |
XSYID event_xsyid= Item_of_CIL(prediction_xsyids,cil_ix); |
| 12751 |
bv_bit_set(bv_prediction_event_trigger,event_xsyid); |
| 12752 |
} |
| 12753 |
} |
| 12754 |
} |
| 12755 |
} |
| 12756 |
|
| 12757 |
if(Ord_of_YS(current_earley_set)<=0) |
| 12758 |
{ |
| 12759 |
|
| 12760 |
|
| 12761 |
|
| 12762 |
|
| 12763 |
|
| 12764 |
|
| 12765 |
|
| 12766 |
|
| 12767 |
int cil_ix; |
| 12768 |
const XSY start_xsy= XSY_by_ID(g->t_start_xsy_id); |
| 12769 |
const CIL nulled_xsyids= Nulled_XSYIDs_of_XSY(start_xsy); |
| 12770 |
const int cil_count= Count_of_CIL(nulled_xsyids); |
| 12771 |
for(cil_ix= 0;cil_ix<cil_count;cil_ix++) |
| 12772 |
{ |
| 12773 |
const XSYID nulled_xsyid= Item_of_CIL(nulled_xsyids,cil_ix); |
| 12774 |
bv_bit_set(bv_nulled_event_trigger,nulled_xsyid); |
| 12775 |
} |
| 12776 |
} |
| 12777 |
|
| 12778 |
for(start= 0;bv_scan(bv_completion_event_trigger,start,&min,&max); |
| 12779 |
start= max+2) |
| 12780 |
{ |
| 12781 |
XSYID event_xsyid; |
| 12782 |
for(event_xsyid= min;event_xsyid<=max; |
| 12783 |
event_xsyid++) |
| 12784 |
{ |
| 12785 |
if(lbv_bit_test |
| 12786 |
(r->t_lbv_xsyid_completion_event_is_active,event_xsyid)) |
| 12787 |
{ |
| 12788 |
int_event_new(g,MARPA_EVENT_SYMBOL_COMPLETED,event_xsyid); |
| 12789 |
} |
| 12790 |
} |
| 12791 |
} |
| 12792 |
for(start= 0;bv_scan(bv_nulled_event_trigger,start,&min,&max); |
| 12793 |
start= max+2) |
| 12794 |
{ |
| 12795 |
XSYID event_xsyid; |
| 12796 |
for(event_xsyid= min;event_xsyid<=max; |
| 12797 |
event_xsyid++) |
| 12798 |
{ |
| 12799 |
if(lbv_bit_test |
| 12800 |
(r->t_lbv_xsyid_nulled_event_is_active,event_xsyid)) |
| 12801 |
{ |
| 12802 |
int_event_new(g,MARPA_EVENT_SYMBOL_NULLED,event_xsyid); |
| 12803 |
} |
| 12804 |
|
| 12805 |
} |
| 12806 |
} |
| 12807 |
for(start= 0;bv_scan(bv_prediction_event_trigger,start,&min,&max); |
| 12808 |
start= max+2) |
| 12809 |
{ |
| 12810 |
XSYID event_xsyid; |
| 12811 |
for(event_xsyid= (NSYID)min;event_xsyid<=(NSYID)max; |
| 12812 |
event_xsyid++) |
| 12813 |
{ |
| 12814 |
if(lbv_bit_test |
| 12815 |
(r->t_lbv_xsyid_prediction_event_is_active,event_xsyid)) |
| 12816 |
{ |
| 12817 |
int_event_new(g,MARPA_EVENT_SYMBOL_PREDICTED,event_xsyid); |
| 12818 |
} |
| 12819 |
} |
| 12820 |
} |
| 12821 |
marpa_obs_free(trigger_events_obs); |
| 12822 |
} |
| 12823 |
|
| 12824 |
/*:754*//*755:*/ |
| 12825 |
#line 8573 "./marpa.w" |
| 12826 |
|
| 12827 |
PRIVATE int trigger_trivial_events(RECCE r) |
| 12828 |
{ |
| 12829 |
int cil_ix; |
| 12830 |
int event_count= 0; |
| 12831 |
GRAMMAR g= G_of_R(r); |
| 12832 |
const XSY start_xsy= XSY_by_ID(g->t_start_xsy_id); |
| 12833 |
const CIL nulled_xsyids= Nulled_XSYIDs_of_XSY(start_xsy); |
| 12834 |
const int cil_count= Count_of_CIL(nulled_xsyids); |
| 12835 |
for(cil_ix= 0;cil_ix<cil_count;cil_ix++) |
| 12836 |
{ |
| 12837 |
const XSYID nulled_xsyid= Item_of_CIL(nulled_xsyids,cil_ix); |
| 12838 |
if(lbv_bit_test(r->t_lbv_xsyid_nulled_event_is_active,nulled_xsyid)){ |
| 12839 |
int_event_new(g,MARPA_EVENT_SYMBOL_NULLED,nulled_xsyid); |
| 12840 |
event_count++; |
| 12841 |
} |
| 12842 |
} |
| 12843 |
return event_count; |
| 12844 |
} |
| 12845 |
|
| 12846 |
/*:755*//*756:*/ |
| 12847 |
#line 8593 "./marpa.w" |
| 12848 |
|
| 12849 |
PRIVATE void earley_set_update_items(RECCE r,YS set) |
| 12850 |
{ |
| 12851 |
YIM*working_earley_items; |
| 12852 |
YIM*finished_earley_items; |
| 12853 |
int working_earley_item_count; |
| 12854 |
int i; |
| 12855 |
YIMs_of_YS(set)= marpa_obs_new(r->t_obs,YIM,YIM_Count_of_YS(set)); |
| 12856 |
finished_earley_items= YIMs_of_YS(set); |
| 12857 |
|
| 12858 |
working_earley_items= Work_YIMs_of_R(r); |
| 12859 |
working_earley_item_count= Work_YIM_Count_of_R(r); |
| 12860 |
for(i= 0;i<working_earley_item_count;i++){ |
| 12861 |
YIM earley_item= working_earley_items[i]; |
| 12862 |
int ordinal= Ord_of_YIM(earley_item); |
| 12863 |
finished_earley_items[ordinal]= earley_item; |
| 12864 |
} |
| 12865 |
WORK_YIMS_CLEAR(r); |
| 12866 |
} |
| 12867 |
|
| 12868 |
/*:756*//*757:*/ |
| 12869 |
#line 8622 "./marpa.w" |
| 12870 |
|
| 12871 |
PRIVATE void r_update_earley_sets(RECCE r) |
| 12872 |
{ |
| 12873 |
YS set; |
| 12874 |
YS first_unstacked_earley_set; |
| 12875 |
if(!MARPA_DSTACK_IS_INITIALIZED(r->t_earley_set_stack)){ |
| 12876 |
first_unstacked_earley_set= First_YS_of_R(r); |
| 12877 |
MARPA_DSTACK_INIT(r->t_earley_set_stack,YS, |
| 12878 |
MAX(1024,YS_Count_of_R(r))); |
| 12879 |
}else{ |
| 12880 |
YS*end_of_stack= MARPA_DSTACK_TOP(r->t_earley_set_stack,YS); |
| 12881 |
first_unstacked_earley_set= Next_YS_of_YS(*end_of_stack); |
| 12882 |
} |
| 12883 |
for(set= first_unstacked_earley_set;set;set= Next_YS_of_YS(set)){ |
| 12884 |
YS*end_of_stack= MARPA_DSTACK_PUSH(r->t_earley_set_stack,YS); |
| 12885 |
(*end_of_stack)= set; |
| 12886 |
} |
| 12887 |
} |
| 12888 |
|
| 12889 |
/*:757*//*773:*/ |
| 12890 |
#line 8726 "./marpa.w" |
| 12891 |
|
| 12892 |
PRIVATE_NOT_INLINE void |
| 12893 |
postdot_items_create(RECCE r, |
| 12894 |
Bit_Vector bv_ok_for_chain, |
| 12895 |
const YS current_earley_set) |
| 12896 |
{ |
| 12897 |
/*560:*/ |
| 12898 |
#line 6100 "./marpa.w" |
| 12899 |
|
| 12900 |
const GRAMMAR g= G_of_R(r); |
| 12901 |
/*:560*/ |
| 12902 |
#line 8732 "./marpa.w" |
| 12903 |
|
| 12904 |
/*772:*/ |
| 12905 |
#line 8723 "./marpa.w" |
| 12906 |
|
| 12907 |
bv_clear(r->t_bv_lim_symbols); |
| 12908 |
bv_clear(r->t_bv_pim_symbols); |
| 12909 |
/*:772*/ |
| 12910 |
#line 8733 "./marpa.w" |
| 12911 |
|
| 12912 |
/*774:*/ |
| 12913 |
#line 8745 "./marpa.w" |
| 12914 |
{ |
| 12915 |
|
| 12916 |
YIM*work_earley_items= MARPA_DSTACK_BASE(r->t_yim_work_stack,YIM); |
| 12917 |
int no_of_work_earley_items= MARPA_DSTACK_LENGTH(r->t_yim_work_stack); |
| 12918 |
int ix; |
| 12919 |
for(ix= 0; |
| 12920 |
ix<no_of_work_earley_items; |
| 12921 |
ix++) |
| 12922 |
{ |
| 12923 |
YIM earley_item= work_earley_items[ix]; |
| 12924 |
AHM ahm= AHM_of_YIM(earley_item); |
| 12925 |
const NSYID postdot_nsyid= Postdot_NSYID_of_AHM(ahm); |
| 12926 |
if(postdot_nsyid<0)continue; |
| 12927 |
{ |
| 12928 |
PIM old_pim= NULL; |
| 12929 |
PIM new_pim; |
| 12930 |
|
| 12931 |
|
| 12932 |
new_pim= marpa__obs_alloc(r->t_obs, |
| 12933 |
sizeof(YIX_Object),ALIGNOF(PIM_Object)); |
| 12934 |
|
| 12935 |
Postdot_NSYID_of_PIM(new_pim)= postdot_nsyid; |
| 12936 |
YIM_of_PIM(new_pim)= earley_item; |
| 12937 |
if(bv_bit_test(r->t_bv_pim_symbols,postdot_nsyid)) |
| 12938 |
old_pim= r->t_pim_workarea[postdot_nsyid]; |
| 12939 |
Next_PIM_of_PIM(new_pim)= old_pim; |
| 12940 |
if(!old_pim)current_earley_set->t_postdot_sym_count++; |
| 12941 |
r->t_pim_workarea[postdot_nsyid]= new_pim; |
| 12942 |
bv_bit_set(r->t_bv_pim_symbols,postdot_nsyid); |
| 12943 |
} |
| 12944 |
} |
| 12945 |
} |
| 12946 |
|
| 12947 |
/*:774*/ |
| 12948 |
#line 8734 "./marpa.w" |
| 12949 |
|
| 12950 |
if(r->t_is_using_leo){ |
| 12951 |
/*776:*/ |
| 12952 |
#line 8788 "./marpa.w" |
| 12953 |
|
| 12954 |
{ |
| 12955 |
int min,max,start; |
| 12956 |
for(start= 0;bv_scan(r->t_bv_pim_symbols,start,&min,&max); |
| 12957 |
start= max+2) |
| 12958 |
{ |
| 12959 |
NSYID nsyid; |
| 12960 |
for(nsyid= (NSYID)min;nsyid<=(NSYID)max;nsyid++) |
| 12961 |
{ |
| 12962 |
const PIM this_pim= r->t_pim_workarea[nsyid]; |
| 12963 |
if(Next_PIM_of_PIM(this_pim)) |
| 12964 |
goto NEXT_NSYID; |
| 12965 |
|
| 12966 |
|
| 12967 |
{ |
| 12968 |
const YIM leo_base= YIM_of_PIM(this_pim); |
| 12969 |
AHM potential_leo_penult_ahm= NULL; |
| 12970 |
const AHM leo_base_ahm= AHM_of_YIM(leo_base); |
| 12971 |
const IRL leo_base_irl= IRL_of_AHM(leo_base_ahm); |
| 12972 |
|
| 12973 |
if(!IRL_is_Leo(leo_base_irl)) |
| 12974 |
goto NEXT_NSYID; |
| 12975 |
potential_leo_penult_ahm= leo_base_ahm; |
| 12976 |
MARPA_ASSERT((int)potential_leo_penult_ahm); |
| 12977 |
{ |
| 12978 |
const AHM trailhead_ahm= |
| 12979 |
Next_AHM_of_AHM(potential_leo_penult_ahm); |
| 12980 |
if(AHM_is_Leo_Completion(trailhead_ahm)) |
| 12981 |
{ |
| 12982 |
/*777:*/ |
| 12983 |
#line 8832 "./marpa.w" |
| 12984 |
{ |
| 12985 |
LIM new_lim; |
| 12986 |
new_lim= marpa_obs_new(r->t_obs,LIM_Object,1); |
| 12987 |
LIM_is_Active(new_lim)= 1; |
| 12988 |
LIM_is_Rejected(new_lim)= 1; |
| 12989 |
Postdot_NSYID_of_LIM(new_lim)= nsyid; |
| 12990 |
YIM_of_PIM(new_lim)= NULL; |
| 12991 |
Predecessor_LIM_of_LIM(new_lim)= NULL; |
| 12992 |
Origin_of_LIM(new_lim)= NULL; |
| 12993 |
CIL_of_LIM(new_lim)= NULL; |
| 12994 |
Top_AHM_of_LIM(new_lim)= trailhead_ahm; |
| 12995 |
Trailhead_AHM_of_LIM(new_lim)= trailhead_ahm; |
| 12996 |
Trailhead_YIM_of_LIM(new_lim)= leo_base; |
| 12997 |
YS_of_LIM(new_lim)= current_earley_set; |
| 12998 |
Next_PIM_of_LIM(new_lim)= this_pim; |
| 12999 |
r->t_pim_workarea[nsyid]= new_lim; |
| 13000 |
bv_bit_set(r->t_bv_lim_symbols,nsyid); |
| 13001 |
} |
| 13002 |
|
| 13003 |
/*:777*/ |
| 13004 |
#line 8817 "./marpa.w" |
| 13005 |
|
| 13006 |
} |
| 13007 |
} |
| 13008 |
} |
| 13009 |
NEXT_NSYID:; |
| 13010 |
} |
| 13011 |
} |
| 13012 |
} |
| 13013 |
|
| 13014 |
/*:776*/ |
| 13015 |
#line 8736 "./marpa.w" |
| 13016 |
|
| 13017 |
/*786:*/ |
| 13018 |
#line 8920 "./marpa.w" |
| 13019 |
{ |
| 13020 |
int min,max,start; |
| 13021 |
|
| 13022 |
bv_copy(bv_ok_for_chain,r->t_bv_lim_symbols); |
| 13023 |
for(start= 0;bv_scan(r->t_bv_lim_symbols,start,&min,&max); |
| 13024 |
start= max+2) |
| 13025 |
{ |
| 13026 |
|
| 13027 |
NSYID main_loop_nsyid; |
| 13028 |
for(main_loop_nsyid= (NSYID)min; |
| 13029 |
main_loop_nsyid<=(NSYID)max; |
| 13030 |
main_loop_nsyid++) |
| 13031 |
{ |
| 13032 |
LIM predecessor_lim; |
| 13033 |
LIM lim_to_process= r->t_pim_workarea[main_loop_nsyid]; |
| 13034 |
if(LIM_is_Populated(lim_to_process))continue; |
| 13035 |
|
| 13036 |
/*788:*/ |
| 13037 |
#line 8976 "./marpa.w" |
| 13038 |
|
| 13039 |
{ |
| 13040 |
const YIM base_yim= Trailhead_YIM_of_LIM(lim_to_process); |
| 13041 |
const YS predecessor_set= Origin_of_YIM(base_yim); |
| 13042 |
const AHM trailhead_ahm= Trailhead_AHM_of_LIM(lim_to_process); |
| 13043 |
const NSYID predecessor_transition_nsyid= |
| 13044 |
LHSID_of_AHM(trailhead_ahm); |
| 13045 |
PIM predecessor_pim; |
| 13046 |
if(Ord_of_YS(predecessor_set)<Ord_of_YS(current_earley_set)) |
| 13047 |
{ |
| 13048 |
predecessor_pim |
| 13049 |
= |
| 13050 |
First_PIM_of_YS_by_NSYID(predecessor_set, |
| 13051 |
predecessor_transition_nsyid); |
| 13052 |
} |
| 13053 |
else |
| 13054 |
{ |
| 13055 |
predecessor_pim= r->t_pim_workarea[predecessor_transition_nsyid]; |
| 13056 |
} |
| 13057 |
predecessor_lim= |
| 13058 |
PIM_is_LIM(predecessor_pim)?LIM_of_PIM(predecessor_pim):NULL; |
| 13059 |
} |
| 13060 |
|
| 13061 |
/*:788*/ |
| 13062 |
#line 8937 "./marpa.w" |
| 13063 |
|
| 13064 |
if(predecessor_lim&&LIM_is_Populated(predecessor_lim)){ |
| 13065 |
/*796:*/ |
| 13066 |
#line 9095 "./marpa.w" |
| 13067 |
|
| 13068 |
{ |
| 13069 |
const AHM new_top_ahm= Top_AHM_of_LIM(predecessor_lim); |
| 13070 |
const CIL predecessor_cil= CIL_of_LIM(predecessor_lim); |
| 13071 |
|
| 13072 |
|
| 13073 |
|
| 13074 |
CIL_of_LIM(lim_to_process)= predecessor_cil; |
| 13075 |
Predecessor_LIM_of_LIM(lim_to_process)= predecessor_lim; |
| 13076 |
Origin_of_LIM(lim_to_process)= Origin_of_LIM(predecessor_lim); |
| 13077 |
if(Event_Group_Size_of_AHM(new_top_ahm)> Count_of_CIL(predecessor_cil)) |
| 13078 |
{ |
| 13079 |
const AHM trailhead_ahm= Trailhead_AHM_of_LIM(lim_to_process); |
| 13080 |
const CIL trailhead_ahm_event_ahmids= |
| 13081 |
Event_AHMIDs_of_AHM(trailhead_ahm); |
| 13082 |
if(Count_of_CIL(trailhead_ahm_event_ahmids)) |
| 13083 |
{ |
| 13084 |
CIL new_cil= cil_merge_one(&g->t_cilar,predecessor_cil, |
| 13085 |
Item_of_CIL |
| 13086 |
(trailhead_ahm_event_ahmids,0)); |
| 13087 |
if(new_cil) |
| 13088 |
{ |
| 13089 |
CIL_of_LIM(lim_to_process)= new_cil; |
| 13090 |
} |
| 13091 |
} |
| 13092 |
} |
| 13093 |
Top_AHM_of_LIM(lim_to_process)= new_top_ahm; |
| 13094 |
} |
| 13095 |
|
| 13096 |
/*:796*/ |
| 13097 |
#line 8939 "./marpa.w" |
| 13098 |
|
| 13099 |
continue; |
| 13100 |
} |
| 13101 |
if(!predecessor_lim){ |
| 13102 |
|
| 13103 |
|
| 13104 |
/*798:*/ |
| 13105 |
#line 9136 "./marpa.w" |
| 13106 |
{ |
| 13107 |
const AHM trailhead_ahm= Trailhead_AHM_of_LIM(lim_to_process); |
| 13108 |
const YIM base_yim= Trailhead_YIM_of_LIM(lim_to_process); |
| 13109 |
Origin_of_LIM(lim_to_process)= Origin_of_YIM(base_yim); |
| 13110 |
CIL_of_LIM(lim_to_process)= Event_AHMIDs_of_AHM(trailhead_ahm); |
| 13111 |
} |
| 13112 |
|
| 13113 |
/*:798*/ |
| 13114 |
#line 8945 "./marpa.w" |
| 13115 |
|
| 13116 |
continue; |
| 13117 |
} |
| 13118 |
/*791:*/ |
| 13119 |
#line 9003 "./marpa.w" |
| 13120 |
{ |
| 13121 |
int lim_chain_ix; |
| 13122 |
/*794:*/ |
| 13123 |
#line 9023 "./marpa.w" |
| 13124 |
|
| 13125 |
{ |
| 13126 |
NSYID postdot_nsyid_of_lim_to_process |
| 13127 |
= Postdot_NSYID_of_LIM(lim_to_process); |
| 13128 |
lim_chain_ix= 0; |
| 13129 |
r->t_lim_chain[lim_chain_ix++]= LIM_of_PIM(lim_to_process); |
| 13130 |
bv_bit_clear(bv_ok_for_chain, |
| 13131 |
postdot_nsyid_of_lim_to_process); |
| 13132 |
|
| 13133 |
|
| 13134 |
while(1) |
| 13135 |
{ |
| 13136 |
|
| 13137 |
|
| 13138 |
|
| 13139 |
|
| 13140 |
|
| 13141 |
|
| 13142 |
|
| 13143 |
|
| 13144 |
lim_to_process= predecessor_lim; |
| 13145 |
postdot_nsyid_of_lim_to_process= Postdot_NSYID_of_LIM(lim_to_process); |
| 13146 |
if(!bv_bit_test |
| 13147 |
(bv_ok_for_chain,postdot_nsyid_of_lim_to_process)) |
| 13148 |
{ |
| 13149 |
|
| 13150 |
|
| 13151 |
|
| 13152 |
|
| 13153 |
|
| 13154 |
break; |
| 13155 |
} |
| 13156 |
|
| 13157 |
/*788:*/ |
| 13158 |
#line 8976 "./marpa.w" |
| 13159 |
|
| 13160 |
{ |
| 13161 |
const YIM base_yim= Trailhead_YIM_of_LIM(lim_to_process); |
| 13162 |
const YS predecessor_set= Origin_of_YIM(base_yim); |
| 13163 |
const AHM trailhead_ahm= Trailhead_AHM_of_LIM(lim_to_process); |
| 13164 |
const NSYID predecessor_transition_nsyid= |
| 13165 |
LHSID_of_AHM(trailhead_ahm); |
| 13166 |
PIM predecessor_pim; |
| 13167 |
if(Ord_of_YS(predecessor_set)<Ord_of_YS(current_earley_set)) |
| 13168 |
{ |
| 13169 |
predecessor_pim |
| 13170 |
= |
| 13171 |
First_PIM_of_YS_by_NSYID(predecessor_set, |
| 13172 |
predecessor_transition_nsyid); |
| 13173 |
} |
| 13174 |
else |
| 13175 |
{ |
| 13176 |
predecessor_pim= r->t_pim_workarea[predecessor_transition_nsyid]; |
| 13177 |
} |
| 13178 |
predecessor_lim= |
| 13179 |
PIM_is_LIM(predecessor_pim)?LIM_of_PIM(predecessor_pim):NULL; |
| 13180 |
} |
| 13181 |
|
| 13182 |
/*:788*/ |
| 13183 |
#line 9056 "./marpa.w" |
| 13184 |
|
| 13185 |
|
| 13186 |
r->t_lim_chain[lim_chain_ix++]= LIM_of_PIM(lim_to_process); |
| 13187 |
|
| 13188 |
|
| 13189 |
bv_bit_clear(bv_ok_for_chain, |
| 13190 |
postdot_nsyid_of_lim_to_process); |
| 13191 |
|
| 13192 |
|
| 13193 |
|
| 13194 |
|
| 13195 |
|
| 13196 |
if(!predecessor_lim) |
| 13197 |
break; |
| 13198 |
if(LIM_is_Populated(predecessor_lim)) |
| 13199 |
break; |
| 13200 |
|
| 13201 |
|
| 13202 |
|
| 13203 |
} |
| 13204 |
} |
| 13205 |
|
| 13206 |
/*:794*/ |
| 13207 |
#line 9005 "./marpa.w" |
| 13208 |
|
| 13209 |
/*795:*/ |
| 13210 |
#line 9078 "./marpa.w" |
| 13211 |
|
| 13212 |
for(lim_chain_ix--;lim_chain_ix>=0;lim_chain_ix--){ |
| 13213 |
lim_to_process= r->t_lim_chain[lim_chain_ix]; |
| 13214 |
if(predecessor_lim&&LIM_is_Populated(predecessor_lim)){ |
| 13215 |
/*796:*/ |
| 13216 |
#line 9095 "./marpa.w" |
| 13217 |
|
| 13218 |
{ |
| 13219 |
const AHM new_top_ahm= Top_AHM_of_LIM(predecessor_lim); |
| 13220 |
const CIL predecessor_cil= CIL_of_LIM(predecessor_lim); |
| 13221 |
|
| 13222 |
|
| 13223 |
|
| 13224 |
CIL_of_LIM(lim_to_process)= predecessor_cil; |
| 13225 |
Predecessor_LIM_of_LIM(lim_to_process)= predecessor_lim; |
| 13226 |
Origin_of_LIM(lim_to_process)= Origin_of_LIM(predecessor_lim); |
| 13227 |
if(Event_Group_Size_of_AHM(new_top_ahm)> Count_of_CIL(predecessor_cil)) |
| 13228 |
{ |
| 13229 |
const AHM trailhead_ahm= Trailhead_AHM_of_LIM(lim_to_process); |
| 13230 |
const CIL trailhead_ahm_event_ahmids= |
| 13231 |
Event_AHMIDs_of_AHM(trailhead_ahm); |
| 13232 |
if(Count_of_CIL(trailhead_ahm_event_ahmids)) |
| 13233 |
{ |
| 13234 |
CIL new_cil= cil_merge_one(&g->t_cilar,predecessor_cil, |
| 13235 |
Item_of_CIL |
| 13236 |
(trailhead_ahm_event_ahmids,0)); |
| 13237 |
if(new_cil) |
| 13238 |
{ |
| 13239 |
CIL_of_LIM(lim_to_process)= new_cil; |
| 13240 |
} |
| 13241 |
} |
| 13242 |
} |
| 13243 |
Top_AHM_of_LIM(lim_to_process)= new_top_ahm; |
| 13244 |
} |
| 13245 |
|
| 13246 |
/*:796*/ |
| 13247 |
#line 9082 "./marpa.w" |
| 13248 |
|
| 13249 |
}else{ |
| 13250 |
/*798:*/ |
| 13251 |
#line 9136 "./marpa.w" |
| 13252 |
{ |
| 13253 |
const AHM trailhead_ahm= Trailhead_AHM_of_LIM(lim_to_process); |
| 13254 |
const YIM base_yim= Trailhead_YIM_of_LIM(lim_to_process); |
| 13255 |
Origin_of_LIM(lim_to_process)= Origin_of_YIM(base_yim); |
| 13256 |
CIL_of_LIM(lim_to_process)= Event_AHMIDs_of_AHM(trailhead_ahm); |
| 13257 |
} |
| 13258 |
|
| 13259 |
/*:798*/ |
| 13260 |
#line 9084 "./marpa.w" |
| 13261 |
|
| 13262 |
} |
| 13263 |
predecessor_lim= lim_to_process; |
| 13264 |
} |
| 13265 |
|
| 13266 |
/*:795*/ |
| 13267 |
#line 9006 "./marpa.w" |
| 13268 |
|
| 13269 |
} |
| 13270 |
|
| 13271 |
/*:791*/ |
| 13272 |
#line 8948 "./marpa.w" |
| 13273 |
|
| 13274 |
} |
| 13275 |
} |
| 13276 |
} |
| 13277 |
|
| 13278 |
/*:786*/ |
| 13279 |
#line 8737 "./marpa.w" |
| 13280 |
|
| 13281 |
} |
| 13282 |
/*799:*/ |
| 13283 |
#line 9143 "./marpa.w" |
| 13284 |
{ |
| 13285 |
PIM*postdot_array |
| 13286 |
= current_earley_set->t_postdot_ary |
| 13287 |
= marpa_obs_new(r->t_obs,PIM,current_earley_set->t_postdot_sym_count); |
| 13288 |
int min,max,start; |
| 13289 |
int postdot_array_ix= 0; |
| 13290 |
for(start= 0;bv_scan(r->t_bv_pim_symbols,start,&min,&max);start= max+2){ |
| 13291 |
NSYID nsyid; |
| 13292 |
for(nsyid= min;nsyid<=max;nsyid++){ |
| 13293 |
PIM this_pim= r->t_pim_workarea[nsyid]; |
| 13294 |
if(lbv_bit_test(r->t_nsy_expected_is_event,nsyid)){ |
| 13295 |
XSY xsy= Source_XSY_of_NSYID(nsyid); |
| 13296 |
int_event_new(g,MARPA_EVENT_SYMBOL_EXPECTED,ID_of_XSY(xsy)); |
| 13297 |
} |
| 13298 |
if(this_pim)postdot_array[postdot_array_ix++]= this_pim; |
| 13299 |
} |
| 13300 |
} |
| 13301 |
} |
| 13302 |
|
| 13303 |
|
| 13304 |
/*:799*/ |
| 13305 |
#line 8739 "./marpa.w" |
| 13306 |
|
| 13307 |
bv_and(r->t_bv_nsyid_is_expected,r->t_bv_pim_symbols,g->t_bv_nsyid_is_terminal); |
| 13308 |
} |
| 13309 |
|
| 13310 |
/*:773*//*802:*/ |
| 13311 |
#line 9179 "./marpa.w" |
| 13312 |
|
| 13313 |
Marpa_Earleme |
| 13314 |
marpa_r_clean(Marpa_Recognizer r) |
| 13315 |
{ |
| 13316 |
/*1230:*/ |
| 13317 |
#line 14864 "./marpa.w" |
| 13318 |
const int failure_indicator= -2; |
| 13319 |
|
| 13320 |
/*:1230*/ |
| 13321 |
#line 9183 "./marpa.w" |
| 13322 |
|
| 13323 |
/*560:*/ |
| 13324 |
#line 6100 "./marpa.w" |
| 13325 |
|
| 13326 |
const GRAMMAR g= G_of_R(r); |
| 13327 |
/*:560*/ |
| 13328 |
#line 9184 "./marpa.w" |
| 13329 |
|
| 13330 |
YSID ysid_to_clean; |
| 13331 |
|
| 13332 |
|
| 13333 |
const YS current_ys= Latest_YS_of_R(r); |
| 13334 |
const YSID current_ys_id= Ord_of_YS(current_ys); |
| 13335 |
|
| 13336 |
int count_of_expected_terminals; |
| 13337 |
/*803:*/ |
| 13338 |
#line 9240 "./marpa.w" |
| 13339 |
|
| 13340 |
|
| 13341 |
|
| 13342 |
|
| 13343 |
struct marpa_obstack*const method_obstack= marpa_obs_init; |
| 13344 |
|
| 13345 |
YIMID*prediction_by_irl= |
| 13346 |
marpa_obs_new(method_obstack,YIMID,IRL_Count_of_G(g)); |
| 13347 |
|
| 13348 |
/*:803*/ |
| 13349 |
#line 9192 "./marpa.w" |
| 13350 |
|
| 13351 |
|
| 13352 |
|
| 13353 |
|
| 13354 |
|
| 13355 |
|
| 13356 |
const JEARLEME return_value= -2; |
| 13357 |
|
| 13358 |
/*1248:*/ |
| 13359 |
#line 14978 "./marpa.w" |
| 13360 |
|
| 13361 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)!=R_DURING_INPUT)){ |
| 13362 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_ACCEPTING_INPUT); |
| 13363 |
return failure_indicator; |
| 13364 |
} |
| 13365 |
|
| 13366 |
if(_MARPA_UNLIKELY(!R_is_Consistent(r))){ |
| 13367 |
MARPA_ERROR(MARPA_ERR_RECCE_IS_INCONSISTENT); |
| 13368 |
return failure_indicator; |
| 13369 |
} |
| 13370 |
|
| 13371 |
/*:1248*/ |
| 13372 |
#line 9200 "./marpa.w" |
| 13373 |
|
| 13374 |
|
| 13375 |
G_EVENTS_CLEAR(g); |
| 13376 |
|
| 13377 |
|
| 13378 |
|
| 13379 |
if(R_is_Consistent(r))return 0; |
| 13380 |
|
| 13381 |
|
| 13382 |
|
| 13383 |
|
| 13384 |
|
| 13385 |
earley_set_update_items(r,current_ys); |
| 13386 |
|
| 13387 |
for(ysid_to_clean= First_Inconsistent_YS_of_R(r); |
| 13388 |
ysid_to_clean<=current_ys_id; |
| 13389 |
ysid_to_clean++){ |
| 13390 |
/*805:*/ |
| 13391 |
#line 9254 "./marpa.w" |
| 13392 |
|
| 13393 |
{ |
| 13394 |
const YS ys_to_clean= YS_of_R_by_Ord(r,ysid_to_clean); |
| 13395 |
const YIM*yims_to_clean= YIMs_of_YS(ys_to_clean); |
| 13396 |
const int yim_to_clean_count= YIM_Count_of_YS(ys_to_clean); |
| 13397 |
Bit_Matrix acceptance_matrix= matrix_obs_create(method_obstack, |
| 13398 |
yim_to_clean_count, |
| 13399 |
yim_to_clean_count); |
| 13400 |
/*806:*/ |
| 13401 |
#line 9274 "./marpa.w" |
| 13402 |
|
| 13403 |
{ |
| 13404 |
int yim_ix= yim_to_clean_count-1; |
| 13405 |
YIM yim= yims_to_clean[yim_ix]; |
| 13406 |
|
| 13407 |
|
| 13408 |
|
| 13409 |
|
| 13410 |
|
| 13411 |
|
| 13412 |
while(YIM_was_Predicted(yim)){ |
| 13413 |
prediction_by_irl[IRLID_of_YIM(yim)]= yim_ix; |
| 13414 |
yim= yims_to_clean[--yim_ix]; |
| 13415 |
} |
| 13416 |
} |
| 13417 |
|
| 13418 |
/*:806*/ |
| 13419 |
#line 9262 "./marpa.w" |
| 13420 |
|
| 13421 |
/*807:*/ |
| 13422 |
#line 9290 "./marpa.w" |
| 13423 |
{ |
| 13424 |
int yim_to_clean_ix; |
| 13425 |
for(yim_to_clean_ix= 0; |
| 13426 |
yim_to_clean_ix<yim_to_clean_count; |
| 13427 |
yim_to_clean_ix++) |
| 13428 |
{ |
| 13429 |
const YIM yim_to_clean= yims_to_clean[yim_to_clean_ix]; |
| 13430 |
|
| 13431 |
|
| 13432 |
|
| 13433 |
|
| 13434 |
MARPA_ASSERT(!YIM_is_Initial(yim_to_clean)|| |
| 13435 |
(YIM_is_Active(yim_to_clean)&&!YIM_is_Rejected(yim_to_clean))); |
| 13436 |
|
| 13437 |
|
| 13438 |
|
| 13439 |
if(!YIM_is_Initial(yim_to_clean))YIM_is_Active(yim_to_clean)= 0; |
| 13440 |
|
| 13441 |
|
| 13442 |
|
| 13443 |
|
| 13444 |
|
| 13445 |
|
| 13446 |
if(YIM_is_Rejected(yim_to_clean))continue; |
| 13447 |
|
| 13448 |
|
| 13449 |
|
| 13450 |
/*808:*/ |
| 13451 |
#line 9327 "./marpa.w" |
| 13452 |
|
| 13453 |
{ |
| 13454 |
const NSYID postdot_nsyid= Postdot_NSYID_of_YIM(yim_to_clean); |
| 13455 |
if(postdot_nsyid>=0) |
| 13456 |
{ |
| 13457 |
int cil_ix; |
| 13458 |
const CIL lhs_cil= LHS_CIL_of_NSYID(postdot_nsyid); |
| 13459 |
const int cil_count= Count_of_CIL(lhs_cil); |
| 13460 |
for(cil_ix= 0;cil_ix<cil_count;cil_ix++) |
| 13461 |
{ |
| 13462 |
const IRLID irlid= Item_of_CIL(lhs_cil,cil_ix); |
| 13463 |
const int predicted_yim_ix= prediction_by_irl[irlid]; |
| 13464 |
const YIM predicted_yim= yims_to_clean[predicted_yim_ix]; |
| 13465 |
if(YIM_is_Rejected(predicted_yim))continue; |
| 13466 |
matrix_bit_set(acceptance_matrix,yim_to_clean_ix, |
| 13467 |
predicted_yim_ix); |
| 13468 |
} |
| 13469 |
} |
| 13470 |
} |
| 13471 |
|
| 13472 |
/*:808*/ |
| 13473 |
#line 9317 "./marpa.w" |
| 13474 |
|
| 13475 |
|
| 13476 |
|
| 13477 |
|
| 13478 |
|
| 13479 |
|
| 13480 |
|
| 13481 |
} |
| 13482 |
} |
| 13483 |
|
| 13484 |
/*:807*/ |
| 13485 |
#line 9263 "./marpa.w" |
| 13486 |
|
| 13487 |
transitive_closure(acceptance_matrix); |
| 13488 |
/*813:*/ |
| 13489 |
#line 9387 "./marpa.w" |
| 13490 |
{ |
| 13491 |
int cause_yim_ix; |
| 13492 |
for(cause_yim_ix= 0;cause_yim_ix<yim_to_clean_count;cause_yim_ix++){ |
| 13493 |
const YIM cause_yim= yims_to_clean[cause_yim_ix]; |
| 13494 |
|
| 13495 |
|
| 13496 |
|
| 13497 |
|
| 13498 |
|
| 13499 |
if(!YIM_is_Initial(cause_yim)&& |
| 13500 |
!YIM_was_Scanned(cause_yim))break; |
| 13501 |
|
| 13502 |
|
| 13503 |
|
| 13504 |
|
| 13505 |
|
| 13506 |
if(YIM_is_Rejected(cause_yim))continue; |
| 13507 |
|
| 13508 |
{ |
| 13509 |
const Bit_Vector bv_yims_to_accept |
| 13510 |
= matrix_row(acceptance_matrix,cause_yim_ix); |
| 13511 |
int min,max,start; |
| 13512 |
for(start= 0;bv_scan(bv_yims_to_accept,start,&min,&max); |
| 13513 |
start= max+2) |
| 13514 |
{ |
| 13515 |
int yim_to_accept_ix; |
| 13516 |
for(yim_to_accept_ix= min; |
| 13517 |
yim_to_accept_ix<=max;yim_to_accept_ix++) |
| 13518 |
{ |
| 13519 |
const YIM yim_to_accept= yims_to_clean[yim_to_accept_ix]; |
| 13520 |
YIM_is_Active(yim_to_accept)= 1; |
| 13521 |
} |
| 13522 |
} |
| 13523 |
} |
| 13524 |
} |
| 13525 |
} |
| 13526 |
|
| 13527 |
/*:813*/ |
| 13528 |
#line 9265 "./marpa.w" |
| 13529 |
|
| 13530 |
/*814:*/ |
| 13531 |
#line 9428 "./marpa.w" |
| 13532 |
{ |
| 13533 |
int yim_ix; |
| 13534 |
for(yim_ix= 0;yim_ix<yim_to_clean_count;yim_ix++){ |
| 13535 |
const YIM yim= yims_to_clean[yim_ix]; |
| 13536 |
if(!YIM_is_Active(yim))continue; |
| 13537 |
YIM_is_Rejected(yim)= 1; |
| 13538 |
} |
| 13539 |
} |
| 13540 |
|
| 13541 |
/*:814*/ |
| 13542 |
#line 9266 "./marpa.w" |
| 13543 |
|
| 13544 |
/*816:*/ |
| 13545 |
#line 9442 "./marpa.w" |
| 13546 |
{} |
| 13547 |
|
| 13548 |
/*:816*/ |
| 13549 |
#line 9267 "./marpa.w" |
| 13550 |
|
| 13551 |
/*817:*/ |
| 13552 |
#line 9446 "./marpa.w" |
| 13553 |
|
| 13554 |
{ |
| 13555 |
int postdot_sym_ix; |
| 13556 |
const int postdot_sym_count= Postdot_SYM_Count_of_YS(ys_to_clean); |
| 13557 |
const PIM*postdot_array= ys_to_clean->t_postdot_ary; |
| 13558 |
|
| 13559 |
|
| 13560 |
|
| 13561 |
for(postdot_sym_ix= 0;postdot_sym_ix<postdot_sym_count;postdot_sym_ix++){ |
| 13562 |
|
| 13563 |
|
| 13564 |
|
| 13565 |
const PIM first_pim= postdot_array[postdot_sym_ix]; |
| 13566 |
if(PIM_is_LIM(first_pim)){ |
| 13567 |
const LIM lim= LIM_of_PIM(first_pim); |
| 13568 |
|
| 13569 |
|
| 13570 |
|
| 13571 |
LIM_is_Rejected(lim)= 1; |
| 13572 |
LIM_is_Active(lim)= 0; |
| 13573 |
|
| 13574 |
|
| 13575 |
|
| 13576 |
if(!YIM_is_Active(Trailhead_YIM_of_LIM(lim)))continue; |
| 13577 |
{ |
| 13578 |
const LIM predecessor_lim= Predecessor_LIM_of_LIM(lim); |
| 13579 |
|
| 13580 |
|
| 13581 |
if(predecessor_lim&&!LIM_is_Active(predecessor_lim))continue; |
| 13582 |
} |
| 13583 |
|
| 13584 |
|
| 13585 |
|
| 13586 |
LIM_is_Rejected(lim)= 0; |
| 13587 |
LIM_is_Active(lim)= 1; |
| 13588 |
} |
| 13589 |
} |
| 13590 |
} |
| 13591 |
|
| 13592 |
/*:817*/ |
| 13593 |
#line 9268 "./marpa.w" |
| 13594 |
|
| 13595 |
} |
| 13596 |
|
| 13597 |
/*:805*/ |
| 13598 |
#line 9217 "./marpa.w" |
| 13599 |
|
| 13600 |
} |
| 13601 |
|
| 13602 |
|
| 13603 |
|
| 13604 |
|
| 13605 |
/*818:*/ |
| 13606 |
#line 9491 "./marpa.w" |
| 13607 |
{ |
| 13608 |
int old_alt_ix; |
| 13609 |
int no_of_alternatives= MARPA_DSTACK_LENGTH(r->t_alternatives); |
| 13610 |
|
| 13611 |
|
| 13612 |
|
| 13613 |
|
| 13614 |
|
| 13615 |
|
| 13616 |
for(old_alt_ix= 0; |
| 13617 |
old_alt_ix<no_of_alternatives; |
| 13618 |
old_alt_ix++) |
| 13619 |
{ |
| 13620 |
const ALT alternative= MARPA_DSTACK_INDEX( |
| 13621 |
r->t_alternatives,ALT_Object,old_alt_ix); |
| 13622 |
if(!alternative_is_acceptable(alternative))break; |
| 13623 |
} |
| 13624 |
|
| 13625 |
|
| 13626 |
|
| 13627 |
|
| 13628 |
|
| 13629 |
if(old_alt_ix<no_of_alternatives){ |
| 13630 |
|
| 13631 |
|
| 13632 |
|
| 13633 |
int empty_alt_ix= old_alt_ix; |
| 13634 |
for(old_alt_ix++;old_alt_ix<no_of_alternatives;old_alt_ix++) |
| 13635 |
{ |
| 13636 |
const ALT alternative= MARPA_DSTACK_INDEX( |
| 13637 |
r->t_alternatives,ALT_Object,old_alt_ix); |
| 13638 |
if(!alternative_is_acceptable(alternative))continue; |
| 13639 |
*MARPA_DSTACK_INDEX(r->t_alternatives,ALT_Object,empty_alt_ix) |
| 13640 |
= *alternative; |
| 13641 |
empty_alt_ix++; |
| 13642 |
} |
| 13643 |
|
| 13644 |
|
| 13645 |
|
| 13646 |
|
| 13647 |
MARPA_DSTACK_COUNT_SET(r->t_alternatives,empty_alt_ix); |
| 13648 |
|
| 13649 |
if(empty_alt_ix){ |
| 13650 |
Furthest_Earleme_of_R(r)= Earleme_of_YS(current_ys); |
| 13651 |
}else{ |
| 13652 |
const ALT furthest_alternative |
| 13653 |
= MARPA_DSTACK_INDEX(r->t_alternatives,ALT_Object,0); |
| 13654 |
Furthest_Earleme_of_R(r)= End_Earleme_of_ALT(furthest_alternative); |
| 13655 |
} |
| 13656 |
|
| 13657 |
} |
| 13658 |
|
| 13659 |
} |
| 13660 |
|
| 13661 |
/*:818*/ |
| 13662 |
#line 9223 "./marpa.w" |
| 13663 |
|
| 13664 |
|
| 13665 |
bv_clear(r->t_bv_nsyid_is_expected); |
| 13666 |
/*820:*/ |
| 13667 |
#line 9571 "./marpa.w" |
| 13668 |
{} |
| 13669 |
|
| 13670 |
/*:820*/ |
| 13671 |
#line 9226 "./marpa.w" |
| 13672 |
|
| 13673 |
count_of_expected_terminals= bv_count(r->t_bv_nsyid_is_expected); |
| 13674 |
if(count_of_expected_terminals<=0 |
| 13675 |
&&MARPA_DSTACK_LENGTH(r->t_alternatives)<=0) |
| 13676 |
{ |
| 13677 |
/*611:*/ |
| 13678 |
#line 6611 "./marpa.w" |
| 13679 |
|
| 13680 |
{ |
| 13681 |
R_is_Exhausted(r)= 1; |
| 13682 |
Input_Phase_of_R(r)= R_AFTER_INPUT; |
| 13683 |
event_new(g,MARPA_EVENT_EXHAUSTED); |
| 13684 |
} |
| 13685 |
|
| 13686 |
/*:611*/ |
| 13687 |
#line 9231 "./marpa.w" |
| 13688 |
|
| 13689 |
} |
| 13690 |
|
| 13691 |
First_Inconsistent_YS_of_R(r)= -1; |
| 13692 |
|
| 13693 |
/*804:*/ |
| 13694 |
#line 9249 "./marpa.w" |
| 13695 |
|
| 13696 |
{ |
| 13697 |
marpa_obs_free(method_obstack); |
| 13698 |
} |
| 13699 |
|
| 13700 |
/*:804*/ |
| 13701 |
#line 9236 "./marpa.w" |
| 13702 |
|
| 13703 |
return return_value; |
| 13704 |
} |
| 13705 |
|
| 13706 |
/*:802*//*819:*/ |
| 13707 |
#line 9545 "./marpa.w" |
| 13708 |
|
| 13709 |
PRIVATE int alternative_is_acceptable(ALT alternative) |
| 13710 |
{ |
| 13711 |
PIM pim; |
| 13712 |
const NSYID token_symbol_id= NSYID_of_ALT(alternative); |
| 13713 |
const YS start_ys= Start_YS_of_ALT(alternative); |
| 13714 |
for(pim= First_PIM_of_YS_by_NSYID(start_ys,token_symbol_id); |
| 13715 |
pim; |
| 13716 |
pim= Next_PIM_of_PIM(pim)) |
| 13717 |
{ |
| 13718 |
YIM predecessor_yim= YIM_of_PIM(pim); |
| 13719 |
|
| 13720 |
|
| 13721 |
|
| 13722 |
|
| 13723 |
|
| 13724 |
|
| 13725 |
if(!predecessor_yim)continue; |
| 13726 |
|
| 13727 |
|
| 13728 |
|
| 13729 |
if(YIM_is_Active(predecessor_yim))return 1; |
| 13730 |
} |
| 13731 |
return 0; |
| 13732 |
} |
| 13733 |
|
| 13734 |
/*:819*//*821:*/ |
| 13735 |
#line 9574 "./marpa.w" |
| 13736 |
|
| 13737 |
int |
| 13738 |
marpa_r_zwa_default_set(Marpa_Recognizer r, |
| 13739 |
Marpa_Assertion_ID zwaid, |
| 13740 |
int default_value) |
| 13741 |
{ |
| 13742 |
/*1230:*/ |
| 13743 |
#line 14864 "./marpa.w" |
| 13744 |
const int failure_indicator= -2; |
| 13745 |
|
| 13746 |
/*:1230*/ |
| 13747 |
#line 9580 "./marpa.w" |
| 13748 |
|
| 13749 |
/*560:*/ |
| 13750 |
#line 6100 "./marpa.w" |
| 13751 |
|
| 13752 |
const GRAMMAR g= G_of_R(r); |
| 13753 |
/*:560*/ |
| 13754 |
#line 9581 "./marpa.w" |
| 13755 |
|
| 13756 |
ZWA zwa; |
| 13757 |
int old_default_value; |
| 13758 |
/*1250:*/ |
| 13759 |
#line 14997 "./marpa.w" |
| 13760 |
|
| 13761 |
if(HEADER_VERSION_MISMATCH){ |
| 13762 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 13763 |
return failure_indicator; |
| 13764 |
} |
| 13765 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 13766 |
MARPA_ERROR(g->t_error); |
| 13767 |
return failure_indicator; |
| 13768 |
} |
| 13769 |
|
| 13770 |
/*:1250*/ |
| 13771 |
#line 9584 "./marpa.w" |
| 13772 |
|
| 13773 |
/*1244:*/ |
| 13774 |
#line 14948 "./marpa.w" |
| 13775 |
|
| 13776 |
if(_MARPA_UNLIKELY(ZWAID_is_Malformed(zwaid))){ |
| 13777 |
MARPA_ERROR(MARPA_ERR_INVALID_ASSERTION_ID); |
| 13778 |
return failure_indicator; |
| 13779 |
} |
| 13780 |
|
| 13781 |
/*:1244*/ |
| 13782 |
#line 9585 "./marpa.w" |
| 13783 |
|
| 13784 |
/*1243:*/ |
| 13785 |
#line 14942 "./marpa.w" |
| 13786 |
|
| 13787 |
if(_MARPA_UNLIKELY(!ZWAID_of_G_Exists(zwaid))){ |
| 13788 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_ASSERTION_ID); |
| 13789 |
return failure_indicator; |
| 13790 |
} |
| 13791 |
/*:1243*/ |
| 13792 |
#line 9586 "./marpa.w" |
| 13793 |
|
| 13794 |
if(_MARPA_UNLIKELY(default_value<0||default_value> 1)) |
| 13795 |
{ |
| 13796 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 13797 |
return failure_indicator; |
| 13798 |
} |
| 13799 |
zwa= RZWA_by_ID(zwaid); |
| 13800 |
old_default_value= Default_Value_of_ZWA(zwa); |
| 13801 |
Default_Value_of_ZWA(zwa)= default_value?1:0; |
| 13802 |
return old_default_value; |
| 13803 |
} |
| 13804 |
|
| 13805 |
/*:821*//*822:*/ |
| 13806 |
#line 9598 "./marpa.w" |
| 13807 |
|
| 13808 |
int |
| 13809 |
marpa_r_zwa_default(Marpa_Recognizer r, |
| 13810 |
Marpa_Assertion_ID zwaid) |
| 13811 |
{ |
| 13812 |
/*1230:*/ |
| 13813 |
#line 14864 "./marpa.w" |
| 13814 |
const int failure_indicator= -2; |
| 13815 |
|
| 13816 |
/*:1230*/ |
| 13817 |
#line 9603 "./marpa.w" |
| 13818 |
|
| 13819 |
/*560:*/ |
| 13820 |
#line 6100 "./marpa.w" |
| 13821 |
|
| 13822 |
const GRAMMAR g= G_of_R(r); |
| 13823 |
/*:560*/ |
| 13824 |
#line 9604 "./marpa.w" |
| 13825 |
|
| 13826 |
ZWA zwa; |
| 13827 |
/*1250:*/ |
| 13828 |
#line 14997 "./marpa.w" |
| 13829 |
|
| 13830 |
if(HEADER_VERSION_MISMATCH){ |
| 13831 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 13832 |
return failure_indicator; |
| 13833 |
} |
| 13834 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 13835 |
MARPA_ERROR(g->t_error); |
| 13836 |
return failure_indicator; |
| 13837 |
} |
| 13838 |
|
| 13839 |
/*:1250*/ |
| 13840 |
#line 9606 "./marpa.w" |
| 13841 |
|
| 13842 |
/*1244:*/ |
| 13843 |
#line 14948 "./marpa.w" |
| 13844 |
|
| 13845 |
if(_MARPA_UNLIKELY(ZWAID_is_Malformed(zwaid))){ |
| 13846 |
MARPA_ERROR(MARPA_ERR_INVALID_ASSERTION_ID); |
| 13847 |
return failure_indicator; |
| 13848 |
} |
| 13849 |
|
| 13850 |
/*:1244*/ |
| 13851 |
#line 9607 "./marpa.w" |
| 13852 |
|
| 13853 |
/*1243:*/ |
| 13854 |
#line 14942 "./marpa.w" |
| 13855 |
|
| 13856 |
if(_MARPA_UNLIKELY(!ZWAID_of_G_Exists(zwaid))){ |
| 13857 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_ASSERTION_ID); |
| 13858 |
return failure_indicator; |
| 13859 |
} |
| 13860 |
/*:1243*/ |
| 13861 |
#line 9608 "./marpa.w" |
| 13862 |
|
| 13863 |
zwa= RZWA_by_ID(zwaid); |
| 13864 |
return Default_Value_of_ZWA(zwa); |
| 13865 |
} |
| 13866 |
|
| 13867 |
/*:822*//*831:*/ |
| 13868 |
#line 9648 "./marpa.w" |
| 13869 |
|
| 13870 |
PRIVATE_NOT_INLINE int report_item_cmp( |
| 13871 |
const void*ap, |
| 13872 |
const void*bp, |
| 13873 |
void*param UNUSED) |
| 13874 |
{ |
| 13875 |
const struct marpa_progress_item*const report_a= ap; |
| 13876 |
const struct marpa_progress_item*const report_b= bp; |
| 13877 |
if(Position_of_PROGRESS(report_a)> Position_of_PROGRESS(report_b))return 1; |
| 13878 |
if(Position_of_PROGRESS(report_a)<Position_of_PROGRESS(report_b))return-1; |
| 13879 |
if(RULEID_of_PROGRESS(report_a)> RULEID_of_PROGRESS(report_b))return 1; |
| 13880 |
if(RULEID_of_PROGRESS(report_a)<RULEID_of_PROGRESS(report_b))return-1; |
| 13881 |
if(Origin_of_PROGRESS(report_a)> Origin_of_PROGRESS(report_b))return 1; |
| 13882 |
if(Origin_of_PROGRESS(report_a)<Origin_of_PROGRESS(report_b))return-1; |
| 13883 |
return 0; |
| 13884 |
} |
| 13885 |
|
| 13886 |
/*:831*//*832:*/ |
| 13887 |
#line 9665 "./marpa.w" |
| 13888 |
|
| 13889 |
int marpa_r_progress_report_start( |
| 13890 |
Marpa_Recognizer r, |
| 13891 |
Marpa_Earley_Set_ID set_id) |
| 13892 |
{ |
| 13893 |
/*1230:*/ |
| 13894 |
#line 14864 "./marpa.w" |
| 13895 |
const int failure_indicator= -2; |
| 13896 |
|
| 13897 |
/*:1230*/ |
| 13898 |
#line 9670 "./marpa.w" |
| 13899 |
|
| 13900 |
YS earley_set; |
| 13901 |
/*560:*/ |
| 13902 |
#line 6100 "./marpa.w" |
| 13903 |
|
| 13904 |
const GRAMMAR g= G_of_R(r); |
| 13905 |
/*:560*/ |
| 13906 |
#line 9672 "./marpa.w" |
| 13907 |
|
| 13908 |
/*1250:*/ |
| 13909 |
#line 14997 "./marpa.w" |
| 13910 |
|
| 13911 |
if(HEADER_VERSION_MISMATCH){ |
| 13912 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 13913 |
return failure_indicator; |
| 13914 |
} |
| 13915 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 13916 |
MARPA_ERROR(g->t_error); |
| 13917 |
return failure_indicator; |
| 13918 |
} |
| 13919 |
|
| 13920 |
/*:1250*/ |
| 13921 |
#line 9673 "./marpa.w" |
| 13922 |
|
| 13923 |
/*1247:*/ |
| 13924 |
#line 14973 "./marpa.w" |
| 13925 |
|
| 13926 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 13927 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 13928 |
return failure_indicator; |
| 13929 |
} |
| 13930 |
/*:1247*/ |
| 13931 |
#line 9674 "./marpa.w" |
| 13932 |
|
| 13933 |
if(set_id<0) |
| 13934 |
{ |
| 13935 |
MARPA_ERROR(MARPA_ERR_INVALID_LOCATION); |
| 13936 |
return failure_indicator; |
| 13937 |
} |
| 13938 |
r_update_earley_sets(r); |
| 13939 |
if(!YS_Ord_is_Valid(r,set_id)) |
| 13940 |
{ |
| 13941 |
MARPA_ERROR(MARPA_ERR_NO_EARLEY_SET_AT_LOCATION); |
| 13942 |
return failure_indicator; |
| 13943 |
} |
| 13944 |
earley_set= YS_of_R_by_Ord(r,set_id); |
| 13945 |
|
| 13946 |
MARPA_OFF_DEBUG3("At %s, starting progress report Earley set %ld", |
| 13947 |
STRLOC,(long)set_id) |
| 13948 |
|
| 13949 |
/*826:*/ |
| 13950 |
#line 9622 "./marpa.w" |
| 13951 |
|
| 13952 |
r->t_current_report_item= &progress_report_not_ready; |
| 13953 |
if(r->t_progress_report_traverser){ |
| 13954 |
_marpa_avl_destroy(MARPA_TREE_OF_AVL_TRAV(r->t_progress_report_traverser)); |
| 13955 |
} |
| 13956 |
r->t_progress_report_traverser= NULL; |
| 13957 |
/*:826*/ |
| 13958 |
#line 9691 "./marpa.w" |
| 13959 |
|
| 13960 |
{ |
| 13961 |
const MARPA_AVL_TREE report_tree= |
| 13962 |
_marpa_avl_create(report_item_cmp,NULL); |
| 13963 |
const YIM*const earley_items= YIMs_of_YS(earley_set); |
| 13964 |
const int earley_item_count= YIM_Count_of_YS(earley_set); |
| 13965 |
int earley_item_id; |
| 13966 |
for(earley_item_id= 0;earley_item_id<earley_item_count; |
| 13967 |
earley_item_id++) |
| 13968 |
{ |
| 13969 |
const YIM earley_item= earley_items[earley_item_id]; |
| 13970 |
if(!YIM_is_Active(earley_item))continue; |
| 13971 |
/*834:*/ |
| 13972 |
#line 9724 "./marpa.w" |
| 13973 |
|
| 13974 |
{ |
| 13975 |
SRCL leo_source_link= NULL; |
| 13976 |
|
| 13977 |
MARPA_OFF_DEBUG2("At %s, Do the progress report",STRLOC) |
| 13978 |
|
| 13979 |
progress_report_items_insert(report_tree,AHM_of_YIM(earley_item), |
| 13980 |
earley_item); |
| 13981 |
for(leo_source_link= First_Leo_SRCL_of_YIM(earley_item); |
| 13982 |
leo_source_link;leo_source_link= Next_SRCL_of_SRCL(leo_source_link)) |
| 13983 |
{ |
| 13984 |
LIM leo_item; |
| 13985 |
MARPA_OFF_DEBUG3("At %s, Leo source link %p",STRLOC,leo_source_link) |
| 13986 |
|
| 13987 |
if(!SRCL_is_Active(leo_source_link))continue; |
| 13988 |
|
| 13989 |
MARPA_OFF_DEBUG3("At %s, active Leo source link %p",STRLOC,leo_source_link) |
| 13990 |
|
| 13991 |
|
| 13992 |
|
| 13993 |
|
| 13994 |
for(leo_item= LIM_of_SRCL(leo_source_link); |
| 13995 |
leo_item;leo_item= Predecessor_LIM_of_LIM(leo_item)) |
| 13996 |
{ |
| 13997 |
const YIM trailhead_yim= Trailhead_YIM_of_LIM(leo_item); |
| 13998 |
const AHM trailhead_ahm= Trailhead_AHM_of_LIM(leo_item); |
| 13999 |
progress_report_items_insert(report_tree,trailhead_ahm, |
| 14000 |
trailhead_yim); |
| 14001 |
} |
| 14002 |
|
| 14003 |
MARPA_OFF_DEBUG3("At %s, finished Leo source link %p",STRLOC,leo_source_link) |
| 14004 |
} |
| 14005 |
} |
| 14006 |
|
| 14007 |
/*:834*/ |
| 14008 |
#line 9703 "./marpa.w" |
| 14009 |
|
| 14010 |
} |
| 14011 |
r->t_progress_report_traverser= _marpa_avl_t_init(report_tree); |
| 14012 |
return(int)marpa_avl_count(report_tree); |
| 14013 |
} |
| 14014 |
} |
| 14015 |
/*:832*//*833:*/ |
| 14016 |
#line 9710 "./marpa.w" |
| 14017 |
|
| 14018 |
int marpa_r_progress_report_reset(Marpa_Recognizer r) |
| 14019 |
{ |
| 14020 |
/*1230:*/ |
| 14021 |
#line 14864 "./marpa.w" |
| 14022 |
const int failure_indicator= -2; |
| 14023 |
|
| 14024 |
/*:1230*/ |
| 14025 |
#line 9713 "./marpa.w" |
| 14026 |
|
| 14027 |
MARPA_AVL_TRAV traverser= r->t_progress_report_traverser; |
| 14028 |
/*560:*/ |
| 14029 |
#line 6100 "./marpa.w" |
| 14030 |
|
| 14031 |
const GRAMMAR g= G_of_R(r); |
| 14032 |
/*:560*/ |
| 14033 |
#line 9715 "./marpa.w" |
| 14034 |
|
| 14035 |
/*1250:*/ |
| 14036 |
#line 14997 "./marpa.w" |
| 14037 |
|
| 14038 |
if(HEADER_VERSION_MISMATCH){ |
| 14039 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 14040 |
return failure_indicator; |
| 14041 |
} |
| 14042 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 14043 |
MARPA_ERROR(g->t_error); |
| 14044 |
return failure_indicator; |
| 14045 |
} |
| 14046 |
|
| 14047 |
/*:1250*/ |
| 14048 |
#line 9716 "./marpa.w" |
| 14049 |
|
| 14050 |
/*1247:*/ |
| 14051 |
#line 14973 "./marpa.w" |
| 14052 |
|
| 14053 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 14054 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 14055 |
return failure_indicator; |
| 14056 |
} |
| 14057 |
/*:1247*/ |
| 14058 |
#line 9717 "./marpa.w" |
| 14059 |
|
| 14060 |
/*838:*/ |
| 14061 |
#line 9866 "./marpa.w" |
| 14062 |
|
| 14063 |
{ |
| 14064 |
if(!traverser) |
| 14065 |
{ |
| 14066 |
MARPA_ERROR(MARPA_ERR_PROGRESS_REPORT_NOT_STARTED); |
| 14067 |
return failure_indicator; |
| 14068 |
} |
| 14069 |
} |
| 14070 |
|
| 14071 |
/*:838*/ |
| 14072 |
#line 9718 "./marpa.w" |
| 14073 |
|
| 14074 |
_marpa_avl_t_reset(traverser); |
| 14075 |
return 1; |
| 14076 |
} |
| 14077 |
|
| 14078 |
/*:833*//*835:*/ |
| 14079 |
#line 9758 "./marpa.w" |
| 14080 |
|
| 14081 |
PRIVATE void |
| 14082 |
progress_report_items_insert(MARPA_AVL_TREE report_tree, |
| 14083 |
AHM report_ahm, |
| 14084 |
YIM origin_yim) |
| 14085 |
{ |
| 14086 |
const XRL source_xrl= XRL_of_AHM(report_ahm); |
| 14087 |
|
| 14088 |
MARPA_OFF_DEBUG5( |
| 14089 |
"%s Calling progress_report_items_insert(%p, %p, %p)", |
| 14090 |
STRLOC,report_tree,report_ahm,origin_yim) |
| 14091 |
|
| 14092 |
if(!source_xrl)return; |
| 14093 |
|
| 14094 |
|
| 14095 |
|
| 14096 |
|
| 14097 |
|
| 14098 |
if(!IRL_has_Virtual_LHS(IRL_of_YIM(origin_yim))){ |
| 14099 |
int xrl_position= XRL_Position_of_AHM(report_ahm); |
| 14100 |
int origin_of_xrl= Origin_Ord_of_YIM(origin_yim); |
| 14101 |
XRLID xrl_id= ID_of_XRL(source_xrl); |
| 14102 |
|
| 14103 |
PROGRESS new_report_item= |
| 14104 |
marpa_obs_new(MARPA_AVL_OBSTACK(report_tree), |
| 14105 |
struct marpa_progress_item,1); |
| 14106 |
|
| 14107 |
Position_of_PROGRESS(new_report_item)= xrl_position; |
| 14108 |
Origin_of_PROGRESS(new_report_item)= origin_of_xrl; |
| 14109 |
RULEID_of_PROGRESS(new_report_item)= xrl_id; |
| 14110 |
_marpa_avl_insert(report_tree,new_report_item); |
| 14111 |
|
| 14112 |
return; |
| 14113 |
} |
| 14114 |
|
| 14115 |
|
| 14116 |
|
| 14117 |
|
| 14118 |
|
| 14119 |
|
| 14120 |
|
| 14121 |
if(XRL_is_Sequence(source_xrl))return; |
| 14122 |
|
| 14123 |
|
| 14124 |
|
| 14125 |
|
| 14126 |
|
| 14127 |
|
| 14128 |
|
| 14129 |
|
| 14130 |
{ |
| 14131 |
const NSYID lhs_nsyid= LHS_NSYID_of_YIM(origin_yim); |
| 14132 |
const YS origin_of_origin_ys= Origin_of_YIM(origin_yim); |
| 14133 |
PIM pim= First_PIM_of_YS_by_NSYID(origin_of_origin_ys,lhs_nsyid); |
| 14134 |
for(;pim;pim= Next_PIM_of_PIM(pim)) |
| 14135 |
{ |
| 14136 |
const YIM predecessor= YIM_of_PIM(pim); |
| 14137 |
|
| 14138 |
|
| 14139 |
|
| 14140 |
|
| 14141 |
if(!predecessor)return; |
| 14142 |
if(YIM_is_Active(predecessor)){ |
| 14143 |
progress_report_items_insert(report_tree, |
| 14144 |
report_ahm,predecessor); |
| 14145 |
} |
| 14146 |
} |
| 14147 |
} |
| 14148 |
} |
| 14149 |
|
| 14150 |
/*:835*//*836:*/ |
| 14151 |
#line 9828 "./marpa.w" |
| 14152 |
|
| 14153 |
int marpa_r_progress_report_finish(Marpa_Recognizer r){ |
| 14154 |
const int success= 1; |
| 14155 |
/*1230:*/ |
| 14156 |
#line 14864 "./marpa.w" |
| 14157 |
const int failure_indicator= -2; |
| 14158 |
|
| 14159 |
/*:1230*/ |
| 14160 |
#line 9831 "./marpa.w" |
| 14161 |
|
| 14162 |
/*560:*/ |
| 14163 |
#line 6100 "./marpa.w" |
| 14164 |
|
| 14165 |
const GRAMMAR g= G_of_R(r); |
| 14166 |
/*:560*/ |
| 14167 |
#line 9832 "./marpa.w" |
| 14168 |
|
| 14169 |
const MARPA_AVL_TRAV traverser= r->t_progress_report_traverser; |
| 14170 |
/*1247:*/ |
| 14171 |
#line 14973 "./marpa.w" |
| 14172 |
|
| 14173 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 14174 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 14175 |
return failure_indicator; |
| 14176 |
} |
| 14177 |
/*:1247*/ |
| 14178 |
#line 9834 "./marpa.w" |
| 14179 |
|
| 14180 |
/*838:*/ |
| 14181 |
#line 9866 "./marpa.w" |
| 14182 |
|
| 14183 |
{ |
| 14184 |
if(!traverser) |
| 14185 |
{ |
| 14186 |
MARPA_ERROR(MARPA_ERR_PROGRESS_REPORT_NOT_STARTED); |
| 14187 |
return failure_indicator; |
| 14188 |
} |
| 14189 |
} |
| 14190 |
|
| 14191 |
/*:838*/ |
| 14192 |
#line 9835 "./marpa.w" |
| 14193 |
|
| 14194 |
/*826:*/ |
| 14195 |
#line 9622 "./marpa.w" |
| 14196 |
|
| 14197 |
r->t_current_report_item= &progress_report_not_ready; |
| 14198 |
if(r->t_progress_report_traverser){ |
| 14199 |
_marpa_avl_destroy(MARPA_TREE_OF_AVL_TRAV(r->t_progress_report_traverser)); |
| 14200 |
} |
| 14201 |
r->t_progress_report_traverser= NULL; |
| 14202 |
/*:826*/ |
| 14203 |
#line 9836 "./marpa.w" |
| 14204 |
|
| 14205 |
return success; |
| 14206 |
} |
| 14207 |
|
| 14208 |
/*:836*//*837:*/ |
| 14209 |
#line 9840 "./marpa.w" |
| 14210 |
|
| 14211 |
Marpa_Rule_ID marpa_r_progress_item( |
| 14212 |
Marpa_Recognizer r,int*position,Marpa_Earley_Set_ID*origin |
| 14213 |
){ |
| 14214 |
/*1230:*/ |
| 14215 |
#line 14864 "./marpa.w" |
| 14216 |
const int failure_indicator= -2; |
| 14217 |
|
| 14218 |
/*:1230*/ |
| 14219 |
#line 9844 "./marpa.w" |
| 14220 |
|
| 14221 |
PROGRESS report_item; |
| 14222 |
MARPA_AVL_TRAV traverser; |
| 14223 |
/*560:*/ |
| 14224 |
#line 6100 "./marpa.w" |
| 14225 |
|
| 14226 |
const GRAMMAR g= G_of_R(r); |
| 14227 |
/*:560*/ |
| 14228 |
#line 9847 "./marpa.w" |
| 14229 |
|
| 14230 |
/*1250:*/ |
| 14231 |
#line 14997 "./marpa.w" |
| 14232 |
|
| 14233 |
if(HEADER_VERSION_MISMATCH){ |
| 14234 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 14235 |
return failure_indicator; |
| 14236 |
} |
| 14237 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 14238 |
MARPA_ERROR(g->t_error); |
| 14239 |
return failure_indicator; |
| 14240 |
} |
| 14241 |
|
| 14242 |
/*:1250*/ |
| 14243 |
#line 9848 "./marpa.w" |
| 14244 |
|
| 14245 |
/*1247:*/ |
| 14246 |
#line 14973 "./marpa.w" |
| 14247 |
|
| 14248 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 14249 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 14250 |
return failure_indicator; |
| 14251 |
} |
| 14252 |
/*:1247*/ |
| 14253 |
#line 9849 "./marpa.w" |
| 14254 |
|
| 14255 |
traverser= r->t_progress_report_traverser; |
| 14256 |
if(_MARPA_UNLIKELY(!position||!origin)){ |
| 14257 |
MARPA_ERROR(MARPA_ERR_POINTER_ARG_NULL); |
| 14258 |
return failure_indicator; |
| 14259 |
} |
| 14260 |
/*838:*/ |
| 14261 |
#line 9866 "./marpa.w" |
| 14262 |
|
| 14263 |
{ |
| 14264 |
if(!traverser) |
| 14265 |
{ |
| 14266 |
MARPA_ERROR(MARPA_ERR_PROGRESS_REPORT_NOT_STARTED); |
| 14267 |
return failure_indicator; |
| 14268 |
} |
| 14269 |
} |
| 14270 |
|
| 14271 |
/*:838*/ |
| 14272 |
#line 9855 "./marpa.w" |
| 14273 |
|
| 14274 |
report_item= _marpa_avl_t_next(traverser); |
| 14275 |
if(!report_item){ |
| 14276 |
MARPA_ERROR(MARPA_ERR_PROGRESS_REPORT_EXHAUSTED); |
| 14277 |
return-1; |
| 14278 |
} |
| 14279 |
*position= Position_of_PROGRESS(report_item); |
| 14280 |
*origin= Origin_of_PROGRESS(report_item); |
| 14281 |
return RULEID_of_PROGRESS(report_item); |
| 14282 |
} |
| 14283 |
|
| 14284 |
/*:837*//*861:*/ |
| 14285 |
#line 10062 "./marpa.w" |
| 14286 |
|
| 14287 |
PRIVATE void ur_node_stack_init(URS stack) |
| 14288 |
{ |
| 14289 |
stack->t_obs= marpa_obs_init; |
| 14290 |
stack->t_base= ur_node_new(stack,0); |
| 14291 |
ur_node_stack_reset(stack); |
| 14292 |
} |
| 14293 |
|
| 14294 |
/*:861*//*862:*/ |
| 14295 |
#line 10070 "./marpa.w" |
| 14296 |
|
| 14297 |
PRIVATE void ur_node_stack_reset(URS stack) |
| 14298 |
{ |
| 14299 |
stack->t_top= stack->t_base; |
| 14300 |
} |
| 14301 |
|
| 14302 |
/*:862*//*863:*/ |
| 14303 |
#line 10076 "./marpa.w" |
| 14304 |
|
| 14305 |
PRIVATE void ur_node_stack_destroy(URS stack) |
| 14306 |
{ |
| 14307 |
if(stack->t_base)marpa_obs_free(stack->t_obs); |
| 14308 |
stack->t_base= NULL; |
| 14309 |
} |
| 14310 |
|
| 14311 |
/*:863*//*864:*/ |
| 14312 |
#line 10083 "./marpa.w" |
| 14313 |
|
| 14314 |
PRIVATE UR ur_node_new(URS stack,UR prev) |
| 14315 |
{ |
| 14316 |
UR new_ur_node; |
| 14317 |
new_ur_node= marpa_obs_new(stack->t_obs,UR_Object,1); |
| 14318 |
Next_UR_of_UR(new_ur_node)= 0; |
| 14319 |
Prev_UR_of_UR(new_ur_node)= prev; |
| 14320 |
return new_ur_node; |
| 14321 |
} |
| 14322 |
|
| 14323 |
/*:864*//*865:*/ |
| 14324 |
#line 10093 "./marpa.w" |
| 14325 |
|
| 14326 |
PRIVATE void |
| 14327 |
ur_node_push(URS stack,YIM earley_item) |
| 14328 |
{ |
| 14329 |
UR old_top= stack->t_top; |
| 14330 |
UR new_top= Next_UR_of_UR(old_top); |
| 14331 |
YIM_of_UR(old_top)= earley_item; |
| 14332 |
if(!new_top) |
| 14333 |
{ |
| 14334 |
new_top= ur_node_new(stack,old_top); |
| 14335 |
Next_UR_of_UR(old_top)= new_top; |
| 14336 |
} |
| 14337 |
stack->t_top= new_top; |
| 14338 |
} |
| 14339 |
|
| 14340 |
/*:865*//*866:*/ |
| 14341 |
#line 10108 "./marpa.w" |
| 14342 |
|
| 14343 |
PRIVATE UR |
| 14344 |
ur_node_pop(URS stack) |
| 14345 |
{ |
| 14346 |
UR new_top= Prev_UR_of_UR(stack->t_top); |
| 14347 |
if(!new_top)return NULL; |
| 14348 |
stack->t_top= new_top; |
| 14349 |
return new_top; |
| 14350 |
} |
| 14351 |
|
| 14352 |
/*:866*//*868:*/ |
| 14353 |
#line 10145 "./marpa.w" |
| 14354 |
|
| 14355 |
PRIVATE void push_ur_if_new( |
| 14356 |
struct s_bocage_setup_per_ys*per_ys_data, |
| 14357 |
URS ur_node_stack,YIM yim) |
| 14358 |
{ |
| 14359 |
if(!psi_test_and_set(per_ys_data,yim)) |
| 14360 |
{ |
| 14361 |
ur_node_push(ur_node_stack,yim); |
| 14362 |
} |
| 14363 |
} |
| 14364 |
|
| 14365 |
/*:868*//*869:*/ |
| 14366 |
#line 10161 "./marpa.w" |
| 14367 |
|
| 14368 |
PRIVATE int psi_test_and_set( |
| 14369 |
struct s_bocage_setup_per_ys*per_ys_data, |
| 14370 |
YIM earley_item |
| 14371 |
) |
| 14372 |
{ |
| 14373 |
const YSID set_ordinal= YS_Ord_of_YIM(earley_item); |
| 14374 |
const int item_ordinal= Ord_of_YIM(earley_item); |
| 14375 |
const OR previous_or_node= |
| 14376 |
OR_by_PSI(per_ys_data,set_ordinal,item_ordinal); |
| 14377 |
if(!previous_or_node) |
| 14378 |
{ |
| 14379 |
OR_by_PSI(per_ys_data,set_ordinal,item_ordinal)= dummy_or_node; |
| 14380 |
return 0; |
| 14381 |
} |
| 14382 |
return 1; |
| 14383 |
} |
| 14384 |
|
| 14385 |
/*:869*//*871:*/ |
| 14386 |
#line 10203 "./marpa.w" |
| 14387 |
|
| 14388 |
PRIVATE void |
| 14389 |
Set_boolean_in_PSI_for_initial_nulls(struct s_bocage_setup_per_ys*per_ys_data, |
| 14390 |
YIM yim) |
| 14391 |
{ |
| 14392 |
const AHM ahm= AHM_of_YIM(yim); |
| 14393 |
if(Null_Count_of_AHM(ahm)) |
| 14394 |
psi_test_and_set(per_ys_data,(yim)); |
| 14395 |
} |
| 14396 |
|
| 14397 |
/*:871*//*896:*/ |
| 14398 |
#line 10503 "./marpa.w" |
| 14399 |
|
| 14400 |
PRIVATE OR or_node_new(BOCAGE b) |
| 14401 |
{ |
| 14402 |
const int or_node_id= OR_Count_of_B(b)++; |
| 14403 |
const OR new_or_node= (OR)marpa_obs_new(OBS_of_B(b),OR_Object,1); |
| 14404 |
ID_of_OR(new_or_node)= or_node_id; |
| 14405 |
DANDs_of_OR(new_or_node)= NULL; |
| 14406 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Capacity_of_B(b))) |
| 14407 |
{ |
| 14408 |
OR_Capacity_of_B(b)*= 2; |
| 14409 |
ORs_of_B(b)= |
| 14410 |
marpa_renew(OR,ORs_of_B(b),OR_Capacity_of_B(b)); |
| 14411 |
} |
| 14412 |
OR_of_B_by_ID(b,or_node_id)= new_or_node; |
| 14413 |
return new_or_node; |
| 14414 |
} |
| 14415 |
|
| 14416 |
/*:896*//*906:*/ |
| 14417 |
#line 10703 "./marpa.w" |
| 14418 |
|
| 14419 |
PRIVATE |
| 14420 |
DAND draft_and_node_new(struct marpa_obstack*obs,OR predecessor,OR cause) |
| 14421 |
{ |
| 14422 |
DAND draft_and_node= marpa_obs_new(obs,DAND_Object,1); |
| 14423 |
Predecessor_OR_of_DAND(draft_and_node)= predecessor; |
| 14424 |
Cause_OR_of_DAND(draft_and_node)= cause; |
| 14425 |
MARPA_ASSERT(cause!=NULL); |
| 14426 |
return draft_and_node; |
| 14427 |
} |
| 14428 |
|
| 14429 |
/*:906*//*907:*/ |
| 14430 |
#line 10714 "./marpa.w" |
| 14431 |
|
| 14432 |
PRIVATE |
| 14433 |
void draft_and_node_add(struct marpa_obstack*obs,OR parent,OR predecessor,OR cause) |
| 14434 |
{ |
| 14435 |
MARPA_OFF_ASSERT(Position_of_OR(parent)<=1||predecessor) |
| 14436 |
const DAND new= draft_and_node_new(obs,predecessor,cause); |
| 14437 |
Next_DAND_of_DAND(new)= DANDs_of_OR(parent); |
| 14438 |
DANDs_of_OR(parent)= new; |
| 14439 |
} |
| 14440 |
|
| 14441 |
/*:907*//*915:*/ |
| 14442 |
#line 10854 "./marpa.w" |
| 14443 |
|
| 14444 |
PRIVATE |
| 14445 |
OR or_by_origin_and_symi(struct s_bocage_setup_per_ys*per_ys_data, |
| 14446 |
YSID origin, |
| 14447 |
SYMI symbol_instance) |
| 14448 |
{ |
| 14449 |
const PSL or_psl_at_origin= per_ys_data[(origin)].t_or_psl; |
| 14450 |
return PSL_Datum(or_psl_at_origin,(symbol_instance)); |
| 14451 |
} |
| 14452 |
|
| 14453 |
/*:915*//*920:*/ |
| 14454 |
#line 10913 "./marpa.w" |
| 14455 |
|
| 14456 |
PRIVATE |
| 14457 |
int dands_are_equal(OR predecessor_a,OR cause_a, |
| 14458 |
OR predecessor_b,OR cause_b) |
| 14459 |
{ |
| 14460 |
const int a_is_token= OR_is_Token(cause_a); |
| 14461 |
const int b_is_token= OR_is_Token(cause_b); |
| 14462 |
if(a_is_token!=b_is_token)return 0; |
| 14463 |
{ |
| 14464 |
|
| 14465 |
|
| 14466 |
const int middle_of_a= predecessor_a?YS_Ord_of_OR(predecessor_a):-1; |
| 14467 |
const int middle_of_b= predecessor_b?YS_Ord_of_OR(predecessor_b):-1; |
| 14468 |
if(middle_of_a!=middle_of_b) |
| 14469 |
return 0; |
| 14470 |
} |
| 14471 |
if(a_is_token) |
| 14472 |
{ |
| 14473 |
const NSYID nsyid_of_a= NSYID_of_OR(cause_a); |
| 14474 |
const NSYID nsyid_of_b= NSYID_of_OR(cause_b); |
| 14475 |
return nsyid_of_a==nsyid_of_b; |
| 14476 |
} |
| 14477 |
{ |
| 14478 |
|
| 14479 |
const IRLID irlid_of_a= IRLID_of_OR(cause_a); |
| 14480 |
const IRLID irlid_of_b= IRLID_of_OR(cause_b); |
| 14481 |
return irlid_of_a==irlid_of_b; |
| 14482 |
} |
| 14483 |
|
| 14484 |
} |
| 14485 |
|
| 14486 |
/*:920*//*921:*/ |
| 14487 |
#line 10947 "./marpa.w" |
| 14488 |
|
| 14489 |
PRIVATE |
| 14490 |
int dand_is_duplicate(OR parent,OR predecessor,OR cause) |
| 14491 |
{ |
| 14492 |
DAND dand; |
| 14493 |
for(dand= DANDs_of_OR(parent);dand;dand= Next_DAND_of_DAND(dand)){ |
| 14494 |
if(dands_are_equal(predecessor,cause, |
| 14495 |
Predecessor_OR_of_DAND(dand),Cause_OR_of_DAND(dand))) |
| 14496 |
{ |
| 14497 |
return 1; |
| 14498 |
} |
| 14499 |
} |
| 14500 |
return 0; |
| 14501 |
} |
| 14502 |
|
| 14503 |
/*:921*//*922:*/ |
| 14504 |
#line 10962 "./marpa.w" |
| 14505 |
|
| 14506 |
PRIVATE |
| 14507 |
OR set_or_from_yim(struct s_bocage_setup_per_ys*per_ys_data, |
| 14508 |
YIM psi_yim) |
| 14509 |
{ |
| 14510 |
const YIM psi_earley_item= psi_yim; |
| 14511 |
const int psi_earley_set_ordinal= YS_Ord_of_YIM(psi_earley_item); |
| 14512 |
const int psi_item_ordinal= Ord_of_YIM(psi_earley_item); |
| 14513 |
return OR_by_PSI(per_ys_data,psi_earley_set_ordinal,psi_item_ordinal); |
| 14514 |
} |
| 14515 |
|
| 14516 |
/*:922*//*925:*/ |
| 14517 |
#line 11020 "./marpa.w" |
| 14518 |
|
| 14519 |
PRIVATE |
| 14520 |
OR safe_or_from_yim( |
| 14521 |
struct s_bocage_setup_per_ys*per_ys_data, |
| 14522 |
YIM yim) |
| 14523 |
{ |
| 14524 |
if(Position_of_AHM(AHM_of_YIM(yim))<1)return NULL; |
| 14525 |
return set_or_from_yim(per_ys_data,yim); |
| 14526 |
} |
| 14527 |
|
| 14528 |
/*:925*//*942:*/ |
| 14529 |
#line 11172 "./marpa.w" |
| 14530 |
|
| 14531 |
Marpa_Bocage marpa_b_new(Marpa_Recognizer r, |
| 14532 |
Marpa_Earley_Set_ID ordinal_arg) |
| 14533 |
{ |
| 14534 |
/*1229:*/ |
| 14535 |
#line 14861 "./marpa.w" |
| 14536 |
void*const failure_indicator= NULL; |
| 14537 |
/*:1229*/ |
| 14538 |
#line 11176 "./marpa.w" |
| 14539 |
|
| 14540 |
/*945:*/ |
| 14541 |
#line 11243 "./marpa.w" |
| 14542 |
|
| 14543 |
const GRAMMAR g= G_of_R(r); |
| 14544 |
const int xsy_count= XSY_Count_of_G(g); |
| 14545 |
BOCAGE b= NULL; |
| 14546 |
YS end_of_parse_earley_set; |
| 14547 |
JEARLEME end_of_parse_earleme; |
| 14548 |
YIM start_yim= NULL; |
| 14549 |
struct marpa_obstack*bocage_setup_obs= NULL; |
| 14550 |
int count_of_earley_items_in_parse; |
| 14551 |
const int earley_set_count_of_r= YS_Count_of_R(r); |
| 14552 |
|
| 14553 |
/*:945*//*948:*/ |
| 14554 |
#line 11266 "./marpa.w" |
| 14555 |
|
| 14556 |
struct s_bocage_setup_per_ys*per_ys_data= NULL; |
| 14557 |
|
| 14558 |
/*:948*/ |
| 14559 |
#line 11177 "./marpa.w" |
| 14560 |
|
| 14561 |
/*1250:*/ |
| 14562 |
#line 14997 "./marpa.w" |
| 14563 |
|
| 14564 |
if(HEADER_VERSION_MISMATCH){ |
| 14565 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 14566 |
return failure_indicator; |
| 14567 |
} |
| 14568 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 14569 |
MARPA_ERROR(g->t_error); |
| 14570 |
return failure_indicator; |
| 14571 |
} |
| 14572 |
|
| 14573 |
/*:1250*/ |
| 14574 |
#line 11178 "./marpa.w" |
| 14575 |
|
| 14576 |
if(_MARPA_UNLIKELY(ordinal_arg<=-2)) |
| 14577 |
{ |
| 14578 |
MARPA_ERROR(MARPA_ERR_INVALID_LOCATION); |
| 14579 |
return failure_indicator; |
| 14580 |
} |
| 14581 |
|
| 14582 |
/*1247:*/ |
| 14583 |
#line 14973 "./marpa.w" |
| 14584 |
|
| 14585 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 14586 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 14587 |
return failure_indicator; |
| 14588 |
} |
| 14589 |
/*:1247*/ |
| 14590 |
#line 11185 "./marpa.w" |
| 14591 |
|
| 14592 |
{ |
| 14593 |
struct marpa_obstack*const obstack= marpa_obs_init; |
| 14594 |
b= marpa_obs_new(obstack,struct marpa_bocage,1); |
| 14595 |
OBS_of_B(b)= obstack; |
| 14596 |
} |
| 14597 |
/*887:*/ |
| 14598 |
#line 10379 "./marpa.w" |
| 14599 |
|
| 14600 |
ORs_of_B(b)= NULL; |
| 14601 |
OR_Count_of_B(b)= 0; |
| 14602 |
ANDs_of_B(b)= NULL; |
| 14603 |
AND_Count_of_B(b)= 0; |
| 14604 |
Top_ORID_of_B(b)= -1; |
| 14605 |
|
| 14606 |
/*:887*//*890:*/ |
| 14607 |
#line 10402 "./marpa.w" |
| 14608 |
|
| 14609 |
{ |
| 14610 |
G_of_B(b)= G_of_R(r); |
| 14611 |
grammar_ref(g); |
| 14612 |
} |
| 14613 |
|
| 14614 |
/*:890*//*944:*/ |
| 14615 |
#line 11238 "./marpa.w" |
| 14616 |
|
| 14617 |
Valued_BV_of_B(b)= lbv_clone(b->t_obs,r->t_valued,xsy_count); |
| 14618 |
Valued_Locked_BV_of_B(b)= |
| 14619 |
lbv_clone(b->t_obs,r->t_valued_locked,xsy_count); |
| 14620 |
|
| 14621 |
/*:944*//*959:*/ |
| 14622 |
#line 11390 "./marpa.w" |
| 14623 |
|
| 14624 |
Ambiguity_Metric_of_B(b)= 1; |
| 14625 |
|
| 14626 |
/*:959*//*963:*/ |
| 14627 |
#line 11404 "./marpa.w" |
| 14628 |
|
| 14629 |
b->t_ref_count= 1; |
| 14630 |
/*:963*//*970:*/ |
| 14631 |
#line 11463 "./marpa.w" |
| 14632 |
|
| 14633 |
B_is_Nulling(b)= 0; |
| 14634 |
/*:970*/ |
| 14635 |
#line 11191 "./marpa.w" |
| 14636 |
|
| 14637 |
|
| 14638 |
if(G_is_Trivial(g)){ |
| 14639 |
switch(ordinal_arg){ |
| 14640 |
default:goto NO_PARSE; |
| 14641 |
case 0:case-1:break; |
| 14642 |
} |
| 14643 |
B_is_Nulling(b)= 1; |
| 14644 |
return b; |
| 14645 |
} |
| 14646 |
r_update_earley_sets(r); |
| 14647 |
/*949:*/ |
| 14648 |
#line 11269 "./marpa.w" |
| 14649 |
|
| 14650 |
{ |
| 14651 |
if(ordinal_arg==-1) |
| 14652 |
{ |
| 14653 |
end_of_parse_earley_set= YS_at_Current_Earleme_of_R(r); |
| 14654 |
} |
| 14655 |
else |
| 14656 |
{ |
| 14657 |
if(!YS_Ord_is_Valid(r,ordinal_arg)) |
| 14658 |
{ |
| 14659 |
MARPA_ERROR(MARPA_ERR_INVALID_LOCATION); |
| 14660 |
return failure_indicator; |
| 14661 |
} |
| 14662 |
end_of_parse_earley_set= YS_of_R_by_Ord(r,ordinal_arg); |
| 14663 |
} |
| 14664 |
|
| 14665 |
if(!end_of_parse_earley_set) |
| 14666 |
goto NO_PARSE; |
| 14667 |
end_of_parse_earleme= Earleme_of_YS(end_of_parse_earley_set); |
| 14668 |
} |
| 14669 |
|
| 14670 |
/*:949*/ |
| 14671 |
#line 11202 "./marpa.w" |
| 14672 |
|
| 14673 |
if(end_of_parse_earleme==0) |
| 14674 |
{ |
| 14675 |
if(!XSY_is_Nullable(XSY_by_ID(g->t_start_xsy_id))) |
| 14676 |
goto NO_PARSE; |
| 14677 |
B_is_Nulling(b)= 1; |
| 14678 |
return b; |
| 14679 |
} |
| 14680 |
/*952:*/ |
| 14681 |
#line 11335 "./marpa.w" |
| 14682 |
|
| 14683 |
{ |
| 14684 |
int yim_ix; |
| 14685 |
YIM*const earley_items= YIMs_of_YS(end_of_parse_earley_set); |
| 14686 |
const IRL start_irl= g->t_start_irl; |
| 14687 |
const IRLID sought_irl_id= ID_of_IRL(start_irl); |
| 14688 |
const int earley_item_count= YIM_Count_of_YS(end_of_parse_earley_set); |
| 14689 |
for(yim_ix= 0;yim_ix<earley_item_count;yim_ix++){ |
| 14690 |
const YIM earley_item= earley_items[yim_ix]; |
| 14691 |
if(Origin_Earleme_of_YIM(earley_item)> 0)continue; |
| 14692 |
if(YIM_was_Predicted(earley_item))continue; |
| 14693 |
{ |
| 14694 |
const AHM ahm= AHM_of_YIM(earley_item); |
| 14695 |
if(IRLID_of_AHM(ahm)==sought_irl_id){ |
| 14696 |
start_yim= earley_item; |
| 14697 |
break; |
| 14698 |
} |
| 14699 |
} |
| 14700 |
} |
| 14701 |
} |
| 14702 |
|
| 14703 |
/*:952*/ |
| 14704 |
#line 11210 "./marpa.w" |
| 14705 |
|
| 14706 |
if(!start_yim)goto NO_PARSE; |
| 14707 |
bocage_setup_obs= marpa_obs_init; |
| 14708 |
/*950:*/ |
| 14709 |
#line 11291 "./marpa.w" |
| 14710 |
|
| 14711 |
{ |
| 14712 |
int earley_set_ordinal; |
| 14713 |
int earley_set_count= YS_Count_of_R(r); |
| 14714 |
count_of_earley_items_in_parse= 0; |
| 14715 |
per_ys_data= marpa_obs_new( |
| 14716 |
bocage_setup_obs,struct s_bocage_setup_per_ys,earley_set_count); |
| 14717 |
for(earley_set_ordinal= 0;earley_set_ordinal<earley_set_count; |
| 14718 |
earley_set_ordinal++) |
| 14719 |
{ |
| 14720 |
const YS_Const earley_set= YS_of_R_by_Ord(r,earley_set_ordinal); |
| 14721 |
const int item_count= YIM_Count_of_YS(earley_set); |
| 14722 |
count_of_earley_items_in_parse+= item_count; |
| 14723 |
{ |
| 14724 |
int item_ordinal; |
| 14725 |
struct s_bocage_setup_per_ys*per_ys= per_ys_data+earley_set_ordinal; |
| 14726 |
per_ys->t_or_node_by_item= |
| 14727 |
marpa_obs_new(bocage_setup_obs,OR,item_count); |
| 14728 |
per_ys->t_or_psl= NULL; |
| 14729 |
per_ys->t_and_psl= NULL; |
| 14730 |
for(item_ordinal= 0;item_ordinal<item_count;item_ordinal++) |
| 14731 |
{ |
| 14732 |
OR_by_PSI(per_ys_data,earley_set_ordinal,item_ordinal)= NULL; |
| 14733 |
} |
| 14734 |
} |
| 14735 |
} |
| 14736 |
} |
| 14737 |
|
| 14738 |
/*:950*/ |
| 14739 |
#line 11213 "./marpa.w" |
| 14740 |
|
| 14741 |
/*867:*/ |
| 14742 |
#line 10126 "./marpa.w" |
| 14743 |
|
| 14744 |
{ |
| 14745 |
UR_Const ur_node; |
| 14746 |
const URS ur_node_stack= URS_of_R(r); |
| 14747 |
ur_node_stack_reset(ur_node_stack); |
| 14748 |
|
| 14749 |
|
| 14750 |
push_ur_if_new(per_ys_data,ur_node_stack,start_yim); |
| 14751 |
while((ur_node= ur_node_pop(ur_node_stack))) |
| 14752 |
{ |
| 14753 |
|
| 14754 |
const YIM parent_earley_item= YIM_of_UR(ur_node); |
| 14755 |
MARPA_ASSERT(!YIM_was_Predicted(parent_earley_item)) |
| 14756 |
/*870:*/ |
| 14757 |
#line 10179 "./marpa.w" |
| 14758 |
|
| 14759 |
{ |
| 14760 |
SRCL source_link; |
| 14761 |
for(source_link= First_Token_SRCL_of_YIM(parent_earley_item); |
| 14762 |
source_link;source_link= Next_SRCL_of_SRCL(source_link)) |
| 14763 |
{ |
| 14764 |
YIM predecessor_earley_item; |
| 14765 |
if(!SRCL_is_Active(source_link))continue; |
| 14766 |
predecessor_earley_item= Predecessor_of_SRCL(source_link); |
| 14767 |
if(!predecessor_earley_item)continue; |
| 14768 |
if(YIM_was_Predicted(predecessor_earley_item)) |
| 14769 |
{ |
| 14770 |
Set_boolean_in_PSI_for_initial_nulls(per_ys_data, |
| 14771 |
predecessor_earley_item); |
| 14772 |
continue; |
| 14773 |
} |
| 14774 |
push_ur_if_new(per_ys_data,ur_node_stack,predecessor_earley_item); |
| 14775 |
} |
| 14776 |
} |
| 14777 |
|
| 14778 |
/*:870*/ |
| 14779 |
#line 10139 "./marpa.w" |
| 14780 |
|
| 14781 |
/*872:*/ |
| 14782 |
#line 10213 "./marpa.w" |
| 14783 |
|
| 14784 |
{ |
| 14785 |
SRCL source_link; |
| 14786 |
for(source_link= First_Completion_SRCL_of_YIM(parent_earley_item); |
| 14787 |
source_link;source_link= Next_SRCL_of_SRCL(source_link)) |
| 14788 |
{ |
| 14789 |
YIM predecessor_earley_item; |
| 14790 |
YIM cause_earley_item; |
| 14791 |
if(!SRCL_is_Active(source_link))continue; |
| 14792 |
cause_earley_item= Cause_of_SRCL(source_link); |
| 14793 |
push_ur_if_new(per_ys_data,ur_node_stack,cause_earley_item); |
| 14794 |
predecessor_earley_item= Predecessor_of_SRCL(source_link); |
| 14795 |
if(!predecessor_earley_item)continue; |
| 14796 |
if(YIM_was_Predicted(predecessor_earley_item)) |
| 14797 |
{ |
| 14798 |
Set_boolean_in_PSI_for_initial_nulls(per_ys_data, |
| 14799 |
predecessor_earley_item); |
| 14800 |
continue; |
| 14801 |
} |
| 14802 |
push_ur_if_new(per_ys_data,ur_node_stack,predecessor_earley_item); |
| 14803 |
} |
| 14804 |
} |
| 14805 |
|
| 14806 |
/*:872*/ |
| 14807 |
#line 10140 "./marpa.w" |
| 14808 |
|
| 14809 |
/*873:*/ |
| 14810 |
#line 10236 "./marpa.w" |
| 14811 |
|
| 14812 |
{ |
| 14813 |
SRCL source_link; |
| 14814 |
|
| 14815 |
for(source_link= First_Leo_SRCL_of_YIM(parent_earley_item); |
| 14816 |
source_link;source_link= Next_SRCL_of_SRCL(source_link)) |
| 14817 |
{ |
| 14818 |
LIM leo_predecessor; |
| 14819 |
YIM cause_earley_item; |
| 14820 |
|
| 14821 |
|
| 14822 |
|
| 14823 |
if(!SRCL_is_Active(source_link)) |
| 14824 |
continue; |
| 14825 |
cause_earley_item= Cause_of_SRCL(source_link); |
| 14826 |
push_ur_if_new(per_ys_data,ur_node_stack,cause_earley_item); |
| 14827 |
for(leo_predecessor= LIM_of_SRCL(source_link);leo_predecessor; |
| 14828 |
|
| 14829 |
leo_predecessor= Predecessor_LIM_of_LIM(leo_predecessor)) |
| 14830 |
{ |
| 14831 |
const YIM leo_base_yim= Trailhead_YIM_of_LIM(leo_predecessor); |
| 14832 |
if(YIM_was_Predicted(leo_base_yim)) |
| 14833 |
{ |
| 14834 |
Set_boolean_in_PSI_for_initial_nulls(per_ys_data, |
| 14835 |
leo_base_yim); |
| 14836 |
} |
| 14837 |
else |
| 14838 |
{ |
| 14839 |
push_ur_if_new(per_ys_data,ur_node_stack,leo_base_yim); |
| 14840 |
} |
| 14841 |
} |
| 14842 |
} |
| 14843 |
} |
| 14844 |
|
| 14845 |
/*:873*/ |
| 14846 |
#line 10141 "./marpa.w" |
| 14847 |
|
| 14848 |
} |
| 14849 |
} |
| 14850 |
|
| 14851 |
/*:867*/ |
| 14852 |
#line 11214 "./marpa.w" |
| 14853 |
|
| 14854 |
/*891:*/ |
| 14855 |
#line 10409 "./marpa.w" |
| 14856 |
|
| 14857 |
{ |
| 14858 |
PSAR_Object or_per_ys_arena; |
| 14859 |
const PSAR or_psar= &or_per_ys_arena; |
| 14860 |
int work_earley_set_ordinal; |
| 14861 |
OR_Capacity_of_B(b)= count_of_earley_items_in_parse; |
| 14862 |
ORs_of_B(b)= marpa_new(OR,OR_Capacity_of_B(b)); |
| 14863 |
psar_init(or_psar,SYMI_Count_of_G(g)); |
| 14864 |
for(work_earley_set_ordinal= 0; |
| 14865 |
work_earley_set_ordinal<earley_set_count_of_r; |
| 14866 |
work_earley_set_ordinal++) |
| 14867 |
{ |
| 14868 |
const YS_Const earley_set= YS_of_R_by_Ord(r,work_earley_set_ordinal); |
| 14869 |
YIM*const yims_of_ys= YIMs_of_YS(earley_set); |
| 14870 |
const int item_count= YIM_Count_of_YS(earley_set); |
| 14871 |
PSL this_earley_set_psl; |
| 14872 |
psar_dealloc(or_psar); |
| 14873 |
this_earley_set_psl |
| 14874 |
= psl_claim_by_es(or_psar,per_ys_data,work_earley_set_ordinal); |
| 14875 |
/*892:*/ |
| 14876 |
#line 10435 "./marpa.w" |
| 14877 |
|
| 14878 |
{ |
| 14879 |
int item_ordinal; |
| 14880 |
for(item_ordinal= 0;item_ordinal<item_count; |
| 14881 |
item_ordinal++) |
| 14882 |
{ |
| 14883 |
if(OR_by_PSI(per_ys_data,work_earley_set_ordinal,item_ordinal)) |
| 14884 |
{ |
| 14885 |
const YIM work_earley_item= yims_of_ys[item_ordinal]; |
| 14886 |
{ |
| 14887 |
/*893:*/ |
| 14888 |
#line 10451 "./marpa.w" |
| 14889 |
|
| 14890 |
{ |
| 14891 |
AHM ahm= AHM_of_YIM(work_earley_item); |
| 14892 |
const int working_ys_ordinal= YS_Ord_of_YIM(work_earley_item); |
| 14893 |
const int working_yim_ordinal= Ord_of_YIM(work_earley_item); |
| 14894 |
const int work_origin_ordinal= |
| 14895 |
Ord_of_YS(Origin_of_YIM(work_earley_item)); |
| 14896 |
SYMI ahm_symbol_instance; |
| 14897 |
OR psi_or_node= NULL; |
| 14898 |
ahm_symbol_instance= SYMI_of_AHM(ahm); |
| 14899 |
{ |
| 14900 |
PSL or_psl= psl_claim_by_es(or_psar,per_ys_data,work_origin_ordinal); |
| 14901 |
OR last_or_node= NULL; |
| 14902 |
/*895:*/ |
| 14903 |
#line 10481 "./marpa.w" |
| 14904 |
|
| 14905 |
{ |
| 14906 |
if(ahm_symbol_instance>=0) |
| 14907 |
{ |
| 14908 |
OR or_node; |
| 14909 |
MARPA_ASSERT(ahm_symbol_instance<SYMI_Count_of_G(g)) |
| 14910 |
or_node= PSL_Datum(or_psl,ahm_symbol_instance); |
| 14911 |
if(!or_node||YS_Ord_of_OR(or_node)!=work_earley_set_ordinal) |
| 14912 |
{ |
| 14913 |
const IRL irl= IRL_of_AHM(ahm); |
| 14914 |
or_node= last_or_node= or_node_new(b); |
| 14915 |
PSL_Datum(or_psl,ahm_symbol_instance)= last_or_node; |
| 14916 |
Origin_Ord_of_OR(or_node)= Origin_Ord_of_YIM(work_earley_item); |
| 14917 |
YS_Ord_of_OR(or_node)= work_earley_set_ordinal; |
| 14918 |
IRL_of_OR(or_node)= irl; |
| 14919 |
Position_of_OR(or_node)= |
| 14920 |
ahm_symbol_instance-SYMI_of_IRL(irl)+1; |
| 14921 |
} |
| 14922 |
psi_or_node= or_node; |
| 14923 |
} |
| 14924 |
} |
| 14925 |
|
| 14926 |
/*:895*/ |
| 14927 |
#line 10464 "./marpa.w" |
| 14928 |
|
| 14929 |
/*898:*/ |
| 14930 |
#line 10529 "./marpa.w" |
| 14931 |
|
| 14932 |
{ |
| 14933 |
const int null_count= Null_Count_of_AHM(ahm); |
| 14934 |
if(null_count> 0) |
| 14935 |
{ |
| 14936 |
const IRL irl= IRL_of_AHM(ahm); |
| 14937 |
const int symbol_instance_of_rule= SYMI_of_IRL(irl); |
| 14938 |
const int first_null_symbol_instance= |
| 14939 |
ahm_symbol_instance< |
| 14940 |
0?symbol_instance_of_rule:ahm_symbol_instance+1; |
| 14941 |
int i; |
| 14942 |
for(i= 0;i<null_count;i++) |
| 14943 |
{ |
| 14944 |
const int symbol_instance= first_null_symbol_instance+i; |
| 14945 |
OR or_node= PSL_Datum(or_psl,symbol_instance); |
| 14946 |
if(!or_node||YS_Ord_of_OR(or_node)!=work_earley_set_ordinal){ |
| 14947 |
const int rhs_ix= symbol_instance-symbol_instance_of_rule; |
| 14948 |
const OR predecessor= rhs_ix?last_or_node:NULL; |
| 14949 |
const OR cause= Nulling_OR_by_NSYID(RHSID_of_IRL(irl,rhs_ix)); |
| 14950 |
or_node= PSL_Datum(or_psl,symbol_instance) |
| 14951 |
= last_or_node= or_node_new(b); |
| 14952 |
Origin_Ord_of_OR(or_node)= work_origin_ordinal; |
| 14953 |
YS_Ord_of_OR(or_node)= work_earley_set_ordinal; |
| 14954 |
IRL_of_OR(or_node)= irl; |
| 14955 |
Position_of_OR(or_node)= rhs_ix+1; |
| 14956 |
MARPA_ASSERT(Position_of_OR(or_node)<=1||predecessor); |
| 14957 |
draft_and_node_add(bocage_setup_obs,or_node,predecessor, |
| 14958 |
cause); |
| 14959 |
} |
| 14960 |
psi_or_node= or_node; |
| 14961 |
} |
| 14962 |
} |
| 14963 |
} |
| 14964 |
|
| 14965 |
/*:898*/ |
| 14966 |
#line 10465 "./marpa.w" |
| 14967 |
|
| 14968 |
} |
| 14969 |
|
| 14970 |
|
| 14971 |
|
| 14972 |
|
| 14973 |
OR_by_PSI(per_ys_data,working_ys_ordinal,working_yim_ordinal) |
| 14974 |
= psi_or_node; |
| 14975 |
/*899:*/ |
| 14976 |
#line 10564 "./marpa.w" |
| 14977 |
|
| 14978 |
{ |
| 14979 |
SRCL source_link; |
| 14980 |
for(source_link= First_Leo_SRCL_of_YIM(work_earley_item); |
| 14981 |
source_link;source_link= Next_SRCL_of_SRCL(source_link)) |
| 14982 |
{ |
| 14983 |
LIM leo_predecessor= LIM_of_SRCL(source_link); |
| 14984 |
if(leo_predecessor){ |
| 14985 |
/*900:*/ |
| 14986 |
#line 10581 "./marpa.w" |
| 14987 |
|
| 14988 |
{ |
| 14989 |
LIM this_leo_item= leo_predecessor; |
| 14990 |
LIM previous_leo_item= this_leo_item; |
| 14991 |
while((this_leo_item= Predecessor_LIM_of_LIM(this_leo_item))) |
| 14992 |
{ |
| 14993 |
const int ordinal_of_set_of_this_leo_item= Ord_of_YS(YS_of_LIM(this_leo_item)); |
| 14994 |
const AHM path_ahm= Trailhead_AHM_of_LIM(previous_leo_item); |
| 14995 |
const IRL path_irl= IRL_of_AHM(path_ahm); |
| 14996 |
const int symbol_instance_of_path_ahm= SYMI_of_AHM(path_ahm); |
| 14997 |
{ |
| 14998 |
OR last_or_node= NULL; |
| 14999 |
/*901:*/ |
| 15000 |
#line 10603 "./marpa.w" |
| 15001 |
|
| 15002 |
{ |
| 15003 |
{ |
| 15004 |
OR or_node; |
| 15005 |
PSL leo_psl |
| 15006 |
= psl_claim_by_es(or_psar,per_ys_data,ordinal_of_set_of_this_leo_item); |
| 15007 |
or_node= PSL_Datum(leo_psl,symbol_instance_of_path_ahm); |
| 15008 |
if(!or_node||YS_Ord_of_OR(or_node)!=work_earley_set_ordinal) |
| 15009 |
{ |
| 15010 |
last_or_node= or_node_new(b); |
| 15011 |
PSL_Datum(leo_psl,symbol_instance_of_path_ahm)= or_node= |
| 15012 |
last_or_node; |
| 15013 |
Origin_Ord_of_OR(or_node)= ordinal_of_set_of_this_leo_item; |
| 15014 |
YS_Ord_of_OR(or_node)= work_earley_set_ordinal; |
| 15015 |
IRL_of_OR(or_node)= path_irl; |
| 15016 |
Position_of_OR(or_node)= |
| 15017 |
symbol_instance_of_path_ahm-SYMI_of_IRL(path_irl)+1; |
| 15018 |
} |
| 15019 |
} |
| 15020 |
} |
| 15021 |
|
| 15022 |
/*:901*/ |
| 15023 |
#line 10593 "./marpa.w" |
| 15024 |
|
| 15025 |
/*902:*/ |
| 15026 |
#line 10628 "./marpa.w" |
| 15027 |
|
| 15028 |
{ |
| 15029 |
int i; |
| 15030 |
const int null_count= Null_Count_of_AHM(path_ahm); |
| 15031 |
for(i= 1;i<=null_count;i++) |
| 15032 |
{ |
| 15033 |
const int symbol_instance= symbol_instance_of_path_ahm+i; |
| 15034 |
OR or_node= PSL_Datum(this_earley_set_psl,symbol_instance); |
| 15035 |
MARPA_ASSERT(symbol_instance<SYMI_Count_of_G(g)) |
| 15036 |
if(!or_node||YS_Ord_of_OR(or_node)!=work_earley_set_ordinal) |
| 15037 |
{ |
| 15038 |
const int rhs_ix= symbol_instance-SYMI_of_IRL(path_irl); |
| 15039 |
MARPA_ASSERT(rhs_ix<Length_of_IRL(path_irl)) |
| 15040 |
const OR predecessor= rhs_ix?last_or_node:NULL; |
| 15041 |
const OR cause= Nulling_OR_by_NSYID(RHSID_of_IRL(path_irl,rhs_ix)); |
| 15042 |
MARPA_ASSERT(symbol_instance<Length_of_IRL(path_irl)) |
| 15043 |
MARPA_ASSERT(symbol_instance>=0) |
| 15044 |
or_node= last_or_node= or_node_new(b); |
| 15045 |
PSL_Datum(this_earley_set_psl,symbol_instance)= or_node; |
| 15046 |
Origin_Ord_of_OR(or_node)= ordinal_of_set_of_this_leo_item; |
| 15047 |
YS_Ord_of_OR(or_node)= work_earley_set_ordinal; |
| 15048 |
IRL_of_OR(or_node)= path_irl; |
| 15049 |
Position_of_OR(or_node)= rhs_ix+1; |
| 15050 |
MARPA_ASSERT(Position_of_OR(or_node)<=1||predecessor); |
| 15051 |
draft_and_node_add(bocage_setup_obs,or_node,predecessor,cause); |
| 15052 |
} |
| 15053 |
MARPA_ASSERT(Position_of_OR(or_node)<= |
| 15054 |
SYMI_of_IRL(path_irl)+Length_of_IRL(path_irl)) |
| 15055 |
MARPA_ASSERT(Position_of_OR(or_node)>=SYMI_of_IRL(path_irl)) |
| 15056 |
} |
| 15057 |
} |
| 15058 |
|
| 15059 |
/*:902*/ |
| 15060 |
#line 10594 "./marpa.w" |
| 15061 |
|
| 15062 |
} |
| 15063 |
previous_leo_item= this_leo_item; |
| 15064 |
} |
| 15065 |
} |
| 15066 |
|
| 15067 |
/*:900*/ |
| 15068 |
#line 10572 "./marpa.w" |
| 15069 |
|
| 15070 |
} |
| 15071 |
} |
| 15072 |
} |
| 15073 |
|
| 15074 |
/*:899*/ |
| 15075 |
#line 10473 "./marpa.w" |
| 15076 |
|
| 15077 |
} |
| 15078 |
|
| 15079 |
/*:893*/ |
| 15080 |
#line 10445 "./marpa.w" |
| 15081 |
|
| 15082 |
} |
| 15083 |
} |
| 15084 |
} |
| 15085 |
} |
| 15086 |
|
| 15087 |
/*:892*/ |
| 15088 |
#line 10428 "./marpa.w" |
| 15089 |
|
| 15090 |
/*908:*/ |
| 15091 |
#line 10724 "./marpa.w" |
| 15092 |
|
| 15093 |
{ |
| 15094 |
int item_ordinal; |
| 15095 |
for(item_ordinal= 0;item_ordinal<item_count;item_ordinal++) |
| 15096 |
{ |
| 15097 |
OR or_node= OR_by_PSI(per_ys_data,work_earley_set_ordinal,item_ordinal); |
| 15098 |
const YIM work_earley_item= yims_of_ys[item_ordinal]; |
| 15099 |
const int work_origin_ordinal= Ord_of_YS(Origin_of_YIM(work_earley_item)); |
| 15100 |
/*909:*/ |
| 15101 |
#line 10741 "./marpa.w" |
| 15102 |
|
| 15103 |
{ |
| 15104 |
while(or_node){ |
| 15105 |
DAND draft_and_node= DANDs_of_OR(or_node); |
| 15106 |
OR predecessor_or; |
| 15107 |
if(!draft_and_node)break; |
| 15108 |
predecessor_or= Predecessor_OR_of_DAND(draft_and_node); |
| 15109 |
if(predecessor_or&& |
| 15110 |
YS_Ord_of_OR(predecessor_or)!=work_earley_set_ordinal) |
| 15111 |
break; |
| 15112 |
or_node= predecessor_or; |
| 15113 |
} |
| 15114 |
} |
| 15115 |
|
| 15116 |
/*:909*/ |
| 15117 |
#line 10732 "./marpa.w" |
| 15118 |
|
| 15119 |
if(or_node){ |
| 15120 |
/*910:*/ |
| 15121 |
#line 10755 "./marpa.w" |
| 15122 |
|
| 15123 |
{ |
| 15124 |
const AHM work_ahm= AHM_of_YIM(work_earley_item); |
| 15125 |
MARPA_ASSERT(work_ahm>=AHM_by_ID(1)) |
| 15126 |
const int work_symbol_instance= SYMI_of_AHM(work_ahm); |
| 15127 |
const OR work_proper_or_node= or_by_origin_and_symi(per_ys_data, |
| 15128 |
work_origin_ordinal,work_symbol_instance); |
| 15129 |
/*912:*/ |
| 15130 |
#line 10797 "./marpa.w" |
| 15131 |
|
| 15132 |
{ |
| 15133 |
SRCL source_link; |
| 15134 |
for(source_link= First_Leo_SRCL_of_YIM(work_earley_item); |
| 15135 |
source_link;source_link= Next_SRCL_of_SRCL(source_link)) |
| 15136 |
{ |
| 15137 |
YIM cause_earley_item; |
| 15138 |
LIM leo_predecessor; |
| 15139 |
|
| 15140 |
|
| 15141 |
|
| 15142 |
if(!SRCL_is_Active(source_link))continue; |
| 15143 |
cause_earley_item= Cause_of_SRCL(source_link); |
| 15144 |
leo_predecessor= LIM_of_SRCL(source_link); |
| 15145 |
if(leo_predecessor){ |
| 15146 |
/*913:*/ |
| 15147 |
#line 10818 "./marpa.w" |
| 15148 |
|
| 15149 |
{ |
| 15150 |
|
| 15151 |
IRL path_irl= NULL; |
| 15152 |
|
| 15153 |
IRL previous_path_irl; |
| 15154 |
LIM path_leo_item= leo_predecessor; |
| 15155 |
LIM higher_path_leo_item= Predecessor_LIM_of_LIM(path_leo_item); |
| 15156 |
OR dand_predecessor; |
| 15157 |
OR path_or_node; |
| 15158 |
YIM base_earley_item= Trailhead_YIM_of_LIM(path_leo_item); |
| 15159 |
dand_predecessor= set_or_from_yim(per_ys_data,base_earley_item); |
| 15160 |
/*914:*/ |
| 15161 |
#line 10845 "./marpa.w" |
| 15162 |
|
| 15163 |
{ |
| 15164 |
if(higher_path_leo_item){ |
| 15165 |
/*923:*/ |
| 15166 |
#line 10973 "./marpa.w" |
| 15167 |
|
| 15168 |
{ |
| 15169 |
int symbol_instance; |
| 15170 |
const int origin_ordinal= Origin_Ord_of_YIM(base_earley_item); |
| 15171 |
const AHM ahm= AHM_of_YIM(base_earley_item); |
| 15172 |
path_irl= IRL_of_AHM(ahm); |
| 15173 |
symbol_instance= Last_Proper_SYMI_of_IRL(path_irl); |
| 15174 |
path_or_node= or_by_origin_and_symi(per_ys_data,origin_ordinal,symbol_instance); |
| 15175 |
} |
| 15176 |
|
| 15177 |
|
| 15178 |
/*:923*/ |
| 15179 |
#line 10848 "./marpa.w" |
| 15180 |
|
| 15181 |
}else{ |
| 15182 |
path_or_node= work_proper_or_node; |
| 15183 |
} |
| 15184 |
} |
| 15185 |
|
| 15186 |
/*:914*/ |
| 15187 |
#line 10830 "./marpa.w" |
| 15188 |
|
| 15189 |
/*916:*/ |
| 15190 |
#line 10864 "./marpa.w" |
| 15191 |
|
| 15192 |
{ |
| 15193 |
const OR dand_cause |
| 15194 |
= set_or_from_yim(per_ys_data,cause_earley_item); |
| 15195 |
if(!dand_is_duplicate(path_or_node,dand_predecessor,dand_cause)){ |
| 15196 |
draft_and_node_add(bocage_setup_obs,path_or_node, |
| 15197 |
dand_predecessor,dand_cause); |
| 15198 |
} |
| 15199 |
} |
| 15200 |
|
| 15201 |
/*:916*/ |
| 15202 |
#line 10831 "./marpa.w" |
| 15203 |
|
| 15204 |
previous_path_irl= path_irl; |
| 15205 |
while(higher_path_leo_item){ |
| 15206 |
path_leo_item= higher_path_leo_item; |
| 15207 |
higher_path_leo_item= Predecessor_LIM_of_LIM(path_leo_item); |
| 15208 |
base_earley_item= Trailhead_YIM_of_LIM(path_leo_item); |
| 15209 |
dand_predecessor |
| 15210 |
= set_or_from_yim(per_ys_data,base_earley_item); |
| 15211 |
/*914:*/ |
| 15212 |
#line 10845 "./marpa.w" |
| 15213 |
|
| 15214 |
{ |
| 15215 |
if(higher_path_leo_item){ |
| 15216 |
/*923:*/ |
| 15217 |
#line 10973 "./marpa.w" |
| 15218 |
|
| 15219 |
{ |
| 15220 |
int symbol_instance; |
| 15221 |
const int origin_ordinal= Origin_Ord_of_YIM(base_earley_item); |
| 15222 |
const AHM ahm= AHM_of_YIM(base_earley_item); |
| 15223 |
path_irl= IRL_of_AHM(ahm); |
| 15224 |
symbol_instance= Last_Proper_SYMI_of_IRL(path_irl); |
| 15225 |
path_or_node= or_by_origin_and_symi(per_ys_data,origin_ordinal,symbol_instance); |
| 15226 |
} |
| 15227 |
|
| 15228 |
|
| 15229 |
/*:923*/ |
| 15230 |
#line 10848 "./marpa.w" |
| 15231 |
|
| 15232 |
}else{ |
| 15233 |
path_or_node= work_proper_or_node; |
| 15234 |
} |
| 15235 |
} |
| 15236 |
|
| 15237 |
/*:914*/ |
| 15238 |
#line 10839 "./marpa.w" |
| 15239 |
|
| 15240 |
/*919:*/ |
| 15241 |
#line 10890 "./marpa.w" |
| 15242 |
|
| 15243 |
{ |
| 15244 |
const SYMI symbol_instance= SYMI_of_Completed_IRL(previous_path_irl); |
| 15245 |
const int origin= Ord_of_YS(YS_of_LIM(path_leo_item)); |
| 15246 |
const OR dand_cause= or_by_origin_and_symi(per_ys_data,origin,symbol_instance); |
| 15247 |
if(!dand_is_duplicate(path_or_node,dand_predecessor,dand_cause)){ |
| 15248 |
draft_and_node_add(bocage_setup_obs,path_or_node, |
| 15249 |
dand_predecessor,dand_cause); |
| 15250 |
} |
| 15251 |
} |
| 15252 |
|
| 15253 |
/*:919*/ |
| 15254 |
#line 10840 "./marpa.w" |
| 15255 |
|
| 15256 |
previous_path_irl= path_irl; |
| 15257 |
} |
| 15258 |
} |
| 15259 |
|
| 15260 |
/*:913*/ |
| 15261 |
#line 10812 "./marpa.w" |
| 15262 |
|
| 15263 |
} |
| 15264 |
} |
| 15265 |
} |
| 15266 |
|
| 15267 |
/*:912*/ |
| 15268 |
#line 10762 "./marpa.w" |
| 15269 |
|
| 15270 |
/*924:*/ |
| 15271 |
#line 10988 "./marpa.w" |
| 15272 |
|
| 15273 |
{ |
| 15274 |
SRCL tkn_source_link; |
| 15275 |
for(tkn_source_link= First_Token_SRCL_of_YIM(work_earley_item); |
| 15276 |
tkn_source_link;tkn_source_link= Next_SRCL_of_SRCL(tkn_source_link)) |
| 15277 |
{ |
| 15278 |
OR new_token_or_node; |
| 15279 |
const NSYID token_nsyid= NSYID_of_SRCL(tkn_source_link); |
| 15280 |
const YIM predecessor_earley_item= Predecessor_of_SRCL(tkn_source_link); |
| 15281 |
const OR dand_predecessor= safe_or_from_yim(per_ys_data, |
| 15282 |
predecessor_earley_item); |
| 15283 |
if(NSYID_is_Valued_in_B(b,token_nsyid)) |
| 15284 |
{ |
| 15285 |
|
| 15286 |
|
| 15287 |
|
| 15288 |
new_token_or_node= (OR)marpa_obs_new(OBS_of_B(b),OR_Object,1); |
| 15289 |
Type_of_OR(new_token_or_node)= VALUED_TOKEN_OR_NODE; |
| 15290 |
NSYID_of_OR(new_token_or_node)= token_nsyid; |
| 15291 |
Value_of_OR(new_token_or_node)= Value_of_SRCL(tkn_source_link); |
| 15292 |
} |
| 15293 |
else |
| 15294 |
{ |
| 15295 |
new_token_or_node= Unvalued_OR_by_NSYID(token_nsyid); |
| 15296 |
} |
| 15297 |
draft_and_node_add(bocage_setup_obs,work_proper_or_node, |
| 15298 |
dand_predecessor,new_token_or_node); |
| 15299 |
} |
| 15300 |
} |
| 15301 |
|
| 15302 |
/*:924*/ |
| 15303 |
#line 10763 "./marpa.w" |
| 15304 |
|
| 15305 |
/*926:*/ |
| 15306 |
#line 11030 "./marpa.w" |
| 15307 |
|
| 15308 |
{ |
| 15309 |
SRCL source_link; |
| 15310 |
for(source_link= First_Completion_SRCL_of_YIM(work_earley_item); |
| 15311 |
source_link;source_link= Next_SRCL_of_SRCL(source_link)) |
| 15312 |
{ |
| 15313 |
YIM predecessor_earley_item= Predecessor_of_SRCL(source_link); |
| 15314 |
YIM cause_earley_item= Cause_of_SRCL(source_link); |
| 15315 |
const int middle_ordinal= Origin_Ord_of_YIM(cause_earley_item); |
| 15316 |
const AHM cause_ahm= AHM_of_YIM(cause_earley_item); |
| 15317 |
const SYMI cause_symbol_instance= |
| 15318 |
SYMI_of_Completed_IRL(IRL_of_AHM(cause_ahm)); |
| 15319 |
OR dand_predecessor= safe_or_from_yim(per_ys_data, |
| 15320 |
predecessor_earley_item); |
| 15321 |
const OR dand_cause= |
| 15322 |
or_by_origin_and_symi(per_ys_data,middle_ordinal, |
| 15323 |
cause_symbol_instance); |
| 15324 |
draft_and_node_add(bocage_setup_obs,work_proper_or_node, |
| 15325 |
dand_predecessor,dand_cause); |
| 15326 |
} |
| 15327 |
} |
| 15328 |
|
| 15329 |
/*:926*/ |
| 15330 |
#line 10764 "./marpa.w" |
| 15331 |
|
| 15332 |
} |
| 15333 |
|
| 15334 |
/*:910*/ |
| 15335 |
#line 10734 "./marpa.w" |
| 15336 |
|
| 15337 |
} |
| 15338 |
} |
| 15339 |
} |
| 15340 |
|
| 15341 |
/*:908*/ |
| 15342 |
#line 10429 "./marpa.w" |
| 15343 |
|
| 15344 |
} |
| 15345 |
psar_destroy(or_psar); |
| 15346 |
ORs_of_B(b)= marpa_renew(OR,ORs_of_B(b),OR_Count_of_B(b)); |
| 15347 |
} |
| 15348 |
|
| 15349 |
/*:891*/ |
| 15350 |
#line 11215 "./marpa.w" |
| 15351 |
|
| 15352 |
/*932:*/ |
| 15353 |
#line 11102 "./marpa.w" |
| 15354 |
|
| 15355 |
{ |
| 15356 |
int unique_draft_and_node_count= 0; |
| 15357 |
/*927:*/ |
| 15358 |
#line 11055 "./marpa.w" |
| 15359 |
|
| 15360 |
{ |
| 15361 |
const int or_node_count_of_b= OR_Count_of_B(b); |
| 15362 |
int or_node_id= 0; |
| 15363 |
while(or_node_id<or_node_count_of_b) |
| 15364 |
{ |
| 15365 |
const OR work_or_node= OR_of_B_by_ID(b,or_node_id); |
| 15366 |
DAND dand= DANDs_of_OR(work_or_node); |
| 15367 |
while(dand) |
| 15368 |
{ |
| 15369 |
unique_draft_and_node_count++; |
| 15370 |
dand= Next_DAND_of_DAND(dand); |
| 15371 |
} |
| 15372 |
or_node_id++; |
| 15373 |
} |
| 15374 |
} |
| 15375 |
|
| 15376 |
/*:927*/ |
| 15377 |
#line 11105 "./marpa.w" |
| 15378 |
|
| 15379 |
/*933:*/ |
| 15380 |
#line 11109 "./marpa.w" |
| 15381 |
|
| 15382 |
{ |
| 15383 |
const int or_count_of_b= OR_Count_of_B(b); |
| 15384 |
int or_node_id; |
| 15385 |
int and_node_id= 0; |
| 15386 |
const AND ands_of_b= ANDs_of_B(b)= |
| 15387 |
marpa_new(AND_Object,unique_draft_and_node_count); |
| 15388 |
for(or_node_id= 0;or_node_id<or_count_of_b;or_node_id++) |
| 15389 |
{ |
| 15390 |
int and_count_of_parent_or= 0; |
| 15391 |
const OR or_node= OR_of_B_by_ID(b,or_node_id); |
| 15392 |
DAND dand= DANDs_of_OR(or_node); |
| 15393 |
First_ANDID_of_OR(or_node)= and_node_id; |
| 15394 |
while(dand) |
| 15395 |
{ |
| 15396 |
const OR cause_or_node= Cause_OR_of_DAND(dand); |
| 15397 |
const AND and_node= ands_of_b+and_node_id; |
| 15398 |
OR_of_AND(and_node)= or_node; |
| 15399 |
Predecessor_OR_of_AND(and_node)= Predecessor_OR_of_DAND(dand); |
| 15400 |
Cause_OR_of_AND(and_node)= cause_or_node; |
| 15401 |
and_node_id++; |
| 15402 |
and_count_of_parent_or++; |
| 15403 |
dand= Next_DAND_of_DAND(dand); |
| 15404 |
} |
| 15405 |
AND_Count_of_OR(or_node)= and_count_of_parent_or; |
| 15406 |
if(and_count_of_parent_or> 1)Ambiguity_Metric_of_B(b)= 2; |
| 15407 |
} |
| 15408 |
AND_Count_of_B(b)= and_node_id; |
| 15409 |
MARPA_ASSERT(and_node_id==unique_draft_and_node_count); |
| 15410 |
} |
| 15411 |
|
| 15412 |
|
| 15413 |
/*:933*/ |
| 15414 |
#line 11106 "./marpa.w" |
| 15415 |
|
| 15416 |
} |
| 15417 |
|
| 15418 |
/*:932*/ |
| 15419 |
#line 11216 "./marpa.w" |
| 15420 |
|
| 15421 |
/*953:*/ |
| 15422 |
#line 11356 "./marpa.w" |
| 15423 |
|
| 15424 |
{ |
| 15425 |
const YSID end_of_parse_ordinal= Ord_of_YS(end_of_parse_earley_set); |
| 15426 |
const int start_earley_item_ordinal= Ord_of_YIM(start_yim); |
| 15427 |
const OR root_or_node= |
| 15428 |
OR_by_PSI(per_ys_data,end_of_parse_ordinal,start_earley_item_ordinal); |
| 15429 |
Top_ORID_of_B(b)= ID_of_OR(root_or_node); |
| 15430 |
} |
| 15431 |
|
| 15432 |
/*:953*/ |
| 15433 |
#line 11217 "./marpa.w" |
| 15434 |
; |
| 15435 |
marpa_obs_free(bocage_setup_obs); |
| 15436 |
return b; |
| 15437 |
NO_PARSE:; |
| 15438 |
MARPA_ERROR(MARPA_ERR_NO_PARSE); |
| 15439 |
if(b){ |
| 15440 |
/*966:*/ |
| 15441 |
#line 11440 "./marpa.w" |
| 15442 |
|
| 15443 |
/*888:*/ |
| 15444 |
#line 10386 "./marpa.w" |
| 15445 |
|
| 15446 |
{ |
| 15447 |
OR*or_nodes= ORs_of_B(b); |
| 15448 |
AND and_nodes= ANDs_of_B(b); |
| 15449 |
|
| 15450 |
grammar_unref(G_of_B(b)); |
| 15451 |
my_free(or_nodes); |
| 15452 |
ORs_of_B(b)= NULL; |
| 15453 |
my_free(and_nodes); |
| 15454 |
ANDs_of_B(b)= NULL; |
| 15455 |
} |
| 15456 |
|
| 15457 |
/*:888*/ |
| 15458 |
#line 11441 "./marpa.w" |
| 15459 |
; |
| 15460 |
/*941:*/ |
| 15461 |
#line 11168 "./marpa.w" |
| 15462 |
|
| 15463 |
marpa_obs_free(OBS_of_B(b)); |
| 15464 |
|
| 15465 |
/*:941*/ |
| 15466 |
#line 11442 "./marpa.w" |
| 15467 |
; |
| 15468 |
|
| 15469 |
/*:966*/ |
| 15470 |
#line 11223 "./marpa.w" |
| 15471 |
; |
| 15472 |
} |
| 15473 |
return NULL; |
| 15474 |
} |
| 15475 |
|
| 15476 |
/*:942*//*955:*/ |
| 15477 |
#line 11367 "./marpa.w" |
| 15478 |
|
| 15479 |
Marpa_Or_Node_ID _marpa_b_top_or_node(Marpa_Bocage b) |
| 15480 |
{ |
| 15481 |
/*1230:*/ |
| 15482 |
#line 14864 "./marpa.w" |
| 15483 |
const int failure_indicator= -2; |
| 15484 |
|
| 15485 |
/*:1230*/ |
| 15486 |
#line 11370 "./marpa.w" |
| 15487 |
|
| 15488 |
/*939:*/ |
| 15489 |
#line 11160 "./marpa.w" |
| 15490 |
|
| 15491 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 15492 |
|
| 15493 |
/*:939*/ |
| 15494 |
#line 11371 "./marpa.w" |
| 15495 |
|
| 15496 |
/*1250:*/ |
| 15497 |
#line 14997 "./marpa.w" |
| 15498 |
|
| 15499 |
if(HEADER_VERSION_MISMATCH){ |
| 15500 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 15501 |
return failure_indicator; |
| 15502 |
} |
| 15503 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 15504 |
MARPA_ERROR(g->t_error); |
| 15505 |
return failure_indicator; |
| 15506 |
} |
| 15507 |
|
| 15508 |
/*:1250*/ |
| 15509 |
#line 11372 "./marpa.w" |
| 15510 |
|
| 15511 |
return Top_ORID_of_B(b); |
| 15512 |
} |
| 15513 |
|
| 15514 |
/*:955*//*960:*/ |
| 15515 |
#line 11393 "./marpa.w" |
| 15516 |
|
| 15517 |
int marpa_b_ambiguity_metric(Marpa_Bocage b) |
| 15518 |
{ |
| 15519 |
/*1230:*/ |
| 15520 |
#line 14864 "./marpa.w" |
| 15521 |
const int failure_indicator= -2; |
| 15522 |
|
| 15523 |
/*:1230*/ |
| 15524 |
#line 11396 "./marpa.w" |
| 15525 |
|
| 15526 |
/*939:*/ |
| 15527 |
#line 11160 "./marpa.w" |
| 15528 |
|
| 15529 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 15530 |
|
| 15531 |
/*:939*/ |
| 15532 |
#line 11397 "./marpa.w" |
| 15533 |
|
| 15534 |
/*1250:*/ |
| 15535 |
#line 14997 "./marpa.w" |
| 15536 |
|
| 15537 |
if(HEADER_VERSION_MISMATCH){ |
| 15538 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 15539 |
return failure_indicator; |
| 15540 |
} |
| 15541 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 15542 |
MARPA_ERROR(g->t_error); |
| 15543 |
return failure_indicator; |
| 15544 |
} |
| 15545 |
|
| 15546 |
/*:1250*/ |
| 15547 |
#line 11398 "./marpa.w" |
| 15548 |
|
| 15549 |
return Ambiguity_Metric_of_B(b); |
| 15550 |
} |
| 15551 |
|
| 15552 |
/*:960*//*964:*/ |
| 15553 |
#line 11407 "./marpa.w" |
| 15554 |
|
| 15555 |
PRIVATE void |
| 15556 |
bocage_unref(BOCAGE b) |
| 15557 |
{ |
| 15558 |
MARPA_ASSERT(b->t_ref_count> 0) |
| 15559 |
b->t_ref_count--; |
| 15560 |
if(b->t_ref_count<=0) |
| 15561 |
{ |
| 15562 |
bocage_free(b); |
| 15563 |
} |
| 15564 |
} |
| 15565 |
void |
| 15566 |
marpa_b_unref(Marpa_Bocage b) |
| 15567 |
{ |
| 15568 |
bocage_unref(b); |
| 15569 |
} |
| 15570 |
|
| 15571 |
/*:964*//*965:*/ |
| 15572 |
#line 11425 "./marpa.w" |
| 15573 |
|
| 15574 |
PRIVATE BOCAGE |
| 15575 |
bocage_ref(BOCAGE b) |
| 15576 |
{ |
| 15577 |
MARPA_ASSERT(b->t_ref_count> 0) |
| 15578 |
b->t_ref_count++; |
| 15579 |
return b; |
| 15580 |
} |
| 15581 |
Marpa_Bocage |
| 15582 |
marpa_b_ref(Marpa_Bocage b) |
| 15583 |
{ |
| 15584 |
return bocage_ref(b); |
| 15585 |
} |
| 15586 |
|
| 15587 |
/*:965*//*967:*/ |
| 15588 |
#line 11447 "./marpa.w" |
| 15589 |
|
| 15590 |
PRIVATE void |
| 15591 |
bocage_free(BOCAGE b) |
| 15592 |
{ |
| 15593 |
/*939:*/ |
| 15594 |
#line 11160 "./marpa.w" |
| 15595 |
|
| 15596 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 15597 |
|
| 15598 |
/*:939*/ |
| 15599 |
#line 11451 "./marpa.w" |
| 15600 |
|
| 15601 |
if(b) |
| 15602 |
{ |
| 15603 |
/*966:*/ |
| 15604 |
#line 11440 "./marpa.w" |
| 15605 |
|
| 15606 |
/*888:*/ |
| 15607 |
#line 10386 "./marpa.w" |
| 15608 |
|
| 15609 |
{ |
| 15610 |
OR*or_nodes= ORs_of_B(b); |
| 15611 |
AND and_nodes= ANDs_of_B(b); |
| 15612 |
|
| 15613 |
grammar_unref(G_of_B(b)); |
| 15614 |
my_free(or_nodes); |
| 15615 |
ORs_of_B(b)= NULL; |
| 15616 |
my_free(and_nodes); |
| 15617 |
ANDs_of_B(b)= NULL; |
| 15618 |
} |
| 15619 |
|
| 15620 |
/*:888*/ |
| 15621 |
#line 11441 "./marpa.w" |
| 15622 |
; |
| 15623 |
/*941:*/ |
| 15624 |
#line 11168 "./marpa.w" |
| 15625 |
|
| 15626 |
marpa_obs_free(OBS_of_B(b)); |
| 15627 |
|
| 15628 |
/*:941*/ |
| 15629 |
#line 11442 "./marpa.w" |
| 15630 |
; |
| 15631 |
|
| 15632 |
/*:966*/ |
| 15633 |
#line 11454 "./marpa.w" |
| 15634 |
; |
| 15635 |
} |
| 15636 |
} |
| 15637 |
|
| 15638 |
/*:967*//*971:*/ |
| 15639 |
#line 11465 "./marpa.w" |
| 15640 |
|
| 15641 |
int marpa_b_is_null(Marpa_Bocage b) |
| 15642 |
{ |
| 15643 |
/*1230:*/ |
| 15644 |
#line 14864 "./marpa.w" |
| 15645 |
const int failure_indicator= -2; |
| 15646 |
|
| 15647 |
/*:1230*/ |
| 15648 |
#line 11468 "./marpa.w" |
| 15649 |
|
| 15650 |
/*939:*/ |
| 15651 |
#line 11160 "./marpa.w" |
| 15652 |
|
| 15653 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 15654 |
|
| 15655 |
/*:939*/ |
| 15656 |
#line 11469 "./marpa.w" |
| 15657 |
|
| 15658 |
/*1250:*/ |
| 15659 |
#line 14997 "./marpa.w" |
| 15660 |
|
| 15661 |
if(HEADER_VERSION_MISMATCH){ |
| 15662 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 15663 |
return failure_indicator; |
| 15664 |
} |
| 15665 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 15666 |
MARPA_ERROR(g->t_error); |
| 15667 |
return failure_indicator; |
| 15668 |
} |
| 15669 |
|
| 15670 |
/*:1250*/ |
| 15671 |
#line 11470 "./marpa.w" |
| 15672 |
|
| 15673 |
return B_is_Nulling(b); |
| 15674 |
} |
| 15675 |
|
| 15676 |
/*:971*//*978:*/ |
| 15677 |
#line 11510 "./marpa.w" |
| 15678 |
|
| 15679 |
Marpa_Order marpa_o_new(Marpa_Bocage b) |
| 15680 |
{ |
| 15681 |
/*1229:*/ |
| 15682 |
#line 14861 "./marpa.w" |
| 15683 |
void*const failure_indicator= NULL; |
| 15684 |
/*:1229*/ |
| 15685 |
#line 11513 "./marpa.w" |
| 15686 |
|
| 15687 |
/*939:*/ |
| 15688 |
#line 11160 "./marpa.w" |
| 15689 |
|
| 15690 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 15691 |
|
| 15692 |
/*:939*/ |
| 15693 |
#line 11514 "./marpa.w" |
| 15694 |
|
| 15695 |
ORDER o; |
| 15696 |
/*1250:*/ |
| 15697 |
#line 14997 "./marpa.w" |
| 15698 |
|
| 15699 |
if(HEADER_VERSION_MISMATCH){ |
| 15700 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 15701 |
return failure_indicator; |
| 15702 |
} |
| 15703 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 15704 |
MARPA_ERROR(g->t_error); |
| 15705 |
return failure_indicator; |
| 15706 |
} |
| 15707 |
|
| 15708 |
/*:1250*/ |
| 15709 |
#line 11516 "./marpa.w" |
| 15710 |
|
| 15711 |
o= my_malloc(sizeof(*o)); |
| 15712 |
B_of_O(o)= b; |
| 15713 |
bocage_ref(b); |
| 15714 |
/*975:*/ |
| 15715 |
#line 11498 "./marpa.w" |
| 15716 |
|
| 15717 |
{ |
| 15718 |
o->t_and_node_orderings= NULL; |
| 15719 |
o->t_is_frozen= 0; |
| 15720 |
OBS_of_O(o)= NULL; |
| 15721 |
} |
| 15722 |
|
| 15723 |
/*:975*//*981:*/ |
| 15724 |
#line 11528 "./marpa.w" |
| 15725 |
|
| 15726 |
o->t_ref_count= 1; |
| 15727 |
|
| 15728 |
/*:981*//*994:*/ |
| 15729 |
#line 11696 "./marpa.w" |
| 15730 |
|
| 15731 |
High_Rank_Count_of_O(o)= 1; |
| 15732 |
/*:994*/ |
| 15733 |
#line 11520 "./marpa.w" |
| 15734 |
|
| 15735 |
O_is_Nulling(o)= B_is_Nulling(b); |
| 15736 |
Ambiguity_Metric_of_O(o)= -1; |
| 15737 |
return o; |
| 15738 |
} |
| 15739 |
|
| 15740 |
/*:978*//*982:*/ |
| 15741 |
#line 11532 "./marpa.w" |
| 15742 |
|
| 15743 |
PRIVATE void |
| 15744 |
order_unref(ORDER o) |
| 15745 |
{ |
| 15746 |
MARPA_ASSERT(o->t_ref_count> 0) |
| 15747 |
o->t_ref_count--; |
| 15748 |
if(o->t_ref_count<=0) |
| 15749 |
{ |
| 15750 |
order_free(o); |
| 15751 |
} |
| 15752 |
} |
| 15753 |
void |
| 15754 |
marpa_o_unref(Marpa_Order o) |
| 15755 |
{ |
| 15756 |
order_unref(o); |
| 15757 |
} |
| 15758 |
|
| 15759 |
/*:982*//*983:*/ |
| 15760 |
#line 11550 "./marpa.w" |
| 15761 |
|
| 15762 |
PRIVATE ORDER |
| 15763 |
order_ref(ORDER o) |
| 15764 |
{ |
| 15765 |
MARPA_ASSERT(o->t_ref_count> 0) |
| 15766 |
o->t_ref_count++; |
| 15767 |
return o; |
| 15768 |
} |
| 15769 |
Marpa_Order |
| 15770 |
marpa_o_ref(Marpa_Order o) |
| 15771 |
{ |
| 15772 |
return order_ref(o); |
| 15773 |
} |
| 15774 |
|
| 15775 |
/*:983*//*984:*/ |
| 15776 |
#line 11564 "./marpa.w" |
| 15777 |
|
| 15778 |
PRIVATE void order_free(ORDER o) |
| 15779 |
{ |
| 15780 |
/*985:*/ |
| 15781 |
#line 11573 "./marpa.w" |
| 15782 |
|
| 15783 |
const BOCAGE b= B_of_O(o); |
| 15784 |
/*939:*/ |
| 15785 |
#line 11160 "./marpa.w" |
| 15786 |
|
| 15787 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 15788 |
|
| 15789 |
/*:939*/ |
| 15790 |
#line 11575 "./marpa.w" |
| 15791 |
|
| 15792 |
|
| 15793 |
/*:985*/ |
| 15794 |
#line 11567 "./marpa.w" |
| 15795 |
|
| 15796 |
bocage_unref(b); |
| 15797 |
marpa_obs_free(OBS_of_O(o)); |
| 15798 |
my_free(o); |
| 15799 |
} |
| 15800 |
|
| 15801 |
/*:984*//*988:*/ |
| 15802 |
#line 11585 "./marpa.w" |
| 15803 |
|
| 15804 |
int marpa_o_ambiguity_metric(Marpa_Order o) |
| 15805 |
{ |
| 15806 |
/*1230:*/ |
| 15807 |
#line 14864 "./marpa.w" |
| 15808 |
const int failure_indicator= -2; |
| 15809 |
|
| 15810 |
/*:1230*/ |
| 15811 |
#line 11588 "./marpa.w" |
| 15812 |
|
| 15813 |
/*985:*/ |
| 15814 |
#line 11573 "./marpa.w" |
| 15815 |
|
| 15816 |
const BOCAGE b= B_of_O(o); |
| 15817 |
/*939:*/ |
| 15818 |
#line 11160 "./marpa.w" |
| 15819 |
|
| 15820 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 15821 |
|
| 15822 |
/*:939*/ |
| 15823 |
#line 11575 "./marpa.w" |
| 15824 |
|
| 15825 |
|
| 15826 |
/*:985*/ |
| 15827 |
#line 11589 "./marpa.w" |
| 15828 |
|
| 15829 |
const int old_ambiguity_metric_of_o |
| 15830 |
= Ambiguity_Metric_of_O(o); |
| 15831 |
const int ambiguity_metric_of_b |
| 15832 |
= (Ambiguity_Metric_of_B(b)<=1?1:2); |
| 15833 |
/*1250:*/ |
| 15834 |
#line 14997 "./marpa.w" |
| 15835 |
|
| 15836 |
if(HEADER_VERSION_MISMATCH){ |
| 15837 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 15838 |
return failure_indicator; |
| 15839 |
} |
| 15840 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 15841 |
MARPA_ERROR(g->t_error); |
| 15842 |
return failure_indicator; |
| 15843 |
} |
| 15844 |
|
| 15845 |
/*:1250*/ |
| 15846 |
#line 11594 "./marpa.w" |
| 15847 |
|
| 15848 |
O_is_Frozen(o)= 1; |
| 15849 |
if(old_ambiguity_metric_of_o>=0) |
| 15850 |
return old_ambiguity_metric_of_o; |
| 15851 |
if(ambiguity_metric_of_b<2 |
| 15852 |
||O_is_Default(o) |
| 15853 |
||High_Rank_Count_of_O(o)<=0 |
| 15854 |
){ |
| 15855 |
Ambiguity_Metric_of_O(o)= ambiguity_metric_of_b; |
| 15856 |
return ambiguity_metric_of_b; |
| 15857 |
} |
| 15858 |
/*989:*/ |
| 15859 |
#line 11613 "./marpa.w" |
| 15860 |
|
| 15861 |
{ |
| 15862 |
ANDID**const and_node_orderings= o->t_and_node_orderings; |
| 15863 |
const AND and_nodes= ANDs_of_B(b); |
| 15864 |
ORID*top_of_stack; |
| 15865 |
const ORID root_or_id= Top_ORID_of_B(b); |
| 15866 |
FSTACK_DECLARE(or_node_stack,ORID) |
| 15867 |
const int or_count= OR_Count_of_B(b); |
| 15868 |
Bit_Vector bv_orid_was_stacked; |
| 15869 |
Ambiguity_Metric_of_O(o)= 1; |
| 15870 |
|
| 15871 |
|
| 15872 |
bv_orid_was_stacked= bv_create(or_count); |
| 15873 |
FSTACK_INIT(or_node_stack,ORID,or_count); |
| 15874 |
*(FSTACK_PUSH(or_node_stack))= root_or_id; |
| 15875 |
bv_bit_set(bv_orid_was_stacked,root_or_id); |
| 15876 |
while((top_of_stack= FSTACK_POP(or_node_stack))) |
| 15877 |
{ |
| 15878 |
const ORID or_id= *top_of_stack; |
| 15879 |
const OR or_node= OR_of_B_by_ID(b,or_id); |
| 15880 |
ANDID*ordering= and_node_orderings[or_id]; |
| 15881 |
int and_count= ordering?ordering[0]:AND_Count_of_OR(or_node); |
| 15882 |
if(and_count> 1) |
| 15883 |
{ |
| 15884 |
|
| 15885 |
|
| 15886 |
|
| 15887 |
Ambiguity_Metric_of_O(o)= 2; |
| 15888 |
|
| 15889 |
goto END_OR_NODE_LOOP; |
| 15890 |
|
| 15891 |
} |
| 15892 |
{ |
| 15893 |
const ANDID and_id= ordering?ordering[1]:First_ANDID_of_OR(or_node); |
| 15894 |
const AND and_node= and_nodes+and_id; |
| 15895 |
const OR predecessor_or= Predecessor_OR_of_AND(and_node); |
| 15896 |
const OR cause_or= Cause_OR_of_AND(and_node); |
| 15897 |
if(predecessor_or) |
| 15898 |
{ |
| 15899 |
const ORID predecessor_or_id= ID_of_OR(predecessor_or); |
| 15900 |
if(!bv_bit_test_then_set(bv_orid_was_stacked,predecessor_or_id)) |
| 15901 |
{ |
| 15902 |
*(FSTACK_PUSH(or_node_stack))= predecessor_or_id; |
| 15903 |
} |
| 15904 |
} |
| 15905 |
if(cause_or&&!OR_is_Token(cause_or)) |
| 15906 |
{ |
| 15907 |
const ORID cause_or_id= ID_of_OR(cause_or); |
| 15908 |
if(!bv_bit_test_then_set(bv_orid_was_stacked,cause_or_id)) |
| 15909 |
{ |
| 15910 |
*(FSTACK_PUSH(or_node_stack))= cause_or_id; |
| 15911 |
} |
| 15912 |
} |
| 15913 |
} |
| 15914 |
} |
| 15915 |
END_OR_NODE_LOOP:; |
| 15916 |
FSTACK_DESTROY(or_node_stack); |
| 15917 |
bv_free(bv_orid_was_stacked); |
| 15918 |
|
| 15919 |
} |
| 15920 |
|
| 15921 |
/*:989*/ |
| 15922 |
#line 11605 "./marpa.w" |
| 15923 |
|
| 15924 |
return Ambiguity_Metric_of_O(o); |
| 15925 |
} |
| 15926 |
|
| 15927 |
/*:988*//*992:*/ |
| 15928 |
#line 11679 "./marpa.w" |
| 15929 |
|
| 15930 |
int marpa_o_is_null(Marpa_Order o) |
| 15931 |
{ |
| 15932 |
/*1230:*/ |
| 15933 |
#line 14864 "./marpa.w" |
| 15934 |
const int failure_indicator= -2; |
| 15935 |
|
| 15936 |
/*:1230*/ |
| 15937 |
#line 11682 "./marpa.w" |
| 15938 |
|
| 15939 |
/*985:*/ |
| 15940 |
#line 11573 "./marpa.w" |
| 15941 |
|
| 15942 |
const BOCAGE b= B_of_O(o); |
| 15943 |
/*939:*/ |
| 15944 |
#line 11160 "./marpa.w" |
| 15945 |
|
| 15946 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 15947 |
|
| 15948 |
/*:939*/ |
| 15949 |
#line 11575 "./marpa.w" |
| 15950 |
|
| 15951 |
|
| 15952 |
/*:985*/ |
| 15953 |
#line 11683 "./marpa.w" |
| 15954 |
|
| 15955 |
/*1250:*/ |
| 15956 |
#line 14997 "./marpa.w" |
| 15957 |
|
| 15958 |
if(HEADER_VERSION_MISMATCH){ |
| 15959 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 15960 |
return failure_indicator; |
| 15961 |
} |
| 15962 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 15963 |
MARPA_ERROR(g->t_error); |
| 15964 |
return failure_indicator; |
| 15965 |
} |
| 15966 |
|
| 15967 |
/*:1250*/ |
| 15968 |
#line 11684 "./marpa.w" |
| 15969 |
|
| 15970 |
return O_is_Nulling(o); |
| 15971 |
} |
| 15972 |
|
| 15973 |
/*:992*//*995:*/ |
| 15974 |
#line 11698 "./marpa.w" |
| 15975 |
|
| 15976 |
int marpa_o_high_rank_only_set( |
| 15977 |
Marpa_Order o, |
| 15978 |
int count) |
| 15979 |
{ |
| 15980 |
/*1230:*/ |
| 15981 |
#line 14864 "./marpa.w" |
| 15982 |
const int failure_indicator= -2; |
| 15983 |
|
| 15984 |
/*:1230*/ |
| 15985 |
#line 11703 "./marpa.w" |
| 15986 |
|
| 15987 |
/*985:*/ |
| 15988 |
#line 11573 "./marpa.w" |
| 15989 |
|
| 15990 |
const BOCAGE b= B_of_O(o); |
| 15991 |
/*939:*/ |
| 15992 |
#line 11160 "./marpa.w" |
| 15993 |
|
| 15994 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 15995 |
|
| 15996 |
/*:939*/ |
| 15997 |
#line 11575 "./marpa.w" |
| 15998 |
|
| 15999 |
|
| 16000 |
/*:985*/ |
| 16001 |
#line 11704 "./marpa.w" |
| 16002 |
|
| 16003 |
/*1250:*/ |
| 16004 |
#line 14997 "./marpa.w" |
| 16005 |
|
| 16006 |
if(HEADER_VERSION_MISMATCH){ |
| 16007 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 16008 |
return failure_indicator; |
| 16009 |
} |
| 16010 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 16011 |
MARPA_ERROR(g->t_error); |
| 16012 |
return failure_indicator; |
| 16013 |
} |
| 16014 |
|
| 16015 |
/*:1250*/ |
| 16016 |
#line 11705 "./marpa.w" |
| 16017 |
|
| 16018 |
if(O_is_Frozen(o)) |
| 16019 |
{ |
| 16020 |
MARPA_ERROR(MARPA_ERR_ORDER_FROZEN); |
| 16021 |
return failure_indicator; |
| 16022 |
} |
| 16023 |
if(_MARPA_UNLIKELY(count<0||count> 1)) |
| 16024 |
{ |
| 16025 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 16026 |
return failure_indicator; |
| 16027 |
} |
| 16028 |
return High_Rank_Count_of_O(o)= count; |
| 16029 |
} |
| 16030 |
|
| 16031 |
/*:995*//*996:*/ |
| 16032 |
#line 11720 "./marpa.w" |
| 16033 |
|
| 16034 |
int marpa_o_high_rank_only(Marpa_Order o) |
| 16035 |
{ |
| 16036 |
/*1230:*/ |
| 16037 |
#line 14864 "./marpa.w" |
| 16038 |
const int failure_indicator= -2; |
| 16039 |
|
| 16040 |
/*:1230*/ |
| 16041 |
#line 11723 "./marpa.w" |
| 16042 |
|
| 16043 |
/*985:*/ |
| 16044 |
#line 11573 "./marpa.w" |
| 16045 |
|
| 16046 |
const BOCAGE b= B_of_O(o); |
| 16047 |
/*939:*/ |
| 16048 |
#line 11160 "./marpa.w" |
| 16049 |
|
| 16050 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 16051 |
|
| 16052 |
/*:939*/ |
| 16053 |
#line 11575 "./marpa.w" |
| 16054 |
|
| 16055 |
|
| 16056 |
/*:985*/ |
| 16057 |
#line 11724 "./marpa.w" |
| 16058 |
|
| 16059 |
/*1250:*/ |
| 16060 |
#line 14997 "./marpa.w" |
| 16061 |
|
| 16062 |
if(HEADER_VERSION_MISMATCH){ |
| 16063 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 16064 |
return failure_indicator; |
| 16065 |
} |
| 16066 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 16067 |
MARPA_ERROR(g->t_error); |
| 16068 |
return failure_indicator; |
| 16069 |
} |
| 16070 |
|
| 16071 |
/*:1250*/ |
| 16072 |
#line 11725 "./marpa.w" |
| 16073 |
|
| 16074 |
return High_Rank_Count_of_O(o); |
| 16075 |
} |
| 16076 |
|
| 16077 |
/*:996*//*1000:*/ |
| 16078 |
#line 11762 "./marpa.w" |
| 16079 |
|
| 16080 |
int marpa_o_rank(Marpa_Order o) |
| 16081 |
{ |
| 16082 |
ANDID**and_node_orderings; |
| 16083 |
struct marpa_obstack*obs; |
| 16084 |
int bocage_was_reordered= 0; |
| 16085 |
/*1230:*/ |
| 16086 |
#line 14864 "./marpa.w" |
| 16087 |
const int failure_indicator= -2; |
| 16088 |
|
| 16089 |
/*:1230*/ |
| 16090 |
#line 11768 "./marpa.w" |
| 16091 |
|
| 16092 |
/*985:*/ |
| 16093 |
#line 11573 "./marpa.w" |
| 16094 |
|
| 16095 |
const BOCAGE b= B_of_O(o); |
| 16096 |
/*939:*/ |
| 16097 |
#line 11160 "./marpa.w" |
| 16098 |
|
| 16099 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 16100 |
|
| 16101 |
/*:939*/ |
| 16102 |
#line 11575 "./marpa.w" |
| 16103 |
|
| 16104 |
|
| 16105 |
/*:985*/ |
| 16106 |
#line 11769 "./marpa.w" |
| 16107 |
|
| 16108 |
/*1250:*/ |
| 16109 |
#line 14997 "./marpa.w" |
| 16110 |
|
| 16111 |
if(HEADER_VERSION_MISMATCH){ |
| 16112 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 16113 |
return failure_indicator; |
| 16114 |
} |
| 16115 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 16116 |
MARPA_ERROR(g->t_error); |
| 16117 |
return failure_indicator; |
| 16118 |
} |
| 16119 |
|
| 16120 |
/*:1250*/ |
| 16121 |
#line 11770 "./marpa.w" |
| 16122 |
|
| 16123 |
if(O_is_Frozen(o)) |
| 16124 |
{ |
| 16125 |
MARPA_ERROR(MARPA_ERR_ORDER_FROZEN); |
| 16126 |
return failure_indicator; |
| 16127 |
} |
| 16128 |
/*1006:*/ |
| 16129 |
#line 11931 "./marpa.w" |
| 16130 |
|
| 16131 |
{ |
| 16132 |
int and_id; |
| 16133 |
const int and_count_of_r= AND_Count_of_B(b); |
| 16134 |
obs= OBS_of_O(o)= marpa_obs_init; |
| 16135 |
o->t_and_node_orderings= |
| 16136 |
and_node_orderings= |
| 16137 |
marpa_obs_new(obs,ANDID*,and_count_of_r); |
| 16138 |
for(and_id= 0;and_id<and_count_of_r;and_id++) |
| 16139 |
{ |
| 16140 |
and_node_orderings[and_id]= (ANDID*)NULL; |
| 16141 |
} |
| 16142 |
} |
| 16143 |
|
| 16144 |
/*:1006*/ |
| 16145 |
#line 11776 "./marpa.w" |
| 16146 |
|
| 16147 |
if(High_Rank_Count_of_O(o)){ |
| 16148 |
/*1001:*/ |
| 16149 |
#line 11791 "./marpa.w" |
| 16150 |
|
| 16151 |
{ |
| 16152 |
const AND and_nodes= ANDs_of_B(b); |
| 16153 |
const int or_node_count_of_b= OR_Count_of_B(b); |
| 16154 |
int or_node_id= 0; |
| 16155 |
|
| 16156 |
while(or_node_id<or_node_count_of_b) |
| 16157 |
{ |
| 16158 |
const OR work_or_node= OR_of_B_by_ID(b,or_node_id); |
| 16159 |
const ANDID and_count_of_or= AND_Count_of_OR(work_or_node); |
| 16160 |
/*1002:*/ |
| 16161 |
#line 11806 "./marpa.w" |
| 16162 |
|
| 16163 |
{ |
| 16164 |
if(and_count_of_or> 1) |
| 16165 |
{ |
| 16166 |
int high_rank_so_far= INT_MIN; |
| 16167 |
const ANDID first_and_node_id= First_ANDID_of_OR(work_or_node); |
| 16168 |
const ANDID last_and_node_id= |
| 16169 |
(first_and_node_id+and_count_of_or)-1; |
| 16170 |
ANDID*const order_base= |
| 16171 |
marpa_obs_start(obs, |
| 16172 |
sizeof(ANDID)*((size_t)and_count_of_or+1), |
| 16173 |
ALIGNOF(ANDID)); |
| 16174 |
ANDID*order= order_base+1; |
| 16175 |
ANDID and_node_id; |
| 16176 |
bocage_was_reordered= 1; |
| 16177 |
for(and_node_id= first_and_node_id;and_node_id<=last_and_node_id; |
| 16178 |
and_node_id++) |
| 16179 |
{ |
| 16180 |
const AND and_node= and_nodes+and_node_id; |
| 16181 |
int and_node_rank; |
| 16182 |
/*1003:*/ |
| 16183 |
#line 11844 "./marpa.w" |
| 16184 |
|
| 16185 |
{ |
| 16186 |
const OR cause_or= Cause_OR_of_AND(and_node); |
| 16187 |
if(OR_is_Token(cause_or)){ |
| 16188 |
const NSYID nsy_id= NSYID_of_OR(cause_or); |
| 16189 |
and_node_rank= Rank_of_NSY(NSY_by_ID(nsy_id)); |
| 16190 |
}else{ |
| 16191 |
and_node_rank= Rank_of_IRL(IRL_of_OR(cause_or)); |
| 16192 |
} |
| 16193 |
} |
| 16194 |
|
| 16195 |
/*:1003*/ |
| 16196 |
#line 11826 "./marpa.w" |
| 16197 |
|
| 16198 |
if(and_node_rank> high_rank_so_far) |
| 16199 |
{ |
| 16200 |
order= order_base+1; |
| 16201 |
high_rank_so_far= and_node_rank; |
| 16202 |
} |
| 16203 |
if(and_node_rank>=high_rank_so_far) |
| 16204 |
*order++= and_node_id; |
| 16205 |
} |
| 16206 |
{ |
| 16207 |
int final_count= (int)(order-order_base)-1; |
| 16208 |
*order_base= final_count; |
| 16209 |
marpa_obs_confirm_fast(obs,(int)sizeof(ANDID)*(final_count+1)); |
| 16210 |
and_node_orderings[or_node_id]= marpa_obs_finish(obs); |
| 16211 |
} |
| 16212 |
} |
| 16213 |
} |
| 16214 |
|
| 16215 |
/*:1002*/ |
| 16216 |
#line 11801 "./marpa.w" |
| 16217 |
|
| 16218 |
or_node_id++; |
| 16219 |
} |
| 16220 |
} |
| 16221 |
|
| 16222 |
/*:1001*/ |
| 16223 |
#line 11778 "./marpa.w" |
| 16224 |
|
| 16225 |
}else{ |
| 16226 |
/*1004:*/ |
| 16227 |
#line 11855 "./marpa.w" |
| 16228 |
|
| 16229 |
{ |
| 16230 |
const AND and_nodes= ANDs_of_B(b); |
| 16231 |
const int or_node_count_of_b= OR_Count_of_B(b); |
| 16232 |
const int and_node_count_of_b= AND_Count_of_B(b); |
| 16233 |
int or_node_id= 0; |
| 16234 |
int*rank_by_and_id= marpa_new(int,and_node_count_of_b); |
| 16235 |
int and_node_id; |
| 16236 |
for(and_node_id= 0;and_node_id<and_node_count_of_b;and_node_id++) |
| 16237 |
{ |
| 16238 |
const AND and_node= and_nodes+and_node_id; |
| 16239 |
int and_node_rank; |
| 16240 |
/*1003:*/ |
| 16241 |
#line 11844 "./marpa.w" |
| 16242 |
|
| 16243 |
{ |
| 16244 |
const OR cause_or= Cause_OR_of_AND(and_node); |
| 16245 |
if(OR_is_Token(cause_or)){ |
| 16246 |
const NSYID nsy_id= NSYID_of_OR(cause_or); |
| 16247 |
and_node_rank= Rank_of_NSY(NSY_by_ID(nsy_id)); |
| 16248 |
}else{ |
| 16249 |
and_node_rank= Rank_of_IRL(IRL_of_OR(cause_or)); |
| 16250 |
} |
| 16251 |
} |
| 16252 |
|
| 16253 |
/*:1003*/ |
| 16254 |
#line 11867 "./marpa.w" |
| 16255 |
|
| 16256 |
rank_by_and_id[and_node_id]= and_node_rank; |
| 16257 |
} |
| 16258 |
while(or_node_id<or_node_count_of_b) |
| 16259 |
{ |
| 16260 |
const OR work_or_node= OR_of_B_by_ID(b,or_node_id); |
| 16261 |
const ANDID and_count_of_or= AND_Count_of_OR(work_or_node); |
| 16262 |
/*1005:*/ |
| 16263 |
#line 11900 "./marpa.w" |
| 16264 |
|
| 16265 |
{ |
| 16266 |
if(and_count_of_or> 1) |
| 16267 |
{ |
| 16268 |
const ANDID first_and_node_id= First_ANDID_of_OR(work_or_node); |
| 16269 |
ANDID*const order_base= |
| 16270 |
marpa_obs_new(obs,ANDID,and_count_of_or+1); |
| 16271 |
ANDID*order= order_base+1; |
| 16272 |
int nodes_inserted_so_far; |
| 16273 |
bocage_was_reordered= 1; |
| 16274 |
and_node_orderings[or_node_id]= order_base; |
| 16275 |
*order_base= and_count_of_or; |
| 16276 |
for(nodes_inserted_so_far= 0;nodes_inserted_so_far<and_count_of_or; |
| 16277 |
nodes_inserted_so_far++) |
| 16278 |
{ |
| 16279 |
const ANDID new_and_node_id= |
| 16280 |
first_and_node_id+nodes_inserted_so_far; |
| 16281 |
int pre_insertion_ix= nodes_inserted_so_far-1; |
| 16282 |
while(pre_insertion_ix>=0) |
| 16283 |
{ |
| 16284 |
if(rank_by_and_id[new_and_node_id]<= |
| 16285 |
rank_by_and_id[order[pre_insertion_ix]]) |
| 16286 |
break; |
| 16287 |
order[pre_insertion_ix+1]= order[pre_insertion_ix]; |
| 16288 |
pre_insertion_ix--; |
| 16289 |
} |
| 16290 |
order[pre_insertion_ix+1]= new_and_node_id; |
| 16291 |
} |
| 16292 |
} |
| 16293 |
} |
| 16294 |
|
| 16295 |
/*:1005*/ |
| 16296 |
#line 11874 "./marpa.w" |
| 16297 |
|
| 16298 |
or_node_id++; |
| 16299 |
} |
| 16300 |
my_free(rank_by_and_id); |
| 16301 |
} |
| 16302 |
|
| 16303 |
/*:1004*/ |
| 16304 |
#line 11780 "./marpa.w" |
| 16305 |
|
| 16306 |
} |
| 16307 |
if(!bocage_was_reordered){ |
| 16308 |
marpa_obs_free(obs); |
| 16309 |
OBS_of_O(o)= NULL; |
| 16310 |
o->t_and_node_orderings= NULL; |
| 16311 |
} |
| 16312 |
O_is_Frozen(o)= 1; |
| 16313 |
return 1; |
| 16314 |
} |
| 16315 |
|
| 16316 |
/*:1000*//*1007:*/ |
| 16317 |
#line 11948 "./marpa.w" |
| 16318 |
|
| 16319 |
PRIVATE ANDID and_order_ix_is_valid(ORDER o,OR or_node,int ix) |
| 16320 |
{ |
| 16321 |
if(ix>=AND_Count_of_OR(or_node))return 0; |
| 16322 |
if(!O_is_Default(o)) |
| 16323 |
{ |
| 16324 |
ANDID**const and_node_orderings= o->t_and_node_orderings; |
| 16325 |
ORID or_node_id= ID_of_OR(or_node); |
| 16326 |
ANDID*ordering= and_node_orderings[or_node_id]; |
| 16327 |
if(ordering) |
| 16328 |
{ |
| 16329 |
int length= ordering[0]; |
| 16330 |
if(ix>=length)return 0; |
| 16331 |
} |
| 16332 |
} |
| 16333 |
return 1; |
| 16334 |
} |
| 16335 |
|
| 16336 |
/*:1007*//*1008:*/ |
| 16337 |
#line 11969 "./marpa.w" |
| 16338 |
|
| 16339 |
PRIVATE ANDID and_order_get(ORDER o,OR or_node,int ix) |
| 16340 |
{ |
| 16341 |
if(!O_is_Default(o)) |
| 16342 |
{ |
| 16343 |
ANDID**const and_node_orderings= o->t_and_node_orderings; |
| 16344 |
ORID or_node_id= ID_of_OR(or_node); |
| 16345 |
ANDID*ordering= and_node_orderings[or_node_id]; |
| 16346 |
if(ordering) |
| 16347 |
return ordering[1+ix]; |
| 16348 |
} |
| 16349 |
return First_ANDID_of_OR(or_node)+ix; |
| 16350 |
} |
| 16351 |
|
| 16352 |
/*:1008*//*1009:*/ |
| 16353 |
#line 11983 "./marpa.w" |
| 16354 |
|
| 16355 |
Marpa_And_Node_ID _marpa_o_and_order_get(Marpa_Order o, |
| 16356 |
Marpa_Or_Node_ID or_node_id,int ix) |
| 16357 |
{ |
| 16358 |
OR or_node; |
| 16359 |
/*1230:*/ |
| 16360 |
#line 14864 "./marpa.w" |
| 16361 |
const int failure_indicator= -2; |
| 16362 |
|
| 16363 |
/*:1230*/ |
| 16364 |
#line 11988 "./marpa.w" |
| 16365 |
|
| 16366 |
/*985:*/ |
| 16367 |
#line 11573 "./marpa.w" |
| 16368 |
|
| 16369 |
const BOCAGE b= B_of_O(o); |
| 16370 |
/*939:*/ |
| 16371 |
#line 11160 "./marpa.w" |
| 16372 |
|
| 16373 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 16374 |
|
| 16375 |
/*:939*/ |
| 16376 |
#line 11575 "./marpa.w" |
| 16377 |
|
| 16378 |
|
| 16379 |
/*:985*/ |
| 16380 |
#line 11989 "./marpa.w" |
| 16381 |
|
| 16382 |
/*1250:*/ |
| 16383 |
#line 14997 "./marpa.w" |
| 16384 |
|
| 16385 |
if(HEADER_VERSION_MISMATCH){ |
| 16386 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 16387 |
return failure_indicator; |
| 16388 |
} |
| 16389 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 16390 |
MARPA_ERROR(g->t_error); |
| 16391 |
return failure_indicator; |
| 16392 |
} |
| 16393 |
|
| 16394 |
/*:1250*/ |
| 16395 |
#line 11990 "./marpa.w" |
| 16396 |
|
| 16397 |
/*1318:*/ |
| 16398 |
#line 15982 "./marpa.w" |
| 16399 |
|
| 16400 |
{ |
| 16401 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Count_of_B(b))) |
| 16402 |
{ |
| 16403 |
return-1; |
| 16404 |
} |
| 16405 |
if(_MARPA_UNLIKELY(or_node_id<0)) |
| 16406 |
{ |
| 16407 |
MARPA_ERROR(MARPA_ERR_ORID_NEGATIVE); |
| 16408 |
return failure_indicator; |
| 16409 |
} |
| 16410 |
} |
| 16411 |
/*:1318*/ |
| 16412 |
#line 11991 "./marpa.w" |
| 16413 |
|
| 16414 |
/*1319:*/ |
| 16415 |
#line 15994 "./marpa.w" |
| 16416 |
|
| 16417 |
{ |
| 16418 |
if(_MARPA_UNLIKELY(!ORs_of_B(b))) |
| 16419 |
{ |
| 16420 |
MARPA_ERROR(MARPA_ERR_NO_OR_NODES); |
| 16421 |
return failure_indicator; |
| 16422 |
} |
| 16423 |
or_node= OR_of_B_by_ID(b,or_node_id); |
| 16424 |
} |
| 16425 |
|
| 16426 |
/*:1319*/ |
| 16427 |
#line 11992 "./marpa.w" |
| 16428 |
|
| 16429 |
if(ix<0){ |
| 16430 |
MARPA_ERROR(MARPA_ERR_ANDIX_NEGATIVE); |
| 16431 |
return failure_indicator; |
| 16432 |
} |
| 16433 |
if(!and_order_ix_is_valid(o,or_node,ix))return-1; |
| 16434 |
return and_order_get(o,or_node,ix); |
| 16435 |
} |
| 16436 |
|
| 16437 |
/*:1009*//*1025:*/ |
| 16438 |
#line 12091 "./marpa.w" |
| 16439 |
|
| 16440 |
PRIVATE void tree_exhaust(TREE t) |
| 16441 |
{ |
| 16442 |
if(MARPA_DSTACK_IS_INITIALIZED(t->t_nook_stack)) |
| 16443 |
{ |
| 16444 |
MARPA_DSTACK_DESTROY(t->t_nook_stack); |
| 16445 |
MARPA_DSTACK_SAFE(t->t_nook_stack); |
| 16446 |
} |
| 16447 |
if(MARPA_DSTACK_IS_INITIALIZED(t->t_nook_worklist)) |
| 16448 |
{ |
| 16449 |
MARPA_DSTACK_DESTROY(t->t_nook_worklist); |
| 16450 |
MARPA_DSTACK_SAFE(t->t_nook_worklist); |
| 16451 |
} |
| 16452 |
bv_free(t->t_or_node_in_use); |
| 16453 |
t->t_or_node_in_use= NULL; |
| 16454 |
T_is_Exhausted(t)= 1; |
| 16455 |
} |
| 16456 |
|
| 16457 |
/*:1025*//*1026:*/ |
| 16458 |
#line 12109 "./marpa.w" |
| 16459 |
|
| 16460 |
Marpa_Tree marpa_t_new(Marpa_Order o) |
| 16461 |
{ |
| 16462 |
/*1229:*/ |
| 16463 |
#line 14861 "./marpa.w" |
| 16464 |
void*const failure_indicator= NULL; |
| 16465 |
/*:1229*/ |
| 16466 |
#line 12112 "./marpa.w" |
| 16467 |
|
| 16468 |
TREE t; |
| 16469 |
/*985:*/ |
| 16470 |
#line 11573 "./marpa.w" |
| 16471 |
|
| 16472 |
const BOCAGE b= B_of_O(o); |
| 16473 |
/*939:*/ |
| 16474 |
#line 11160 "./marpa.w" |
| 16475 |
|
| 16476 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 16477 |
|
| 16478 |
/*:939*/ |
| 16479 |
#line 11575 "./marpa.w" |
| 16480 |
|
| 16481 |
|
| 16482 |
/*:985*/ |
| 16483 |
#line 12114 "./marpa.w" |
| 16484 |
|
| 16485 |
/*1250:*/ |
| 16486 |
#line 14997 "./marpa.w" |
| 16487 |
|
| 16488 |
if(HEADER_VERSION_MISMATCH){ |
| 16489 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 16490 |
return failure_indicator; |
| 16491 |
} |
| 16492 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 16493 |
MARPA_ERROR(g->t_error); |
| 16494 |
return failure_indicator; |
| 16495 |
} |
| 16496 |
|
| 16497 |
/*:1250*/ |
| 16498 |
#line 12115 "./marpa.w" |
| 16499 |
|
| 16500 |
t= my_malloc(sizeof(*t)); |
| 16501 |
O_of_T(t)= o; |
| 16502 |
order_ref(o); |
| 16503 |
O_is_Frozen(o)= 1; |
| 16504 |
/*1043:*/ |
| 16505 |
#line 12301 "./marpa.w" |
| 16506 |
|
| 16507 |
T_is_Exhausted(t)= 0; |
| 16508 |
|
| 16509 |
/*:1043*/ |
| 16510 |
#line 12120 "./marpa.w" |
| 16511 |
|
| 16512 |
/*1027:*/ |
| 16513 |
#line 12125 "./marpa.w" |
| 16514 |
|
| 16515 |
{ |
| 16516 |
t->t_parse_count= 0; |
| 16517 |
if(O_is_Nulling(o)) |
| 16518 |
{ |
| 16519 |
T_is_Nulling(t)= 1; |
| 16520 |
t->t_or_node_in_use= NULL; |
| 16521 |
MARPA_DSTACK_SAFE(t->t_nook_stack); |
| 16522 |
MARPA_DSTACK_SAFE(t->t_nook_worklist); |
| 16523 |
} |
| 16524 |
else |
| 16525 |
{ |
| 16526 |
const int and_count= AND_Count_of_B(b); |
| 16527 |
const int or_count= OR_Count_of_B(b); |
| 16528 |
T_is_Nulling(t)= 0; |
| 16529 |
t->t_or_node_in_use= bv_create(or_count); |
| 16530 |
MARPA_DSTACK_INIT(t->t_nook_stack,NOOK_Object,and_count); |
| 16531 |
MARPA_DSTACK_INIT(t->t_nook_worklist,NOOKID,and_count); |
| 16532 |
} |
| 16533 |
} |
| 16534 |
|
| 16535 |
/*:1027*//*1030:*/ |
| 16536 |
#line 12149 "./marpa.w" |
| 16537 |
|
| 16538 |
t->t_ref_count= 1; |
| 16539 |
|
| 16540 |
/*:1030*//*1037:*/ |
| 16541 |
#line 12228 "./marpa.w" |
| 16542 |
t->t_pause_counter= 0; |
| 16543 |
/*:1037*/ |
| 16544 |
#line 12121 "./marpa.w" |
| 16545 |
|
| 16546 |
return t; |
| 16547 |
} |
| 16548 |
|
| 16549 |
/*:1026*//*1031:*/ |
| 16550 |
#line 12153 "./marpa.w" |
| 16551 |
|
| 16552 |
PRIVATE void |
| 16553 |
tree_unref(TREE t) |
| 16554 |
{ |
| 16555 |
MARPA_ASSERT(t->t_ref_count> 0) |
| 16556 |
t->t_ref_count--; |
| 16557 |
if(t->t_ref_count<=0) |
| 16558 |
{ |
| 16559 |
tree_free(t); |
| 16560 |
} |
| 16561 |
} |
| 16562 |
void |
| 16563 |
marpa_t_unref(Marpa_Tree t) |
| 16564 |
{ |
| 16565 |
tree_unref(t); |
| 16566 |
} |
| 16567 |
|
| 16568 |
/*:1031*//*1032:*/ |
| 16569 |
#line 12171 "./marpa.w" |
| 16570 |
|
| 16571 |
PRIVATE TREE |
| 16572 |
tree_ref(TREE t) |
| 16573 |
{ |
| 16574 |
MARPA_ASSERT(t->t_ref_count> 0) |
| 16575 |
t->t_ref_count++; |
| 16576 |
return t; |
| 16577 |
} |
| 16578 |
Marpa_Tree |
| 16579 |
marpa_t_ref(Marpa_Tree t) |
| 16580 |
{ |
| 16581 |
return tree_ref(t); |
| 16582 |
} |
| 16583 |
|
| 16584 |
/*:1032*//*1033:*/ |
| 16585 |
#line 12185 "./marpa.w" |
| 16586 |
|
| 16587 |
PRIVATE void tree_free(TREE t) |
| 16588 |
{ |
| 16589 |
order_unref(O_of_T(t)); |
| 16590 |
tree_exhaust(t); |
| 16591 |
my_free(t); |
| 16592 |
} |
| 16593 |
|
| 16594 |
/*:1033*//*1038:*/ |
| 16595 |
#line 12229 "./marpa.w" |
| 16596 |
|
| 16597 |
PRIVATE void |
| 16598 |
tree_pause(TREE t) |
| 16599 |
{ |
| 16600 |
MARPA_ASSERT(t->t_pause_counter>=0); |
| 16601 |
MARPA_ASSERT(t->t_ref_count>=t->t_pause_counter); |
| 16602 |
t->t_pause_counter++; |
| 16603 |
tree_ref(t); |
| 16604 |
} |
| 16605 |
/*:1038*//*1039:*/ |
| 16606 |
#line 12238 "./marpa.w" |
| 16607 |
|
| 16608 |
PRIVATE void |
| 16609 |
tree_unpause(TREE t) |
| 16610 |
{ |
| 16611 |
MARPA_ASSERT(t->t_pause_counter> 0); |
| 16612 |
MARPA_ASSERT(t->t_ref_count>=t->t_pause_counter); |
| 16613 |
t->t_pause_counter--; |
| 16614 |
tree_unref(t); |
| 16615 |
} |
| 16616 |
|
| 16617 |
/*:1039*//*1040:*/ |
| 16618 |
#line 12248 "./marpa.w" |
| 16619 |
|
| 16620 |
int marpa_t_next(Marpa_Tree t) |
| 16621 |
{ |
| 16622 |
/*1230:*/ |
| 16623 |
#line 14864 "./marpa.w" |
| 16624 |
const int failure_indicator= -2; |
| 16625 |
|
| 16626 |
/*:1230*/ |
| 16627 |
#line 12251 "./marpa.w" |
| 16628 |
|
| 16629 |
const int termination_indicator= -1; |
| 16630 |
int is_first_tree_attempt= (t->t_parse_count<1); |
| 16631 |
/*1024:*/ |
| 16632 |
#line 12087 "./marpa.w" |
| 16633 |
|
| 16634 |
ORDER o= O_of_T(t); |
| 16635 |
/*985:*/ |
| 16636 |
#line 11573 "./marpa.w" |
| 16637 |
|
| 16638 |
const BOCAGE b= B_of_O(o); |
| 16639 |
/*939:*/ |
| 16640 |
#line 11160 "./marpa.w" |
| 16641 |
|
| 16642 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 16643 |
|
| 16644 |
/*:939*/ |
| 16645 |
#line 11575 "./marpa.w" |
| 16646 |
|
| 16647 |
|
| 16648 |
/*:985*/ |
| 16649 |
#line 12089 "./marpa.w" |
| 16650 |
; |
| 16651 |
|
| 16652 |
/*:1024*/ |
| 16653 |
#line 12254 "./marpa.w" |
| 16654 |
|
| 16655 |
/*1250:*/ |
| 16656 |
#line 14997 "./marpa.w" |
| 16657 |
|
| 16658 |
if(HEADER_VERSION_MISMATCH){ |
| 16659 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 16660 |
return failure_indicator; |
| 16661 |
} |
| 16662 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 16663 |
MARPA_ERROR(g->t_error); |
| 16664 |
return failure_indicator; |
| 16665 |
} |
| 16666 |
|
| 16667 |
/*:1250*/ |
| 16668 |
#line 12255 "./marpa.w" |
| 16669 |
|
| 16670 |
if(T_is_Paused(t)){ |
| 16671 |
MARPA_ERROR(MARPA_ERR_TREE_PAUSED); |
| 16672 |
return failure_indicator; |
| 16673 |
} |
| 16674 |
|
| 16675 |
if(T_is_Exhausted(t)) |
| 16676 |
{ |
| 16677 |
MARPA_ERROR(MARPA_ERR_TREE_EXHAUSTED); |
| 16678 |
return termination_indicator; |
| 16679 |
} |
| 16680 |
|
| 16681 |
if(T_is_Nulling(t)){ |
| 16682 |
if(is_first_tree_attempt){ |
| 16683 |
t->t_parse_count++; |
| 16684 |
return 0; |
| 16685 |
}else{ |
| 16686 |
goto TREE_IS_EXHAUSTED; |
| 16687 |
} |
| 16688 |
} |
| 16689 |
|
| 16690 |
while(1){ |
| 16691 |
const AND ands_of_b= ANDs_of_B(b); |
| 16692 |
if(is_first_tree_attempt){ |
| 16693 |
is_first_tree_attempt= 0; |
| 16694 |
/*1049:*/ |
| 16695 |
#line 12341 "./marpa.w" |
| 16696 |
|
| 16697 |
{ |
| 16698 |
ORID root_or_id= Top_ORID_of_B(b); |
| 16699 |
OR root_or_node= OR_of_B_by_ID(b,root_or_id); |
| 16700 |
NOOK nook; |
| 16701 |
|
| 16702 |
|
| 16703 |
|
| 16704 |
const int choice= 0; |
| 16705 |
if(!and_order_ix_is_valid(o,root_or_node,choice)) |
| 16706 |
goto TREE_IS_EXHAUSTED; |
| 16707 |
nook= MARPA_DSTACK_PUSH(t->t_nook_stack,NOOK_Object); |
| 16708 |
tree_or_node_try(t,root_or_id); |
| 16709 |
OR_of_NOOK(nook)= root_or_node; |
| 16710 |
Choice_of_NOOK(nook)= choice; |
| 16711 |
Parent_of_NOOK(nook)= -1; |
| 16712 |
NOOK_Cause_is_Expanded(nook)= 0; |
| 16713 |
NOOK_is_Cause(nook)= 0; |
| 16714 |
NOOK_Predecessor_is_Expanded(nook)= 0; |
| 16715 |
NOOK_is_Predecessor(nook)= 0; |
| 16716 |
} |
| 16717 |
|
| 16718 |
/*:1049*/ |
| 16719 |
#line 12280 "./marpa.w" |
| 16720 |
|
| 16721 |
}else{ |
| 16722 |
/*1050:*/ |
| 16723 |
#line 12366 "./marpa.w" |
| 16724 |
{ |
| 16725 |
MARPA_DEBUG1("Start new iteration of tree"); |
| 16726 |
while(1){ |
| 16727 |
OR iteration_candidate_or_node; |
| 16728 |
const NOOK iteration_candidate= MARPA_DSTACK_TOP(t->t_nook_stack,NOOK_Object); |
| 16729 |
int choice; |
| 16730 |
if(!iteration_candidate)break; |
| 16731 |
iteration_candidate_or_node= OR_of_NOOK(iteration_candidate); |
| 16732 |
choice= Choice_of_NOOK(iteration_candidate)+1; |
| 16733 |
MARPA_ASSERT(choice> 0); |
| 16734 |
if(and_order_ix_is_valid(o,iteration_candidate_or_node,choice)){ |
| 16735 |
|
| 16736 |
|
| 16737 |
|
| 16738 |
|
| 16739 |
|
| 16740 |
Choice_of_NOOK(iteration_candidate)= choice; |
| 16741 |
NOOK_Cause_is_Expanded(iteration_candidate)= 0; |
| 16742 |
NOOK_Predecessor_is_Expanded(iteration_candidate)= 0; |
| 16743 |
break; |
| 16744 |
} |
| 16745 |
{ |
| 16746 |
|
| 16747 |
|
| 16748 |
const int parent_nook_ix= Parent_of_NOOK(iteration_candidate); |
| 16749 |
if(parent_nook_ix>=0){ |
| 16750 |
NOOK parent_nook= NOOK_of_TREE_by_IX(t,parent_nook_ix); |
| 16751 |
if(NOOK_is_Cause(iteration_candidate)){ |
| 16752 |
NOOK_Cause_is_Expanded(parent_nook)= 0; |
| 16753 |
} |
| 16754 |
if(NOOK_is_Predecessor(iteration_candidate)){ |
| 16755 |
NOOK_Predecessor_is_Expanded(parent_nook)= 0; |
| 16756 |
} |
| 16757 |
} |
| 16758 |
|
| 16759 |
|
| 16760 |
tree_or_node_release(t,ID_of_OR(iteration_candidate_or_node)); |
| 16761 |
MARPA_DSTACK_POP(t->t_nook_stack,NOOK_Object); |
| 16762 |
} |
| 16763 |
} |
| 16764 |
if(Size_of_T(t)<=0)goto TREE_IS_EXHAUSTED; |
| 16765 |
} |
| 16766 |
|
| 16767 |
/*:1050*/ |
| 16768 |
#line 12282 "./marpa.w" |
| 16769 |
|
| 16770 |
} |
| 16771 |
/*1054:*/ |
| 16772 |
#line 12428 "./marpa.w" |
| 16773 |
{ |
| 16774 |
{ |
| 16775 |
const int stack_length= Size_of_T(t); |
| 16776 |
int i; |
| 16777 |
|
| 16778 |
|
| 16779 |
|
| 16780 |
|
| 16781 |
MARPA_DSTACK_CLEAR(t->t_nook_worklist); |
| 16782 |
for(i= 0;i<stack_length;i++){ |
| 16783 |
*(MARPA_DSTACK_PUSH(t->t_nook_worklist,NOOKID))= i; |
| 16784 |
} |
| 16785 |
} |
| 16786 |
while(1){ |
| 16787 |
NOOKID work_nook_id; |
| 16788 |
NOOK work_nook; |
| 16789 |
ANDID work_and_node_id; |
| 16790 |
AND work_and_node; |
| 16791 |
OR work_or_node; |
| 16792 |
OR child_or_node= NULL; |
| 16793 |
int choice; |
| 16794 |
int child_is_cause= 0; |
| 16795 |
int child_is_predecessor= 0; |
| 16796 |
if(MARPA_DSTACK_LENGTH(t->t_nook_worklist)<=0){goto TREE_IS_FINISHED;} |
| 16797 |
work_nook_id= *MARPA_DSTACK_TOP(t->t_nook_worklist,NOOKID); |
| 16798 |
work_nook= NOOK_of_TREE_by_IX(t,work_nook_id); |
| 16799 |
work_or_node= OR_of_NOOK(work_nook); |
| 16800 |
work_and_node_id= and_order_get(o,work_or_node,Choice_of_NOOK(work_nook)); |
| 16801 |
work_and_node= ands_of_b+work_and_node_id; |
| 16802 |
do |
| 16803 |
{ |
| 16804 |
if(!NOOK_Cause_is_Expanded(work_nook)) |
| 16805 |
{ |
| 16806 |
const OR cause_or_node= Cause_OR_of_AND(work_and_node); |
| 16807 |
if(!OR_is_Token(cause_or_node)) |
| 16808 |
{ |
| 16809 |
child_or_node= cause_or_node; |
| 16810 |
child_is_cause= 1; |
| 16811 |
MARPA_DEBUG3("Work nook ID is %ld, child OR %ld is cause", |
| 16812 |
(long)work_nook_id,ID_of_OR(child_or_node)); |
| 16813 |
break; |
| 16814 |
} |
| 16815 |
} |
| 16816 |
NOOK_Cause_is_Expanded(work_nook)= 1; |
| 16817 |
if(!NOOK_Predecessor_is_Expanded(work_nook)) |
| 16818 |
{ |
| 16819 |
child_or_node= Predecessor_OR_of_AND(work_and_node); |
| 16820 |
if(child_or_node) |
| 16821 |
{ |
| 16822 |
child_is_predecessor= 1; |
| 16823 |
MARPA_DEBUG3("Work nook ID is %ld, child OR %ld is predecessor", |
| 16824 |
(long)work_nook_id,ID_of_OR(child_or_node)); |
| 16825 |
break; |
| 16826 |
} |
| 16827 |
} |
| 16828 |
NOOK_Predecessor_is_Expanded(work_nook)= 1; |
| 16829 |
MARPA_DSTACK_POP(t->t_nook_worklist,NOOKID); |
| 16830 |
goto NEXT_NOOK_ON_WORKLIST; |
| 16831 |
} |
| 16832 |
while(0); |
| 16833 |
/*1064:*/ |
| 16834 |
#line 12624 "./marpa.w" |
| 16835 |
|
| 16836 |
{ |
| 16837 |
/*1062:*/ |
| 16838 |
#line 12599 "./marpa.w" |
| 16839 |
|
| 16840 |
/*1061:*/ |
| 16841 |
#line 12584 "./marpa.w" |
| 16842 |
|
| 16843 |
/*1056:*/ |
| 16844 |
#line 12521 "./marpa.w" |
| 16845 |
|
| 16846 |
|
| 16847 |
/*:1056*/ |
| 16848 |
#line 12585 "./marpa.w" |
| 16849 |
|
| 16850 |
/*1059:*/ |
| 16851 |
#line 12546 "./marpa.w" |
| 16852 |
|
| 16853 |
|
| 16854 |
/*:1059*/ |
| 16855 |
#line 12586 "./marpa.w" |
| 16856 |
|
| 16857 |
/*1060:*/ |
| 16858 |
#line 12571 "./marpa.w" |
| 16859 |
|
| 16860 |
|
| 16861 |
/*:1060*/ |
| 16862 |
#line 12587 "./marpa.w" |
| 16863 |
|
| 16864 |
|
| 16865 |
/*:1061*/ |
| 16866 |
#line 12600 "./marpa.w" |
| 16867 |
|
| 16868 |
|
| 16869 |
/*:1062*/ |
| 16870 |
#line 12626 "./marpa.w" |
| 16871 |
|
| 16872 |
/*1063:*/ |
| 16873 |
#line 12621 "./marpa.w" |
| 16874 |
|
| 16875 |
/*1061:*/ |
| 16876 |
#line 12584 "./marpa.w" |
| 16877 |
|
| 16878 |
/*1056:*/ |
| 16879 |
#line 12521 "./marpa.w" |
| 16880 |
|
| 16881 |
|
| 16882 |
/*:1056*/ |
| 16883 |
#line 12585 "./marpa.w" |
| 16884 |
|
| 16885 |
/*1059:*/ |
| 16886 |
#line 12546 "./marpa.w" |
| 16887 |
|
| 16888 |
|
| 16889 |
/*:1059*/ |
| 16890 |
#line 12586 "./marpa.w" |
| 16891 |
|
| 16892 |
/*1060:*/ |
| 16893 |
#line 12571 "./marpa.w" |
| 16894 |
|
| 16895 |
|
| 16896 |
/*:1060*/ |
| 16897 |
#line 12587 "./marpa.w" |
| 16898 |
|
| 16899 |
|
| 16900 |
/*:1061*/ |
| 16901 |
#line 12622 "./marpa.w" |
| 16902 |
|
| 16903 |
|
| 16904 |
/*:1063*/ |
| 16905 |
#line 12627 "./marpa.w" |
| 16906 |
|
| 16907 |
MARPA_DEBUG3("Before check for duplicate or node, node=%lx ID=%ld", |
| 16908 |
(long)child_or_node,(long)ID_of_OR(child_or_node)); |
| 16909 |
|
| 16910 |
|
| 16911 |
|
| 16912 |
if(Length_of_OR(child_or_node) |
| 16913 |
&&!tree_or_node_try(t,ID_of_OR(child_or_node)) |
| 16914 |
)goto NEXT_TREE; |
| 16915 |
MARPA_DEBUG3("After check for duplicate or node, node=%lx ID=%ld", |
| 16916 |
(long)child_or_node,(long)ID_of_OR(child_or_node)); |
| 16917 |
} |
| 16918 |
|
| 16919 |
/*:1064*/ |
| 16920 |
#line 12488 "./marpa.w" |
| 16921 |
|
| 16922 |
choice= 0; |
| 16923 |
if(!and_order_ix_is_valid(o,child_or_node,choice))goto NEXT_TREE; |
| 16924 |
MARPA_DEBUG2("After check for valid and order ix, node=%lx",(long)child_or_node); |
| 16925 |
/*1065:*/ |
| 16926 |
#line 12640 "./marpa.w" |
| 16927 |
|
| 16928 |
{ |
| 16929 |
NOOKID new_nook_id= Size_of_T(t); |
| 16930 |
NOOK new_nook= MARPA_DSTACK_PUSH(t->t_nook_stack,NOOK_Object); |
| 16931 |
*(MARPA_DSTACK_PUSH(t->t_nook_worklist,NOOKID))= new_nook_id; |
| 16932 |
work_nook= NOOK_of_TREE_by_IX(t,work_nook_id); |
| 16933 |
|
| 16934 |
Parent_of_NOOK(new_nook)= work_nook_id; |
| 16935 |
Choice_of_NOOK(new_nook)= choice; |
| 16936 |
OR_of_NOOK(new_nook)= child_or_node; |
| 16937 |
MARPA_DEBUG5("New node is %ld, OR=%ld, choice=%ld, AND=%ld\n", |
| 16938 |
(long)new_nook_id,(long)ID_of_OR(child_or_node),(long)choice, |
| 16939 |
(long)and_order_get(o,child_or_node,choice)); |
| 16940 |
NOOK_Cause_is_Expanded(new_nook)= 0; |
| 16941 |
if((NOOK_is_Cause(new_nook)= Boolean(child_is_cause))) |
| 16942 |
{ |
| 16943 |
NOOK_Cause_is_Expanded(work_nook)= 1; |
| 16944 |
} |
| 16945 |
NOOK_Predecessor_is_Expanded(new_nook)= 0; |
| 16946 |
if((NOOK_is_Predecessor(new_nook)= Boolean(child_is_predecessor))) |
| 16947 |
{ |
| 16948 |
NOOK_Predecessor_is_Expanded(work_nook)= 1; |
| 16949 |
} |
| 16950 |
} |
| 16951 |
|
| 16952 |
/*:1065*/ |
| 16953 |
#line 12492 "./marpa.w" |
| 16954 |
; |
| 16955 |
NEXT_NOOK_ON_WORKLIST:; |
| 16956 |
} |
| 16957 |
NEXT_TREE:; |
| 16958 |
} |
| 16959 |
|
| 16960 |
/*:1054*/ |
| 16961 |
#line 12284 "./marpa.w" |
| 16962 |
|
| 16963 |
} |
| 16964 |
TREE_IS_FINISHED:; |
| 16965 |
t->t_parse_count++; |
| 16966 |
return MARPA_DSTACK_LENGTH(t->t_nook_stack); |
| 16967 |
TREE_IS_EXHAUSTED:; |
| 16968 |
tree_exhaust(t); |
| 16969 |
MARPA_ERROR(MARPA_ERR_TREE_EXHAUSTED); |
| 16970 |
return termination_indicator; |
| 16971 |
|
| 16972 |
} |
| 16973 |
|
| 16974 |
/*:1040*//*1047:*/ |
| 16975 |
#line 12318 "./marpa.w" |
| 16976 |
|
| 16977 |
PRIVATE int tree_or_node_try(TREE tree,ORID or_node_id) |
| 16978 |
{ |
| 16979 |
return!bv_bit_test_then_set(tree->t_or_node_in_use,or_node_id); |
| 16980 |
} |
| 16981 |
/*:1047*//*1048:*/ |
| 16982 |
#line 12327 "./marpa.w" |
| 16983 |
|
| 16984 |
PRIVATE void tree_or_node_release(TREE tree,ORID or_node_id) |
| 16985 |
{ |
| 16986 |
bv_bit_clear(tree->t_or_node_in_use,or_node_id); |
| 16987 |
} |
| 16988 |
|
| 16989 |
/*:1048*//*1066:*/ |
| 16990 |
#line 12666 "./marpa.w" |
| 16991 |
|
| 16992 |
int marpa_t_parse_count(Marpa_Tree t) |
| 16993 |
{ |
| 16994 |
return t->t_parse_count; |
| 16995 |
} |
| 16996 |
|
| 16997 |
/*:1066*//*1067:*/ |
| 16998 |
#line 12674 "./marpa.w" |
| 16999 |
|
| 17000 |
int _marpa_t_size(Marpa_Tree t) |
| 17001 |
{ |
| 17002 |
/*1230:*/ |
| 17003 |
#line 14864 "./marpa.w" |
| 17004 |
const int failure_indicator= -2; |
| 17005 |
|
| 17006 |
/*:1230*/ |
| 17007 |
#line 12677 "./marpa.w" |
| 17008 |
|
| 17009 |
/*1024:*/ |
| 17010 |
#line 12087 "./marpa.w" |
| 17011 |
|
| 17012 |
ORDER o= O_of_T(t); |
| 17013 |
/*985:*/ |
| 17014 |
#line 11573 "./marpa.w" |
| 17015 |
|
| 17016 |
const BOCAGE b= B_of_O(o); |
| 17017 |
/*939:*/ |
| 17018 |
#line 11160 "./marpa.w" |
| 17019 |
|
| 17020 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 17021 |
|
| 17022 |
/*:939*/ |
| 17023 |
#line 11575 "./marpa.w" |
| 17024 |
|
| 17025 |
|
| 17026 |
/*:985*/ |
| 17027 |
#line 12089 "./marpa.w" |
| 17028 |
; |
| 17029 |
|
| 17030 |
/*:1024*/ |
| 17031 |
#line 12678 "./marpa.w" |
| 17032 |
|
| 17033 |
/*1250:*/ |
| 17034 |
#line 14997 "./marpa.w" |
| 17035 |
|
| 17036 |
if(HEADER_VERSION_MISMATCH){ |
| 17037 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 17038 |
return failure_indicator; |
| 17039 |
} |
| 17040 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 17041 |
MARPA_ERROR(g->t_error); |
| 17042 |
return failure_indicator; |
| 17043 |
} |
| 17044 |
|
| 17045 |
/*:1250*/ |
| 17046 |
#line 12679 "./marpa.w" |
| 17047 |
|
| 17048 |
if(T_is_Exhausted(t)){ |
| 17049 |
MARPA_ERROR(MARPA_ERR_TREE_EXHAUSTED); |
| 17050 |
return failure_indicator; |
| 17051 |
} |
| 17052 |
if(T_is_Nulling(t))return 0; |
| 17053 |
return Size_of_T(t); |
| 17054 |
} |
| 17055 |
|
| 17056 |
/*:1067*//*1084:*/ |
| 17057 |
#line 12862 "./marpa.w" |
| 17058 |
|
| 17059 |
Marpa_Value marpa_v_new(Marpa_Tree t) |
| 17060 |
{ |
| 17061 |
/*1229:*/ |
| 17062 |
#line 14861 "./marpa.w" |
| 17063 |
void*const failure_indicator= NULL; |
| 17064 |
/*:1229*/ |
| 17065 |
#line 12865 "./marpa.w" |
| 17066 |
|
| 17067 |
/*1024:*/ |
| 17068 |
#line 12087 "./marpa.w" |
| 17069 |
|
| 17070 |
ORDER o= O_of_T(t); |
| 17071 |
/*985:*/ |
| 17072 |
#line 11573 "./marpa.w" |
| 17073 |
|
| 17074 |
const BOCAGE b= B_of_O(o); |
| 17075 |
/*939:*/ |
| 17076 |
#line 11160 "./marpa.w" |
| 17077 |
|
| 17078 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 17079 |
|
| 17080 |
/*:939*/ |
| 17081 |
#line 11575 "./marpa.w" |
| 17082 |
|
| 17083 |
|
| 17084 |
/*:985*/ |
| 17085 |
#line 12089 "./marpa.w" |
| 17086 |
; |
| 17087 |
|
| 17088 |
/*:1024*/ |
| 17089 |
#line 12866 "./marpa.w" |
| 17090 |
; |
| 17091 |
/*1250:*/ |
| 17092 |
#line 14997 "./marpa.w" |
| 17093 |
|
| 17094 |
if(HEADER_VERSION_MISMATCH){ |
| 17095 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 17096 |
return failure_indicator; |
| 17097 |
} |
| 17098 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 17099 |
MARPA_ERROR(g->t_error); |
| 17100 |
return failure_indicator; |
| 17101 |
} |
| 17102 |
|
| 17103 |
/*:1250*/ |
| 17104 |
#line 12867 "./marpa.w" |
| 17105 |
|
| 17106 |
if(t->t_parse_count<=0){ |
| 17107 |
MARPA_ERROR(MARPA_ERR_BEFORE_FIRST_TREE); |
| 17108 |
return NULL; |
| 17109 |
} |
| 17110 |
if(!T_is_Exhausted(t)) |
| 17111 |
{ |
| 17112 |
const XSYID xsy_count= XSY_Count_of_G(g); |
| 17113 |
struct marpa_obstack*const obstack= marpa_obs_init; |
| 17114 |
const VALUE v= marpa_obs_new(obstack,struct s_value,1); |
| 17115 |
v->t_obs= obstack; |
| 17116 |
Step_Type_of_V(v)= Next_Value_Type_of_V(v)= MARPA_STEP_INITIAL; |
| 17117 |
/*1075:*/ |
| 17118 |
#line 12788 "./marpa.w" |
| 17119 |
|
| 17120 |
XSYID_of_V(v)= -1; |
| 17121 |
RULEID_of_V(v)= -1; |
| 17122 |
Token_Value_of_V(v)= -1; |
| 17123 |
Token_Type_of_V(v)= DUMMY_OR_NODE; |
| 17124 |
Arg_0_of_V(v)= -1; |
| 17125 |
Arg_N_of_V(v)= -1; |
| 17126 |
Result_of_V(v)= -1; |
| 17127 |
Rule_Start_of_V(v)= -1; |
| 17128 |
Token_Start_of_V(v)= -1; |
| 17129 |
YS_ID_of_V(v)= -1; |
| 17130 |
|
| 17131 |
/*:1075*//*1082:*/ |
| 17132 |
#line 12851 "./marpa.w" |
| 17133 |
|
| 17134 |
MARPA_DSTACK_SAFE(VStack_of_V(v)); |
| 17135 |
/*:1082*//*1087:*/ |
| 17136 |
#line 12899 "./marpa.w" |
| 17137 |
|
| 17138 |
v->t_ref_count= 1; |
| 17139 |
|
| 17140 |
/*:1087*//*1094:*/ |
| 17141 |
#line 12952 "./marpa.w" |
| 17142 |
|
| 17143 |
V_is_Nulling(v)= 0; |
| 17144 |
|
| 17145 |
/*:1094*//*1096:*/ |
| 17146 |
#line 12959 "./marpa.w" |
| 17147 |
|
| 17148 |
V_is_Trace(v)= 0; |
| 17149 |
/*:1096*//*1099:*/ |
| 17150 |
#line 12980 "./marpa.w" |
| 17151 |
|
| 17152 |
NOOK_of_V(v)= -1; |
| 17153 |
/*:1099*//*1104:*/ |
| 17154 |
#line 13007 "./marpa.w" |
| 17155 |
|
| 17156 |
{ |
| 17157 |
XSY_is_Valued_BV_of_V(v)= lbv_clone(v->t_obs,Valued_BV_of_B(b),xsy_count); |
| 17158 |
Valued_Locked_BV_of_V(v)= |
| 17159 |
lbv_clone(v->t_obs,Valued_Locked_BV_of_B(b),xsy_count); |
| 17160 |
} |
| 17161 |
|
| 17162 |
|
| 17163 |
/*:1104*/ |
| 17164 |
#line 12879 "./marpa.w" |
| 17165 |
|
| 17166 |
tree_pause(t); |
| 17167 |
T_of_V(v)= t; |
| 17168 |
if(T_is_Nulling(o)){ |
| 17169 |
V_is_Nulling(v)= 1; |
| 17170 |
}else{ |
| 17171 |
const int minimum_stack_size= (8192/sizeof(int)); |
| 17172 |
const int initial_stack_size= |
| 17173 |
MAX(Size_of_TREE(t)/1024,minimum_stack_size); |
| 17174 |
MARPA_DSTACK_INIT(VStack_of_V(v),int,initial_stack_size); |
| 17175 |
} |
| 17176 |
return(Marpa_Value)v; |
| 17177 |
} |
| 17178 |
MARPA_ERROR(MARPA_ERR_TREE_EXHAUSTED); |
| 17179 |
return NULL; |
| 17180 |
} |
| 17181 |
|
| 17182 |
/*:1084*//*1088:*/ |
| 17183 |
#line 12903 "./marpa.w" |
| 17184 |
|
| 17185 |
PRIVATE void |
| 17186 |
value_unref(VALUE v) |
| 17187 |
{ |
| 17188 |
MARPA_ASSERT(v->t_ref_count> 0) |
| 17189 |
v->t_ref_count--; |
| 17190 |
if(v->t_ref_count<=0) |
| 17191 |
{ |
| 17192 |
value_free(v); |
| 17193 |
} |
| 17194 |
} |
| 17195 |
void |
| 17196 |
marpa_v_unref(Marpa_Value public_v) |
| 17197 |
{ |
| 17198 |
value_unref((VALUE)public_v); |
| 17199 |
} |
| 17200 |
|
| 17201 |
/*:1088*//*1089:*/ |
| 17202 |
#line 12921 "./marpa.w" |
| 17203 |
|
| 17204 |
PRIVATE VALUE |
| 17205 |
value_ref(VALUE v) |
| 17206 |
{ |
| 17207 |
MARPA_ASSERT(v->t_ref_count> 0) |
| 17208 |
v->t_ref_count++; |
| 17209 |
return v; |
| 17210 |
} |
| 17211 |
Marpa_Value |
| 17212 |
marpa_v_ref(Marpa_Value v) |
| 17213 |
{ |
| 17214 |
return(Marpa_Value)value_ref((VALUE)v); |
| 17215 |
} |
| 17216 |
|
| 17217 |
/*:1089*//*1090:*/ |
| 17218 |
#line 12935 "./marpa.w" |
| 17219 |
|
| 17220 |
PRIVATE void value_free(VALUE v) |
| 17221 |
{ |
| 17222 |
tree_unpause(T_of_V(v)); |
| 17223 |
/*1083:*/ |
| 17224 |
#line 12853 "./marpa.w" |
| 17225 |
|
| 17226 |
{ |
| 17227 |
if(_MARPA_LIKELY(MARPA_DSTACK_IS_INITIALIZED(VStack_of_V(v))!=NULL)) |
| 17228 |
{ |
| 17229 |
MARPA_DSTACK_DESTROY(VStack_of_V(v)); |
| 17230 |
} |
| 17231 |
} |
| 17232 |
|
| 17233 |
/*:1083*/ |
| 17234 |
#line 12939 "./marpa.w" |
| 17235 |
|
| 17236 |
/*1077:*/ |
| 17237 |
#line 12804 "./marpa.w" |
| 17238 |
|
| 17239 |
marpa_obs_free(v->t_obs); |
| 17240 |
|
| 17241 |
/*:1077*/ |
| 17242 |
#line 12940 "./marpa.w" |
| 17243 |
|
| 17244 |
} |
| 17245 |
|
| 17246 |
/*:1090*//*1097:*/ |
| 17247 |
#line 12961 "./marpa.w" |
| 17248 |
|
| 17249 |
int _marpa_v_trace(Marpa_Value public_v,int flag) |
| 17250 |
{ |
| 17251 |
/*1230:*/ |
| 17252 |
#line 14864 "./marpa.w" |
| 17253 |
const int failure_indicator= -2; |
| 17254 |
|
| 17255 |
/*:1230*/ |
| 17256 |
#line 12964 "./marpa.w" |
| 17257 |
|
| 17258 |
const VALUE v= (VALUE)public_v; |
| 17259 |
/*1091:*/ |
| 17260 |
#line 12943 "./marpa.w" |
| 17261 |
|
| 17262 |
TREE t= T_of_V(v); |
| 17263 |
/*1024:*/ |
| 17264 |
#line 12087 "./marpa.w" |
| 17265 |
|
| 17266 |
ORDER o= O_of_T(t); |
| 17267 |
/*985:*/ |
| 17268 |
#line 11573 "./marpa.w" |
| 17269 |
|
| 17270 |
const BOCAGE b= B_of_O(o); |
| 17271 |
/*939:*/ |
| 17272 |
#line 11160 "./marpa.w" |
| 17273 |
|
| 17274 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 17275 |
|
| 17276 |
/*:939*/ |
| 17277 |
#line 11575 "./marpa.w" |
| 17278 |
|
| 17279 |
|
| 17280 |
/*:985*/ |
| 17281 |
#line 12089 "./marpa.w" |
| 17282 |
; |
| 17283 |
|
| 17284 |
/*:1024*/ |
| 17285 |
#line 12945 "./marpa.w" |
| 17286 |
|
| 17287 |
|
| 17288 |
/*:1091*/ |
| 17289 |
#line 12966 "./marpa.w" |
| 17290 |
|
| 17291 |
/*1250:*/ |
| 17292 |
#line 14997 "./marpa.w" |
| 17293 |
|
| 17294 |
if(HEADER_VERSION_MISMATCH){ |
| 17295 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 17296 |
return failure_indicator; |
| 17297 |
} |
| 17298 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 17299 |
MARPA_ERROR(g->t_error); |
| 17300 |
return failure_indicator; |
| 17301 |
} |
| 17302 |
|
| 17303 |
/*:1250*/ |
| 17304 |
#line 12967 "./marpa.w" |
| 17305 |
|
| 17306 |
if(_MARPA_UNLIKELY(!V_is_Active(v))){ |
| 17307 |
MARPA_ERROR(MARPA_ERR_VALUATOR_INACTIVE); |
| 17308 |
return failure_indicator; |
| 17309 |
} |
| 17310 |
V_is_Trace(v)= Boolean(flag); |
| 17311 |
return 1; |
| 17312 |
} |
| 17313 |
|
| 17314 |
/*:1097*//*1100:*/ |
| 17315 |
#line 12983 "./marpa.w" |
| 17316 |
|
| 17317 |
Marpa_Nook_ID _marpa_v_nook(Marpa_Value public_v) |
| 17318 |
{ |
| 17319 |
/*1230:*/ |
| 17320 |
#line 14864 "./marpa.w" |
| 17321 |
const int failure_indicator= -2; |
| 17322 |
|
| 17323 |
/*:1230*/ |
| 17324 |
#line 12986 "./marpa.w" |
| 17325 |
|
| 17326 |
const VALUE v= (VALUE)public_v; |
| 17327 |
/*1091:*/ |
| 17328 |
#line 12943 "./marpa.w" |
| 17329 |
|
| 17330 |
TREE t= T_of_V(v); |
| 17331 |
/*1024:*/ |
| 17332 |
#line 12087 "./marpa.w" |
| 17333 |
|
| 17334 |
ORDER o= O_of_T(t); |
| 17335 |
/*985:*/ |
| 17336 |
#line 11573 "./marpa.w" |
| 17337 |
|
| 17338 |
const BOCAGE b= B_of_O(o); |
| 17339 |
/*939:*/ |
| 17340 |
#line 11160 "./marpa.w" |
| 17341 |
|
| 17342 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 17343 |
|
| 17344 |
/*:939*/ |
| 17345 |
#line 11575 "./marpa.w" |
| 17346 |
|
| 17347 |
|
| 17348 |
/*:985*/ |
| 17349 |
#line 12089 "./marpa.w" |
| 17350 |
; |
| 17351 |
|
| 17352 |
/*:1024*/ |
| 17353 |
#line 12945 "./marpa.w" |
| 17354 |
|
| 17355 |
|
| 17356 |
/*:1091*/ |
| 17357 |
#line 12988 "./marpa.w" |
| 17358 |
|
| 17359 |
/*1250:*/ |
| 17360 |
#line 14997 "./marpa.w" |
| 17361 |
|
| 17362 |
if(HEADER_VERSION_MISMATCH){ |
| 17363 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 17364 |
return failure_indicator; |
| 17365 |
} |
| 17366 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 17367 |
MARPA_ERROR(g->t_error); |
| 17368 |
return failure_indicator; |
| 17369 |
} |
| 17370 |
|
| 17371 |
/*:1250*/ |
| 17372 |
#line 12989 "./marpa.w" |
| 17373 |
|
| 17374 |
if(_MARPA_UNLIKELY(V_is_Nulling(v)))return-1; |
| 17375 |
if(_MARPA_UNLIKELY(!V_is_Active(v))){ |
| 17376 |
MARPA_ERROR(MARPA_ERR_VALUATOR_INACTIVE); |
| 17377 |
return failure_indicator; |
| 17378 |
} |
| 17379 |
return NOOK_of_V(v); |
| 17380 |
} |
| 17381 |
|
| 17382 |
/*:1100*//*1105:*/ |
| 17383 |
#line 13016 "./marpa.w" |
| 17384 |
|
| 17385 |
PRIVATE int symbol_is_valued( |
| 17386 |
VALUE v, |
| 17387 |
Marpa_Symbol_ID xsy_id) |
| 17388 |
{ |
| 17389 |
return lbv_bit_test(XSY_is_Valued_BV_of_V(v),xsy_id); |
| 17390 |
} |
| 17391 |
|
| 17392 |
/*:1105*//*1106:*/ |
| 17393 |
#line 13025 "./marpa.w" |
| 17394 |
|
| 17395 |
int marpa_v_symbol_is_valued( |
| 17396 |
Marpa_Value public_v, |
| 17397 |
Marpa_Symbol_ID xsy_id) |
| 17398 |
{ |
| 17399 |
/*1230:*/ |
| 17400 |
#line 14864 "./marpa.w" |
| 17401 |
const int failure_indicator= -2; |
| 17402 |
|
| 17403 |
/*:1230*/ |
| 17404 |
#line 13030 "./marpa.w" |
| 17405 |
|
| 17406 |
const VALUE v= (VALUE)public_v; |
| 17407 |
/*1091:*/ |
| 17408 |
#line 12943 "./marpa.w" |
| 17409 |
|
| 17410 |
TREE t= T_of_V(v); |
| 17411 |
/*1024:*/ |
| 17412 |
#line 12087 "./marpa.w" |
| 17413 |
|
| 17414 |
ORDER o= O_of_T(t); |
| 17415 |
/*985:*/ |
| 17416 |
#line 11573 "./marpa.w" |
| 17417 |
|
| 17418 |
const BOCAGE b= B_of_O(o); |
| 17419 |
/*939:*/ |
| 17420 |
#line 11160 "./marpa.w" |
| 17421 |
|
| 17422 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 17423 |
|
| 17424 |
/*:939*/ |
| 17425 |
#line 11575 "./marpa.w" |
| 17426 |
|
| 17427 |
|
| 17428 |
/*:985*/ |
| 17429 |
#line 12089 "./marpa.w" |
| 17430 |
; |
| 17431 |
|
| 17432 |
/*:1024*/ |
| 17433 |
#line 12945 "./marpa.w" |
| 17434 |
|
| 17435 |
|
| 17436 |
/*:1091*/ |
| 17437 |
#line 13032 "./marpa.w" |
| 17438 |
|
| 17439 |
/*1250:*/ |
| 17440 |
#line 14997 "./marpa.w" |
| 17441 |
|
| 17442 |
if(HEADER_VERSION_MISMATCH){ |
| 17443 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 17444 |
return failure_indicator; |
| 17445 |
} |
| 17446 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 17447 |
MARPA_ERROR(g->t_error); |
| 17448 |
return failure_indicator; |
| 17449 |
} |
| 17450 |
|
| 17451 |
/*:1250*/ |
| 17452 |
#line 13033 "./marpa.w" |
| 17453 |
|
| 17454 |
/*1233:*/ |
| 17455 |
#line 14880 "./marpa.w" |
| 17456 |
|
| 17457 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 17458 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 17459 |
return failure_indicator; |
| 17460 |
} |
| 17461 |
/*:1233*/ |
| 17462 |
#line 13034 "./marpa.w" |
| 17463 |
|
| 17464 |
/*1234:*/ |
| 17465 |
#line 14887 "./marpa.w" |
| 17466 |
|
| 17467 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 17468 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 17469 |
return-1; |
| 17470 |
} |
| 17471 |
/*:1234*/ |
| 17472 |
#line 13035 "./marpa.w" |
| 17473 |
|
| 17474 |
return lbv_bit_test(XSY_is_Valued_BV_of_V(v),xsy_id); |
| 17475 |
} |
| 17476 |
|
| 17477 |
/*:1106*//*1107:*/ |
| 17478 |
#line 13041 "./marpa.w" |
| 17479 |
|
| 17480 |
PRIVATE int symbol_is_valued_set( |
| 17481 |
VALUE v,XSYID xsy_id,int value) |
| 17482 |
{ |
| 17483 |
/*1230:*/ |
| 17484 |
#line 14864 "./marpa.w" |
| 17485 |
const int failure_indicator= -2; |
| 17486 |
|
| 17487 |
/*:1230*/ |
| 17488 |
#line 13045 "./marpa.w" |
| 17489 |
|
| 17490 |
const int old_value= lbv_bit_test(XSY_is_Valued_BV_of_V(v),xsy_id); |
| 17491 |
if(old_value==value){ |
| 17492 |
lbv_bit_set(Valued_Locked_BV_of_V(v),xsy_id); |
| 17493 |
return value; |
| 17494 |
} |
| 17495 |
|
| 17496 |
if(_MARPA_UNLIKELY(lbv_bit_test(Valued_Locked_BV_of_V(v),xsy_id))){ |
| 17497 |
return failure_indicator; |
| 17498 |
} |
| 17499 |
lbv_bit_set(Valued_Locked_BV_of_V(v),xsy_id); |
| 17500 |
if(value){ |
| 17501 |
lbv_bit_set(XSY_is_Valued_BV_of_V(v),xsy_id); |
| 17502 |
}else{ |
| 17503 |
lbv_bit_clear(XSY_is_Valued_BV_of_V(v),xsy_id); |
| 17504 |
} |
| 17505 |
return value; |
| 17506 |
} |
| 17507 |
|
| 17508 |
/*:1107*//*1108:*/ |
| 17509 |
#line 13064 "./marpa.w" |
| 17510 |
|
| 17511 |
int marpa_v_symbol_is_valued_set( |
| 17512 |
Marpa_Value public_v,Marpa_Symbol_ID xsy_id,int value) |
| 17513 |
{ |
| 17514 |
const VALUE v= (VALUE)public_v; |
| 17515 |
/*1230:*/ |
| 17516 |
#line 14864 "./marpa.w" |
| 17517 |
const int failure_indicator= -2; |
| 17518 |
|
| 17519 |
/*:1230*/ |
| 17520 |
#line 13069 "./marpa.w" |
| 17521 |
|
| 17522 |
/*1091:*/ |
| 17523 |
#line 12943 "./marpa.w" |
| 17524 |
|
| 17525 |
TREE t= T_of_V(v); |
| 17526 |
/*1024:*/ |
| 17527 |
#line 12087 "./marpa.w" |
| 17528 |
|
| 17529 |
ORDER o= O_of_T(t); |
| 17530 |
/*985:*/ |
| 17531 |
#line 11573 "./marpa.w" |
| 17532 |
|
| 17533 |
const BOCAGE b= B_of_O(o); |
| 17534 |
/*939:*/ |
| 17535 |
#line 11160 "./marpa.w" |
| 17536 |
|
| 17537 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 17538 |
|
| 17539 |
/*:939*/ |
| 17540 |
#line 11575 "./marpa.w" |
| 17541 |
|
| 17542 |
|
| 17543 |
/*:985*/ |
| 17544 |
#line 12089 "./marpa.w" |
| 17545 |
; |
| 17546 |
|
| 17547 |
/*:1024*/ |
| 17548 |
#line 12945 "./marpa.w" |
| 17549 |
|
| 17550 |
|
| 17551 |
/*:1091*/ |
| 17552 |
#line 13070 "./marpa.w" |
| 17553 |
|
| 17554 |
/*1250:*/ |
| 17555 |
#line 14997 "./marpa.w" |
| 17556 |
|
| 17557 |
if(HEADER_VERSION_MISMATCH){ |
| 17558 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 17559 |
return failure_indicator; |
| 17560 |
} |
| 17561 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 17562 |
MARPA_ERROR(g->t_error); |
| 17563 |
return failure_indicator; |
| 17564 |
} |
| 17565 |
|
| 17566 |
/*:1250*/ |
| 17567 |
#line 13071 "./marpa.w" |
| 17568 |
|
| 17569 |
if(_MARPA_UNLIKELY(value<0||value> 1)) |
| 17570 |
{ |
| 17571 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 17572 |
return failure_indicator; |
| 17573 |
} |
| 17574 |
/*1233:*/ |
| 17575 |
#line 14880 "./marpa.w" |
| 17576 |
|
| 17577 |
if(_MARPA_UNLIKELY(XSYID_is_Malformed(xsy_id))){ |
| 17578 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 17579 |
return failure_indicator; |
| 17580 |
} |
| 17581 |
/*:1233*/ |
| 17582 |
#line 13077 "./marpa.w" |
| 17583 |
|
| 17584 |
/*1234:*/ |
| 17585 |
#line 14887 "./marpa.w" |
| 17586 |
|
| 17587 |
if(_MARPA_UNLIKELY(!XSYID_of_G_Exists(xsy_id))){ |
| 17588 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 17589 |
return-1; |
| 17590 |
} |
| 17591 |
/*:1234*/ |
| 17592 |
#line 13078 "./marpa.w" |
| 17593 |
|
| 17594 |
return symbol_is_valued_set(v,xsy_id,value); |
| 17595 |
} |
| 17596 |
|
| 17597 |
/*:1108*//*1109:*/ |
| 17598 |
#line 13084 "./marpa.w" |
| 17599 |
|
| 17600 |
int |
| 17601 |
marpa_v_valued_force(Marpa_Value public_v) |
| 17602 |
{ |
| 17603 |
const VALUE v= (VALUE)public_v; |
| 17604 |
/*1230:*/ |
| 17605 |
#line 14864 "./marpa.w" |
| 17606 |
const int failure_indicator= -2; |
| 17607 |
|
| 17608 |
/*:1230*/ |
| 17609 |
#line 13089 "./marpa.w" |
| 17610 |
|
| 17611 |
XSYID xsy_count; |
| 17612 |
XSYID xsy_id; |
| 17613 |
/*1091:*/ |
| 17614 |
#line 12943 "./marpa.w" |
| 17615 |
|
| 17616 |
TREE t= T_of_V(v); |
| 17617 |
/*1024:*/ |
| 17618 |
#line 12087 "./marpa.w" |
| 17619 |
|
| 17620 |
ORDER o= O_of_T(t); |
| 17621 |
/*985:*/ |
| 17622 |
#line 11573 "./marpa.w" |
| 17623 |
|
| 17624 |
const BOCAGE b= B_of_O(o); |
| 17625 |
/*939:*/ |
| 17626 |
#line 11160 "./marpa.w" |
| 17627 |
|
| 17628 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 17629 |
|
| 17630 |
/*:939*/ |
| 17631 |
#line 11575 "./marpa.w" |
| 17632 |
|
| 17633 |
|
| 17634 |
/*:985*/ |
| 17635 |
#line 12089 "./marpa.w" |
| 17636 |
; |
| 17637 |
|
| 17638 |
/*:1024*/ |
| 17639 |
#line 12945 "./marpa.w" |
| 17640 |
|
| 17641 |
|
| 17642 |
/*:1091*/ |
| 17643 |
#line 13092 "./marpa.w" |
| 17644 |
|
| 17645 |
/*1250:*/ |
| 17646 |
#line 14997 "./marpa.w" |
| 17647 |
|
| 17648 |
if(HEADER_VERSION_MISMATCH){ |
| 17649 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 17650 |
return failure_indicator; |
| 17651 |
} |
| 17652 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 17653 |
MARPA_ERROR(g->t_error); |
| 17654 |
return failure_indicator; |
| 17655 |
} |
| 17656 |
|
| 17657 |
/*:1250*/ |
| 17658 |
#line 13093 "./marpa.w" |
| 17659 |
|
| 17660 |
xsy_count= XSY_Count_of_G(g); |
| 17661 |
for(xsy_id= 0;xsy_id<xsy_count;xsy_id++) |
| 17662 |
{ |
| 17663 |
if(_MARPA_UNLIKELY(!lbv_bit_test(XSY_is_Valued_BV_of_V(v),xsy_id)&& |
| 17664 |
lbv_bit_test(Valued_Locked_BV_of_V(v),xsy_id))) |
| 17665 |
{ |
| 17666 |
return failure_indicator; |
| 17667 |
} |
| 17668 |
lbv_bit_set(Valued_Locked_BV_of_V(v),xsy_id); |
| 17669 |
lbv_bit_set(XSY_is_Valued_BV_of_V(v),xsy_id); |
| 17670 |
} |
| 17671 |
return xsy_count; |
| 17672 |
} |
| 17673 |
|
| 17674 |
/*:1109*//*1110:*/ |
| 17675 |
#line 13108 "./marpa.w" |
| 17676 |
|
| 17677 |
int marpa_v_rule_is_valued_set( |
| 17678 |
Marpa_Value public_v,Marpa_Rule_ID xrl_id,int value) |
| 17679 |
{ |
| 17680 |
const VALUE v= (VALUE)public_v; |
| 17681 |
/*1230:*/ |
| 17682 |
#line 14864 "./marpa.w" |
| 17683 |
const int failure_indicator= -2; |
| 17684 |
|
| 17685 |
/*:1230*/ |
| 17686 |
#line 13113 "./marpa.w" |
| 17687 |
|
| 17688 |
/*1091:*/ |
| 17689 |
#line 12943 "./marpa.w" |
| 17690 |
|
| 17691 |
TREE t= T_of_V(v); |
| 17692 |
/*1024:*/ |
| 17693 |
#line 12087 "./marpa.w" |
| 17694 |
|
| 17695 |
ORDER o= O_of_T(t); |
| 17696 |
/*985:*/ |
| 17697 |
#line 11573 "./marpa.w" |
| 17698 |
|
| 17699 |
const BOCAGE b= B_of_O(o); |
| 17700 |
/*939:*/ |
| 17701 |
#line 11160 "./marpa.w" |
| 17702 |
|
| 17703 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 17704 |
|
| 17705 |
/*:939*/ |
| 17706 |
#line 11575 "./marpa.w" |
| 17707 |
|
| 17708 |
|
| 17709 |
/*:985*/ |
| 17710 |
#line 12089 "./marpa.w" |
| 17711 |
; |
| 17712 |
|
| 17713 |
/*:1024*/ |
| 17714 |
#line 12945 "./marpa.w" |
| 17715 |
|
| 17716 |
|
| 17717 |
/*:1091*/ |
| 17718 |
#line 13114 "./marpa.w" |
| 17719 |
|
| 17720 |
/*1250:*/ |
| 17721 |
#line 14997 "./marpa.w" |
| 17722 |
|
| 17723 |
if(HEADER_VERSION_MISMATCH){ |
| 17724 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 17725 |
return failure_indicator; |
| 17726 |
} |
| 17727 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 17728 |
MARPA_ERROR(g->t_error); |
| 17729 |
return failure_indicator; |
| 17730 |
} |
| 17731 |
|
| 17732 |
/*:1250*/ |
| 17733 |
#line 13115 "./marpa.w" |
| 17734 |
|
| 17735 |
if(_MARPA_UNLIKELY(value<0||value> 1)) |
| 17736 |
{ |
| 17737 |
MARPA_ERROR(MARPA_ERR_INVALID_BOOLEAN); |
| 17738 |
return failure_indicator; |
| 17739 |
} |
| 17740 |
/*1242:*/ |
| 17741 |
#line 14936 "./marpa.w" |
| 17742 |
|
| 17743 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 17744 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 17745 |
return failure_indicator; |
| 17746 |
} |
| 17747 |
|
| 17748 |
/*:1242*/ |
| 17749 |
#line 13121 "./marpa.w" |
| 17750 |
|
| 17751 |
/*1240:*/ |
| 17752 |
#line 14924 "./marpa.w" |
| 17753 |
|
| 17754 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 17755 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 17756 |
return-1; |
| 17757 |
} |
| 17758 |
|
| 17759 |
/*:1240*/ |
| 17760 |
#line 13122 "./marpa.w" |
| 17761 |
|
| 17762 |
{ |
| 17763 |
const XRL xrl= XRL_by_ID(xrl_id); |
| 17764 |
const XSYID xsy_id= LHS_ID_of_XRL(xrl); |
| 17765 |
return symbol_is_valued_set(v,xsy_id,value); |
| 17766 |
} |
| 17767 |
} |
| 17768 |
|
| 17769 |
/*:1110*//*1111:*/ |
| 17770 |
#line 13130 "./marpa.w" |
| 17771 |
|
| 17772 |
int marpa_v_rule_is_valued( |
| 17773 |
Marpa_Value public_v,Marpa_Rule_ID xrl_id) |
| 17774 |
{ |
| 17775 |
const VALUE v= (VALUE)public_v; |
| 17776 |
/*1230:*/ |
| 17777 |
#line 14864 "./marpa.w" |
| 17778 |
const int failure_indicator= -2; |
| 17779 |
|
| 17780 |
/*:1230*/ |
| 17781 |
#line 13135 "./marpa.w" |
| 17782 |
|
| 17783 |
/*1091:*/ |
| 17784 |
#line 12943 "./marpa.w" |
| 17785 |
|
| 17786 |
TREE t= T_of_V(v); |
| 17787 |
/*1024:*/ |
| 17788 |
#line 12087 "./marpa.w" |
| 17789 |
|
| 17790 |
ORDER o= O_of_T(t); |
| 17791 |
/*985:*/ |
| 17792 |
#line 11573 "./marpa.w" |
| 17793 |
|
| 17794 |
const BOCAGE b= B_of_O(o); |
| 17795 |
/*939:*/ |
| 17796 |
#line 11160 "./marpa.w" |
| 17797 |
|
| 17798 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 17799 |
|
| 17800 |
/*:939*/ |
| 17801 |
#line 11575 "./marpa.w" |
| 17802 |
|
| 17803 |
|
| 17804 |
/*:985*/ |
| 17805 |
#line 12089 "./marpa.w" |
| 17806 |
; |
| 17807 |
|
| 17808 |
/*:1024*/ |
| 17809 |
#line 12945 "./marpa.w" |
| 17810 |
|
| 17811 |
|
| 17812 |
/*:1091*/ |
| 17813 |
#line 13136 "./marpa.w" |
| 17814 |
|
| 17815 |
/*1250:*/ |
| 17816 |
#line 14997 "./marpa.w" |
| 17817 |
|
| 17818 |
if(HEADER_VERSION_MISMATCH){ |
| 17819 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 17820 |
return failure_indicator; |
| 17821 |
} |
| 17822 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 17823 |
MARPA_ERROR(g->t_error); |
| 17824 |
return failure_indicator; |
| 17825 |
} |
| 17826 |
|
| 17827 |
/*:1250*/ |
| 17828 |
#line 13137 "./marpa.w" |
| 17829 |
|
| 17830 |
/*1242:*/ |
| 17831 |
#line 14936 "./marpa.w" |
| 17832 |
|
| 17833 |
if(_MARPA_UNLIKELY(XRLID_is_Malformed(xrl_id))){ |
| 17834 |
MARPA_ERROR(MARPA_ERR_INVALID_RULE_ID); |
| 17835 |
return failure_indicator; |
| 17836 |
} |
| 17837 |
|
| 17838 |
/*:1242*/ |
| 17839 |
#line 13138 "./marpa.w" |
| 17840 |
|
| 17841 |
/*1240:*/ |
| 17842 |
#line 14924 "./marpa.w" |
| 17843 |
|
| 17844 |
if(_MARPA_UNLIKELY(!XRLID_of_G_Exists(xrl_id))){ |
| 17845 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_RULE_ID); |
| 17846 |
return-1; |
| 17847 |
} |
| 17848 |
|
| 17849 |
/*:1240*/ |
| 17850 |
#line 13139 "./marpa.w" |
| 17851 |
|
| 17852 |
{ |
| 17853 |
const XRL xrl= XRL_by_ID(xrl_id); |
| 17854 |
const XSYID xsy_id= LHS_ID_of_XRL(xrl); |
| 17855 |
return symbol_is_valued(v,xsy_id); |
| 17856 |
} |
| 17857 |
} |
| 17858 |
|
| 17859 |
/*:1111*//*1113:*/ |
| 17860 |
#line 13154 "./marpa.w" |
| 17861 |
|
| 17862 |
Marpa_Step_Type marpa_v_step(Marpa_Value public_v) |
| 17863 |
{ |
| 17864 |
/*1230:*/ |
| 17865 |
#line 14864 "./marpa.w" |
| 17866 |
const int failure_indicator= -2; |
| 17867 |
|
| 17868 |
/*:1230*/ |
| 17869 |
#line 13157 "./marpa.w" |
| 17870 |
|
| 17871 |
const VALUE v= (VALUE)public_v; |
| 17872 |
|
| 17873 |
if(V_is_Nulling(v)){ |
| 17874 |
/*1091:*/ |
| 17875 |
#line 12943 "./marpa.w" |
| 17876 |
|
| 17877 |
TREE t= T_of_V(v); |
| 17878 |
/*1024:*/ |
| 17879 |
#line 12087 "./marpa.w" |
| 17880 |
|
| 17881 |
ORDER o= O_of_T(t); |
| 17882 |
/*985:*/ |
| 17883 |
#line 11573 "./marpa.w" |
| 17884 |
|
| 17885 |
const BOCAGE b= B_of_O(o); |
| 17886 |
/*939:*/ |
| 17887 |
#line 11160 "./marpa.w" |
| 17888 |
|
| 17889 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 17890 |
|
| 17891 |
/*:939*/ |
| 17892 |
#line 11575 "./marpa.w" |
| 17893 |
|
| 17894 |
|
| 17895 |
/*:985*/ |
| 17896 |
#line 12089 "./marpa.w" |
| 17897 |
; |
| 17898 |
|
| 17899 |
/*:1024*/ |
| 17900 |
#line 12945 "./marpa.w" |
| 17901 |
|
| 17902 |
|
| 17903 |
/*:1091*/ |
| 17904 |
#line 13161 "./marpa.w" |
| 17905 |
|
| 17906 |
/*1115:*/ |
| 17907 |
#line 13243 "./marpa.w" |
| 17908 |
|
| 17909 |
{ |
| 17910 |
XSYID_of_V(v)= g->t_start_xsy_id; |
| 17911 |
Token_Start_of_V(v)= YS_ID_of_V(v)= 0; |
| 17912 |
Result_of_V(v)= Arg_0_of_V(v)= Arg_N_of_V(v)= 0; |
| 17913 |
Step_Type_of_V(v)= MARPA_STEP_INACTIVE; |
| 17914 |
if(Next_Value_Type_of_V(v)==MARPA_STEP_INITIAL&& |
| 17915 |
lbv_bit_test(XSY_is_Valued_BV_of_V(v),XSYID_of_V(v))){ |
| 17916 |
Step_Type_of_V(v)= MARPA_STEP_NULLING_SYMBOL; |
| 17917 |
} |
| 17918 |
Next_Value_Type_of_V(v)= MARPA_STEP_INACTIVE; |
| 17919 |
} |
| 17920 |
|
| 17921 |
/*:1115*/ |
| 17922 |
#line 13162 "./marpa.w" |
| 17923 |
|
| 17924 |
return Step_Type_of_V(v); |
| 17925 |
} |
| 17926 |
|
| 17927 |
while(V_is_Active(v)){ |
| 17928 |
Marpa_Step_Type current_value_type= Next_Value_Type_of_V(v); |
| 17929 |
switch(current_value_type) |
| 17930 |
{ |
| 17931 |
case MARPA_STEP_INITIAL: |
| 17932 |
{ |
| 17933 |
XSYID xsy_count; |
| 17934 |
/*1091:*/ |
| 17935 |
#line 12943 "./marpa.w" |
| 17936 |
|
| 17937 |
TREE t= T_of_V(v); |
| 17938 |
/*1024:*/ |
| 17939 |
#line 12087 "./marpa.w" |
| 17940 |
|
| 17941 |
ORDER o= O_of_T(t); |
| 17942 |
/*985:*/ |
| 17943 |
#line 11573 "./marpa.w" |
| 17944 |
|
| 17945 |
const BOCAGE b= B_of_O(o); |
| 17946 |
/*939:*/ |
| 17947 |
#line 11160 "./marpa.w" |
| 17948 |
|
| 17949 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 17950 |
|
| 17951 |
/*:939*/ |
| 17952 |
#line 11575 "./marpa.w" |
| 17953 |
|
| 17954 |
|
| 17955 |
/*:985*/ |
| 17956 |
#line 12089 "./marpa.w" |
| 17957 |
; |
| 17958 |
|
| 17959 |
/*:1024*/ |
| 17960 |
#line 12945 "./marpa.w" |
| 17961 |
|
| 17962 |
|
| 17963 |
/*:1091*/ |
| 17964 |
#line 13173 "./marpa.w" |
| 17965 |
|
| 17966 |
xsy_count= XSY_Count_of_G(g); |
| 17967 |
lbv_fill(Valued_Locked_BV_of_V(v),xsy_count); |
| 17968 |
/*1114:*/ |
| 17969 |
#line 13226 "./marpa.w" |
| 17970 |
|
| 17971 |
{ |
| 17972 |
const LBV xsy_bv= XSY_is_Valued_BV_of_V(v); |
| 17973 |
const XRLID xrl_count= XRL_Count_of_G(g); |
| 17974 |
const LBV xrl_bv= lbv_obs_new0(v->t_obs,xrl_count); |
| 17975 |
XRLID xrlid; |
| 17976 |
XRL_is_Valued_BV_of_V(v)= xrl_bv; |
| 17977 |
for(xrlid= 0;xrlid<xrl_count;xrlid++){ |
| 17978 |
const XRL xrl= XRL_by_ID(xrlid); |
| 17979 |
const XSYID lhs_xsy_id= LHS_ID_of_XRL(xrl); |
| 17980 |
if(lbv_bit_test(xsy_bv,lhs_xsy_id)){ |
| 17981 |
lbv_bit_set(xrl_bv,xrlid); |
| 17982 |
} |
| 17983 |
} |
| 17984 |
} |
| 17985 |
|
| 17986 |
/*:1114*/ |
| 17987 |
#line 13176 "./marpa.w" |
| 17988 |
|
| 17989 |
} |
| 17990 |
FALL_THROUGH; |
| 17991 |
case STEP_GET_DATA: |
| 17992 |
/*1116:*/ |
| 17993 |
#line 13256 "./marpa.w" |
| 17994 |
|
| 17995 |
{ |
| 17996 |
AND and_nodes; |
| 17997 |
|
| 17998 |
|
| 17999 |
|
| 18000 |
|
| 18001 |
|
| 18002 |
|
| 18003 |
int pop_arguments= 1; |
| 18004 |
/*1091:*/ |
| 18005 |
#line 12943 "./marpa.w" |
| 18006 |
|
| 18007 |
TREE t= T_of_V(v); |
| 18008 |
/*1024:*/ |
| 18009 |
#line 12087 "./marpa.w" |
| 18010 |
|
| 18011 |
ORDER o= O_of_T(t); |
| 18012 |
/*985:*/ |
| 18013 |
#line 11573 "./marpa.w" |
| 18014 |
|
| 18015 |
const BOCAGE b= B_of_O(o); |
| 18016 |
/*939:*/ |
| 18017 |
#line 11160 "./marpa.w" |
| 18018 |
|
| 18019 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 18020 |
|
| 18021 |
/*:939*/ |
| 18022 |
#line 11575 "./marpa.w" |
| 18023 |
|
| 18024 |
|
| 18025 |
/*:985*/ |
| 18026 |
#line 12089 "./marpa.w" |
| 18027 |
; |
| 18028 |
|
| 18029 |
/*:1024*/ |
| 18030 |
#line 12945 "./marpa.w" |
| 18031 |
|
| 18032 |
|
| 18033 |
/*:1091*/ |
| 18034 |
#line 13266 "./marpa.w" |
| 18035 |
|
| 18036 |
/*1250:*/ |
| 18037 |
#line 14997 "./marpa.w" |
| 18038 |
|
| 18039 |
if(HEADER_VERSION_MISMATCH){ |
| 18040 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 18041 |
return failure_indicator; |
| 18042 |
} |
| 18043 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 18044 |
MARPA_ERROR(g->t_error); |
| 18045 |
return failure_indicator; |
| 18046 |
} |
| 18047 |
|
| 18048 |
/*:1250*/ |
| 18049 |
#line 13267 "./marpa.w" |
| 18050 |
|
| 18051 |
and_nodes= ANDs_of_B(B_of_O(o)); |
| 18052 |
|
| 18053 |
if(NOOK_of_V(v)<0){ |
| 18054 |
NOOK_of_V(v)= Size_of_TREE(t); |
| 18055 |
} |
| 18056 |
|
| 18057 |
while(1) |
| 18058 |
{ |
| 18059 |
OR or; |
| 18060 |
IRL nook_irl; |
| 18061 |
Token_Value_of_V(v)= -1; |
| 18062 |
RULEID_of_V(v)= -1; |
| 18063 |
NOOK_of_V(v)--; |
| 18064 |
if(NOOK_of_V(v)<0) |
| 18065 |
{ |
| 18066 |
Next_Value_Type_of_V(v)= MARPA_STEP_INACTIVE; |
| 18067 |
break; |
| 18068 |
} |
| 18069 |
if(pop_arguments) |
| 18070 |
{ |
| 18071 |
|
| 18072 |
|
| 18073 |
Arg_N_of_V(v)= Arg_0_of_V(v); |
| 18074 |
pop_arguments= 0; |
| 18075 |
} |
| 18076 |
{ |
| 18077 |
ANDID and_node_id; |
| 18078 |
AND and_node; |
| 18079 |
int cause_or_node_type; |
| 18080 |
OR cause_or_node; |
| 18081 |
const NOOK nook= NOOK_of_TREE_by_IX(t,NOOK_of_V(v)); |
| 18082 |
const int choice= Choice_of_NOOK(nook); |
| 18083 |
or= OR_of_NOOK(nook); |
| 18084 |
YS_ID_of_V(v)= YS_Ord_of_OR(or); |
| 18085 |
and_node_id= and_order_get(o,or,choice); |
| 18086 |
and_node= and_nodes+and_node_id; |
| 18087 |
cause_or_node= Cause_OR_of_AND(and_node); |
| 18088 |
cause_or_node_type= Type_of_OR(cause_or_node); |
| 18089 |
switch(cause_or_node_type) |
| 18090 |
{ |
| 18091 |
case VALUED_TOKEN_OR_NODE: |
| 18092 |
Token_Type_of_V(v)= cause_or_node_type; |
| 18093 |
Arg_0_of_V(v)= ++Arg_N_of_V(v); |
| 18094 |
{ |
| 18095 |
const OR predecessor= Predecessor_OR_of_AND(and_node); |
| 18096 |
XSYID_of_V(v)= |
| 18097 |
ID_of_XSY(Source_XSY_of_NSYID(NSYID_of_OR(cause_or_node))); |
| 18098 |
Token_Start_of_V(v)= |
| 18099 |
predecessor?YS_Ord_of_OR(predecessor):Origin_Ord_of_OR(or); |
| 18100 |
Token_Value_of_V(v)= Value_of_OR(cause_or_node); |
| 18101 |
} |
| 18102 |
|
| 18103 |
break; |
| 18104 |
case NULLING_TOKEN_OR_NODE: |
| 18105 |
Token_Type_of_V(v)= cause_or_node_type; |
| 18106 |
Arg_0_of_V(v)= ++Arg_N_of_V(v); |
| 18107 |
{ |
| 18108 |
const XSY source_xsy= |
| 18109 |
Source_XSY_of_NSYID(NSYID_of_OR(cause_or_node)); |
| 18110 |
const XSYID source_xsy_id= ID_of_XSY(source_xsy); |
| 18111 |
if(bv_bit_test(XSY_is_Valued_BV_of_V(v),source_xsy_id)) |
| 18112 |
{ |
| 18113 |
XSYID_of_V(v)= source_xsy_id; |
| 18114 |
Token_Start_of_V(v)= YS_ID_of_V(v); |
| 18115 |
} |
| 18116 |
else |
| 18117 |
{ |
| 18118 |
Token_Type_of_V(v)= DUMMY_OR_NODE; |
| 18119 |
|
| 18120 |
|
| 18121 |
} |
| 18122 |
} |
| 18123 |
|
| 18124 |
break; |
| 18125 |
default: |
| 18126 |
Token_Type_of_V(v)= DUMMY_OR_NODE; |
| 18127 |
} |
| 18128 |
} |
| 18129 |
nook_irl= IRL_of_OR(or); |
| 18130 |
if(Position_of_OR(or)==Length_of_IRL(nook_irl)) |
| 18131 |
{ |
| 18132 |
int virtual_rhs= IRL_has_Virtual_RHS(nook_irl); |
| 18133 |
int virtual_lhs= IRL_has_Virtual_LHS(nook_irl); |
| 18134 |
int real_symbol_count; |
| 18135 |
const MARPA_DSTACK virtual_stack= &VStack_of_V(v); |
| 18136 |
if(virtual_lhs) |
| 18137 |
{ |
| 18138 |
real_symbol_count= Real_SYM_Count_of_IRL(nook_irl); |
| 18139 |
if(virtual_rhs) |
| 18140 |
{ |
| 18141 |
*(MARPA_DSTACK_TOP(*virtual_stack,int))+= real_symbol_count; |
| 18142 |
} |
| 18143 |
else |
| 18144 |
{ |
| 18145 |
*MARPA_DSTACK_PUSH(*virtual_stack,int)= real_symbol_count; |
| 18146 |
} |
| 18147 |
} |
| 18148 |
else |
| 18149 |
{ |
| 18150 |
|
| 18151 |
if(virtual_rhs) |
| 18152 |
{ |
| 18153 |
real_symbol_count= Real_SYM_Count_of_IRL(nook_irl); |
| 18154 |
real_symbol_count+= *MARPA_DSTACK_POP(*virtual_stack,int); |
| 18155 |
} |
| 18156 |
else |
| 18157 |
{ |
| 18158 |
real_symbol_count= Length_of_IRL(nook_irl); |
| 18159 |
} |
| 18160 |
{ |
| 18161 |
|
| 18162 |
|
| 18163 |
XRLID original_rule_id= ID_of_XRL(Source_XRL_of_IRL(nook_irl)); |
| 18164 |
Arg_0_of_V(v)= Arg_N_of_V(v)-real_symbol_count+1; |
| 18165 |
pop_arguments= 1; |
| 18166 |
if(lbv_bit_test(XRL_is_Valued_BV_of_V(v),original_rule_id)) |
| 18167 |
{ |
| 18168 |
RULEID_of_V(v)= original_rule_id; |
| 18169 |
Rule_Start_of_V(v)= Origin_Ord_of_OR(or); |
| 18170 |
} |
| 18171 |
} |
| 18172 |
|
| 18173 |
} |
| 18174 |
} |
| 18175 |
if(RULEID_of_V(v)>=0) |
| 18176 |
break; |
| 18177 |
if(Token_Type_of_V(v)!=DUMMY_OR_NODE) |
| 18178 |
break; |
| 18179 |
if(V_is_Trace(v)) |
| 18180 |
break; |
| 18181 |
} |
| 18182 |
} |
| 18183 |
|
| 18184 |
/*:1116*/ |
| 18185 |
#line 13180 "./marpa.w" |
| 18186 |
|
| 18187 |
if(!V_is_Active(v))break; |
| 18188 |
FALL_THROUGH; |
| 18189 |
case MARPA_STEP_TOKEN: |
| 18190 |
{ |
| 18191 |
int tkn_type= Token_Type_of_V(v); |
| 18192 |
Next_Value_Type_of_V(v)= MARPA_STEP_RULE; |
| 18193 |
if(tkn_type==NULLING_TOKEN_OR_NODE) |
| 18194 |
{ |
| 18195 |
if(lbv_bit_test(XSY_is_Valued_BV_of_V(v),XSYID_of_V(v))){ |
| 18196 |
Result_of_V(v)= Arg_N_of_V(v); |
| 18197 |
return Step_Type_of_V(v)= MARPA_STEP_NULLING_SYMBOL; |
| 18198 |
} |
| 18199 |
} |
| 18200 |
else if(tkn_type!=DUMMY_OR_NODE) |
| 18201 |
{ |
| 18202 |
Result_of_V(v)= Arg_N_of_V(v); |
| 18203 |
return Step_Type_of_V(v)= MARPA_STEP_TOKEN; |
| 18204 |
} |
| 18205 |
} |
| 18206 |
FALL_THROUGH; |
| 18207 |
case MARPA_STEP_RULE: |
| 18208 |
if(RULEID_of_V(v)>=0) |
| 18209 |
{ |
| 18210 |
Next_Value_Type_of_V(v)= MARPA_STEP_TRACE; |
| 18211 |
Result_of_V(v)= Arg_0_of_V(v); |
| 18212 |
return Step_Type_of_V(v)= MARPA_STEP_RULE; |
| 18213 |
} |
| 18214 |
FALL_THROUGH; |
| 18215 |
case MARPA_STEP_TRACE: |
| 18216 |
Next_Value_Type_of_V(v)= STEP_GET_DATA; |
| 18217 |
if(V_is_Trace(v)) |
| 18218 |
{ |
| 18219 |
return Step_Type_of_V(v)= MARPA_STEP_TRACE; |
| 18220 |
} |
| 18221 |
} |
| 18222 |
} |
| 18223 |
|
| 18224 |
Next_Value_Type_of_V(v)= MARPA_STEP_INACTIVE; |
| 18225 |
return Step_Type_of_V(v)= MARPA_STEP_INACTIVE; |
| 18226 |
} |
| 18227 |
|
| 18228 |
/*:1113*//*1118:*/ |
| 18229 |
#line 13419 "./marpa.w" |
| 18230 |
|
| 18231 |
PRIVATE int lbv_bits_to_size(int bits) |
| 18232 |
{ |
| 18233 |
const LBW result= (LBW)(((unsigned int)bits+(lbv_wordbits-1))/lbv_wordbits); |
| 18234 |
return(int)result; |
| 18235 |
} |
| 18236 |
|
| 18237 |
/*:1118*//*1119:*/ |
| 18238 |
#line 13427 "./marpa.w" |
| 18239 |
|
| 18240 |
PRIVATE Bit_Vector |
| 18241 |
lbv_obs_new(struct marpa_obstack*obs,int bits) |
| 18242 |
{ |
| 18243 |
int size= lbv_bits_to_size(bits); |
| 18244 |
LBV lbv= marpa_obs_new(obs,LBW,size); |
| 18245 |
return lbv; |
| 18246 |
} |
| 18247 |
|
| 18248 |
/*:1119*//*1120:*/ |
| 18249 |
#line 13437 "./marpa.w" |
| 18250 |
|
| 18251 |
PRIVATE Bit_Vector |
| 18252 |
lbv_zero(Bit_Vector lbv,int bits) |
| 18253 |
{ |
| 18254 |
int size= lbv_bits_to_size(bits); |
| 18255 |
if(size> 0){ |
| 18256 |
LBW*addr= lbv; |
| 18257 |
while(size--)*addr++= 0u; |
| 18258 |
} |
| 18259 |
return lbv; |
| 18260 |
} |
| 18261 |
|
| 18262 |
/*:1120*//*1121:*/ |
| 18263 |
#line 13450 "./marpa.w" |
| 18264 |
|
| 18265 |
PRIVATE Bit_Vector |
| 18266 |
lbv_obs_new0(struct marpa_obstack*obs,int bits) |
| 18267 |
{ |
| 18268 |
LBV lbv= lbv_obs_new(obs,bits); |
| 18269 |
return lbv_zero(lbv,bits); |
| 18270 |
} |
| 18271 |
|
| 18272 |
/*:1121*//*1123:*/ |
| 18273 |
#line 13469 "./marpa.w" |
| 18274 |
|
| 18275 |
PRIVATE LBV lbv_clone( |
| 18276 |
struct marpa_obstack*obs,LBV old_lbv,int bits) |
| 18277 |
{ |
| 18278 |
int size= lbv_bits_to_size(bits); |
| 18279 |
const LBV new_lbv= marpa_obs_new(obs,LBW,size); |
| 18280 |
if(size> 0){ |
| 18281 |
LBW*from_addr= old_lbv; |
| 18282 |
LBW*to_addr= new_lbv; |
| 18283 |
while(size--)*to_addr++= *from_addr++; |
| 18284 |
} |
| 18285 |
return new_lbv; |
| 18286 |
} |
| 18287 |
|
| 18288 |
/*:1123*//*1124:*/ |
| 18289 |
#line 13485 "./marpa.w" |
| 18290 |
|
| 18291 |
PRIVATE LBV lbv_fill( |
| 18292 |
LBV lbv,int bits) |
| 18293 |
{ |
| 18294 |
int size= lbv_bits_to_size(bits); |
| 18295 |
if(size> 0){ |
| 18296 |
LBW*to_addr= lbv; |
| 18297 |
while(size--)*to_addr++= ~((LBW)0); |
| 18298 |
} |
| 18299 |
return lbv; |
| 18300 |
} |
| 18301 |
|
| 18302 |
/*:1124*//*1127:*/ |
| 18303 |
#line 13521 "./marpa.w" |
| 18304 |
|
| 18305 |
PRIVATE unsigned int bv_bits_to_size(int bits) |
| 18306 |
{ |
| 18307 |
return((LBW)bits+bv_modmask)/bv_wordbits; |
| 18308 |
} |
| 18309 |
/*:1127*//*1128:*/ |
| 18310 |
#line 13527 "./marpa.w" |
| 18311 |
|
| 18312 |
PRIVATE unsigned int bv_bits_to_unused_mask(int bits) |
| 18313 |
{ |
| 18314 |
LBW mask= (LBW)bits&bv_modmask; |
| 18315 |
if(mask)mask= (LBW)~(~0uL<<mask);else mask= (LBW)~0uL; |
| 18316 |
return(mask); |
| 18317 |
} |
| 18318 |
|
| 18319 |
/*:1128*//*1130:*/ |
| 18320 |
#line 13541 "./marpa.w" |
| 18321 |
|
| 18322 |
PRIVATE Bit_Vector bv_create(int bits) |
| 18323 |
{ |
| 18324 |
LBW size= bv_bits_to_size(bits); |
| 18325 |
LBW bytes= (size+(LBW)bv_hiddenwords)*(LBW)sizeof(Bit_Vector_Word); |
| 18326 |
LBW*addr= (Bit_Vector)my_malloc0((size_t)bytes); |
| 18327 |
*addr++= (LBW)bits; |
| 18328 |
*addr++= size; |
| 18329 |
*addr++= bv_bits_to_unused_mask(bits); |
| 18330 |
return addr; |
| 18331 |
} |
| 18332 |
|
| 18333 |
/*:1130*//*1132:*/ |
| 18334 |
#line 13559 "./marpa.w" |
| 18335 |
|
| 18336 |
PRIVATE Bit_Vector |
| 18337 |
bv_obs_create(struct marpa_obstack*obs,int bits) |
| 18338 |
{ |
| 18339 |
LBW size= bv_bits_to_size(bits); |
| 18340 |
LBW bytes= (size+(LBW)bv_hiddenwords)*(LBW)sizeof(Bit_Vector_Word); |
| 18341 |
LBW*addr= (Bit_Vector)marpa__obs_alloc(obs,(size_t)bytes,ALIGNOF(LBW)); |
| 18342 |
*addr++= (LBW)bits; |
| 18343 |
*addr++= size; |
| 18344 |
*addr++= bv_bits_to_unused_mask(bits); |
| 18345 |
if(size> 0){ |
| 18346 |
Bit_Vector bv= addr; |
| 18347 |
while(size--)*bv++= 0u; |
| 18348 |
} |
| 18349 |
return addr; |
| 18350 |
} |
| 18351 |
|
| 18352 |
|
| 18353 |
/*:1132*//*1133:*/ |
| 18354 |
#line 13580 "./marpa.w" |
| 18355 |
|
| 18356 |
PRIVATE Bit_Vector bv_shadow(Bit_Vector bv) |
| 18357 |
{ |
| 18358 |
return bv_create((int)BV_BITS(bv)); |
| 18359 |
} |
| 18360 |
PRIVATE Bit_Vector bv_obs_shadow(struct marpa_obstack*obs,Bit_Vector bv) |
| 18361 |
{ |
| 18362 |
return bv_obs_create(obs,(int)BV_BITS(bv)); |
| 18363 |
} |
| 18364 |
|
| 18365 |
/*:1133*//*1134:*/ |
| 18366 |
#line 13594 "./marpa.w" |
| 18367 |
|
| 18368 |
PRIVATE |
| 18369 |
Bit_Vector bv_copy(Bit_Vector bv_to,Bit_Vector bv_from) |
| 18370 |
{ |
| 18371 |
LBW*p_to= bv_to; |
| 18372 |
const LBW bits= BV_BITS(bv_to); |
| 18373 |
if(bits> 0) |
| 18374 |
{ |
| 18375 |
LBW count= BV_SIZE(bv_to); |
| 18376 |
while(count--)*p_to++= *bv_from++; |
| 18377 |
} |
| 18378 |
return(bv_to); |
| 18379 |
} |
| 18380 |
|
| 18381 |
/*:1134*//*1135:*/ |
| 18382 |
#line 13612 "./marpa.w" |
| 18383 |
|
| 18384 |
PRIVATE |
| 18385 |
Bit_Vector bv_clone(Bit_Vector bv) |
| 18386 |
{ |
| 18387 |
return bv_copy(bv_shadow(bv),bv); |
| 18388 |
} |
| 18389 |
|
| 18390 |
PRIVATE |
| 18391 |
Bit_Vector bv_obs_clone(struct marpa_obstack*obs,Bit_Vector bv) |
| 18392 |
{ |
| 18393 |
return bv_copy(bv_obs_shadow(obs,bv),bv); |
| 18394 |
} |
| 18395 |
|
| 18396 |
/*:1135*//*1136:*/ |
| 18397 |
#line 13626 "./marpa.w" |
| 18398 |
|
| 18399 |
PRIVATE void bv_free(Bit_Vector vector) |
| 18400 |
{ |
| 18401 |
if(_MARPA_LIKELY(vector!=NULL)) |
| 18402 |
{ |
| 18403 |
vector-= bv_hiddenwords; |
| 18404 |
my_free(vector); |
| 18405 |
} |
| 18406 |
} |
| 18407 |
|
| 18408 |
/*:1136*//*1137:*/ |
| 18409 |
#line 13637 "./marpa.w" |
| 18410 |
|
| 18411 |
PRIVATE void bv_fill(Bit_Vector bv) |
| 18412 |
{ |
| 18413 |
LBW size= BV_SIZE(bv); |
| 18414 |
if(size<=0)return; |
| 18415 |
while(size--)*bv++= ~0u; |
| 18416 |
--bv; |
| 18417 |
*bv&= BV_MASK(bv); |
| 18418 |
} |
| 18419 |
|
| 18420 |
/*:1137*//*1138:*/ |
| 18421 |
#line 13648 "./marpa.w" |
| 18422 |
|
| 18423 |
PRIVATE void bv_clear(Bit_Vector bv) |
| 18424 |
{ |
| 18425 |
LBW size= BV_SIZE(bv); |
| 18426 |
if(size<=0)return; |
| 18427 |
while(size--)*bv++= 0u; |
| 18428 |
} |
| 18429 |
|
| 18430 |
/*:1138*//*1140:*/ |
| 18431 |
#line 13662 "./marpa.w" |
| 18432 |
|
| 18433 |
PRIVATE void bv_over_clear(Bit_Vector bv,int raw_bit) |
| 18434 |
{ |
| 18435 |
const LBW bit= (LBW)raw_bit; |
| 18436 |
LBW length= bit/bv_wordbits+1; |
| 18437 |
while(length--)*bv++= 0u; |
| 18438 |
} |
| 18439 |
|
| 18440 |
/*:1140*//*1142:*/ |
| 18441 |
#line 13671 "./marpa.w" |
| 18442 |
|
| 18443 |
PRIVATE void bv_bit_set(Bit_Vector vector,int raw_bit) |
| 18444 |
{ |
| 18445 |
const LBW bit= (LBW)raw_bit; |
| 18446 |
*(vector+(bit/bv_wordbits))|= (bv_lsb<<(bit%bv_wordbits)); |
| 18447 |
} |
| 18448 |
|
| 18449 |
/*:1142*//*1143:*/ |
| 18450 |
#line 13679 "./marpa.w" |
| 18451 |
|
| 18452 |
PRIVATE void bv_bit_clear(Bit_Vector vector,int raw_bit) |
| 18453 |
{ |
| 18454 |
const LBW bit= (LBW)raw_bit; |
| 18455 |
*(vector+(bit/bv_wordbits))&= ~(bv_lsb<<(bit%bv_wordbits)); |
| 18456 |
} |
| 18457 |
|
| 18458 |
/*:1143*//*1144:*/ |
| 18459 |
#line 13687 "./marpa.w" |
| 18460 |
|
| 18461 |
PRIVATE int bv_bit_test(Bit_Vector vector,int raw_bit) |
| 18462 |
{ |
| 18463 |
const LBW bit= (LBW)raw_bit; |
| 18464 |
return(*(vector+(bit/bv_wordbits))&(bv_lsb<<(bit%bv_wordbits)))!=0u; |
| 18465 |
} |
| 18466 |
|
| 18467 |
/*:1144*//*1145:*/ |
| 18468 |
#line 13699 "./marpa.w" |
| 18469 |
|
| 18470 |
PRIVATE int |
| 18471 |
bv_bit_test_then_set(Bit_Vector vector,int raw_bit) |
| 18472 |
{ |
| 18473 |
const LBW bit= (LBW)raw_bit; |
| 18474 |
Bit_Vector addr= vector+(bit/bv_wordbits); |
| 18475 |
LBW mask= bv_lsb<<(bit%bv_wordbits); |
| 18476 |
if((*addr&mask)!=0u) |
| 18477 |
return 1; |
| 18478 |
*addr|= mask; |
| 18479 |
return 0; |
| 18480 |
} |
| 18481 |
|
| 18482 |
/*:1145*//*1146:*/ |
| 18483 |
#line 13713 "./marpa.w" |
| 18484 |
|
| 18485 |
PRIVATE |
| 18486 |
int bv_is_empty(Bit_Vector addr) |
| 18487 |
{ |
| 18488 |
LBW size= BV_SIZE(addr); |
| 18489 |
int r= 1; |
| 18490 |
if(size> 0){ |
| 18491 |
*(addr+size-1)&= BV_MASK(addr); |
| 18492 |
while(r&&(size--> 0))r= (*addr++==0); |
| 18493 |
} |
| 18494 |
return(r); |
| 18495 |
} |
| 18496 |
|
| 18497 |
/*:1146*//*1147:*/ |
| 18498 |
#line 13727 "./marpa.w" |
| 18499 |
|
| 18500 |
PRIVATE void bv_not(Bit_Vector X,Bit_Vector Y) |
| 18501 |
{ |
| 18502 |
LBW size= BV_SIZE(X); |
| 18503 |
LBW mask= BV_MASK(X); |
| 18504 |
while(size--> 0)*X++= ~*Y++; |
| 18505 |
*(--X)&= mask; |
| 18506 |
} |
| 18507 |
|
| 18508 |
/*:1147*//*1148:*/ |
| 18509 |
#line 13737 "./marpa.w" |
| 18510 |
|
| 18511 |
PRIVATE void bv_and(Bit_Vector X,Bit_Vector Y,Bit_Vector Z) |
| 18512 |
{ |
| 18513 |
LBW size= BV_SIZE(X); |
| 18514 |
LBW mask= BV_MASK(X); |
| 18515 |
while(size--> 0)*X++= *Y++&*Z++; |
| 18516 |
*(--X)&= mask; |
| 18517 |
} |
| 18518 |
|
| 18519 |
/*:1148*//*1149:*/ |
| 18520 |
#line 13747 "./marpa.w" |
| 18521 |
|
| 18522 |
PRIVATE void bv_or(Bit_Vector X,Bit_Vector Y,Bit_Vector Z) |
| 18523 |
{ |
| 18524 |
LBW size= BV_SIZE(X); |
| 18525 |
LBW mask= BV_MASK(X); |
| 18526 |
while(size--> 0)*X++= *Y++|*Z++; |
| 18527 |
*(--X)&= mask; |
| 18528 |
} |
| 18529 |
|
| 18530 |
/*:1149*//*1150:*/ |
| 18531 |
#line 13757 "./marpa.w" |
| 18532 |
|
| 18533 |
PRIVATE void bv_or_assign(Bit_Vector X,Bit_Vector Y) |
| 18534 |
{ |
| 18535 |
LBW size= BV_SIZE(X); |
| 18536 |
LBW mask= BV_MASK(X); |
| 18537 |
while(size--> 0)*X++|= *Y++; |
| 18538 |
*(--X)&= mask; |
| 18539 |
} |
| 18540 |
|
| 18541 |
/*:1150*//*1151:*/ |
| 18542 |
#line 13767 "./marpa.w" |
| 18543 |
|
| 18544 |
PRIVATE_NOT_INLINE |
| 18545 |
int bv_scan(Bit_Vector bv,int raw_start,int*raw_min,int*raw_max) |
| 18546 |
{ |
| 18547 |
LBW start= (LBW)raw_start; |
| 18548 |
LBW min; |
| 18549 |
LBW max; |
| 18550 |
LBW size= BV_SIZE(bv); |
| 18551 |
LBW mask= BV_MASK(bv); |
| 18552 |
LBW offset; |
| 18553 |
LBW bitmask; |
| 18554 |
LBW value; |
| 18555 |
int empty; |
| 18556 |
|
| 18557 |
if(size==0)return 0; |
| 18558 |
if(start>=BV_BITS(bv))return 0; |
| 18559 |
min= start; |
| 18560 |
max= start; |
| 18561 |
offset= start/bv_wordbits; |
| 18562 |
*(bv+size-1)&= mask; |
| 18563 |
bv+= offset; |
| 18564 |
size-= offset; |
| 18565 |
bitmask= (LBW)1<<(start&bv_modmask); |
| 18566 |
mask= ~(bitmask|(bitmask-(LBW)1)); |
| 18567 |
value= *bv++; |
| 18568 |
if((value&bitmask)==0) |
| 18569 |
{ |
| 18570 |
value&= mask; |
| 18571 |
if(value==0) |
| 18572 |
{ |
| 18573 |
offset++; |
| 18574 |
empty= 1; |
| 18575 |
while(empty&&(--size> 0)) |
| 18576 |
{ |
| 18577 |
if((value= *bv++))empty= 0;else offset++; |
| 18578 |
} |
| 18579 |
if(empty){ |
| 18580 |
*raw_min= (int)min; |
| 18581 |
*raw_max= (int)max; |
| 18582 |
return 0; |
| 18583 |
} |
| 18584 |
} |
| 18585 |
start= offset*bv_wordbits; |
| 18586 |
bitmask= bv_lsb; |
| 18587 |
mask= value; |
| 18588 |
while(!(mask&bv_lsb)) |
| 18589 |
{ |
| 18590 |
bitmask<<= 1; |
| 18591 |
mask>>= 1; |
| 18592 |
start++; |
| 18593 |
} |
| 18594 |
mask= ~(bitmask|(bitmask-1)); |
| 18595 |
min= start; |
| 18596 |
max= start; |
| 18597 |
} |
| 18598 |
value= ~value; |
| 18599 |
value&= mask; |
| 18600 |
if(value==0) |
| 18601 |
{ |
| 18602 |
offset++; |
| 18603 |
empty= 1; |
| 18604 |
while(empty&&(--size> 0)) |
| 18605 |
{ |
| 18606 |
if((value= ~*bv++))empty= 0;else offset++; |
| 18607 |
} |
| 18608 |
if(empty)value= bv_lsb; |
| 18609 |
} |
| 18610 |
start= offset*bv_wordbits; |
| 18611 |
while(!(value&bv_lsb)) |
| 18612 |
{ |
| 18613 |
value>>= 1; |
| 18614 |
start++; |
| 18615 |
} |
| 18616 |
max= --start; |
| 18617 |
*raw_min= (int)min; |
| 18618 |
*raw_max= (int)max; |
| 18619 |
return 1; |
| 18620 |
} |
| 18621 |
|
| 18622 |
/*:1151*//*1152:*/ |
| 18623 |
#line 13847 "./marpa.w" |
| 18624 |
|
| 18625 |
PRIVATE int |
| 18626 |
bv_count(Bit_Vector v) |
| 18627 |
{ |
| 18628 |
int start,min,max; |
| 18629 |
int count= 0; |
| 18630 |
for(start= 0;bv_scan(v,start,&min,&max);start= max+2) |
| 18631 |
{ |
| 18632 |
count+= max-min+1; |
| 18633 |
} |
| 18634 |
return count; |
| 18635 |
} |
| 18636 |
|
| 18637 |
/*:1152*//*1157:*/ |
| 18638 |
#line 13894 "./marpa.w" |
| 18639 |
|
| 18640 |
PRIVATE void |
| 18641 |
rhs_closure(GRAMMAR g,Bit_Vector bv,XRLID**xrl_list_x_rh_sym) |
| 18642 |
{ |
| 18643 |
int min,max,start= 0; |
| 18644 |
Marpa_Symbol_ID*end_of_stack= NULL; |
| 18645 |
|
| 18646 |
|
| 18647 |
|
| 18648 |
FSTACK_DECLARE(stack,XSYID) |
| 18649 |
FSTACK_INIT(stack,XSYID,XSY_Count_of_G(g)); |
| 18650 |
|
| 18651 |
|
| 18652 |
|
| 18653 |
|
| 18654 |
|
| 18655 |
|
| 18656 |
|
| 18657 |
|
| 18658 |
|
| 18659 |
|
| 18660 |
while(bv_scan(bv,start,&min,&max)) |
| 18661 |
{ |
| 18662 |
XSYID xsy_id; |
| 18663 |
for(xsy_id= min;xsy_id<=max;xsy_id++) |
| 18664 |
{ |
| 18665 |
*(FSTACK_PUSH(stack))= xsy_id; |
| 18666 |
} |
| 18667 |
start= max+2; |
| 18668 |
} |
| 18669 |
|
| 18670 |
|
| 18671 |
|
| 18672 |
while((end_of_stack= FSTACK_POP(stack))) |
| 18673 |
{ |
| 18674 |
|
| 18675 |
|
| 18676 |
const XSYID xsy_id= *end_of_stack; |
| 18677 |
XRLID*p_xrl= xrl_list_x_rh_sym[xsy_id]; |
| 18678 |
const XRLID*p_one_past_rules= xrl_list_x_rh_sym[xsy_id+1]; |
| 18679 |
|
| 18680 |
for(;p_xrl<p_one_past_rules;p_xrl++) |
| 18681 |
{ |
| 18682 |
|
| 18683 |
|
| 18684 |
const XRLID rule_id= *p_xrl; |
| 18685 |
const XRL rule= XRL_by_ID(rule_id); |
| 18686 |
int rule_length; |
| 18687 |
int rh_ix; |
| 18688 |
const XSYID lhs_id= LHS_ID_of_XRL(rule); |
| 18689 |
|
| 18690 |
const int is_sequence= XRL_is_Sequence(rule); |
| 18691 |
|
| 18692 |
|
| 18693 |
|
| 18694 |
|
| 18695 |
if(bv_bit_test(bv,lhs_id)) |
| 18696 |
goto NEXT_RULE; |
| 18697 |
|
| 18698 |
rule_length= Length_of_XRL(rule); |
| 18699 |
|
| 18700 |
|
| 18701 |
|
| 18702 |
|
| 18703 |
|
| 18704 |
|
| 18705 |
|
| 18706 |
|
| 18707 |
|
| 18708 |
|
| 18709 |
|
| 18710 |
|
| 18711 |
|
| 18712 |
for(rh_ix= 0;rh_ix<rule_length;rh_ix++) |
| 18713 |
{ |
| 18714 |
if(!bv_bit_test |
| 18715 |
(bv,RHS_ID_of_XRL(rule,rh_ix))) |
| 18716 |
goto NEXT_RULE; |
| 18717 |
} |
| 18718 |
|
| 18719 |
|
| 18720 |
|
| 18721 |
|
| 18722 |
|
| 18723 |
|
| 18724 |
|
| 18725 |
|
| 18726 |
|
| 18727 |
|
| 18728 |
if(is_sequence&&Minimum_of_XRL(rule)>=2) |
| 18729 |
{ |
| 18730 |
XSYID separator_id= Separator_of_XRL(rule); |
| 18731 |
if(separator_id>=0) |
| 18732 |
{ |
| 18733 |
if(!bv_bit_test(bv,separator_id)) |
| 18734 |
goto NEXT_RULE; |
| 18735 |
} |
| 18736 |
} |
| 18737 |
|
| 18738 |
|
| 18739 |
|
| 18740 |
|
| 18741 |
|
| 18742 |
|
| 18743 |
|
| 18744 |
bv_bit_set(bv,lhs_id); |
| 18745 |
*(FSTACK_PUSH(stack))= lhs_id; |
| 18746 |
NEXT_RULE:; |
| 18747 |
} |
| 18748 |
} |
| 18749 |
FSTACK_DESTROY(stack); |
| 18750 |
} |
| 18751 |
|
| 18752 |
/*:1157*//*1162:*/ |
| 18753 |
#line 14041 "./marpa.w" |
| 18754 |
|
| 18755 |
PRIVATE Bit_Matrix |
| 18756 |
matrix_buffer_create(void*buffer,int rows,int columns) |
| 18757 |
{ |
| 18758 |
int row; |
| 18759 |
const LBW bv_data_words= bv_bits_to_size(columns); |
| 18760 |
const LBW bv_mask= bv_bits_to_unused_mask(columns); |
| 18761 |
|
| 18762 |
Bit_Matrix matrix_addr= buffer; |
| 18763 |
matrix_addr->t_row_count= rows; |
| 18764 |
for(row= 0;row<rows;row++){ |
| 18765 |
const LBW row_start= (LBW)row*(bv_data_words+bv_hiddenwords); |
| 18766 |
LBW*p_current_word= matrix_addr->t_row_data+row_start; |
| 18767 |
LBW data_word_counter= bv_data_words; |
| 18768 |
*p_current_word++= (LBW)columns; |
| 18769 |
*p_current_word++= bv_data_words; |
| 18770 |
*p_current_word++= bv_mask; |
| 18771 |
while(data_word_counter--)*p_current_word++= 0; |
| 18772 |
} |
| 18773 |
return matrix_addr; |
| 18774 |
} |
| 18775 |
|
| 18776 |
/*:1162*//*1164:*/ |
| 18777 |
#line 14064 "./marpa.w" |
| 18778 |
|
| 18779 |
PRIVATE size_t matrix_sizeof(int rows,int columns) |
| 18780 |
{ |
| 18781 |
const LBW bv_data_words= bv_bits_to_size(columns); |
| 18782 |
const LBW row_bytes= |
| 18783 |
(LBW)(bv_data_words+bv_hiddenwords)*(LBW)sizeof(Bit_Vector_Word); |
| 18784 |
return offsetof(struct s_bit_matrix, |
| 18785 |
t_row_data)+((size_t)rows)*row_bytes; |
| 18786 |
} |
| 18787 |
|
| 18788 |
/*:1164*//*1166:*/ |
| 18789 |
#line 14075 "./marpa.w" |
| 18790 |
|
| 18791 |
PRIVATE Bit_Matrix matrix_obs_create( |
| 18792 |
struct marpa_obstack*obs, |
| 18793 |
int rows, |
| 18794 |
int columns) |
| 18795 |
{ |
| 18796 |
|
| 18797 |
Bit_Matrix matrix_addr= |
| 18798 |
marpa__obs_alloc(obs,matrix_sizeof(rows,columns),ALIGNOF(Bit_Matrix_Object)); |
| 18799 |
return matrix_buffer_create(matrix_addr,rows,columns); |
| 18800 |
} |
| 18801 |
|
| 18802 |
/*:1166*//*1167:*/ |
| 18803 |
#line 14088 "./marpa.w" |
| 18804 |
|
| 18805 |
PRIVATE void matrix_clear(Bit_Matrix matrix) |
| 18806 |
{ |
| 18807 |
Bit_Vector row; |
| 18808 |
int row_ix; |
| 18809 |
const int row_count= matrix->t_row_count; |
| 18810 |
Bit_Vector row0= matrix->t_row_data+bv_hiddenwords; |
| 18811 |
LBW words_per_row= BV_SIZE(row0)+bv_hiddenwords; |
| 18812 |
row_ix= 0;row= row0; |
| 18813 |
while(row_ix<row_count){ |
| 18814 |
bv_clear(row); |
| 18815 |
row_ix++; |
| 18816 |
row+= words_per_row; |
| 18817 |
} |
| 18818 |
} |
| 18819 |
|
| 18820 |
/*:1167*//*1168:*/ |
| 18821 |
#line 14110 "./marpa.w" |
| 18822 |
|
| 18823 |
PRIVATE int matrix_columns(Bit_Matrix matrix) |
| 18824 |
{ |
| 18825 |
Bit_Vector row0= matrix->t_row_data+bv_hiddenwords; |
| 18826 |
return(int)BV_BITS(row0); |
| 18827 |
} |
| 18828 |
|
| 18829 |
/*:1168*//*1169:*/ |
| 18830 |
#line 14126 "./marpa.w" |
| 18831 |
|
| 18832 |
PRIVATE Bit_Vector matrix_row(Bit_Matrix matrix,int row) |
| 18833 |
{ |
| 18834 |
Bit_Vector row0= matrix->t_row_data+bv_hiddenwords; |
| 18835 |
LBW words_per_row= BV_SIZE(row0)+bv_hiddenwords; |
| 18836 |
return row0+(LBW)row*words_per_row; |
| 18837 |
} |
| 18838 |
|
| 18839 |
/*:1169*//*1171:*/ |
| 18840 |
#line 14135 "./marpa.w" |
| 18841 |
|
| 18842 |
PRIVATE void matrix_bit_set(Bit_Matrix matrix,int row,int column) |
| 18843 |
{ |
| 18844 |
Bit_Vector vector= matrix_row(matrix,row); |
| 18845 |
bv_bit_set(vector,column); |
| 18846 |
} |
| 18847 |
|
| 18848 |
/*:1171*//*1173:*/ |
| 18849 |
#line 14143 "./marpa.w" |
| 18850 |
|
| 18851 |
PRIVATE void matrix_bit_clear(Bit_Matrix matrix,int row,int column) |
| 18852 |
{ |
| 18853 |
Bit_Vector vector= matrix_row(matrix,row); |
| 18854 |
bv_bit_clear(vector,column); |
| 18855 |
} |
| 18856 |
|
| 18857 |
/*:1173*//*1175:*/ |
| 18858 |
#line 14151 "./marpa.w" |
| 18859 |
|
| 18860 |
PRIVATE int matrix_bit_test(Bit_Matrix matrix,int row,int column) |
| 18861 |
{ |
| 18862 |
Bit_Vector vector= matrix_row(matrix,row); |
| 18863 |
return bv_bit_test(vector,column); |
| 18864 |
} |
| 18865 |
|
| 18866 |
/*:1175*//*1176:*/ |
| 18867 |
#line 14168 "./marpa.w" |
| 18868 |
|
| 18869 |
PRIVATE_NOT_INLINE void transitive_closure(Bit_Matrix matrix) |
| 18870 |
{ |
| 18871 |
int size= matrix_columns(matrix); |
| 18872 |
int outer_row; |
| 18873 |
for(outer_row= 0;outer_row<size;outer_row++) |
| 18874 |
{ |
| 18875 |
Bit_Vector outer_row_v= matrix_row(matrix,outer_row); |
| 18876 |
int column; |
| 18877 |
for(column= 0;column<size;column++) |
| 18878 |
{ |
| 18879 |
Bit_Vector inner_row_v= matrix_row(matrix,column); |
| 18880 |
if(bv_bit_test(inner_row_v,outer_row)) |
| 18881 |
{ |
| 18882 |
bv_or_assign(inner_row_v,outer_row_v); |
| 18883 |
} |
| 18884 |
} |
| 18885 |
} |
| 18886 |
} |
| 18887 |
|
| 18888 |
/*:1176*//*1188:*/ |
| 18889 |
#line 14309 "./marpa.w" |
| 18890 |
|
| 18891 |
PRIVATE void |
| 18892 |
cilar_init(const CILAR cilar) |
| 18893 |
{ |
| 18894 |
cilar->t_obs= marpa_obs_init; |
| 18895 |
cilar->t_avl= _marpa_avl_create(cil_cmp,NULL); |
| 18896 |
MARPA_DSTACK_INIT(cilar->t_buffer,int,2); |
| 18897 |
*MARPA_DSTACK_INDEX(cilar->t_buffer,int,0)= 0; |
| 18898 |
} |
| 18899 |
/*:1188*//*1189:*/ |
| 18900 |
#line 14323 "./marpa.w" |
| 18901 |
|
| 18902 |
PRIVATE void |
| 18903 |
cilar_buffer_reinit(const CILAR cilar) |
| 18904 |
{ |
| 18905 |
MARPA_DSTACK_DESTROY(cilar->t_buffer); |
| 18906 |
MARPA_DSTACK_INIT(cilar->t_buffer,int,2); |
| 18907 |
*MARPA_DSTACK_INDEX(cilar->t_buffer,int,0)= 0; |
| 18908 |
} |
| 18909 |
|
| 18910 |
/*:1189*//*1190:*/ |
| 18911 |
#line 14332 "./marpa.w" |
| 18912 |
|
| 18913 |
PRIVATE void cilar_destroy(const CILAR cilar) |
| 18914 |
{ |
| 18915 |
_marpa_avl_destroy(cilar->t_avl); |
| 18916 |
marpa_obs_free(cilar->t_obs); |
| 18917 |
MARPA_DSTACK_DESTROY((cilar->t_buffer)); |
| 18918 |
} |
| 18919 |
|
| 18920 |
/*:1190*//*1191:*/ |
| 18921 |
#line 14341 "./marpa.w" |
| 18922 |
|
| 18923 |
PRIVATE CIL cil_empty(CILAR cilar) |
| 18924 |
{ |
| 18925 |
CIL cil= MARPA_DSTACK_BASE(cilar->t_buffer,int); |
| 18926 |
|
| 18927 |
Count_of_CIL(cil)= 0; |
| 18928 |
return cil_buffer_add(cilar); |
| 18929 |
} |
| 18930 |
|
| 18931 |
/*:1191*//*1192:*/ |
| 18932 |
#line 14351 "./marpa.w" |
| 18933 |
|
| 18934 |
PRIVATE CIL cil_singleton(CILAR cilar,int element) |
| 18935 |
{ |
| 18936 |
CIL cil= MARPA_DSTACK_BASE(cilar->t_buffer,int); |
| 18937 |
Count_of_CIL(cil)= 1; |
| 18938 |
Item_of_CIL(cil,0)= element; |
| 18939 |
|
| 18940 |
return cil_buffer_add(cilar); |
| 18941 |
} |
| 18942 |
|
| 18943 |
/*:1192*//*1193:*/ |
| 18944 |
#line 14367 "./marpa.w" |
| 18945 |
|
| 18946 |
PRIVATE CIL cil_buffer_add(CILAR cilar) |
| 18947 |
{ |
| 18948 |
|
| 18949 |
CIL cil_in_buffer= MARPA_DSTACK_BASE(cilar->t_buffer,int); |
| 18950 |
CIL found_cil= _marpa_avl_find(cilar->t_avl,cil_in_buffer); |
| 18951 |
if(!found_cil) |
| 18952 |
{ |
| 18953 |
int i; |
| 18954 |
const int cil_size_in_ints= Count_of_CIL(cil_in_buffer)+1; |
| 18955 |
found_cil= marpa_obs_new(cilar->t_obs,int,cil_size_in_ints); |
| 18956 |
for(i= 0;i<cil_size_in_ints;i++) |
| 18957 |
{ |
| 18958 |
found_cil[i]= cil_in_buffer[i]; |
| 18959 |
} |
| 18960 |
_marpa_avl_insert(cilar->t_avl,found_cil); |
| 18961 |
} |
| 18962 |
return found_cil; |
| 18963 |
} |
| 18964 |
|
| 18965 |
/*:1193*//*1194:*/ |
| 18966 |
#line 14395 "./marpa.w" |
| 18967 |
|
| 18968 |
PRIVATE CIL cil_bv_add(CILAR cilar,Bit_Vector bv) |
| 18969 |
{ |
| 18970 |
int min,max,start= 0; |
| 18971 |
cil_buffer_clear(cilar); |
| 18972 |
for(start= 0;bv_scan(bv,start,&min,&max);start= max+2) |
| 18973 |
{ |
| 18974 |
int new_item; |
| 18975 |
for(new_item= min;new_item<=max;new_item++) |
| 18976 |
{ |
| 18977 |
cil_buffer_push(cilar,new_item); |
| 18978 |
} |
| 18979 |
} |
| 18980 |
return cil_buffer_add(cilar); |
| 18981 |
} |
| 18982 |
|
| 18983 |
/*:1194*//*1195:*/ |
| 18984 |
#line 14412 "./marpa.w" |
| 18985 |
|
| 18986 |
PRIVATE void cil_buffer_clear(CILAR cilar) |
| 18987 |
{ |
| 18988 |
const MARPA_DSTACK dstack= &cilar->t_buffer; |
| 18989 |
MARPA_DSTACK_CLEAR(*dstack); |
| 18990 |
|
| 18991 |
|
| 18992 |
|
| 18993 |
|
| 18994 |
*MARPA_DSTACK_PUSH(*dstack,int)= 0; |
| 18995 |
} |
| 18996 |
|
| 18997 |
/*:1195*//*1196:*/ |
| 18998 |
#line 14427 "./marpa.w" |
| 18999 |
|
| 19000 |
PRIVATE CIL cil_buffer_push(CILAR cilar,int new_item) |
| 19001 |
{ |
| 19002 |
CIL cil_in_buffer; |
| 19003 |
MARPA_DSTACK dstack= &cilar->t_buffer; |
| 19004 |
*MARPA_DSTACK_PUSH(*dstack,int)= new_item; |
| 19005 |
|
| 19006 |
|
| 19007 |
|
| 19008 |
cil_in_buffer= MARPA_DSTACK_BASE(*dstack,int); |
| 19009 |
Count_of_CIL(cil_in_buffer)++; |
| 19010 |
return cil_in_buffer; |
| 19011 |
} |
| 19012 |
|
| 19013 |
/*:1196*//*1197:*/ |
| 19014 |
#line 14443 "./marpa.w" |
| 19015 |
|
| 19016 |
PRIVATE CIL cil_buffer_reserve(CILAR cilar,int element_count) |
| 19017 |
{ |
| 19018 |
const int desired_dstack_capacity= element_count+1; |
| 19019 |
|
| 19020 |
const int old_dstack_capacity= MARPA_DSTACK_CAPACITY(cilar->t_buffer); |
| 19021 |
if(old_dstack_capacity<desired_dstack_capacity) |
| 19022 |
{ |
| 19023 |
const int target_capacity= |
| 19024 |
MAX(old_dstack_capacity*2,desired_dstack_capacity); |
| 19025 |
MARPA_DSTACK_RESIZE(&(cilar->t_buffer),int,target_capacity); |
| 19026 |
} |
| 19027 |
return MARPA_DSTACK_BASE(cilar->t_buffer,int); |
| 19028 |
} |
| 19029 |
|
| 19030 |
/*:1197*//*1198:*/ |
| 19031 |
#line 14462 "./marpa.w" |
| 19032 |
|
| 19033 |
PRIVATE CIL cil_merge(CILAR cilar,CIL cil1,CIL cil2) |
| 19034 |
{ |
| 19035 |
const int cil1_count= Count_of_CIL(cil1); |
| 19036 |
const int cil2_count= Count_of_CIL(cil2); |
| 19037 |
CIL new_cil= cil_buffer_reserve(cilar,cil1_count+cil2_count); |
| 19038 |
int new_cil_ix= 0; |
| 19039 |
int cil1_ix= 0; |
| 19040 |
int cil2_ix= 0; |
| 19041 |
while(cil1_ix<cil1_count&&cil2_ix<cil2_count) |
| 19042 |
{ |
| 19043 |
const int item1= Item_of_CIL(cil1,cil1_ix); |
| 19044 |
const int item2= Item_of_CIL(cil2,cil2_ix); |
| 19045 |
if(item1<item2) |
| 19046 |
{ |
| 19047 |
Item_of_CIL(new_cil,new_cil_ix)= item1; |
| 19048 |
cil1_ix++; |
| 19049 |
new_cil_ix++; |
| 19050 |
continue; |
| 19051 |
} |
| 19052 |
if(item2<item1) |
| 19053 |
{ |
| 19054 |
Item_of_CIL(new_cil,new_cil_ix)= item2; |
| 19055 |
cil2_ix++; |
| 19056 |
new_cil_ix++; |
| 19057 |
continue; |
| 19058 |
} |
| 19059 |
Item_of_CIL(new_cil,new_cil_ix)= item1; |
| 19060 |
cil1_ix++; |
| 19061 |
cil2_ix++; |
| 19062 |
new_cil_ix++; |
| 19063 |
} |
| 19064 |
while(cil1_ix<cil1_count){ |
| 19065 |
const int item1= Item_of_CIL(cil1,cil1_ix); |
| 19066 |
Item_of_CIL(new_cil,new_cil_ix)= item1; |
| 19067 |
cil1_ix++; |
| 19068 |
new_cil_ix++; |
| 19069 |
} |
| 19070 |
while(cil2_ix<cil2_count){ |
| 19071 |
const int item2= Item_of_CIL(cil2,cil2_ix); |
| 19072 |
Item_of_CIL(new_cil,new_cil_ix)= item2; |
| 19073 |
cil2_ix++; |
| 19074 |
new_cil_ix++; |
| 19075 |
} |
| 19076 |
Count_of_CIL(new_cil)= new_cil_ix; |
| 19077 |
return cil_buffer_add(cilar); |
| 19078 |
} |
| 19079 |
|
| 19080 |
/*:1198*//*1199:*/ |
| 19081 |
#line 14515 "./marpa.w" |
| 19082 |
|
| 19083 |
PRIVATE CIL cil_merge_one(CILAR cilar,CIL cil,int new_element) |
| 19084 |
{ |
| 19085 |
const int cil_count= Count_of_CIL(cil); |
| 19086 |
CIL new_cil= cil_buffer_reserve(cilar,cil_count+1); |
| 19087 |
int new_cil_ix= 0; |
| 19088 |
int cil_ix= 0; |
| 19089 |
while(cil_ix<cil_count) |
| 19090 |
{ |
| 19091 |
const int cil_item= Item_of_CIL(cil,cil_ix); |
| 19092 |
if(cil_item==new_element) |
| 19093 |
{ |
| 19094 |
|
| 19095 |
|
| 19096 |
return NULL; |
| 19097 |
} |
| 19098 |
if(cil_item> new_element) |
| 19099 |
break; |
| 19100 |
Item_of_CIL(new_cil,new_cil_ix)= cil_item; |
| 19101 |
cil_ix++; |
| 19102 |
new_cil_ix++; |
| 19103 |
} |
| 19104 |
Item_of_CIL(new_cil,new_cil_ix)= new_element; |
| 19105 |
new_cil_ix++; |
| 19106 |
while(cil_ix<cil_count) |
| 19107 |
{ |
| 19108 |
const int cil_item= Item_of_CIL(cil,cil_ix); |
| 19109 |
Item_of_CIL(new_cil,new_cil_ix)= cil_item; |
| 19110 |
cil_ix++; |
| 19111 |
new_cil_ix++; |
| 19112 |
} |
| 19113 |
Count_of_CIL(new_cil)= new_cil_ix; |
| 19114 |
return cil_buffer_add(cilar); |
| 19115 |
} |
| 19116 |
|
| 19117 |
/*:1199*//*1200:*/ |
| 19118 |
#line 14550 "./marpa.w" |
| 19119 |
|
| 19120 |
PRIVATE_NOT_INLINE int |
| 19121 |
cil_cmp(const void*ap,const void*bp,void*param UNUSED) |
| 19122 |
{ |
| 19123 |
int ix; |
| 19124 |
CIL cil1= (CIL)ap; |
| 19125 |
CIL cil2= (CIL)bp; |
| 19126 |
int count1= Count_of_CIL(cil1); |
| 19127 |
int count2= Count_of_CIL(cil2); |
| 19128 |
if(count1!=count2) |
| 19129 |
{ |
| 19130 |
return count1> count2?1:-1; |
| 19131 |
} |
| 19132 |
for(ix= 0;ix<count1;ix++) |
| 19133 |
{ |
| 19134 |
const int item1= Item_of_CIL(cil1,ix); |
| 19135 |
const int item2= Item_of_CIL(cil2,ix); |
| 19136 |
if(item1==item2) |
| 19137 |
continue; |
| 19138 |
return item1> item2?1:-1; |
| 19139 |
} |
| 19140 |
return 0; |
| 19141 |
} |
| 19142 |
|
| 19143 |
/*:1200*//*1213:*/ |
| 19144 |
#line 14689 "./marpa.w" |
| 19145 |
|
| 19146 |
PRIVATE void |
| 19147 |
psar_safe(const PSAR psar) |
| 19148 |
{ |
| 19149 |
psar->t_psl_length= 0; |
| 19150 |
psar->t_first_psl= psar->t_first_free_psl= NULL; |
| 19151 |
} |
| 19152 |
/*:1213*//*1214:*/ |
| 19153 |
#line 14696 "./marpa.w" |
| 19154 |
|
| 19155 |
PRIVATE void |
| 19156 |
psar_init(const PSAR psar,int length) |
| 19157 |
{ |
| 19158 |
psar->t_psl_length= length; |
| 19159 |
psar->t_first_psl= psar->t_first_free_psl= psl_new(psar); |
| 19160 |
} |
| 19161 |
/*:1214*//*1215:*/ |
| 19162 |
#line 14703 "./marpa.w" |
| 19163 |
|
| 19164 |
PRIVATE void psar_destroy(const PSAR psar) |
| 19165 |
{ |
| 19166 |
PSL psl= psar->t_first_psl; |
| 19167 |
while(psl) |
| 19168 |
{ |
| 19169 |
PSL next_psl= psl->t_next; |
| 19170 |
PSL*owner= psl->t_owner; |
| 19171 |
if(owner) |
| 19172 |
*owner= NULL; |
| 19173 |
my_free(psl); |
| 19174 |
psl= next_psl; |
| 19175 |
} |
| 19176 |
} |
| 19177 |
/*:1215*//*1216:*/ |
| 19178 |
#line 14717 "./marpa.w" |
| 19179 |
|
| 19180 |
PRIVATE PSL psl_new(const PSAR psar) |
| 19181 |
{ |
| 19182 |
int i; |
| 19183 |
PSL new_psl= my_malloc(Sizeof_PSL(psar)); |
| 19184 |
new_psl->t_next= NULL; |
| 19185 |
new_psl->t_prev= NULL; |
| 19186 |
new_psl->t_owner= NULL; |
| 19187 |
for(i= 0;i<psar->t_psl_length;i++){ |
| 19188 |
PSL_Datum(new_psl,i)= NULL; |
| 19189 |
} |
| 19190 |
return new_psl; |
| 19191 |
} |
| 19192 |
/*:1216*//*1219:*/ |
| 19193 |
#line 14748 "./marpa.w" |
| 19194 |
|
| 19195 |
PRIVATE void psar_reset(const PSAR psar) |
| 19196 |
{ |
| 19197 |
PSL psl= psar->t_first_psl; |
| 19198 |
while(psl&&psl->t_owner){ |
| 19199 |
int i; |
| 19200 |
for(i= 0;i<psar->t_psl_length;i++){ |
| 19201 |
PSL_Datum(psl,i)= NULL; |
| 19202 |
} |
| 19203 |
psl= psl->t_next; |
| 19204 |
} |
| 19205 |
psar_dealloc(psar); |
| 19206 |
} |
| 19207 |
|
| 19208 |
/*:1219*//*1221:*/ |
| 19209 |
#line 14766 "./marpa.w" |
| 19210 |
|
| 19211 |
PRIVATE void psar_dealloc(const PSAR psar) |
| 19212 |
{ |
| 19213 |
PSL psl= psar->t_first_psl; |
| 19214 |
while(psl){ |
| 19215 |
PSL*owner= psl->t_owner; |
| 19216 |
if(!owner)break; |
| 19217 |
(*owner)= NULL; |
| 19218 |
psl->t_owner= NULL; |
| 19219 |
psl= psl->t_next; |
| 19220 |
} |
| 19221 |
psar->t_first_free_psl= psar->t_first_psl; |
| 19222 |
} |
| 19223 |
|
| 19224 |
/*:1221*//*1223:*/ |
| 19225 |
#line 14786 "./marpa.w" |
| 19226 |
|
| 19227 |
PRIVATE void psl_claim( |
| 19228 |
PSL*const psl_owner,const PSAR psar) |
| 19229 |
{ |
| 19230 |
PSL new_psl= psl_alloc(psar); |
| 19231 |
(*psl_owner)= new_psl; |
| 19232 |
new_psl->t_owner= psl_owner; |
| 19233 |
} |
| 19234 |
|
| 19235 |
|
| 19236 |
/*:1223*//*1224:*/ |
| 19237 |
#line 14796 "./marpa.w" |
| 19238 |
|
| 19239 |
PRIVATE PSL psl_claim_by_es( |
| 19240 |
PSAR or_psar, |
| 19241 |
struct s_bocage_setup_per_ys*per_ys_data, |
| 19242 |
YSID ysid) |
| 19243 |
{ |
| 19244 |
PSL*psl_owner= &(per_ys_data[ysid].t_or_psl); |
| 19245 |
if(!*psl_owner) |
| 19246 |
psl_claim(psl_owner,or_psar); |
| 19247 |
return*psl_owner; |
| 19248 |
} |
| 19249 |
|
| 19250 |
/*:1224*//*1225:*/ |
| 19251 |
#line 14813 "./marpa.w" |
| 19252 |
|
| 19253 |
PRIVATE PSL psl_alloc(const PSAR psar) |
| 19254 |
{ |
| 19255 |
PSL free_psl= psar->t_first_free_psl; |
| 19256 |
PSL next_psl= free_psl->t_next; |
| 19257 |
if(!next_psl){ |
| 19258 |
next_psl= free_psl->t_next= psl_new(psar); |
| 19259 |
next_psl->t_prev= free_psl; |
| 19260 |
} |
| 19261 |
psar->t_first_free_psl= next_psl; |
| 19262 |
return free_psl; |
| 19263 |
} |
| 19264 |
|
| 19265 |
/*:1225*//*1253:*/ |
| 19266 |
#line 15045 "./marpa.w" |
| 19267 |
|
| 19268 |
PRIVATE_NOT_INLINE void |
| 19269 |
set_error(GRAMMAR g,Marpa_Error_Code code,const char*message,unsigned int flags) |
| 19270 |
{ |
| 19271 |
g->t_error= code; |
| 19272 |
g->t_error_string= message; |
| 19273 |
if(flags&FATAL_FLAG) |
| 19274 |
g->t_is_ok= 0; |
| 19275 |
} |
| 19276 |
/*:1253*//*1254:*/ |
| 19277 |
#line 15064 "./marpa.w" |
| 19278 |
|
| 19279 |
PRIVATE Marpa_Error_Code |
| 19280 |
clear_error(GRAMMAR g) |
| 19281 |
{ |
| 19282 |
if(!IS_G_OK(g)) |
| 19283 |
{ |
| 19284 |
if(g->t_error==MARPA_ERR_NONE) |
| 19285 |
g->t_error= MARPA_ERR_I_AM_NOT_OK; |
| 19286 |
return g->t_error; |
| 19287 |
} |
| 19288 |
g->t_error= MARPA_ERR_NONE; |
| 19289 |
g->t_error_string= NULL; |
| 19290 |
return MARPA_ERR_NONE; |
| 19291 |
} |
| 19292 |
|
| 19293 |
/*:1254*//*1258:*/ |
| 19294 |
#line 15107 "./marpa.w" |
| 19295 |
|
| 19296 |
PRIVATE_NOT_INLINE void* |
| 19297 |
marpa__default_out_of_memory(void) |
| 19298 |
{ |
| 19299 |
abort(); |
| 19300 |
return NULL; |
| 19301 |
} |
| 19302 |
void*(*const marpa__out_of_memory)(void)= marpa__default_out_of_memory; |
| 19303 |
|
| 19304 |
/*:1258*//*1263:*/ |
| 19305 |
#line 15145 "./marpa.w" |
| 19306 |
|
| 19307 |
Marpa_Earley_Set_ID _marpa_r_trace_earley_set(Marpa_Recognizer r) |
| 19308 |
{ |
| 19309 |
/*1230:*/ |
| 19310 |
#line 14864 "./marpa.w" |
| 19311 |
const int failure_indicator= -2; |
| 19312 |
|
| 19313 |
/*:1230*/ |
| 19314 |
#line 15148 "./marpa.w" |
| 19315 |
|
| 19316 |
/*560:*/ |
| 19317 |
#line 6100 "./marpa.w" |
| 19318 |
|
| 19319 |
const GRAMMAR g= G_of_R(r); |
| 19320 |
/*:560*/ |
| 19321 |
#line 15149 "./marpa.w" |
| 19322 |
|
| 19323 |
YS trace_earley_set= r->t_trace_earley_set; |
| 19324 |
/*1249:*/ |
| 19325 |
#line 14989 "./marpa.w" |
| 19326 |
|
| 19327 |
/*1250:*/ |
| 19328 |
#line 14997 "./marpa.w" |
| 19329 |
|
| 19330 |
if(HEADER_VERSION_MISMATCH){ |
| 19331 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 19332 |
return failure_indicator; |
| 19333 |
} |
| 19334 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 19335 |
MARPA_ERROR(g->t_error); |
| 19336 |
return failure_indicator; |
| 19337 |
} |
| 19338 |
|
| 19339 |
/*:1250*/ |
| 19340 |
#line 14990 "./marpa.w" |
| 19341 |
|
| 19342 |
/*1247:*/ |
| 19343 |
#line 14973 "./marpa.w" |
| 19344 |
|
| 19345 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 19346 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 19347 |
return failure_indicator; |
| 19348 |
} |
| 19349 |
/*:1247*/ |
| 19350 |
#line 14991 "./marpa.w" |
| 19351 |
|
| 19352 |
|
| 19353 |
/*:1249*/ |
| 19354 |
#line 15151 "./marpa.w" |
| 19355 |
|
| 19356 |
if(!trace_earley_set){ |
| 19357 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_YS); |
| 19358 |
return failure_indicator; |
| 19359 |
} |
| 19360 |
return Ord_of_YS(trace_earley_set); |
| 19361 |
} |
| 19362 |
|
| 19363 |
/*:1263*//*1264:*/ |
| 19364 |
#line 15159 "./marpa.w" |
| 19365 |
|
| 19366 |
Marpa_Earley_Set_ID marpa_r_latest_earley_set(Marpa_Recognizer r) |
| 19367 |
{ |
| 19368 |
/*1230:*/ |
| 19369 |
#line 14864 "./marpa.w" |
| 19370 |
const int failure_indicator= -2; |
| 19371 |
|
| 19372 |
/*:1230*/ |
| 19373 |
#line 15162 "./marpa.w" |
| 19374 |
|
| 19375 |
/*560:*/ |
| 19376 |
#line 6100 "./marpa.w" |
| 19377 |
|
| 19378 |
const GRAMMAR g= G_of_R(r); |
| 19379 |
/*:560*/ |
| 19380 |
#line 15163 "./marpa.w" |
| 19381 |
|
| 19382 |
/*1249:*/ |
| 19383 |
#line 14989 "./marpa.w" |
| 19384 |
|
| 19385 |
/*1250:*/ |
| 19386 |
#line 14997 "./marpa.w" |
| 19387 |
|
| 19388 |
if(HEADER_VERSION_MISMATCH){ |
| 19389 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 19390 |
return failure_indicator; |
| 19391 |
} |
| 19392 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 19393 |
MARPA_ERROR(g->t_error); |
| 19394 |
return failure_indicator; |
| 19395 |
} |
| 19396 |
|
| 19397 |
/*:1250*/ |
| 19398 |
#line 14990 "./marpa.w" |
| 19399 |
|
| 19400 |
/*1247:*/ |
| 19401 |
#line 14973 "./marpa.w" |
| 19402 |
|
| 19403 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 19404 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 19405 |
return failure_indicator; |
| 19406 |
} |
| 19407 |
/*:1247*/ |
| 19408 |
#line 14991 "./marpa.w" |
| 19409 |
|
| 19410 |
|
| 19411 |
/*:1249*/ |
| 19412 |
#line 15164 "./marpa.w" |
| 19413 |
|
| 19414 |
if(G_is_Trivial(g))return 0; |
| 19415 |
return Ord_of_YS(Latest_YS_of_R(r)); |
| 19416 |
} |
| 19417 |
|
| 19418 |
/*:1264*//*1265:*/ |
| 19419 |
#line 15169 "./marpa.w" |
| 19420 |
|
| 19421 |
Marpa_Earleme marpa_r_earleme(Marpa_Recognizer r,Marpa_Earley_Set_ID set_id) |
| 19422 |
{ |
| 19423 |
/*560:*/ |
| 19424 |
#line 6100 "./marpa.w" |
| 19425 |
|
| 19426 |
const GRAMMAR g= G_of_R(r); |
| 19427 |
/*:560*/ |
| 19428 |
#line 15172 "./marpa.w" |
| 19429 |
|
| 19430 |
/*1230:*/ |
| 19431 |
#line 14864 "./marpa.w" |
| 19432 |
const int failure_indicator= -2; |
| 19433 |
|
| 19434 |
/*:1230*/ |
| 19435 |
#line 15173 "./marpa.w" |
| 19436 |
|
| 19437 |
YS earley_set; |
| 19438 |
/*1247:*/ |
| 19439 |
#line 14973 "./marpa.w" |
| 19440 |
|
| 19441 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 19442 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 19443 |
return failure_indicator; |
| 19444 |
} |
| 19445 |
/*:1247*/ |
| 19446 |
#line 15175 "./marpa.w" |
| 19447 |
|
| 19448 |
/*1250:*/ |
| 19449 |
#line 14997 "./marpa.w" |
| 19450 |
|
| 19451 |
if(HEADER_VERSION_MISMATCH){ |
| 19452 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 19453 |
return failure_indicator; |
| 19454 |
} |
| 19455 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 19456 |
MARPA_ERROR(g->t_error); |
| 19457 |
return failure_indicator; |
| 19458 |
} |
| 19459 |
|
| 19460 |
/*:1250*/ |
| 19461 |
#line 15176 "./marpa.w" |
| 19462 |
|
| 19463 |
if(set_id<0){ |
| 19464 |
MARPA_ERROR(MARPA_ERR_INVALID_LOCATION); |
| 19465 |
return failure_indicator; |
| 19466 |
} |
| 19467 |
r_update_earley_sets(r); |
| 19468 |
if(!YS_Ord_is_Valid(r,set_id)) |
| 19469 |
{ |
| 19470 |
MARPA_ERROR(MARPA_ERR_NO_EARLEY_SET_AT_LOCATION); |
| 19471 |
return failure_indicator; |
| 19472 |
} |
| 19473 |
earley_set= YS_of_R_by_Ord(r,set_id); |
| 19474 |
return Earleme_of_YS(earley_set); |
| 19475 |
} |
| 19476 |
|
| 19477 |
/*:1265*//*1267:*/ |
| 19478 |
#line 15194 "./marpa.w" |
| 19479 |
|
| 19480 |
int _marpa_r_earley_set_size(Marpa_Recognizer r,Marpa_Earley_Set_ID set_id) |
| 19481 |
{ |
| 19482 |
/*1230:*/ |
| 19483 |
#line 14864 "./marpa.w" |
| 19484 |
const int failure_indicator= -2; |
| 19485 |
|
| 19486 |
/*:1230*/ |
| 19487 |
#line 15197 "./marpa.w" |
| 19488 |
|
| 19489 |
YS earley_set; |
| 19490 |
/*560:*/ |
| 19491 |
#line 6100 "./marpa.w" |
| 19492 |
|
| 19493 |
const GRAMMAR g= G_of_R(r); |
| 19494 |
/*:560*/ |
| 19495 |
#line 15199 "./marpa.w" |
| 19496 |
|
| 19497 |
/*1247:*/ |
| 19498 |
#line 14973 "./marpa.w" |
| 19499 |
|
| 19500 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 19501 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 19502 |
return failure_indicator; |
| 19503 |
} |
| 19504 |
/*:1247*/ |
| 19505 |
#line 15200 "./marpa.w" |
| 19506 |
|
| 19507 |
/*1250:*/ |
| 19508 |
#line 14997 "./marpa.w" |
| 19509 |
|
| 19510 |
if(HEADER_VERSION_MISMATCH){ |
| 19511 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 19512 |
return failure_indicator; |
| 19513 |
} |
| 19514 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 19515 |
MARPA_ERROR(g->t_error); |
| 19516 |
return failure_indicator; |
| 19517 |
} |
| 19518 |
|
| 19519 |
/*:1250*/ |
| 19520 |
#line 15201 "./marpa.w" |
| 19521 |
|
| 19522 |
r_update_earley_sets(r); |
| 19523 |
if(!YS_Ord_is_Valid(r,set_id)) |
| 19524 |
{ |
| 19525 |
MARPA_ERROR(MARPA_ERR_INVALID_LOCATION); |
| 19526 |
return failure_indicator; |
| 19527 |
} |
| 19528 |
earley_set= YS_of_R_by_Ord(r,set_id); |
| 19529 |
return YIM_Count_of_YS(earley_set); |
| 19530 |
} |
| 19531 |
|
| 19532 |
/*:1267*//*1272:*/ |
| 19533 |
#line 15243 "./marpa.w" |
| 19534 |
|
| 19535 |
Marpa_Earleme |
| 19536 |
_marpa_r_earley_set_trace(Marpa_Recognizer r,Marpa_Earley_Set_ID set_id) |
| 19537 |
{ |
| 19538 |
YS earley_set; |
| 19539 |
const int es_does_not_exist= -1; |
| 19540 |
/*1230:*/ |
| 19541 |
#line 14864 "./marpa.w" |
| 19542 |
const int failure_indicator= -2; |
| 19543 |
|
| 19544 |
/*:1230*/ |
| 19545 |
#line 15249 "./marpa.w" |
| 19546 |
|
| 19547 |
/*560:*/ |
| 19548 |
#line 6100 "./marpa.w" |
| 19549 |
|
| 19550 |
const GRAMMAR g= G_of_R(r); |
| 19551 |
/*:560*/ |
| 19552 |
#line 15250 "./marpa.w" |
| 19553 |
|
| 19554 |
/*1249:*/ |
| 19555 |
#line 14989 "./marpa.w" |
| 19556 |
|
| 19557 |
/*1250:*/ |
| 19558 |
#line 14997 "./marpa.w" |
| 19559 |
|
| 19560 |
if(HEADER_VERSION_MISMATCH){ |
| 19561 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 19562 |
return failure_indicator; |
| 19563 |
} |
| 19564 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 19565 |
MARPA_ERROR(g->t_error); |
| 19566 |
return failure_indicator; |
| 19567 |
} |
| 19568 |
|
| 19569 |
/*:1250*/ |
| 19570 |
#line 14990 "./marpa.w" |
| 19571 |
|
| 19572 |
/*1247:*/ |
| 19573 |
#line 14973 "./marpa.w" |
| 19574 |
|
| 19575 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 19576 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 19577 |
return failure_indicator; |
| 19578 |
} |
| 19579 |
/*:1247*/ |
| 19580 |
#line 14991 "./marpa.w" |
| 19581 |
|
| 19582 |
|
| 19583 |
/*:1249*/ |
| 19584 |
#line 15251 "./marpa.w" |
| 19585 |
|
| 19586 |
if(r->t_trace_earley_set&&Ord_of_YS(r->t_trace_earley_set)==set_id) |
| 19587 |
{ |
| 19588 |
|
| 19589 |
|
| 19590 |
return Earleme_of_YS(r->t_trace_earley_set); |
| 19591 |
} |
| 19592 |
/*1273:*/ |
| 19593 |
#line 15274 "./marpa.w" |
| 19594 |
{ |
| 19595 |
r->t_trace_earley_set= NULL; |
| 19596 |
trace_earley_item_clear(r); |
| 19597 |
/*1286:*/ |
| 19598 |
#line 15480 "./marpa.w" |
| 19599 |
|
| 19600 |
r->t_trace_pim_nsy_p= NULL; |
| 19601 |
r->t_trace_postdot_item= NULL; |
| 19602 |
|
| 19603 |
/*:1286*/ |
| 19604 |
#line 15277 "./marpa.w" |
| 19605 |
|
| 19606 |
} |
| 19607 |
|
| 19608 |
/*:1273*/ |
| 19609 |
#line 15258 "./marpa.w" |
| 19610 |
|
| 19611 |
if(set_id<0) |
| 19612 |
{ |
| 19613 |
MARPA_ERROR(MARPA_ERR_INVALID_LOCATION); |
| 19614 |
return failure_indicator; |
| 19615 |
} |
| 19616 |
r_update_earley_sets(r); |
| 19617 |
if(set_id>=MARPA_DSTACK_LENGTH(r->t_earley_set_stack)) |
| 19618 |
{ |
| 19619 |
return es_does_not_exist; |
| 19620 |
} |
| 19621 |
earley_set= YS_of_R_by_Ord(r,set_id); |
| 19622 |
r->t_trace_earley_set= earley_set; |
| 19623 |
return Earleme_of_YS(earley_set); |
| 19624 |
} |
| 19625 |
|
| 19626 |
/*:1272*//*1274:*/ |
| 19627 |
#line 15280 "./marpa.w" |
| 19628 |
|
| 19629 |
Marpa_AHM_ID |
| 19630 |
_marpa_r_earley_item_trace(Marpa_Recognizer r,Marpa_Earley_Item_ID item_id) |
| 19631 |
{ |
| 19632 |
const int yim_does_not_exist= -1; |
| 19633 |
/*1230:*/ |
| 19634 |
#line 14864 "./marpa.w" |
| 19635 |
const int failure_indicator= -2; |
| 19636 |
|
| 19637 |
/*:1230*/ |
| 19638 |
#line 15285 "./marpa.w" |
| 19639 |
|
| 19640 |
YS trace_earley_set; |
| 19641 |
YIM earley_item; |
| 19642 |
YIM*earley_items; |
| 19643 |
/*560:*/ |
| 19644 |
#line 6100 "./marpa.w" |
| 19645 |
|
| 19646 |
const GRAMMAR g= G_of_R(r); |
| 19647 |
/*:560*/ |
| 19648 |
#line 15289 "./marpa.w" |
| 19649 |
|
| 19650 |
/*1249:*/ |
| 19651 |
#line 14989 "./marpa.w" |
| 19652 |
|
| 19653 |
/*1250:*/ |
| 19654 |
#line 14997 "./marpa.w" |
| 19655 |
|
| 19656 |
if(HEADER_VERSION_MISMATCH){ |
| 19657 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 19658 |
return failure_indicator; |
| 19659 |
} |
| 19660 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 19661 |
MARPA_ERROR(g->t_error); |
| 19662 |
return failure_indicator; |
| 19663 |
} |
| 19664 |
|
| 19665 |
/*:1250*/ |
| 19666 |
#line 14990 "./marpa.w" |
| 19667 |
|
| 19668 |
/*1247:*/ |
| 19669 |
#line 14973 "./marpa.w" |
| 19670 |
|
| 19671 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 19672 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 19673 |
return failure_indicator; |
| 19674 |
} |
| 19675 |
/*:1247*/ |
| 19676 |
#line 14991 "./marpa.w" |
| 19677 |
|
| 19678 |
|
| 19679 |
/*:1249*/ |
| 19680 |
#line 15290 "./marpa.w" |
| 19681 |
|
| 19682 |
trace_earley_set= r->t_trace_earley_set; |
| 19683 |
if(!trace_earley_set) |
| 19684 |
{ |
| 19685 |
/*1273:*/ |
| 19686 |
#line 15274 "./marpa.w" |
| 19687 |
{ |
| 19688 |
r->t_trace_earley_set= NULL; |
| 19689 |
trace_earley_item_clear(r); |
| 19690 |
/*1286:*/ |
| 19691 |
#line 15480 "./marpa.w" |
| 19692 |
|
| 19693 |
r->t_trace_pim_nsy_p= NULL; |
| 19694 |
r->t_trace_postdot_item= NULL; |
| 19695 |
|
| 19696 |
/*:1286*/ |
| 19697 |
#line 15277 "./marpa.w" |
| 19698 |
|
| 19699 |
} |
| 19700 |
|
| 19701 |
/*:1273*/ |
| 19702 |
#line 15294 "./marpa.w" |
| 19703 |
|
| 19704 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_YS); |
| 19705 |
return failure_indicator; |
| 19706 |
} |
| 19707 |
trace_earley_item_clear(r); |
| 19708 |
if(item_id<0) |
| 19709 |
{ |
| 19710 |
MARPA_ERROR(MARPA_ERR_YIM_ID_INVALID); |
| 19711 |
return failure_indicator; |
| 19712 |
} |
| 19713 |
if(item_id>=YIM_Count_of_YS(trace_earley_set)) |
| 19714 |
{ |
| 19715 |
return yim_does_not_exist; |
| 19716 |
} |
| 19717 |
earley_items= YIMs_of_YS(trace_earley_set); |
| 19718 |
earley_item= earley_items[item_id]; |
| 19719 |
r->t_trace_earley_item= earley_item; |
| 19720 |
return AHMID_of_YIM(earley_item); |
| 19721 |
} |
| 19722 |
|
| 19723 |
/*:1274*//*1276:*/ |
| 19724 |
#line 15323 "./marpa.w" |
| 19725 |
|
| 19726 |
PRIVATE void trace_earley_item_clear(RECCE r) |
| 19727 |
{ |
| 19728 |
/*1275:*/ |
| 19729 |
#line 15320 "./marpa.w" |
| 19730 |
|
| 19731 |
r->t_trace_earley_item= NULL; |
| 19732 |
|
| 19733 |
/*:1275*/ |
| 19734 |
#line 15326 "./marpa.w" |
| 19735 |
|
| 19736 |
trace_source_link_clear(r); |
| 19737 |
} |
| 19738 |
|
| 19739 |
/*:1276*//*1277:*/ |
| 19740 |
#line 15330 "./marpa.w" |
| 19741 |
|
| 19742 |
Marpa_Earley_Set_ID _marpa_r_earley_item_origin(Marpa_Recognizer r) |
| 19743 |
{ |
| 19744 |
/*1230:*/ |
| 19745 |
#line 14864 "./marpa.w" |
| 19746 |
const int failure_indicator= -2; |
| 19747 |
|
| 19748 |
/*:1230*/ |
| 19749 |
#line 15333 "./marpa.w" |
| 19750 |
|
| 19751 |
YIM item= r->t_trace_earley_item; |
| 19752 |
/*560:*/ |
| 19753 |
#line 6100 "./marpa.w" |
| 19754 |
|
| 19755 |
const GRAMMAR g= G_of_R(r); |
| 19756 |
/*:560*/ |
| 19757 |
#line 15335 "./marpa.w" |
| 19758 |
|
| 19759 |
/*1249:*/ |
| 19760 |
#line 14989 "./marpa.w" |
| 19761 |
|
| 19762 |
/*1250:*/ |
| 19763 |
#line 14997 "./marpa.w" |
| 19764 |
|
| 19765 |
if(HEADER_VERSION_MISMATCH){ |
| 19766 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 19767 |
return failure_indicator; |
| 19768 |
} |
| 19769 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 19770 |
MARPA_ERROR(g->t_error); |
| 19771 |
return failure_indicator; |
| 19772 |
} |
| 19773 |
|
| 19774 |
/*:1250*/ |
| 19775 |
#line 14990 "./marpa.w" |
| 19776 |
|
| 19777 |
/*1247:*/ |
| 19778 |
#line 14973 "./marpa.w" |
| 19779 |
|
| 19780 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 19781 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 19782 |
return failure_indicator; |
| 19783 |
} |
| 19784 |
/*:1247*/ |
| 19785 |
#line 14991 "./marpa.w" |
| 19786 |
|
| 19787 |
|
| 19788 |
/*:1249*/ |
| 19789 |
#line 15336 "./marpa.w" |
| 19790 |
|
| 19791 |
if(!item){ |
| 19792 |
/*1275:*/ |
| 19793 |
#line 15320 "./marpa.w" |
| 19794 |
|
| 19795 |
r->t_trace_earley_item= NULL; |
| 19796 |
|
| 19797 |
/*:1275*/ |
| 19798 |
#line 15338 "./marpa.w" |
| 19799 |
|
| 19800 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_YIM); |
| 19801 |
return failure_indicator; |
| 19802 |
} |
| 19803 |
return Origin_Ord_of_YIM(item); |
| 19804 |
} |
| 19805 |
|
| 19806 |
/*:1277*//*1279:*/ |
| 19807 |
#line 15350 "./marpa.w" |
| 19808 |
|
| 19809 |
Marpa_Symbol_ID _marpa_r_leo_predecessor_symbol(Marpa_Recognizer r) |
| 19810 |
{ |
| 19811 |
const Marpa_Symbol_ID no_predecessor= -1; |
| 19812 |
/*1230:*/ |
| 19813 |
#line 14864 "./marpa.w" |
| 19814 |
const int failure_indicator= -2; |
| 19815 |
|
| 19816 |
/*:1230*/ |
| 19817 |
#line 15354 "./marpa.w" |
| 19818 |
|
| 19819 |
PIM postdot_item= r->t_trace_postdot_item; |
| 19820 |
LIM predecessor_leo_item; |
| 19821 |
/*560:*/ |
| 19822 |
#line 6100 "./marpa.w" |
| 19823 |
|
| 19824 |
const GRAMMAR g= G_of_R(r); |
| 19825 |
/*:560*/ |
| 19826 |
#line 15357 "./marpa.w" |
| 19827 |
|
| 19828 |
/*1249:*/ |
| 19829 |
#line 14989 "./marpa.w" |
| 19830 |
|
| 19831 |
/*1250:*/ |
| 19832 |
#line 14997 "./marpa.w" |
| 19833 |
|
| 19834 |
if(HEADER_VERSION_MISMATCH){ |
| 19835 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 19836 |
return failure_indicator; |
| 19837 |
} |
| 19838 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 19839 |
MARPA_ERROR(g->t_error); |
| 19840 |
return failure_indicator; |
| 19841 |
} |
| 19842 |
|
| 19843 |
/*:1250*/ |
| 19844 |
#line 14990 "./marpa.w" |
| 19845 |
|
| 19846 |
/*1247:*/ |
| 19847 |
#line 14973 "./marpa.w" |
| 19848 |
|
| 19849 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 19850 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 19851 |
return failure_indicator; |
| 19852 |
} |
| 19853 |
/*:1247*/ |
| 19854 |
#line 14991 "./marpa.w" |
| 19855 |
|
| 19856 |
|
| 19857 |
/*:1249*/ |
| 19858 |
#line 15358 "./marpa.w" |
| 19859 |
|
| 19860 |
if(!postdot_item){ |
| 19861 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_PIM); |
| 19862 |
return failure_indicator; |
| 19863 |
} |
| 19864 |
if(YIM_of_PIM(postdot_item)){ |
| 19865 |
MARPA_ERROR(MARPA_ERR_PIM_IS_NOT_LIM); |
| 19866 |
return failure_indicator; |
| 19867 |
} |
| 19868 |
predecessor_leo_item= Predecessor_LIM_of_LIM(LIM_of_PIM(postdot_item)); |
| 19869 |
if(!predecessor_leo_item)return no_predecessor; |
| 19870 |
return Postdot_NSYID_of_LIM(predecessor_leo_item); |
| 19871 |
} |
| 19872 |
|
| 19873 |
/*:1279*//*1280:*/ |
| 19874 |
#line 15372 "./marpa.w" |
| 19875 |
|
| 19876 |
Marpa_Earley_Set_ID _marpa_r_leo_base_origin(Marpa_Recognizer r) |
| 19877 |
{ |
| 19878 |
const JEARLEME pim_is_not_a_leo_item= -1; |
| 19879 |
/*1230:*/ |
| 19880 |
#line 14864 "./marpa.w" |
| 19881 |
const int failure_indicator= -2; |
| 19882 |
|
| 19883 |
/*:1230*/ |
| 19884 |
#line 15376 "./marpa.w" |
| 19885 |
|
| 19886 |
PIM postdot_item= r->t_trace_postdot_item; |
| 19887 |
/*560:*/ |
| 19888 |
#line 6100 "./marpa.w" |
| 19889 |
|
| 19890 |
const GRAMMAR g= G_of_R(r); |
| 19891 |
/*:560*/ |
| 19892 |
#line 15378 "./marpa.w" |
| 19893 |
|
| 19894 |
YIM base_earley_item; |
| 19895 |
/*1249:*/ |
| 19896 |
#line 14989 "./marpa.w" |
| 19897 |
|
| 19898 |
/*1250:*/ |
| 19899 |
#line 14997 "./marpa.w" |
| 19900 |
|
| 19901 |
if(HEADER_VERSION_MISMATCH){ |
| 19902 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 19903 |
return failure_indicator; |
| 19904 |
} |
| 19905 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 19906 |
MARPA_ERROR(g->t_error); |
| 19907 |
return failure_indicator; |
| 19908 |
} |
| 19909 |
|
| 19910 |
/*:1250*/ |
| 19911 |
#line 14990 "./marpa.w" |
| 19912 |
|
| 19913 |
/*1247:*/ |
| 19914 |
#line 14973 "./marpa.w" |
| 19915 |
|
| 19916 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 19917 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 19918 |
return failure_indicator; |
| 19919 |
} |
| 19920 |
/*:1247*/ |
| 19921 |
#line 14991 "./marpa.w" |
| 19922 |
|
| 19923 |
|
| 19924 |
/*:1249*/ |
| 19925 |
#line 15380 "./marpa.w" |
| 19926 |
|
| 19927 |
if(!postdot_item){ |
| 19928 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_PIM); |
| 19929 |
return failure_indicator; |
| 19930 |
} |
| 19931 |
if(YIM_of_PIM(postdot_item))return pim_is_not_a_leo_item; |
| 19932 |
base_earley_item= Trailhead_YIM_of_LIM(LIM_of_PIM(postdot_item)); |
| 19933 |
return Origin_Ord_of_YIM(base_earley_item); |
| 19934 |
} |
| 19935 |
|
| 19936 |
/*:1280*//*1281:*/ |
| 19937 |
#line 15391 "./marpa.w" |
| 19938 |
|
| 19939 |
Marpa_AHM_ID _marpa_r_leo_base_state(Marpa_Recognizer r) |
| 19940 |
{ |
| 19941 |
const JEARLEME pim_is_not_a_leo_item= -1; |
| 19942 |
/*1230:*/ |
| 19943 |
#line 14864 "./marpa.w" |
| 19944 |
const int failure_indicator= -2; |
| 19945 |
|
| 19946 |
/*:1230*/ |
| 19947 |
#line 15395 "./marpa.w" |
| 19948 |
|
| 19949 |
PIM postdot_item= r->t_trace_postdot_item; |
| 19950 |
YIM base_earley_item; |
| 19951 |
/*560:*/ |
| 19952 |
#line 6100 "./marpa.w" |
| 19953 |
|
| 19954 |
const GRAMMAR g= G_of_R(r); |
| 19955 |
/*:560*/ |
| 19956 |
#line 15398 "./marpa.w" |
| 19957 |
|
| 19958 |
/*1249:*/ |
| 19959 |
#line 14989 "./marpa.w" |
| 19960 |
|
| 19961 |
/*1250:*/ |
| 19962 |
#line 14997 "./marpa.w" |
| 19963 |
|
| 19964 |
if(HEADER_VERSION_MISMATCH){ |
| 19965 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 19966 |
return failure_indicator; |
| 19967 |
} |
| 19968 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 19969 |
MARPA_ERROR(g->t_error); |
| 19970 |
return failure_indicator; |
| 19971 |
} |
| 19972 |
|
| 19973 |
/*:1250*/ |
| 19974 |
#line 14990 "./marpa.w" |
| 19975 |
|
| 19976 |
/*1247:*/ |
| 19977 |
#line 14973 "./marpa.w" |
| 19978 |
|
| 19979 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 19980 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 19981 |
return failure_indicator; |
| 19982 |
} |
| 19983 |
/*:1247*/ |
| 19984 |
#line 14991 "./marpa.w" |
| 19985 |
|
| 19986 |
|
| 19987 |
/*:1249*/ |
| 19988 |
#line 15399 "./marpa.w" |
| 19989 |
|
| 19990 |
if(!postdot_item){ |
| 19991 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_PIM); |
| 19992 |
return failure_indicator; |
| 19993 |
} |
| 19994 |
if(YIM_of_PIM(postdot_item))return pim_is_not_a_leo_item; |
| 19995 |
base_earley_item= Trailhead_YIM_of_LIM(LIM_of_PIM(postdot_item)); |
| 19996 |
return AHMID_of_YIM(base_earley_item); |
| 19997 |
} |
| 19998 |
|
| 19999 |
/*:1281*//*1282:*/ |
| 20000 |
#line 15410 "./marpa.w" |
| 20001 |
|
| 20002 |
Marpa_AHM_ID _marpa_r_leo_top_ahm(Marpa_Recognizer r) |
| 20003 |
{ |
| 20004 |
const JEARLEME pim_is_not_a_leo_item= -1; |
| 20005 |
/*1230:*/ |
| 20006 |
#line 14864 "./marpa.w" |
| 20007 |
const int failure_indicator= -2; |
| 20008 |
|
| 20009 |
/*:1230*/ |
| 20010 |
#line 15414 "./marpa.w" |
| 20011 |
|
| 20012 |
PIM postdot_item= r->t_trace_postdot_item; |
| 20013 |
/*560:*/ |
| 20014 |
#line 6100 "./marpa.w" |
| 20015 |
|
| 20016 |
const GRAMMAR g= G_of_R(r); |
| 20017 |
/*:560*/ |
| 20018 |
#line 15416 "./marpa.w" |
| 20019 |
|
| 20020 |
/*1249:*/ |
| 20021 |
#line 14989 "./marpa.w" |
| 20022 |
|
| 20023 |
/*1250:*/ |
| 20024 |
#line 14997 "./marpa.w" |
| 20025 |
|
| 20026 |
if(HEADER_VERSION_MISMATCH){ |
| 20027 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 20028 |
return failure_indicator; |
| 20029 |
} |
| 20030 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 20031 |
MARPA_ERROR(g->t_error); |
| 20032 |
return failure_indicator; |
| 20033 |
} |
| 20034 |
|
| 20035 |
/*:1250*/ |
| 20036 |
#line 14990 "./marpa.w" |
| 20037 |
|
| 20038 |
/*1247:*/ |
| 20039 |
#line 14973 "./marpa.w" |
| 20040 |
|
| 20041 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 20042 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 20043 |
return failure_indicator; |
| 20044 |
} |
| 20045 |
/*:1247*/ |
| 20046 |
#line 14991 "./marpa.w" |
| 20047 |
|
| 20048 |
|
| 20049 |
/*:1249*/ |
| 20050 |
#line 15417 "./marpa.w" |
| 20051 |
|
| 20052 |
if(!postdot_item){ |
| 20053 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_PIM); |
| 20054 |
return failure_indicator; |
| 20055 |
} |
| 20056 |
if(YIM_of_PIM(postdot_item))return pim_is_not_a_leo_item; |
| 20057 |
return ID_of_AHM(Top_AHM_of_LIM(LIM_of_PIM(postdot_item))); |
| 20058 |
} |
| 20059 |
|
| 20060 |
/*:1282*//*1285:*/ |
| 20061 |
#line 15454 "./marpa.w" |
| 20062 |
|
| 20063 |
Marpa_Symbol_ID |
| 20064 |
_marpa_r_postdot_symbol_trace(Marpa_Recognizer r, |
| 20065 |
Marpa_Symbol_ID nsy_id) |
| 20066 |
{ |
| 20067 |
/*1230:*/ |
| 20068 |
#line 14864 "./marpa.w" |
| 20069 |
const int failure_indicator= -2; |
| 20070 |
|
| 20071 |
/*:1230*/ |
| 20072 |
#line 15459 "./marpa.w" |
| 20073 |
|
| 20074 |
YS current_ys= r->t_trace_earley_set; |
| 20075 |
PIM*pim_nsy_p; |
| 20076 |
PIM pim; |
| 20077 |
/*560:*/ |
| 20078 |
#line 6100 "./marpa.w" |
| 20079 |
|
| 20080 |
const GRAMMAR g= G_of_R(r); |
| 20081 |
/*:560*/ |
| 20082 |
#line 15463 "./marpa.w" |
| 20083 |
|
| 20084 |
/*1286:*/ |
| 20085 |
#line 15480 "./marpa.w" |
| 20086 |
|
| 20087 |
r->t_trace_pim_nsy_p= NULL; |
| 20088 |
r->t_trace_postdot_item= NULL; |
| 20089 |
|
| 20090 |
/*:1286*/ |
| 20091 |
#line 15464 "./marpa.w" |
| 20092 |
|
| 20093 |
/*1249:*/ |
| 20094 |
#line 14989 "./marpa.w" |
| 20095 |
|
| 20096 |
/*1250:*/ |
| 20097 |
#line 14997 "./marpa.w" |
| 20098 |
|
| 20099 |
if(HEADER_VERSION_MISMATCH){ |
| 20100 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 20101 |
return failure_indicator; |
| 20102 |
} |
| 20103 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 20104 |
MARPA_ERROR(g->t_error); |
| 20105 |
return failure_indicator; |
| 20106 |
} |
| 20107 |
|
| 20108 |
/*:1250*/ |
| 20109 |
#line 14990 "./marpa.w" |
| 20110 |
|
| 20111 |
/*1247:*/ |
| 20112 |
#line 14973 "./marpa.w" |
| 20113 |
|
| 20114 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 20115 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 20116 |
return failure_indicator; |
| 20117 |
} |
| 20118 |
/*:1247*/ |
| 20119 |
#line 14991 "./marpa.w" |
| 20120 |
|
| 20121 |
|
| 20122 |
/*:1249*/ |
| 20123 |
#line 15465 "./marpa.w" |
| 20124 |
|
| 20125 |
/*1237:*/ |
| 20126 |
#line 14903 "./marpa.w" |
| 20127 |
|
| 20128 |
if(_MARPA_UNLIKELY(NSYID_is_Malformed(nsy_id))){ |
| 20129 |
MARPA_ERROR(MARPA_ERR_INVALID_SYMBOL_ID); |
| 20130 |
return failure_indicator; |
| 20131 |
} |
| 20132 |
/*:1237*/ |
| 20133 |
#line 15466 "./marpa.w" |
| 20134 |
|
| 20135 |
/*1238:*/ |
| 20136 |
#line 14910 "./marpa.w" |
| 20137 |
|
| 20138 |
if(_MARPA_UNLIKELY(!NSYID_of_G_Exists(nsy_id))){ |
| 20139 |
MARPA_ERROR(MARPA_ERR_NO_SUCH_SYMBOL_ID); |
| 20140 |
return-1; |
| 20141 |
} |
| 20142 |
|
| 20143 |
/*:1238*/ |
| 20144 |
#line 15467 "./marpa.w" |
| 20145 |
|
| 20146 |
if(!current_ys){ |
| 20147 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_YS); |
| 20148 |
return failure_indicator; |
| 20149 |
} |
| 20150 |
pim_nsy_p= PIM_NSY_P_of_YS_by_NSYID(current_ys,nsy_id); |
| 20151 |
pim= *pim_nsy_p; |
| 20152 |
if(!pim)return-1; |
| 20153 |
r->t_trace_pim_nsy_p= pim_nsy_p; |
| 20154 |
r->t_trace_postdot_item= pim; |
| 20155 |
return nsy_id; |
| 20156 |
} |
| 20157 |
|
| 20158 |
/*:1285*//*1287:*/ |
| 20159 |
#line 15490 "./marpa.w" |
| 20160 |
|
| 20161 |
Marpa_Symbol_ID |
| 20162 |
_marpa_r_first_postdot_item_trace(Marpa_Recognizer r) |
| 20163 |
{ |
| 20164 |
/*1230:*/ |
| 20165 |
#line 14864 "./marpa.w" |
| 20166 |
const int failure_indicator= -2; |
| 20167 |
|
| 20168 |
/*:1230*/ |
| 20169 |
#line 15494 "./marpa.w" |
| 20170 |
|
| 20171 |
YS current_earley_set= r->t_trace_earley_set; |
| 20172 |
PIM pim; |
| 20173 |
/*560:*/ |
| 20174 |
#line 6100 "./marpa.w" |
| 20175 |
|
| 20176 |
const GRAMMAR g= G_of_R(r); |
| 20177 |
/*:560*/ |
| 20178 |
#line 15497 "./marpa.w" |
| 20179 |
|
| 20180 |
PIM*pim_nsy_p; |
| 20181 |
/*1286:*/ |
| 20182 |
#line 15480 "./marpa.w" |
| 20183 |
|
| 20184 |
r->t_trace_pim_nsy_p= NULL; |
| 20185 |
r->t_trace_postdot_item= NULL; |
| 20186 |
|
| 20187 |
/*:1286*/ |
| 20188 |
#line 15499 "./marpa.w" |
| 20189 |
|
| 20190 |
/*1249:*/ |
| 20191 |
#line 14989 "./marpa.w" |
| 20192 |
|
| 20193 |
/*1250:*/ |
| 20194 |
#line 14997 "./marpa.w" |
| 20195 |
|
| 20196 |
if(HEADER_VERSION_MISMATCH){ |
| 20197 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 20198 |
return failure_indicator; |
| 20199 |
} |
| 20200 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 20201 |
MARPA_ERROR(g->t_error); |
| 20202 |
return failure_indicator; |
| 20203 |
} |
| 20204 |
|
| 20205 |
/*:1250*/ |
| 20206 |
#line 14990 "./marpa.w" |
| 20207 |
|
| 20208 |
/*1247:*/ |
| 20209 |
#line 14973 "./marpa.w" |
| 20210 |
|
| 20211 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 20212 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 20213 |
return failure_indicator; |
| 20214 |
} |
| 20215 |
/*:1247*/ |
| 20216 |
#line 14991 "./marpa.w" |
| 20217 |
|
| 20218 |
|
| 20219 |
/*:1249*/ |
| 20220 |
#line 15500 "./marpa.w" |
| 20221 |
|
| 20222 |
if(!current_earley_set){ |
| 20223 |
/*1275:*/ |
| 20224 |
#line 15320 "./marpa.w" |
| 20225 |
|
| 20226 |
r->t_trace_earley_item= NULL; |
| 20227 |
|
| 20228 |
/*:1275*/ |
| 20229 |
#line 15502 "./marpa.w" |
| 20230 |
|
| 20231 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_YS); |
| 20232 |
return failure_indicator; |
| 20233 |
} |
| 20234 |
if(current_earley_set->t_postdot_sym_count<=0)return-1; |
| 20235 |
pim_nsy_p= current_earley_set->t_postdot_ary+0; |
| 20236 |
pim= pim_nsy_p[0]; |
| 20237 |
r->t_trace_pim_nsy_p= pim_nsy_p; |
| 20238 |
r->t_trace_postdot_item= pim; |
| 20239 |
return Postdot_NSYID_of_PIM(pim); |
| 20240 |
} |
| 20241 |
|
| 20242 |
/*:1287*//*1288:*/ |
| 20243 |
#line 15521 "./marpa.w" |
| 20244 |
|
| 20245 |
Marpa_Symbol_ID |
| 20246 |
_marpa_r_next_postdot_item_trace(Marpa_Recognizer r) |
| 20247 |
{ |
| 20248 |
const XSYID no_more_postdot_symbols= -1; |
| 20249 |
/*1230:*/ |
| 20250 |
#line 14864 "./marpa.w" |
| 20251 |
const int failure_indicator= -2; |
| 20252 |
|
| 20253 |
/*:1230*/ |
| 20254 |
#line 15526 "./marpa.w" |
| 20255 |
|
| 20256 |
YS current_set= r->t_trace_earley_set; |
| 20257 |
PIM pim; |
| 20258 |
PIM*pim_nsy_p; |
| 20259 |
/*560:*/ |
| 20260 |
#line 6100 "./marpa.w" |
| 20261 |
|
| 20262 |
const GRAMMAR g= G_of_R(r); |
| 20263 |
/*:560*/ |
| 20264 |
#line 15530 "./marpa.w" |
| 20265 |
|
| 20266 |
|
| 20267 |
pim_nsy_p= r->t_trace_pim_nsy_p; |
| 20268 |
pim= r->t_trace_postdot_item; |
| 20269 |
/*1286:*/ |
| 20270 |
#line 15480 "./marpa.w" |
| 20271 |
|
| 20272 |
r->t_trace_pim_nsy_p= NULL; |
| 20273 |
r->t_trace_postdot_item= NULL; |
| 20274 |
|
| 20275 |
/*:1286*/ |
| 20276 |
#line 15534 "./marpa.w" |
| 20277 |
|
| 20278 |
if(!pim_nsy_p||!pim){ |
| 20279 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_PIM); |
| 20280 |
return failure_indicator; |
| 20281 |
} |
| 20282 |
/*1249:*/ |
| 20283 |
#line 14989 "./marpa.w" |
| 20284 |
|
| 20285 |
/*1250:*/ |
| 20286 |
#line 14997 "./marpa.w" |
| 20287 |
|
| 20288 |
if(HEADER_VERSION_MISMATCH){ |
| 20289 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 20290 |
return failure_indicator; |
| 20291 |
} |
| 20292 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 20293 |
MARPA_ERROR(g->t_error); |
| 20294 |
return failure_indicator; |
| 20295 |
} |
| 20296 |
|
| 20297 |
/*:1250*/ |
| 20298 |
#line 14990 "./marpa.w" |
| 20299 |
|
| 20300 |
/*1247:*/ |
| 20301 |
#line 14973 "./marpa.w" |
| 20302 |
|
| 20303 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 20304 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 20305 |
return failure_indicator; |
| 20306 |
} |
| 20307 |
/*:1247*/ |
| 20308 |
#line 14991 "./marpa.w" |
| 20309 |
|
| 20310 |
|
| 20311 |
/*:1249*/ |
| 20312 |
#line 15539 "./marpa.w" |
| 20313 |
|
| 20314 |
if(!current_set){ |
| 20315 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_YS); |
| 20316 |
return failure_indicator; |
| 20317 |
} |
| 20318 |
pim= Next_PIM_of_PIM(pim); |
| 20319 |
if(!pim){ |
| 20320 |
|
| 20321 |
pim_nsy_p++; |
| 20322 |
if(pim_nsy_p-current_set->t_postdot_ary |
| 20323 |
>=current_set->t_postdot_sym_count){ |
| 20324 |
return no_more_postdot_symbols; |
| 20325 |
} |
| 20326 |
pim= *pim_nsy_p; |
| 20327 |
} |
| 20328 |
r->t_trace_pim_nsy_p= pim_nsy_p; |
| 20329 |
r->t_trace_postdot_item= pim; |
| 20330 |
return Postdot_NSYID_of_PIM(pim); |
| 20331 |
} |
| 20332 |
|
| 20333 |
/*:1288*//*1289:*/ |
| 20334 |
#line 15559 "./marpa.w" |
| 20335 |
|
| 20336 |
Marpa_Symbol_ID _marpa_r_postdot_item_symbol(Marpa_Recognizer r) |
| 20337 |
{ |
| 20338 |
/*1230:*/ |
| 20339 |
#line 14864 "./marpa.w" |
| 20340 |
const int failure_indicator= -2; |
| 20341 |
|
| 20342 |
/*:1230*/ |
| 20343 |
#line 15562 "./marpa.w" |
| 20344 |
|
| 20345 |
PIM postdot_item= r->t_trace_postdot_item; |
| 20346 |
/*560:*/ |
| 20347 |
#line 6100 "./marpa.w" |
| 20348 |
|
| 20349 |
const GRAMMAR g= G_of_R(r); |
| 20350 |
/*:560*/ |
| 20351 |
#line 15564 "./marpa.w" |
| 20352 |
|
| 20353 |
/*1249:*/ |
| 20354 |
#line 14989 "./marpa.w" |
| 20355 |
|
| 20356 |
/*1250:*/ |
| 20357 |
#line 14997 "./marpa.w" |
| 20358 |
|
| 20359 |
if(HEADER_VERSION_MISMATCH){ |
| 20360 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 20361 |
return failure_indicator; |
| 20362 |
} |
| 20363 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 20364 |
MARPA_ERROR(g->t_error); |
| 20365 |
return failure_indicator; |
| 20366 |
} |
| 20367 |
|
| 20368 |
/*:1250*/ |
| 20369 |
#line 14990 "./marpa.w" |
| 20370 |
|
| 20371 |
/*1247:*/ |
| 20372 |
#line 14973 "./marpa.w" |
| 20373 |
|
| 20374 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 20375 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 20376 |
return failure_indicator; |
| 20377 |
} |
| 20378 |
/*:1247*/ |
| 20379 |
#line 14991 "./marpa.w" |
| 20380 |
|
| 20381 |
|
| 20382 |
/*:1249*/ |
| 20383 |
#line 15565 "./marpa.w" |
| 20384 |
|
| 20385 |
if(!postdot_item){ |
| 20386 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_PIM); |
| 20387 |
return failure_indicator; |
| 20388 |
} |
| 20389 |
return Postdot_NSYID_of_PIM(postdot_item); |
| 20390 |
} |
| 20391 |
|
| 20392 |
/*:1289*//*1294:*/ |
| 20393 |
#line 15595 "./marpa.w" |
| 20394 |
|
| 20395 |
Marpa_Symbol_ID _marpa_r_first_token_link_trace(Marpa_Recognizer r) |
| 20396 |
{ |
| 20397 |
/*1230:*/ |
| 20398 |
#line 14864 "./marpa.w" |
| 20399 |
const int failure_indicator= -2; |
| 20400 |
|
| 20401 |
/*:1230*/ |
| 20402 |
#line 15598 "./marpa.w" |
| 20403 |
|
| 20404 |
SRCL source_link; |
| 20405 |
unsigned int source_type; |
| 20406 |
YIM item= r->t_trace_earley_item; |
| 20407 |
/*560:*/ |
| 20408 |
#line 6100 "./marpa.w" |
| 20409 |
|
| 20410 |
const GRAMMAR g= G_of_R(r); |
| 20411 |
/*:560*/ |
| 20412 |
#line 15602 "./marpa.w" |
| 20413 |
|
| 20414 |
/*1249:*/ |
| 20415 |
#line 14989 "./marpa.w" |
| 20416 |
|
| 20417 |
/*1250:*/ |
| 20418 |
#line 14997 "./marpa.w" |
| 20419 |
|
| 20420 |
if(HEADER_VERSION_MISMATCH){ |
| 20421 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 20422 |
return failure_indicator; |
| 20423 |
} |
| 20424 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 20425 |
MARPA_ERROR(g->t_error); |
| 20426 |
return failure_indicator; |
| 20427 |
} |
| 20428 |
|
| 20429 |
/*:1250*/ |
| 20430 |
#line 14990 "./marpa.w" |
| 20431 |
|
| 20432 |
/*1247:*/ |
| 20433 |
#line 14973 "./marpa.w" |
| 20434 |
|
| 20435 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 20436 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 20437 |
return failure_indicator; |
| 20438 |
} |
| 20439 |
/*:1247*/ |
| 20440 |
#line 14991 "./marpa.w" |
| 20441 |
|
| 20442 |
|
| 20443 |
/*:1249*/ |
| 20444 |
#line 15603 "./marpa.w" |
| 20445 |
|
| 20446 |
/*1308:*/ |
| 20447 |
#line 15790 "./marpa.w" |
| 20448 |
|
| 20449 |
item= r->t_trace_earley_item; |
| 20450 |
if(!item){ |
| 20451 |
trace_source_link_clear(r); |
| 20452 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_YIM); |
| 20453 |
return failure_indicator; |
| 20454 |
} |
| 20455 |
|
| 20456 |
/*:1308*/ |
| 20457 |
#line 15604 "./marpa.w" |
| 20458 |
|
| 20459 |
source_type= Source_Type_of_YIM(item); |
| 20460 |
switch(source_type) |
| 20461 |
{ |
| 20462 |
case SOURCE_IS_TOKEN: |
| 20463 |
r->t_trace_source_type= SOURCE_IS_TOKEN; |
| 20464 |
source_link= SRCL_of_YIM(item); |
| 20465 |
r->t_trace_source_link= source_link; |
| 20466 |
return NSYID_of_SRCL(source_link); |
| 20467 |
case SOURCE_IS_AMBIGUOUS: |
| 20468 |
{ |
| 20469 |
source_link= LV_First_Token_SRCL_of_YIM(item); |
| 20470 |
if(source_link) |
| 20471 |
{ |
| 20472 |
r->t_trace_source_type= SOURCE_IS_TOKEN; |
| 20473 |
r->t_trace_source_link= source_link; |
| 20474 |
return NSYID_of_SRCL(source_link); |
| 20475 |
} |
| 20476 |
} |
| 20477 |
} |
| 20478 |
trace_source_link_clear(r); |
| 20479 |
return-1; |
| 20480 |
} |
| 20481 |
|
| 20482 |
/*:1294*//*1297:*/ |
| 20483 |
#line 15636 "./marpa.w" |
| 20484 |
|
| 20485 |
Marpa_Symbol_ID _marpa_r_next_token_link_trace(Marpa_Recognizer r) |
| 20486 |
{ |
| 20487 |
/*1230:*/ |
| 20488 |
#line 14864 "./marpa.w" |
| 20489 |
const int failure_indicator= -2; |
| 20490 |
|
| 20491 |
/*:1230*/ |
| 20492 |
#line 15639 "./marpa.w" |
| 20493 |
|
| 20494 |
SRCL source_link; |
| 20495 |
YIM item; |
| 20496 |
/*560:*/ |
| 20497 |
#line 6100 "./marpa.w" |
| 20498 |
|
| 20499 |
const GRAMMAR g= G_of_R(r); |
| 20500 |
/*:560*/ |
| 20501 |
#line 15642 "./marpa.w" |
| 20502 |
|
| 20503 |
/*1249:*/ |
| 20504 |
#line 14989 "./marpa.w" |
| 20505 |
|
| 20506 |
/*1250:*/ |
| 20507 |
#line 14997 "./marpa.w" |
| 20508 |
|
| 20509 |
if(HEADER_VERSION_MISMATCH){ |
| 20510 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 20511 |
return failure_indicator; |
| 20512 |
} |
| 20513 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 20514 |
MARPA_ERROR(g->t_error); |
| 20515 |
return failure_indicator; |
| 20516 |
} |
| 20517 |
|
| 20518 |
/*:1250*/ |
| 20519 |
#line 14990 "./marpa.w" |
| 20520 |
|
| 20521 |
/*1247:*/ |
| 20522 |
#line 14973 "./marpa.w" |
| 20523 |
|
| 20524 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 20525 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 20526 |
return failure_indicator; |
| 20527 |
} |
| 20528 |
/*:1247*/ |
| 20529 |
#line 14991 "./marpa.w" |
| 20530 |
|
| 20531 |
|
| 20532 |
/*:1249*/ |
| 20533 |
#line 15643 "./marpa.w" |
| 20534 |
|
| 20535 |
/*1308:*/ |
| 20536 |
#line 15790 "./marpa.w" |
| 20537 |
|
| 20538 |
item= r->t_trace_earley_item; |
| 20539 |
if(!item){ |
| 20540 |
trace_source_link_clear(r); |
| 20541 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_YIM); |
| 20542 |
return failure_indicator; |
| 20543 |
} |
| 20544 |
|
| 20545 |
/*:1308*/ |
| 20546 |
#line 15644 "./marpa.w" |
| 20547 |
|
| 20548 |
if(r->t_trace_source_type!=SOURCE_IS_TOKEN){ |
| 20549 |
trace_source_link_clear(r); |
| 20550 |
MARPA_ERROR(MARPA_ERR_NOT_TRACING_TOKEN_LINKS); |
| 20551 |
return failure_indicator; |
| 20552 |
} |
| 20553 |
source_link= Next_SRCL_of_SRCL(r->t_trace_source_link); |
| 20554 |
if(!source_link){ |
| 20555 |
trace_source_link_clear(r); |
| 20556 |
return-1; |
| 20557 |
} |
| 20558 |
r->t_trace_source_link= source_link; |
| 20559 |
return NSYID_of_SRCL(source_link); |
| 20560 |
} |
| 20561 |
|
| 20562 |
/*:1297*//*1299:*/ |
| 20563 |
#line 15666 "./marpa.w" |
| 20564 |
|
| 20565 |
Marpa_Symbol_ID _marpa_r_first_completion_link_trace(Marpa_Recognizer r) |
| 20566 |
{ |
| 20567 |
/*1230:*/ |
| 20568 |
#line 14864 "./marpa.w" |
| 20569 |
const int failure_indicator= -2; |
| 20570 |
|
| 20571 |
/*:1230*/ |
| 20572 |
#line 15669 "./marpa.w" |
| 20573 |
|
| 20574 |
SRCL source_link; |
| 20575 |
unsigned int source_type; |
| 20576 |
YIM item= r->t_trace_earley_item; |
| 20577 |
/*560:*/ |
| 20578 |
#line 6100 "./marpa.w" |
| 20579 |
|
| 20580 |
const GRAMMAR g= G_of_R(r); |
| 20581 |
/*:560*/ |
| 20582 |
#line 15673 "./marpa.w" |
| 20583 |
|
| 20584 |
/*1249:*/ |
| 20585 |
#line 14989 "./marpa.w" |
| 20586 |
|
| 20587 |
/*1250:*/ |
| 20588 |
#line 14997 "./marpa.w" |
| 20589 |
|
| 20590 |
if(HEADER_VERSION_MISMATCH){ |
| 20591 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 20592 |
return failure_indicator; |
| 20593 |
} |
| 20594 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 20595 |
MARPA_ERROR(g->t_error); |
| 20596 |
return failure_indicator; |
| 20597 |
} |
| 20598 |
|
| 20599 |
/*:1250*/ |
| 20600 |
#line 14990 "./marpa.w" |
| 20601 |
|
| 20602 |
/*1247:*/ |
| 20603 |
#line 14973 "./marpa.w" |
| 20604 |
|
| 20605 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 20606 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 20607 |
return failure_indicator; |
| 20608 |
} |
| 20609 |
/*:1247*/ |
| 20610 |
#line 14991 "./marpa.w" |
| 20611 |
|
| 20612 |
|
| 20613 |
/*:1249*/ |
| 20614 |
#line 15674 "./marpa.w" |
| 20615 |
|
| 20616 |
/*1308:*/ |
| 20617 |
#line 15790 "./marpa.w" |
| 20618 |
|
| 20619 |
item= r->t_trace_earley_item; |
| 20620 |
if(!item){ |
| 20621 |
trace_source_link_clear(r); |
| 20622 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_YIM); |
| 20623 |
return failure_indicator; |
| 20624 |
} |
| 20625 |
|
| 20626 |
/*:1308*/ |
| 20627 |
#line 15675 "./marpa.w" |
| 20628 |
|
| 20629 |
switch((source_type= Source_Type_of_YIM(item))) |
| 20630 |
{ |
| 20631 |
case SOURCE_IS_COMPLETION: |
| 20632 |
r->t_trace_source_type= SOURCE_IS_COMPLETION; |
| 20633 |
source_link= SRCL_of_YIM(item); |
| 20634 |
r->t_trace_source_link= source_link; |
| 20635 |
return Cause_AHMID_of_SRCL(source_link); |
| 20636 |
case SOURCE_IS_AMBIGUOUS: |
| 20637 |
{ |
| 20638 |
source_link= LV_First_Completion_SRCL_of_YIM(item); |
| 20639 |
if(source_link) |
| 20640 |
{ |
| 20641 |
r->t_trace_source_type= SOURCE_IS_COMPLETION; |
| 20642 |
r->t_trace_source_link= source_link; |
| 20643 |
return Cause_AHMID_of_SRCL(source_link); |
| 20644 |
} |
| 20645 |
} |
| 20646 |
} |
| 20647 |
trace_source_link_clear(r); |
| 20648 |
return-1; |
| 20649 |
} |
| 20650 |
|
| 20651 |
/*:1299*//*1302:*/ |
| 20652 |
#line 15706 "./marpa.w" |
| 20653 |
|
| 20654 |
Marpa_Symbol_ID _marpa_r_next_completion_link_trace(Marpa_Recognizer r) |
| 20655 |
{ |
| 20656 |
/*1230:*/ |
| 20657 |
#line 14864 "./marpa.w" |
| 20658 |
const int failure_indicator= -2; |
| 20659 |
|
| 20660 |
/*:1230*/ |
| 20661 |
#line 15709 "./marpa.w" |
| 20662 |
|
| 20663 |
SRCL source_link; |
| 20664 |
YIM item; |
| 20665 |
/*560:*/ |
| 20666 |
#line 6100 "./marpa.w" |
| 20667 |
|
| 20668 |
const GRAMMAR g= G_of_R(r); |
| 20669 |
/*:560*/ |
| 20670 |
#line 15712 "./marpa.w" |
| 20671 |
|
| 20672 |
/*1249:*/ |
| 20673 |
#line 14989 "./marpa.w" |
| 20674 |
|
| 20675 |
/*1250:*/ |
| 20676 |
#line 14997 "./marpa.w" |
| 20677 |
|
| 20678 |
if(HEADER_VERSION_MISMATCH){ |
| 20679 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 20680 |
return failure_indicator; |
| 20681 |
} |
| 20682 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 20683 |
MARPA_ERROR(g->t_error); |
| 20684 |
return failure_indicator; |
| 20685 |
} |
| 20686 |
|
| 20687 |
/*:1250*/ |
| 20688 |
#line 14990 "./marpa.w" |
| 20689 |
|
| 20690 |
/*1247:*/ |
| 20691 |
#line 14973 "./marpa.w" |
| 20692 |
|
| 20693 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 20694 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 20695 |
return failure_indicator; |
| 20696 |
} |
| 20697 |
/*:1247*/ |
| 20698 |
#line 14991 "./marpa.w" |
| 20699 |
|
| 20700 |
|
| 20701 |
/*:1249*/ |
| 20702 |
#line 15713 "./marpa.w" |
| 20703 |
|
| 20704 |
/*1308:*/ |
| 20705 |
#line 15790 "./marpa.w" |
| 20706 |
|
| 20707 |
item= r->t_trace_earley_item; |
| 20708 |
if(!item){ |
| 20709 |
trace_source_link_clear(r); |
| 20710 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_YIM); |
| 20711 |
return failure_indicator; |
| 20712 |
} |
| 20713 |
|
| 20714 |
/*:1308*/ |
| 20715 |
#line 15714 "./marpa.w" |
| 20716 |
|
| 20717 |
if(r->t_trace_source_type!=SOURCE_IS_COMPLETION){ |
| 20718 |
trace_source_link_clear(r); |
| 20719 |
MARPA_ERROR(MARPA_ERR_NOT_TRACING_COMPLETION_LINKS); |
| 20720 |
return failure_indicator; |
| 20721 |
} |
| 20722 |
source_link= Next_SRCL_of_SRCL(r->t_trace_source_link); |
| 20723 |
if(!source_link){ |
| 20724 |
trace_source_link_clear(r); |
| 20725 |
return-1; |
| 20726 |
} |
| 20727 |
r->t_trace_source_link= source_link; |
| 20728 |
return Cause_AHMID_of_SRCL(source_link); |
| 20729 |
} |
| 20730 |
|
| 20731 |
/*:1302*//*1304:*/ |
| 20732 |
#line 15736 "./marpa.w" |
| 20733 |
|
| 20734 |
Marpa_Symbol_ID |
| 20735 |
_marpa_r_first_leo_link_trace(Marpa_Recognizer r) |
| 20736 |
{ |
| 20737 |
/*1230:*/ |
| 20738 |
#line 14864 "./marpa.w" |
| 20739 |
const int failure_indicator= -2; |
| 20740 |
|
| 20741 |
/*:1230*/ |
| 20742 |
#line 15740 "./marpa.w" |
| 20743 |
|
| 20744 |
SRCL source_link; |
| 20745 |
YIM item= r->t_trace_earley_item; |
| 20746 |
/*560:*/ |
| 20747 |
#line 6100 "./marpa.w" |
| 20748 |
|
| 20749 |
const GRAMMAR g= G_of_R(r); |
| 20750 |
/*:560*/ |
| 20751 |
#line 15743 "./marpa.w" |
| 20752 |
|
| 20753 |
/*1249:*/ |
| 20754 |
#line 14989 "./marpa.w" |
| 20755 |
|
| 20756 |
/*1250:*/ |
| 20757 |
#line 14997 "./marpa.w" |
| 20758 |
|
| 20759 |
if(HEADER_VERSION_MISMATCH){ |
| 20760 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 20761 |
return failure_indicator; |
| 20762 |
} |
| 20763 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 20764 |
MARPA_ERROR(g->t_error); |
| 20765 |
return failure_indicator; |
| 20766 |
} |
| 20767 |
|
| 20768 |
/*:1250*/ |
| 20769 |
#line 14990 "./marpa.w" |
| 20770 |
|
| 20771 |
/*1247:*/ |
| 20772 |
#line 14973 "./marpa.w" |
| 20773 |
|
| 20774 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 20775 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 20776 |
return failure_indicator; |
| 20777 |
} |
| 20778 |
/*:1247*/ |
| 20779 |
#line 14991 "./marpa.w" |
| 20780 |
|
| 20781 |
|
| 20782 |
/*:1249*/ |
| 20783 |
#line 15744 "./marpa.w" |
| 20784 |
|
| 20785 |
/*1308:*/ |
| 20786 |
#line 15790 "./marpa.w" |
| 20787 |
|
| 20788 |
item= r->t_trace_earley_item; |
| 20789 |
if(!item){ |
| 20790 |
trace_source_link_clear(r); |
| 20791 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_YIM); |
| 20792 |
return failure_indicator; |
| 20793 |
} |
| 20794 |
|
| 20795 |
/*:1308*/ |
| 20796 |
#line 15745 "./marpa.w" |
| 20797 |
|
| 20798 |
source_link= First_Leo_SRCL_of_YIM(item); |
| 20799 |
if(source_link){ |
| 20800 |
r->t_trace_source_type= SOURCE_IS_LEO; |
| 20801 |
r->t_trace_source_link= source_link; |
| 20802 |
return Cause_AHMID_of_SRCL(source_link); |
| 20803 |
} |
| 20804 |
trace_source_link_clear(r); |
| 20805 |
return-1; |
| 20806 |
} |
| 20807 |
|
| 20808 |
/*:1304*//*1307:*/ |
| 20809 |
#line 15764 "./marpa.w" |
| 20810 |
|
| 20811 |
Marpa_Symbol_ID |
| 20812 |
_marpa_r_next_leo_link_trace(Marpa_Recognizer r) |
| 20813 |
{ |
| 20814 |
/*1230:*/ |
| 20815 |
#line 14864 "./marpa.w" |
| 20816 |
const int failure_indicator= -2; |
| 20817 |
|
| 20818 |
/*:1230*/ |
| 20819 |
#line 15768 "./marpa.w" |
| 20820 |
|
| 20821 |
SRCL source_link; |
| 20822 |
YIM item; |
| 20823 |
/*560:*/ |
| 20824 |
#line 6100 "./marpa.w" |
| 20825 |
|
| 20826 |
const GRAMMAR g= G_of_R(r); |
| 20827 |
/*:560*/ |
| 20828 |
#line 15771 "./marpa.w" |
| 20829 |
|
| 20830 |
/*1249:*/ |
| 20831 |
#line 14989 "./marpa.w" |
| 20832 |
|
| 20833 |
/*1250:*/ |
| 20834 |
#line 14997 "./marpa.w" |
| 20835 |
|
| 20836 |
if(HEADER_VERSION_MISMATCH){ |
| 20837 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 20838 |
return failure_indicator; |
| 20839 |
} |
| 20840 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 20841 |
MARPA_ERROR(g->t_error); |
| 20842 |
return failure_indicator; |
| 20843 |
} |
| 20844 |
|
| 20845 |
/*:1250*/ |
| 20846 |
#line 14990 "./marpa.w" |
| 20847 |
|
| 20848 |
/*1247:*/ |
| 20849 |
#line 14973 "./marpa.w" |
| 20850 |
|
| 20851 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 20852 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 20853 |
return failure_indicator; |
| 20854 |
} |
| 20855 |
/*:1247*/ |
| 20856 |
#line 14991 "./marpa.w" |
| 20857 |
|
| 20858 |
|
| 20859 |
/*:1249*/ |
| 20860 |
#line 15772 "./marpa.w" |
| 20861 |
|
| 20862 |
/*1308:*/ |
| 20863 |
#line 15790 "./marpa.w" |
| 20864 |
|
| 20865 |
item= r->t_trace_earley_item; |
| 20866 |
if(!item){ |
| 20867 |
trace_source_link_clear(r); |
| 20868 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_YIM); |
| 20869 |
return failure_indicator; |
| 20870 |
} |
| 20871 |
|
| 20872 |
/*:1308*/ |
| 20873 |
#line 15773 "./marpa.w" |
| 20874 |
|
| 20875 |
if(r->t_trace_source_type!=SOURCE_IS_LEO) |
| 20876 |
{ |
| 20877 |
trace_source_link_clear(r); |
| 20878 |
MARPA_ERROR(MARPA_ERR_NOT_TRACING_LEO_LINKS); |
| 20879 |
return failure_indicator; |
| 20880 |
} |
| 20881 |
source_link= Next_SRCL_of_SRCL(r->t_trace_source_link); |
| 20882 |
if(!source_link) |
| 20883 |
{ |
| 20884 |
trace_source_link_clear(r); |
| 20885 |
return-1; |
| 20886 |
} |
| 20887 |
r->t_trace_source_link= source_link; |
| 20888 |
return Cause_AHMID_of_SRCL(source_link); |
| 20889 |
} |
| 20890 |
|
| 20891 |
/*:1307*//*1309:*/ |
| 20892 |
#line 15799 "./marpa.w" |
| 20893 |
|
| 20894 |
PRIVATE void trace_source_link_clear(RECCE r) |
| 20895 |
{ |
| 20896 |
r->t_trace_source_link= NULL; |
| 20897 |
r->t_trace_source_type= NO_SOURCE; |
| 20898 |
} |
| 20899 |
|
| 20900 |
/*:1309*//*1310:*/ |
| 20901 |
#line 15814 "./marpa.w" |
| 20902 |
|
| 20903 |
AHMID _marpa_r_source_predecessor_state(Marpa_Recognizer r) |
| 20904 |
{ |
| 20905 |
/*1230:*/ |
| 20906 |
#line 14864 "./marpa.w" |
| 20907 |
const int failure_indicator= -2; |
| 20908 |
|
| 20909 |
/*:1230*/ |
| 20910 |
#line 15817 "./marpa.w" |
| 20911 |
|
| 20912 |
unsigned int source_type; |
| 20913 |
SRCL source_link; |
| 20914 |
/*560:*/ |
| 20915 |
#line 6100 "./marpa.w" |
| 20916 |
|
| 20917 |
const GRAMMAR g= G_of_R(r); |
| 20918 |
/*:560*/ |
| 20919 |
#line 15820 "./marpa.w" |
| 20920 |
|
| 20921 |
/*1249:*/ |
| 20922 |
#line 14989 "./marpa.w" |
| 20923 |
|
| 20924 |
/*1250:*/ |
| 20925 |
#line 14997 "./marpa.w" |
| 20926 |
|
| 20927 |
if(HEADER_VERSION_MISMATCH){ |
| 20928 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 20929 |
return failure_indicator; |
| 20930 |
} |
| 20931 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 20932 |
MARPA_ERROR(g->t_error); |
| 20933 |
return failure_indicator; |
| 20934 |
} |
| 20935 |
|
| 20936 |
/*:1250*/ |
| 20937 |
#line 14990 "./marpa.w" |
| 20938 |
|
| 20939 |
/*1247:*/ |
| 20940 |
#line 14973 "./marpa.w" |
| 20941 |
|
| 20942 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 20943 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 20944 |
return failure_indicator; |
| 20945 |
} |
| 20946 |
/*:1247*/ |
| 20947 |
#line 14991 "./marpa.w" |
| 20948 |
|
| 20949 |
|
| 20950 |
/*:1249*/ |
| 20951 |
#line 15821 "./marpa.w" |
| 20952 |
|
| 20953 |
source_type= r->t_trace_source_type; |
| 20954 |
/*1316:*/ |
| 20955 |
#line 15966 "./marpa.w" |
| 20956 |
|
| 20957 |
source_link= r->t_trace_source_link; |
| 20958 |
if(!source_link){ |
| 20959 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_SRCL); |
| 20960 |
return failure_indicator; |
| 20961 |
} |
| 20962 |
|
| 20963 |
/*:1316*/ |
| 20964 |
#line 15823 "./marpa.w" |
| 20965 |
|
| 20966 |
switch(source_type) |
| 20967 |
{ |
| 20968 |
case SOURCE_IS_TOKEN: |
| 20969 |
case SOURCE_IS_COMPLETION:{ |
| 20970 |
YIM predecessor= Predecessor_of_SRCL(source_link); |
| 20971 |
if(!predecessor)return-1; |
| 20972 |
return AHMID_of_YIM(predecessor); |
| 20973 |
} |
| 20974 |
} |
| 20975 |
MARPA_ERROR(invalid_source_type_code(source_type)); |
| 20976 |
return failure_indicator; |
| 20977 |
} |
| 20978 |
|
| 20979 |
/*:1310*//*1311:*/ |
| 20980 |
#line 15855 "./marpa.w" |
| 20981 |
|
| 20982 |
Marpa_Symbol_ID _marpa_r_source_token(Marpa_Recognizer r,int*value_p) |
| 20983 |
{ |
| 20984 |
/*1230:*/ |
| 20985 |
#line 14864 "./marpa.w" |
| 20986 |
const int failure_indicator= -2; |
| 20987 |
|
| 20988 |
/*:1230*/ |
| 20989 |
#line 15858 "./marpa.w" |
| 20990 |
|
| 20991 |
unsigned int source_type; |
| 20992 |
SRCL source_link; |
| 20993 |
/*560:*/ |
| 20994 |
#line 6100 "./marpa.w" |
| 20995 |
|
| 20996 |
const GRAMMAR g= G_of_R(r); |
| 20997 |
/*:560*/ |
| 20998 |
#line 15861 "./marpa.w" |
| 20999 |
|
| 21000 |
/*1249:*/ |
| 21001 |
#line 14989 "./marpa.w" |
| 21002 |
|
| 21003 |
/*1250:*/ |
| 21004 |
#line 14997 "./marpa.w" |
| 21005 |
|
| 21006 |
if(HEADER_VERSION_MISMATCH){ |
| 21007 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21008 |
return failure_indicator; |
| 21009 |
} |
| 21010 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21011 |
MARPA_ERROR(g->t_error); |
| 21012 |
return failure_indicator; |
| 21013 |
} |
| 21014 |
|
| 21015 |
/*:1250*/ |
| 21016 |
#line 14990 "./marpa.w" |
| 21017 |
|
| 21018 |
/*1247:*/ |
| 21019 |
#line 14973 "./marpa.w" |
| 21020 |
|
| 21021 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 21022 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 21023 |
return failure_indicator; |
| 21024 |
} |
| 21025 |
/*:1247*/ |
| 21026 |
#line 14991 "./marpa.w" |
| 21027 |
|
| 21028 |
|
| 21029 |
/*:1249*/ |
| 21030 |
#line 15862 "./marpa.w" |
| 21031 |
|
| 21032 |
source_type= r->t_trace_source_type; |
| 21033 |
/*1316:*/ |
| 21034 |
#line 15966 "./marpa.w" |
| 21035 |
|
| 21036 |
source_link= r->t_trace_source_link; |
| 21037 |
if(!source_link){ |
| 21038 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_SRCL); |
| 21039 |
return failure_indicator; |
| 21040 |
} |
| 21041 |
|
| 21042 |
/*:1316*/ |
| 21043 |
#line 15864 "./marpa.w" |
| 21044 |
|
| 21045 |
if(source_type==SOURCE_IS_TOKEN){ |
| 21046 |
if(value_p)*value_p= Value_of_SRCL(source_link); |
| 21047 |
return NSYID_of_SRCL(source_link); |
| 21048 |
} |
| 21049 |
MARPA_ERROR(invalid_source_type_code(source_type)); |
| 21050 |
return failure_indicator; |
| 21051 |
} |
| 21052 |
|
| 21053 |
/*:1311*//*1313:*/ |
| 21054 |
#line 15886 "./marpa.w" |
| 21055 |
|
| 21056 |
Marpa_Symbol_ID _marpa_r_source_leo_transition_symbol(Marpa_Recognizer r) |
| 21057 |
{ |
| 21058 |
/*1230:*/ |
| 21059 |
#line 14864 "./marpa.w" |
| 21060 |
const int failure_indicator= -2; |
| 21061 |
|
| 21062 |
/*:1230*/ |
| 21063 |
#line 15889 "./marpa.w" |
| 21064 |
|
| 21065 |
unsigned int source_type; |
| 21066 |
SRCL source_link; |
| 21067 |
/*560:*/ |
| 21068 |
#line 6100 "./marpa.w" |
| 21069 |
|
| 21070 |
const GRAMMAR g= G_of_R(r); |
| 21071 |
/*:560*/ |
| 21072 |
#line 15892 "./marpa.w" |
| 21073 |
|
| 21074 |
/*1249:*/ |
| 21075 |
#line 14989 "./marpa.w" |
| 21076 |
|
| 21077 |
/*1250:*/ |
| 21078 |
#line 14997 "./marpa.w" |
| 21079 |
|
| 21080 |
if(HEADER_VERSION_MISMATCH){ |
| 21081 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21082 |
return failure_indicator; |
| 21083 |
} |
| 21084 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21085 |
MARPA_ERROR(g->t_error); |
| 21086 |
return failure_indicator; |
| 21087 |
} |
| 21088 |
|
| 21089 |
/*:1250*/ |
| 21090 |
#line 14990 "./marpa.w" |
| 21091 |
|
| 21092 |
/*1247:*/ |
| 21093 |
#line 14973 "./marpa.w" |
| 21094 |
|
| 21095 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 21096 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 21097 |
return failure_indicator; |
| 21098 |
} |
| 21099 |
/*:1247*/ |
| 21100 |
#line 14991 "./marpa.w" |
| 21101 |
|
| 21102 |
|
| 21103 |
/*:1249*/ |
| 21104 |
#line 15893 "./marpa.w" |
| 21105 |
|
| 21106 |
source_type= r->t_trace_source_type; |
| 21107 |
/*1316:*/ |
| 21108 |
#line 15966 "./marpa.w" |
| 21109 |
|
| 21110 |
source_link= r->t_trace_source_link; |
| 21111 |
if(!source_link){ |
| 21112 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_SRCL); |
| 21113 |
return failure_indicator; |
| 21114 |
} |
| 21115 |
|
| 21116 |
/*:1316*/ |
| 21117 |
#line 15895 "./marpa.w" |
| 21118 |
|
| 21119 |
switch(source_type) |
| 21120 |
{ |
| 21121 |
case SOURCE_IS_LEO: |
| 21122 |
return Leo_Transition_NSYID_of_SRCL(source_link); |
| 21123 |
} |
| 21124 |
MARPA_ERROR(invalid_source_type_code(source_type)); |
| 21125 |
return failure_indicator; |
| 21126 |
} |
| 21127 |
|
| 21128 |
/*:1313*//*1315:*/ |
| 21129 |
#line 15929 "./marpa.w" |
| 21130 |
|
| 21131 |
Marpa_Earley_Set_ID _marpa_r_source_middle(Marpa_Recognizer r) |
| 21132 |
{ |
| 21133 |
/*1230:*/ |
| 21134 |
#line 14864 "./marpa.w" |
| 21135 |
const int failure_indicator= -2; |
| 21136 |
|
| 21137 |
/*:1230*/ |
| 21138 |
#line 15932 "./marpa.w" |
| 21139 |
|
| 21140 |
YIM predecessor_yim= NULL; |
| 21141 |
unsigned int source_type; |
| 21142 |
SRCL source_link; |
| 21143 |
/*560:*/ |
| 21144 |
#line 6100 "./marpa.w" |
| 21145 |
|
| 21146 |
const GRAMMAR g= G_of_R(r); |
| 21147 |
/*:560*/ |
| 21148 |
#line 15936 "./marpa.w" |
| 21149 |
|
| 21150 |
/*1249:*/ |
| 21151 |
#line 14989 "./marpa.w" |
| 21152 |
|
| 21153 |
/*1250:*/ |
| 21154 |
#line 14997 "./marpa.w" |
| 21155 |
|
| 21156 |
if(HEADER_VERSION_MISMATCH){ |
| 21157 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21158 |
return failure_indicator; |
| 21159 |
} |
| 21160 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21161 |
MARPA_ERROR(g->t_error); |
| 21162 |
return failure_indicator; |
| 21163 |
} |
| 21164 |
|
| 21165 |
/*:1250*/ |
| 21166 |
#line 14990 "./marpa.w" |
| 21167 |
|
| 21168 |
/*1247:*/ |
| 21169 |
#line 14973 "./marpa.w" |
| 21170 |
|
| 21171 |
if(_MARPA_UNLIKELY(Input_Phase_of_R(r)==R_BEFORE_INPUT)){ |
| 21172 |
MARPA_ERROR(MARPA_ERR_RECCE_NOT_STARTED); |
| 21173 |
return failure_indicator; |
| 21174 |
} |
| 21175 |
/*:1247*/ |
| 21176 |
#line 14991 "./marpa.w" |
| 21177 |
|
| 21178 |
|
| 21179 |
/*:1249*/ |
| 21180 |
#line 15937 "./marpa.w" |
| 21181 |
|
| 21182 |
source_type= r->t_trace_source_type; |
| 21183 |
/*1316:*/ |
| 21184 |
#line 15966 "./marpa.w" |
| 21185 |
|
| 21186 |
source_link= r->t_trace_source_link; |
| 21187 |
if(!source_link){ |
| 21188 |
MARPA_ERROR(MARPA_ERR_NO_TRACE_SRCL); |
| 21189 |
return failure_indicator; |
| 21190 |
} |
| 21191 |
|
| 21192 |
/*:1316*/ |
| 21193 |
#line 15939 "./marpa.w" |
| 21194 |
|
| 21195 |
|
| 21196 |
switch(source_type) |
| 21197 |
{ |
| 21198 |
case SOURCE_IS_LEO: |
| 21199 |
{ |
| 21200 |
LIM predecessor= LIM_of_SRCL(source_link); |
| 21201 |
if(predecessor) |
| 21202 |
predecessor_yim= Trailhead_YIM_of_LIM(predecessor); |
| 21203 |
break; |
| 21204 |
} |
| 21205 |
case SOURCE_IS_TOKEN: |
| 21206 |
case SOURCE_IS_COMPLETION: |
| 21207 |
{ |
| 21208 |
predecessor_yim= Predecessor_of_SRCL(source_link); |
| 21209 |
break; |
| 21210 |
} |
| 21211 |
default: |
| 21212 |
MARPA_ERROR(invalid_source_type_code(source_type)); |
| 21213 |
return failure_indicator; |
| 21214 |
} |
| 21215 |
|
| 21216 |
if(predecessor_yim) |
| 21217 |
return YS_Ord_of_YIM(predecessor_yim); |
| 21218 |
return Origin_Ord_of_YIM(r->t_trace_earley_item); |
| 21219 |
} |
| 21220 |
|
| 21221 |
/*:1315*//*1320:*/ |
| 21222 |
#line 16004 "./marpa.w" |
| 21223 |
|
| 21224 |
int _marpa_b_or_node_set(Marpa_Bocage b, |
| 21225 |
Marpa_Or_Node_ID or_node_id) |
| 21226 |
{ |
| 21227 |
OR or_node; |
| 21228 |
/*1230:*/ |
| 21229 |
#line 14864 "./marpa.w" |
| 21230 |
const int failure_indicator= -2; |
| 21231 |
|
| 21232 |
/*:1230*/ |
| 21233 |
#line 16009 "./marpa.w" |
| 21234 |
|
| 21235 |
/*939:*/ |
| 21236 |
#line 11160 "./marpa.w" |
| 21237 |
|
| 21238 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 21239 |
|
| 21240 |
/*:939*/ |
| 21241 |
#line 16010 "./marpa.w" |
| 21242 |
|
| 21243 |
/*1250:*/ |
| 21244 |
#line 14997 "./marpa.w" |
| 21245 |
|
| 21246 |
if(HEADER_VERSION_MISMATCH){ |
| 21247 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21248 |
return failure_indicator; |
| 21249 |
} |
| 21250 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21251 |
MARPA_ERROR(g->t_error); |
| 21252 |
return failure_indicator; |
| 21253 |
} |
| 21254 |
|
| 21255 |
/*:1250*/ |
| 21256 |
#line 16011 "./marpa.w" |
| 21257 |
|
| 21258 |
/*1318:*/ |
| 21259 |
#line 15982 "./marpa.w" |
| 21260 |
|
| 21261 |
{ |
| 21262 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Count_of_B(b))) |
| 21263 |
{ |
| 21264 |
return-1; |
| 21265 |
} |
| 21266 |
if(_MARPA_UNLIKELY(or_node_id<0)) |
| 21267 |
{ |
| 21268 |
MARPA_ERROR(MARPA_ERR_ORID_NEGATIVE); |
| 21269 |
return failure_indicator; |
| 21270 |
} |
| 21271 |
} |
| 21272 |
/*:1318*/ |
| 21273 |
#line 16012 "./marpa.w" |
| 21274 |
|
| 21275 |
/*1319:*/ |
| 21276 |
#line 15994 "./marpa.w" |
| 21277 |
|
| 21278 |
{ |
| 21279 |
if(_MARPA_UNLIKELY(!ORs_of_B(b))) |
| 21280 |
{ |
| 21281 |
MARPA_ERROR(MARPA_ERR_NO_OR_NODES); |
| 21282 |
return failure_indicator; |
| 21283 |
} |
| 21284 |
or_node= OR_of_B_by_ID(b,or_node_id); |
| 21285 |
} |
| 21286 |
|
| 21287 |
/*:1319*/ |
| 21288 |
#line 16013 "./marpa.w" |
| 21289 |
|
| 21290 |
return YS_Ord_of_OR(or_node); |
| 21291 |
} |
| 21292 |
|
| 21293 |
/*:1320*//*1321:*/ |
| 21294 |
#line 16017 "./marpa.w" |
| 21295 |
|
| 21296 |
int _marpa_b_or_node_origin(Marpa_Bocage b, |
| 21297 |
Marpa_Or_Node_ID or_node_id) |
| 21298 |
{ |
| 21299 |
OR or_node; |
| 21300 |
/*1230:*/ |
| 21301 |
#line 14864 "./marpa.w" |
| 21302 |
const int failure_indicator= -2; |
| 21303 |
|
| 21304 |
/*:1230*/ |
| 21305 |
#line 16022 "./marpa.w" |
| 21306 |
|
| 21307 |
/*939:*/ |
| 21308 |
#line 11160 "./marpa.w" |
| 21309 |
|
| 21310 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 21311 |
|
| 21312 |
/*:939*/ |
| 21313 |
#line 16023 "./marpa.w" |
| 21314 |
|
| 21315 |
/*1250:*/ |
| 21316 |
#line 14997 "./marpa.w" |
| 21317 |
|
| 21318 |
if(HEADER_VERSION_MISMATCH){ |
| 21319 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21320 |
return failure_indicator; |
| 21321 |
} |
| 21322 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21323 |
MARPA_ERROR(g->t_error); |
| 21324 |
return failure_indicator; |
| 21325 |
} |
| 21326 |
|
| 21327 |
/*:1250*/ |
| 21328 |
#line 16024 "./marpa.w" |
| 21329 |
|
| 21330 |
/*1318:*/ |
| 21331 |
#line 15982 "./marpa.w" |
| 21332 |
|
| 21333 |
{ |
| 21334 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Count_of_B(b))) |
| 21335 |
{ |
| 21336 |
return-1; |
| 21337 |
} |
| 21338 |
if(_MARPA_UNLIKELY(or_node_id<0)) |
| 21339 |
{ |
| 21340 |
MARPA_ERROR(MARPA_ERR_ORID_NEGATIVE); |
| 21341 |
return failure_indicator; |
| 21342 |
} |
| 21343 |
} |
| 21344 |
/*:1318*/ |
| 21345 |
#line 16025 "./marpa.w" |
| 21346 |
|
| 21347 |
/*1319:*/ |
| 21348 |
#line 15994 "./marpa.w" |
| 21349 |
|
| 21350 |
{ |
| 21351 |
if(_MARPA_UNLIKELY(!ORs_of_B(b))) |
| 21352 |
{ |
| 21353 |
MARPA_ERROR(MARPA_ERR_NO_OR_NODES); |
| 21354 |
return failure_indicator; |
| 21355 |
} |
| 21356 |
or_node= OR_of_B_by_ID(b,or_node_id); |
| 21357 |
} |
| 21358 |
|
| 21359 |
/*:1319*/ |
| 21360 |
#line 16026 "./marpa.w" |
| 21361 |
|
| 21362 |
return Origin_Ord_of_OR(or_node); |
| 21363 |
} |
| 21364 |
|
| 21365 |
/*:1321*//*1322:*/ |
| 21366 |
#line 16030 "./marpa.w" |
| 21367 |
|
| 21368 |
Marpa_IRL_ID _marpa_b_or_node_irl(Marpa_Bocage b, |
| 21369 |
Marpa_Or_Node_ID or_node_id) |
| 21370 |
{ |
| 21371 |
OR or_node; |
| 21372 |
/*1230:*/ |
| 21373 |
#line 14864 "./marpa.w" |
| 21374 |
const int failure_indicator= -2; |
| 21375 |
|
| 21376 |
/*:1230*/ |
| 21377 |
#line 16035 "./marpa.w" |
| 21378 |
|
| 21379 |
/*939:*/ |
| 21380 |
#line 11160 "./marpa.w" |
| 21381 |
|
| 21382 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 21383 |
|
| 21384 |
/*:939*/ |
| 21385 |
#line 16036 "./marpa.w" |
| 21386 |
|
| 21387 |
/*1250:*/ |
| 21388 |
#line 14997 "./marpa.w" |
| 21389 |
|
| 21390 |
if(HEADER_VERSION_MISMATCH){ |
| 21391 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21392 |
return failure_indicator; |
| 21393 |
} |
| 21394 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21395 |
MARPA_ERROR(g->t_error); |
| 21396 |
return failure_indicator; |
| 21397 |
} |
| 21398 |
|
| 21399 |
/*:1250*/ |
| 21400 |
#line 16037 "./marpa.w" |
| 21401 |
|
| 21402 |
/*1318:*/ |
| 21403 |
#line 15982 "./marpa.w" |
| 21404 |
|
| 21405 |
{ |
| 21406 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Count_of_B(b))) |
| 21407 |
{ |
| 21408 |
return-1; |
| 21409 |
} |
| 21410 |
if(_MARPA_UNLIKELY(or_node_id<0)) |
| 21411 |
{ |
| 21412 |
MARPA_ERROR(MARPA_ERR_ORID_NEGATIVE); |
| 21413 |
return failure_indicator; |
| 21414 |
} |
| 21415 |
} |
| 21416 |
/*:1318*/ |
| 21417 |
#line 16038 "./marpa.w" |
| 21418 |
|
| 21419 |
/*1319:*/ |
| 21420 |
#line 15994 "./marpa.w" |
| 21421 |
|
| 21422 |
{ |
| 21423 |
if(_MARPA_UNLIKELY(!ORs_of_B(b))) |
| 21424 |
{ |
| 21425 |
MARPA_ERROR(MARPA_ERR_NO_OR_NODES); |
| 21426 |
return failure_indicator; |
| 21427 |
} |
| 21428 |
or_node= OR_of_B_by_ID(b,or_node_id); |
| 21429 |
} |
| 21430 |
|
| 21431 |
/*:1319*/ |
| 21432 |
#line 16039 "./marpa.w" |
| 21433 |
|
| 21434 |
return IRLID_of_OR(or_node); |
| 21435 |
} |
| 21436 |
|
| 21437 |
/*:1322*//*1323:*/ |
| 21438 |
#line 16043 "./marpa.w" |
| 21439 |
|
| 21440 |
int _marpa_b_or_node_position(Marpa_Bocage b, |
| 21441 |
Marpa_Or_Node_ID or_node_id) |
| 21442 |
{ |
| 21443 |
OR or_node; |
| 21444 |
/*1230:*/ |
| 21445 |
#line 14864 "./marpa.w" |
| 21446 |
const int failure_indicator= -2; |
| 21447 |
|
| 21448 |
/*:1230*/ |
| 21449 |
#line 16048 "./marpa.w" |
| 21450 |
|
| 21451 |
/*939:*/ |
| 21452 |
#line 11160 "./marpa.w" |
| 21453 |
|
| 21454 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 21455 |
|
| 21456 |
/*:939*/ |
| 21457 |
#line 16049 "./marpa.w" |
| 21458 |
|
| 21459 |
/*1250:*/ |
| 21460 |
#line 14997 "./marpa.w" |
| 21461 |
|
| 21462 |
if(HEADER_VERSION_MISMATCH){ |
| 21463 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21464 |
return failure_indicator; |
| 21465 |
} |
| 21466 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21467 |
MARPA_ERROR(g->t_error); |
| 21468 |
return failure_indicator; |
| 21469 |
} |
| 21470 |
|
| 21471 |
/*:1250*/ |
| 21472 |
#line 16050 "./marpa.w" |
| 21473 |
|
| 21474 |
/*1318:*/ |
| 21475 |
#line 15982 "./marpa.w" |
| 21476 |
|
| 21477 |
{ |
| 21478 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Count_of_B(b))) |
| 21479 |
{ |
| 21480 |
return-1; |
| 21481 |
} |
| 21482 |
if(_MARPA_UNLIKELY(or_node_id<0)) |
| 21483 |
{ |
| 21484 |
MARPA_ERROR(MARPA_ERR_ORID_NEGATIVE); |
| 21485 |
return failure_indicator; |
| 21486 |
} |
| 21487 |
} |
| 21488 |
/*:1318*/ |
| 21489 |
#line 16051 "./marpa.w" |
| 21490 |
|
| 21491 |
/*1319:*/ |
| 21492 |
#line 15994 "./marpa.w" |
| 21493 |
|
| 21494 |
{ |
| 21495 |
if(_MARPA_UNLIKELY(!ORs_of_B(b))) |
| 21496 |
{ |
| 21497 |
MARPA_ERROR(MARPA_ERR_NO_OR_NODES); |
| 21498 |
return failure_indicator; |
| 21499 |
} |
| 21500 |
or_node= OR_of_B_by_ID(b,or_node_id); |
| 21501 |
} |
| 21502 |
|
| 21503 |
/*:1319*/ |
| 21504 |
#line 16052 "./marpa.w" |
| 21505 |
|
| 21506 |
return Position_of_OR(or_node); |
| 21507 |
} |
| 21508 |
|
| 21509 |
/*:1323*//*1324:*/ |
| 21510 |
#line 16056 "./marpa.w" |
| 21511 |
|
| 21512 |
int _marpa_b_or_node_is_whole(Marpa_Bocage b, |
| 21513 |
Marpa_Or_Node_ID or_node_id) |
| 21514 |
{ |
| 21515 |
OR or_node; |
| 21516 |
/*1230:*/ |
| 21517 |
#line 14864 "./marpa.w" |
| 21518 |
const int failure_indicator= -2; |
| 21519 |
|
| 21520 |
/*:1230*/ |
| 21521 |
#line 16061 "./marpa.w" |
| 21522 |
|
| 21523 |
/*939:*/ |
| 21524 |
#line 11160 "./marpa.w" |
| 21525 |
|
| 21526 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 21527 |
|
| 21528 |
/*:939*/ |
| 21529 |
#line 16062 "./marpa.w" |
| 21530 |
|
| 21531 |
/*1250:*/ |
| 21532 |
#line 14997 "./marpa.w" |
| 21533 |
|
| 21534 |
if(HEADER_VERSION_MISMATCH){ |
| 21535 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21536 |
return failure_indicator; |
| 21537 |
} |
| 21538 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21539 |
MARPA_ERROR(g->t_error); |
| 21540 |
return failure_indicator; |
| 21541 |
} |
| 21542 |
|
| 21543 |
/*:1250*/ |
| 21544 |
#line 16063 "./marpa.w" |
| 21545 |
|
| 21546 |
/*1318:*/ |
| 21547 |
#line 15982 "./marpa.w" |
| 21548 |
|
| 21549 |
{ |
| 21550 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Count_of_B(b))) |
| 21551 |
{ |
| 21552 |
return-1; |
| 21553 |
} |
| 21554 |
if(_MARPA_UNLIKELY(or_node_id<0)) |
| 21555 |
{ |
| 21556 |
MARPA_ERROR(MARPA_ERR_ORID_NEGATIVE); |
| 21557 |
return failure_indicator; |
| 21558 |
} |
| 21559 |
} |
| 21560 |
/*:1318*/ |
| 21561 |
#line 16064 "./marpa.w" |
| 21562 |
|
| 21563 |
/*1319:*/ |
| 21564 |
#line 15994 "./marpa.w" |
| 21565 |
|
| 21566 |
{ |
| 21567 |
if(_MARPA_UNLIKELY(!ORs_of_B(b))) |
| 21568 |
{ |
| 21569 |
MARPA_ERROR(MARPA_ERR_NO_OR_NODES); |
| 21570 |
return failure_indicator; |
| 21571 |
} |
| 21572 |
or_node= OR_of_B_by_ID(b,or_node_id); |
| 21573 |
} |
| 21574 |
|
| 21575 |
/*:1319*/ |
| 21576 |
#line 16065 "./marpa.w" |
| 21577 |
|
| 21578 |
return Position_of_OR(or_node)>=Length_of_IRL(IRL_of_OR(or_node))?1:0; |
| 21579 |
} |
| 21580 |
|
| 21581 |
/*:1324*//*1325:*/ |
| 21582 |
#line 16069 "./marpa.w" |
| 21583 |
|
| 21584 |
int _marpa_b_or_node_is_semantic(Marpa_Bocage b, |
| 21585 |
Marpa_Or_Node_ID or_node_id) |
| 21586 |
{ |
| 21587 |
OR or_node; |
| 21588 |
/*1230:*/ |
| 21589 |
#line 14864 "./marpa.w" |
| 21590 |
const int failure_indicator= -2; |
| 21591 |
|
| 21592 |
/*:1230*/ |
| 21593 |
#line 16074 "./marpa.w" |
| 21594 |
|
| 21595 |
/*939:*/ |
| 21596 |
#line 11160 "./marpa.w" |
| 21597 |
|
| 21598 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 21599 |
|
| 21600 |
/*:939*/ |
| 21601 |
#line 16075 "./marpa.w" |
| 21602 |
|
| 21603 |
/*1250:*/ |
| 21604 |
#line 14997 "./marpa.w" |
| 21605 |
|
| 21606 |
if(HEADER_VERSION_MISMATCH){ |
| 21607 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21608 |
return failure_indicator; |
| 21609 |
} |
| 21610 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21611 |
MARPA_ERROR(g->t_error); |
| 21612 |
return failure_indicator; |
| 21613 |
} |
| 21614 |
|
| 21615 |
/*:1250*/ |
| 21616 |
#line 16076 "./marpa.w" |
| 21617 |
|
| 21618 |
/*1318:*/ |
| 21619 |
#line 15982 "./marpa.w" |
| 21620 |
|
| 21621 |
{ |
| 21622 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Count_of_B(b))) |
| 21623 |
{ |
| 21624 |
return-1; |
| 21625 |
} |
| 21626 |
if(_MARPA_UNLIKELY(or_node_id<0)) |
| 21627 |
{ |
| 21628 |
MARPA_ERROR(MARPA_ERR_ORID_NEGATIVE); |
| 21629 |
return failure_indicator; |
| 21630 |
} |
| 21631 |
} |
| 21632 |
/*:1318*/ |
| 21633 |
#line 16077 "./marpa.w" |
| 21634 |
|
| 21635 |
/*1319:*/ |
| 21636 |
#line 15994 "./marpa.w" |
| 21637 |
|
| 21638 |
{ |
| 21639 |
if(_MARPA_UNLIKELY(!ORs_of_B(b))) |
| 21640 |
{ |
| 21641 |
MARPA_ERROR(MARPA_ERR_NO_OR_NODES); |
| 21642 |
return failure_indicator; |
| 21643 |
} |
| 21644 |
or_node= OR_of_B_by_ID(b,or_node_id); |
| 21645 |
} |
| 21646 |
|
| 21647 |
/*:1319*/ |
| 21648 |
#line 16078 "./marpa.w" |
| 21649 |
|
| 21650 |
return!IRL_has_Virtual_LHS(IRL_of_OR(or_node)); |
| 21651 |
} |
| 21652 |
|
| 21653 |
/*:1325*//*1326:*/ |
| 21654 |
#line 16082 "./marpa.w" |
| 21655 |
|
| 21656 |
int _marpa_b_or_node_first_and(Marpa_Bocage b, |
| 21657 |
Marpa_Or_Node_ID or_node_id) |
| 21658 |
{ |
| 21659 |
OR or_node; |
| 21660 |
/*1230:*/ |
| 21661 |
#line 14864 "./marpa.w" |
| 21662 |
const int failure_indicator= -2; |
| 21663 |
|
| 21664 |
/*:1230*/ |
| 21665 |
#line 16087 "./marpa.w" |
| 21666 |
|
| 21667 |
/*939:*/ |
| 21668 |
#line 11160 "./marpa.w" |
| 21669 |
|
| 21670 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 21671 |
|
| 21672 |
/*:939*/ |
| 21673 |
#line 16088 "./marpa.w" |
| 21674 |
|
| 21675 |
/*1250:*/ |
| 21676 |
#line 14997 "./marpa.w" |
| 21677 |
|
| 21678 |
if(HEADER_VERSION_MISMATCH){ |
| 21679 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21680 |
return failure_indicator; |
| 21681 |
} |
| 21682 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21683 |
MARPA_ERROR(g->t_error); |
| 21684 |
return failure_indicator; |
| 21685 |
} |
| 21686 |
|
| 21687 |
/*:1250*/ |
| 21688 |
#line 16089 "./marpa.w" |
| 21689 |
|
| 21690 |
/*1318:*/ |
| 21691 |
#line 15982 "./marpa.w" |
| 21692 |
|
| 21693 |
{ |
| 21694 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Count_of_B(b))) |
| 21695 |
{ |
| 21696 |
return-1; |
| 21697 |
} |
| 21698 |
if(_MARPA_UNLIKELY(or_node_id<0)) |
| 21699 |
{ |
| 21700 |
MARPA_ERROR(MARPA_ERR_ORID_NEGATIVE); |
| 21701 |
return failure_indicator; |
| 21702 |
} |
| 21703 |
} |
| 21704 |
/*:1318*/ |
| 21705 |
#line 16090 "./marpa.w" |
| 21706 |
|
| 21707 |
/*1319:*/ |
| 21708 |
#line 15994 "./marpa.w" |
| 21709 |
|
| 21710 |
{ |
| 21711 |
if(_MARPA_UNLIKELY(!ORs_of_B(b))) |
| 21712 |
{ |
| 21713 |
MARPA_ERROR(MARPA_ERR_NO_OR_NODES); |
| 21714 |
return failure_indicator; |
| 21715 |
} |
| 21716 |
or_node= OR_of_B_by_ID(b,or_node_id); |
| 21717 |
} |
| 21718 |
|
| 21719 |
/*:1319*/ |
| 21720 |
#line 16091 "./marpa.w" |
| 21721 |
|
| 21722 |
return First_ANDID_of_OR(or_node); |
| 21723 |
} |
| 21724 |
|
| 21725 |
/*:1326*//*1327:*/ |
| 21726 |
#line 16095 "./marpa.w" |
| 21727 |
|
| 21728 |
int _marpa_b_or_node_last_and(Marpa_Bocage b, |
| 21729 |
Marpa_Or_Node_ID or_node_id) |
| 21730 |
{ |
| 21731 |
OR or_node; |
| 21732 |
/*1230:*/ |
| 21733 |
#line 14864 "./marpa.w" |
| 21734 |
const int failure_indicator= -2; |
| 21735 |
|
| 21736 |
/*:1230*/ |
| 21737 |
#line 16100 "./marpa.w" |
| 21738 |
|
| 21739 |
/*939:*/ |
| 21740 |
#line 11160 "./marpa.w" |
| 21741 |
|
| 21742 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 21743 |
|
| 21744 |
/*:939*/ |
| 21745 |
#line 16101 "./marpa.w" |
| 21746 |
|
| 21747 |
/*1250:*/ |
| 21748 |
#line 14997 "./marpa.w" |
| 21749 |
|
| 21750 |
if(HEADER_VERSION_MISMATCH){ |
| 21751 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21752 |
return failure_indicator; |
| 21753 |
} |
| 21754 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21755 |
MARPA_ERROR(g->t_error); |
| 21756 |
return failure_indicator; |
| 21757 |
} |
| 21758 |
|
| 21759 |
/*:1250*/ |
| 21760 |
#line 16102 "./marpa.w" |
| 21761 |
|
| 21762 |
/*1318:*/ |
| 21763 |
#line 15982 "./marpa.w" |
| 21764 |
|
| 21765 |
{ |
| 21766 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Count_of_B(b))) |
| 21767 |
{ |
| 21768 |
return-1; |
| 21769 |
} |
| 21770 |
if(_MARPA_UNLIKELY(or_node_id<0)) |
| 21771 |
{ |
| 21772 |
MARPA_ERROR(MARPA_ERR_ORID_NEGATIVE); |
| 21773 |
return failure_indicator; |
| 21774 |
} |
| 21775 |
} |
| 21776 |
/*:1318*/ |
| 21777 |
#line 16103 "./marpa.w" |
| 21778 |
|
| 21779 |
/*1319:*/ |
| 21780 |
#line 15994 "./marpa.w" |
| 21781 |
|
| 21782 |
{ |
| 21783 |
if(_MARPA_UNLIKELY(!ORs_of_B(b))) |
| 21784 |
{ |
| 21785 |
MARPA_ERROR(MARPA_ERR_NO_OR_NODES); |
| 21786 |
return failure_indicator; |
| 21787 |
} |
| 21788 |
or_node= OR_of_B_by_ID(b,or_node_id); |
| 21789 |
} |
| 21790 |
|
| 21791 |
/*:1319*/ |
| 21792 |
#line 16104 "./marpa.w" |
| 21793 |
|
| 21794 |
return First_ANDID_of_OR(or_node) |
| 21795 |
+AND_Count_of_OR(or_node)-1; |
| 21796 |
} |
| 21797 |
|
| 21798 |
/*:1327*//*1328:*/ |
| 21799 |
#line 16109 "./marpa.w" |
| 21800 |
|
| 21801 |
int _marpa_b_or_node_and_count(Marpa_Bocage b, |
| 21802 |
Marpa_Or_Node_ID or_node_id) |
| 21803 |
{ |
| 21804 |
OR or_node; |
| 21805 |
/*1230:*/ |
| 21806 |
#line 14864 "./marpa.w" |
| 21807 |
const int failure_indicator= -2; |
| 21808 |
|
| 21809 |
/*:1230*/ |
| 21810 |
#line 16114 "./marpa.w" |
| 21811 |
|
| 21812 |
/*939:*/ |
| 21813 |
#line 11160 "./marpa.w" |
| 21814 |
|
| 21815 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 21816 |
|
| 21817 |
/*:939*/ |
| 21818 |
#line 16115 "./marpa.w" |
| 21819 |
|
| 21820 |
/*1250:*/ |
| 21821 |
#line 14997 "./marpa.w" |
| 21822 |
|
| 21823 |
if(HEADER_VERSION_MISMATCH){ |
| 21824 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21825 |
return failure_indicator; |
| 21826 |
} |
| 21827 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21828 |
MARPA_ERROR(g->t_error); |
| 21829 |
return failure_indicator; |
| 21830 |
} |
| 21831 |
|
| 21832 |
/*:1250*/ |
| 21833 |
#line 16116 "./marpa.w" |
| 21834 |
|
| 21835 |
/*1318:*/ |
| 21836 |
#line 15982 "./marpa.w" |
| 21837 |
|
| 21838 |
{ |
| 21839 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Count_of_B(b))) |
| 21840 |
{ |
| 21841 |
return-1; |
| 21842 |
} |
| 21843 |
if(_MARPA_UNLIKELY(or_node_id<0)) |
| 21844 |
{ |
| 21845 |
MARPA_ERROR(MARPA_ERR_ORID_NEGATIVE); |
| 21846 |
return failure_indicator; |
| 21847 |
} |
| 21848 |
} |
| 21849 |
/*:1318*/ |
| 21850 |
#line 16117 "./marpa.w" |
| 21851 |
|
| 21852 |
/*1319:*/ |
| 21853 |
#line 15994 "./marpa.w" |
| 21854 |
|
| 21855 |
{ |
| 21856 |
if(_MARPA_UNLIKELY(!ORs_of_B(b))) |
| 21857 |
{ |
| 21858 |
MARPA_ERROR(MARPA_ERR_NO_OR_NODES); |
| 21859 |
return failure_indicator; |
| 21860 |
} |
| 21861 |
or_node= OR_of_B_by_ID(b,or_node_id); |
| 21862 |
} |
| 21863 |
|
| 21864 |
/*:1319*/ |
| 21865 |
#line 16118 "./marpa.w" |
| 21866 |
|
| 21867 |
return AND_Count_of_OR(or_node); |
| 21868 |
} |
| 21869 |
|
| 21870 |
/*:1328*//*1331:*/ |
| 21871 |
#line 16132 "./marpa.w" |
| 21872 |
|
| 21873 |
int _marpa_o_or_node_and_node_count(Marpa_Order o, |
| 21874 |
Marpa_Or_Node_ID or_node_id) |
| 21875 |
{ |
| 21876 |
/*1230:*/ |
| 21877 |
#line 14864 "./marpa.w" |
| 21878 |
const int failure_indicator= -2; |
| 21879 |
|
| 21880 |
/*:1230*/ |
| 21881 |
#line 16136 "./marpa.w" |
| 21882 |
|
| 21883 |
/*985:*/ |
| 21884 |
#line 11573 "./marpa.w" |
| 21885 |
|
| 21886 |
const BOCAGE b= B_of_O(o); |
| 21887 |
/*939:*/ |
| 21888 |
#line 11160 "./marpa.w" |
| 21889 |
|
| 21890 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 21891 |
|
| 21892 |
/*:939*/ |
| 21893 |
#line 11575 "./marpa.w" |
| 21894 |
|
| 21895 |
|
| 21896 |
/*:985*/ |
| 21897 |
#line 16137 "./marpa.w" |
| 21898 |
|
| 21899 |
/*1250:*/ |
| 21900 |
#line 14997 "./marpa.w" |
| 21901 |
|
| 21902 |
if(HEADER_VERSION_MISMATCH){ |
| 21903 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21904 |
return failure_indicator; |
| 21905 |
} |
| 21906 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21907 |
MARPA_ERROR(g->t_error); |
| 21908 |
return failure_indicator; |
| 21909 |
} |
| 21910 |
|
| 21911 |
/*:1250*/ |
| 21912 |
#line 16138 "./marpa.w" |
| 21913 |
|
| 21914 |
/*1318:*/ |
| 21915 |
#line 15982 "./marpa.w" |
| 21916 |
|
| 21917 |
{ |
| 21918 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Count_of_B(b))) |
| 21919 |
{ |
| 21920 |
return-1; |
| 21921 |
} |
| 21922 |
if(_MARPA_UNLIKELY(or_node_id<0)) |
| 21923 |
{ |
| 21924 |
MARPA_ERROR(MARPA_ERR_ORID_NEGATIVE); |
| 21925 |
return failure_indicator; |
| 21926 |
} |
| 21927 |
} |
| 21928 |
/*:1318*/ |
| 21929 |
#line 16139 "./marpa.w" |
| 21930 |
|
| 21931 |
if(!O_is_Default(o)) |
| 21932 |
{ |
| 21933 |
ANDID**const and_node_orderings= o->t_and_node_orderings; |
| 21934 |
ANDID*ordering= and_node_orderings[or_node_id]; |
| 21935 |
if(ordering)return ordering[0]; |
| 21936 |
} |
| 21937 |
{ |
| 21938 |
OR or_node; |
| 21939 |
/*1319:*/ |
| 21940 |
#line 15994 "./marpa.w" |
| 21941 |
|
| 21942 |
{ |
| 21943 |
if(_MARPA_UNLIKELY(!ORs_of_B(b))) |
| 21944 |
{ |
| 21945 |
MARPA_ERROR(MARPA_ERR_NO_OR_NODES); |
| 21946 |
return failure_indicator; |
| 21947 |
} |
| 21948 |
or_node= OR_of_B_by_ID(b,or_node_id); |
| 21949 |
} |
| 21950 |
|
| 21951 |
/*:1319*/ |
| 21952 |
#line 16148 "./marpa.w" |
| 21953 |
|
| 21954 |
return AND_Count_of_OR(or_node); |
| 21955 |
} |
| 21956 |
} |
| 21957 |
|
| 21958 |
/*:1331*//*1332:*/ |
| 21959 |
#line 16153 "./marpa.w" |
| 21960 |
|
| 21961 |
int _marpa_o_or_node_and_node_id_by_ix(Marpa_Order o, |
| 21962 |
Marpa_Or_Node_ID or_node_id,int ix) |
| 21963 |
{ |
| 21964 |
/*1230:*/ |
| 21965 |
#line 14864 "./marpa.w" |
| 21966 |
const int failure_indicator= -2; |
| 21967 |
|
| 21968 |
/*:1230*/ |
| 21969 |
#line 16157 "./marpa.w" |
| 21970 |
|
| 21971 |
/*985:*/ |
| 21972 |
#line 11573 "./marpa.w" |
| 21973 |
|
| 21974 |
const BOCAGE b= B_of_O(o); |
| 21975 |
/*939:*/ |
| 21976 |
#line 11160 "./marpa.w" |
| 21977 |
|
| 21978 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 21979 |
|
| 21980 |
/*:939*/ |
| 21981 |
#line 11575 "./marpa.w" |
| 21982 |
|
| 21983 |
|
| 21984 |
/*:985*/ |
| 21985 |
#line 16158 "./marpa.w" |
| 21986 |
|
| 21987 |
/*1250:*/ |
| 21988 |
#line 14997 "./marpa.w" |
| 21989 |
|
| 21990 |
if(HEADER_VERSION_MISMATCH){ |
| 21991 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 21992 |
return failure_indicator; |
| 21993 |
} |
| 21994 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 21995 |
MARPA_ERROR(g->t_error); |
| 21996 |
return failure_indicator; |
| 21997 |
} |
| 21998 |
|
| 21999 |
/*:1250*/ |
| 22000 |
#line 16159 "./marpa.w" |
| 22001 |
|
| 22002 |
/*1318:*/ |
| 22003 |
#line 15982 "./marpa.w" |
| 22004 |
|
| 22005 |
{ |
| 22006 |
if(_MARPA_UNLIKELY(or_node_id>=OR_Count_of_B(b))) |
| 22007 |
{ |
| 22008 |
return-1; |
| 22009 |
} |
| 22010 |
if(_MARPA_UNLIKELY(or_node_id<0)) |
| 22011 |
{ |
| 22012 |
MARPA_ERROR(MARPA_ERR_ORID_NEGATIVE); |
| 22013 |
return failure_indicator; |
| 22014 |
} |
| 22015 |
} |
| 22016 |
/*:1318*/ |
| 22017 |
#line 16160 "./marpa.w" |
| 22018 |
|
| 22019 |
if(!O_is_Default(o)) |
| 22020 |
{ |
| 22021 |
ANDID**const and_node_orderings= o->t_and_node_orderings; |
| 22022 |
ANDID*ordering= and_node_orderings[or_node_id]; |
| 22023 |
if(ordering)return ordering[1+ix]; |
| 22024 |
} |
| 22025 |
{ |
| 22026 |
OR or_node; |
| 22027 |
/*1319:*/ |
| 22028 |
#line 15994 "./marpa.w" |
| 22029 |
|
| 22030 |
{ |
| 22031 |
if(_MARPA_UNLIKELY(!ORs_of_B(b))) |
| 22032 |
{ |
| 22033 |
MARPA_ERROR(MARPA_ERR_NO_OR_NODES); |
| 22034 |
return failure_indicator; |
| 22035 |
} |
| 22036 |
or_node= OR_of_B_by_ID(b,or_node_id); |
| 22037 |
} |
| 22038 |
|
| 22039 |
/*:1319*/ |
| 22040 |
#line 16169 "./marpa.w" |
| 22041 |
|
| 22042 |
return First_ANDID_of_OR(or_node)+ix; |
| 22043 |
} |
| 22044 |
} |
| 22045 |
|
| 22046 |
/*:1332*//*1334:*/ |
| 22047 |
#line 16176 "./marpa.w" |
| 22048 |
|
| 22049 |
int _marpa_b_and_node_count(Marpa_Bocage b) |
| 22050 |
{ |
| 22051 |
/*939:*/ |
| 22052 |
#line 11160 "./marpa.w" |
| 22053 |
|
| 22054 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22055 |
|
| 22056 |
/*:939*/ |
| 22057 |
#line 16179 "./marpa.w" |
| 22058 |
|
| 22059 |
/*1230:*/ |
| 22060 |
#line 14864 "./marpa.w" |
| 22061 |
const int failure_indicator= -2; |
| 22062 |
|
| 22063 |
/*:1230*/ |
| 22064 |
#line 16180 "./marpa.w" |
| 22065 |
|
| 22066 |
/*1250:*/ |
| 22067 |
#line 14997 "./marpa.w" |
| 22068 |
|
| 22069 |
if(HEADER_VERSION_MISMATCH){ |
| 22070 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 22071 |
return failure_indicator; |
| 22072 |
} |
| 22073 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 22074 |
MARPA_ERROR(g->t_error); |
| 22075 |
return failure_indicator; |
| 22076 |
} |
| 22077 |
|
| 22078 |
/*:1250*/ |
| 22079 |
#line 16181 "./marpa.w" |
| 22080 |
|
| 22081 |
return AND_Count_of_B(b); |
| 22082 |
} |
| 22083 |
|
| 22084 |
/*:1334*//*1336:*/ |
| 22085 |
#line 16207 "./marpa.w" |
| 22086 |
|
| 22087 |
int _marpa_b_and_node_parent(Marpa_Bocage b, |
| 22088 |
Marpa_And_Node_ID and_node_id) |
| 22089 |
{ |
| 22090 |
AND and_node; |
| 22091 |
/*1230:*/ |
| 22092 |
#line 14864 "./marpa.w" |
| 22093 |
const int failure_indicator= -2; |
| 22094 |
|
| 22095 |
/*:1230*/ |
| 22096 |
#line 16212 "./marpa.w" |
| 22097 |
|
| 22098 |
/*939:*/ |
| 22099 |
#line 11160 "./marpa.w" |
| 22100 |
|
| 22101 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22102 |
|
| 22103 |
/*:939*/ |
| 22104 |
#line 16213 "./marpa.w" |
| 22105 |
|
| 22106 |
/*1335:*/ |
| 22107 |
#line 16185 "./marpa.w" |
| 22108 |
|
| 22109 |
{ |
| 22110 |
if(and_node_id>=AND_Count_of_B(b)) |
| 22111 |
{ |
| 22112 |
return-1; |
| 22113 |
} |
| 22114 |
if(and_node_id<0) |
| 22115 |
{ |
| 22116 |
MARPA_ERROR(MARPA_ERR_ANDID_NEGATIVE); |
| 22117 |
return failure_indicator; |
| 22118 |
} |
| 22119 |
{ |
| 22120 |
AND and_nodes= ANDs_of_B(b); |
| 22121 |
if(!and_nodes) |
| 22122 |
{ |
| 22123 |
MARPA_ERROR(MARPA_ERR_NO_AND_NODES); |
| 22124 |
return failure_indicator; |
| 22125 |
} |
| 22126 |
and_node= and_nodes+and_node_id; |
| 22127 |
} |
| 22128 |
} |
| 22129 |
|
| 22130 |
/*:1335*/ |
| 22131 |
#line 16214 "./marpa.w" |
| 22132 |
|
| 22133 |
return ID_of_OR(OR_of_AND(and_node)); |
| 22134 |
} |
| 22135 |
|
| 22136 |
/*:1336*//*1337:*/ |
| 22137 |
#line 16218 "./marpa.w" |
| 22138 |
|
| 22139 |
int _marpa_b_and_node_predecessor(Marpa_Bocage b, |
| 22140 |
Marpa_And_Node_ID and_node_id) |
| 22141 |
{ |
| 22142 |
AND and_node; |
| 22143 |
/*1230:*/ |
| 22144 |
#line 14864 "./marpa.w" |
| 22145 |
const int failure_indicator= -2; |
| 22146 |
|
| 22147 |
/*:1230*/ |
| 22148 |
#line 16223 "./marpa.w" |
| 22149 |
|
| 22150 |
/*939:*/ |
| 22151 |
#line 11160 "./marpa.w" |
| 22152 |
|
| 22153 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22154 |
|
| 22155 |
/*:939*/ |
| 22156 |
#line 16224 "./marpa.w" |
| 22157 |
|
| 22158 |
/*1335:*/ |
| 22159 |
#line 16185 "./marpa.w" |
| 22160 |
|
| 22161 |
{ |
| 22162 |
if(and_node_id>=AND_Count_of_B(b)) |
| 22163 |
{ |
| 22164 |
return-1; |
| 22165 |
} |
| 22166 |
if(and_node_id<0) |
| 22167 |
{ |
| 22168 |
MARPA_ERROR(MARPA_ERR_ANDID_NEGATIVE); |
| 22169 |
return failure_indicator; |
| 22170 |
} |
| 22171 |
{ |
| 22172 |
AND and_nodes= ANDs_of_B(b); |
| 22173 |
if(!and_nodes) |
| 22174 |
{ |
| 22175 |
MARPA_ERROR(MARPA_ERR_NO_AND_NODES); |
| 22176 |
return failure_indicator; |
| 22177 |
} |
| 22178 |
and_node= and_nodes+and_node_id; |
| 22179 |
} |
| 22180 |
} |
| 22181 |
|
| 22182 |
/*:1335*/ |
| 22183 |
#line 16225 "./marpa.w" |
| 22184 |
|
| 22185 |
{ |
| 22186 |
const OR predecessor_or= Predecessor_OR_of_AND(and_node); |
| 22187 |
const ORID predecessor_or_id= |
| 22188 |
predecessor_or?ID_of_OR(predecessor_or):-1; |
| 22189 |
return predecessor_or_id; |
| 22190 |
} |
| 22191 |
} |
| 22192 |
|
| 22193 |
/*:1337*//*1338:*/ |
| 22194 |
#line 16234 "./marpa.w" |
| 22195 |
|
| 22196 |
int _marpa_b_and_node_cause(Marpa_Bocage b, |
| 22197 |
Marpa_And_Node_ID and_node_id) |
| 22198 |
{ |
| 22199 |
AND and_node; |
| 22200 |
/*1230:*/ |
| 22201 |
#line 14864 "./marpa.w" |
| 22202 |
const int failure_indicator= -2; |
| 22203 |
|
| 22204 |
/*:1230*/ |
| 22205 |
#line 16239 "./marpa.w" |
| 22206 |
|
| 22207 |
/*939:*/ |
| 22208 |
#line 11160 "./marpa.w" |
| 22209 |
|
| 22210 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22211 |
|
| 22212 |
/*:939*/ |
| 22213 |
#line 16240 "./marpa.w" |
| 22214 |
|
| 22215 |
/*1335:*/ |
| 22216 |
#line 16185 "./marpa.w" |
| 22217 |
|
| 22218 |
{ |
| 22219 |
if(and_node_id>=AND_Count_of_B(b)) |
| 22220 |
{ |
| 22221 |
return-1; |
| 22222 |
} |
| 22223 |
if(and_node_id<0) |
| 22224 |
{ |
| 22225 |
MARPA_ERROR(MARPA_ERR_ANDID_NEGATIVE); |
| 22226 |
return failure_indicator; |
| 22227 |
} |
| 22228 |
{ |
| 22229 |
AND and_nodes= ANDs_of_B(b); |
| 22230 |
if(!and_nodes) |
| 22231 |
{ |
| 22232 |
MARPA_ERROR(MARPA_ERR_NO_AND_NODES); |
| 22233 |
return failure_indicator; |
| 22234 |
} |
| 22235 |
and_node= and_nodes+and_node_id; |
| 22236 |
} |
| 22237 |
} |
| 22238 |
|
| 22239 |
/*:1335*/ |
| 22240 |
#line 16241 "./marpa.w" |
| 22241 |
|
| 22242 |
{ |
| 22243 |
const OR cause_or= Cause_OR_of_AND(and_node); |
| 22244 |
const ORID cause_or_id= |
| 22245 |
OR_is_Token(cause_or)?-1:ID_of_OR(cause_or); |
| 22246 |
return cause_or_id; |
| 22247 |
} |
| 22248 |
} |
| 22249 |
|
| 22250 |
/*:1338*//*1339:*/ |
| 22251 |
#line 16250 "./marpa.w" |
| 22252 |
|
| 22253 |
int _marpa_b_and_node_symbol(Marpa_Bocage b, |
| 22254 |
Marpa_And_Node_ID and_node_id) |
| 22255 |
{ |
| 22256 |
AND and_node; |
| 22257 |
/*1230:*/ |
| 22258 |
#line 14864 "./marpa.w" |
| 22259 |
const int failure_indicator= -2; |
| 22260 |
|
| 22261 |
/*:1230*/ |
| 22262 |
#line 16255 "./marpa.w" |
| 22263 |
|
| 22264 |
/*939:*/ |
| 22265 |
#line 11160 "./marpa.w" |
| 22266 |
|
| 22267 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22268 |
|
| 22269 |
/*:939*/ |
| 22270 |
#line 16256 "./marpa.w" |
| 22271 |
|
| 22272 |
/*1335:*/ |
| 22273 |
#line 16185 "./marpa.w" |
| 22274 |
|
| 22275 |
{ |
| 22276 |
if(and_node_id>=AND_Count_of_B(b)) |
| 22277 |
{ |
| 22278 |
return-1; |
| 22279 |
} |
| 22280 |
if(and_node_id<0) |
| 22281 |
{ |
| 22282 |
MARPA_ERROR(MARPA_ERR_ANDID_NEGATIVE); |
| 22283 |
return failure_indicator; |
| 22284 |
} |
| 22285 |
{ |
| 22286 |
AND and_nodes= ANDs_of_B(b); |
| 22287 |
if(!and_nodes) |
| 22288 |
{ |
| 22289 |
MARPA_ERROR(MARPA_ERR_NO_AND_NODES); |
| 22290 |
return failure_indicator; |
| 22291 |
} |
| 22292 |
and_node= and_nodes+and_node_id; |
| 22293 |
} |
| 22294 |
} |
| 22295 |
|
| 22296 |
/*:1335*/ |
| 22297 |
#line 16257 "./marpa.w" |
| 22298 |
|
| 22299 |
{ |
| 22300 |
const OR cause_or= Cause_OR_of_AND(and_node); |
| 22301 |
const XSYID symbol_id= |
| 22302 |
OR_is_Token(cause_or)?NSYID_of_OR(cause_or):-1; |
| 22303 |
return symbol_id; |
| 22304 |
} |
| 22305 |
} |
| 22306 |
|
| 22307 |
/*:1339*//*1340:*/ |
| 22308 |
#line 16266 "./marpa.w" |
| 22309 |
|
| 22310 |
Marpa_Symbol_ID _marpa_b_and_node_token(Marpa_Bocage b, |
| 22311 |
Marpa_And_Node_ID and_node_id,int*value_p) |
| 22312 |
{ |
| 22313 |
AND and_node; |
| 22314 |
OR cause_or; |
| 22315 |
/*1230:*/ |
| 22316 |
#line 14864 "./marpa.w" |
| 22317 |
const int failure_indicator= -2; |
| 22318 |
|
| 22319 |
/*:1230*/ |
| 22320 |
#line 16272 "./marpa.w" |
| 22321 |
|
| 22322 |
/*939:*/ |
| 22323 |
#line 11160 "./marpa.w" |
| 22324 |
|
| 22325 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22326 |
|
| 22327 |
/*:939*/ |
| 22328 |
#line 16273 "./marpa.w" |
| 22329 |
|
| 22330 |
/*1335:*/ |
| 22331 |
#line 16185 "./marpa.w" |
| 22332 |
|
| 22333 |
{ |
| 22334 |
if(and_node_id>=AND_Count_of_B(b)) |
| 22335 |
{ |
| 22336 |
return-1; |
| 22337 |
} |
| 22338 |
if(and_node_id<0) |
| 22339 |
{ |
| 22340 |
MARPA_ERROR(MARPA_ERR_ANDID_NEGATIVE); |
| 22341 |
return failure_indicator; |
| 22342 |
} |
| 22343 |
{ |
| 22344 |
AND and_nodes= ANDs_of_B(b); |
| 22345 |
if(!and_nodes) |
| 22346 |
{ |
| 22347 |
MARPA_ERROR(MARPA_ERR_NO_AND_NODES); |
| 22348 |
return failure_indicator; |
| 22349 |
} |
| 22350 |
and_node= and_nodes+and_node_id; |
| 22351 |
} |
| 22352 |
} |
| 22353 |
|
| 22354 |
/*:1335*/ |
| 22355 |
#line 16274 "./marpa.w" |
| 22356 |
|
| 22357 |
|
| 22358 |
cause_or= Cause_OR_of_AND(and_node); |
| 22359 |
if(!OR_is_Token(cause_or))return-1; |
| 22360 |
if(value_p)*value_p= Value_of_OR(cause_or); |
| 22361 |
return NSYID_of_OR(cause_or); |
| 22362 |
} |
| 22363 |
|
| 22364 |
/*:1340*//*1341:*/ |
| 22365 |
#line 16289 "./marpa.w" |
| 22366 |
|
| 22367 |
Marpa_Earley_Set_ID _marpa_b_and_node_middle(Marpa_Bocage b, |
| 22368 |
Marpa_And_Node_ID and_node_id) |
| 22369 |
{ |
| 22370 |
AND and_node; |
| 22371 |
/*1230:*/ |
| 22372 |
#line 14864 "./marpa.w" |
| 22373 |
const int failure_indicator= -2; |
| 22374 |
|
| 22375 |
/*:1230*/ |
| 22376 |
#line 16294 "./marpa.w" |
| 22377 |
|
| 22378 |
/*939:*/ |
| 22379 |
#line 11160 "./marpa.w" |
| 22380 |
|
| 22381 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22382 |
|
| 22383 |
/*:939*/ |
| 22384 |
#line 16295 "./marpa.w" |
| 22385 |
|
| 22386 |
/*1335:*/ |
| 22387 |
#line 16185 "./marpa.w" |
| 22388 |
|
| 22389 |
{ |
| 22390 |
if(and_node_id>=AND_Count_of_B(b)) |
| 22391 |
{ |
| 22392 |
return-1; |
| 22393 |
} |
| 22394 |
if(and_node_id<0) |
| 22395 |
{ |
| 22396 |
MARPA_ERROR(MARPA_ERR_ANDID_NEGATIVE); |
| 22397 |
return failure_indicator; |
| 22398 |
} |
| 22399 |
{ |
| 22400 |
AND and_nodes= ANDs_of_B(b); |
| 22401 |
if(!and_nodes) |
| 22402 |
{ |
| 22403 |
MARPA_ERROR(MARPA_ERR_NO_AND_NODES); |
| 22404 |
return failure_indicator; |
| 22405 |
} |
| 22406 |
and_node= and_nodes+and_node_id; |
| 22407 |
} |
| 22408 |
} |
| 22409 |
|
| 22410 |
/*:1335*/ |
| 22411 |
#line 16296 "./marpa.w" |
| 22412 |
|
| 22413 |
{ |
| 22414 |
const OR predecessor_or= Predecessor_OR_of_AND(and_node); |
| 22415 |
if(predecessor_or) |
| 22416 |
{ |
| 22417 |
return YS_Ord_of_OR(predecessor_or); |
| 22418 |
} |
| 22419 |
} |
| 22420 |
return Origin_Ord_of_OR(OR_of_AND(and_node)); |
| 22421 |
} |
| 22422 |
|
| 22423 |
/*:1341*//*1344:*/ |
| 22424 |
#line 16329 "./marpa.w" |
| 22425 |
|
| 22426 |
int _marpa_t_nook_or_node(Marpa_Tree t,int nook_id) |
| 22427 |
{ |
| 22428 |
NOOK nook; |
| 22429 |
/*1230:*/ |
| 22430 |
#line 14864 "./marpa.w" |
| 22431 |
const int failure_indicator= -2; |
| 22432 |
|
| 22433 |
/*:1230*/ |
| 22434 |
#line 16333 "./marpa.w" |
| 22435 |
|
| 22436 |
/*1024:*/ |
| 22437 |
#line 12087 "./marpa.w" |
| 22438 |
|
| 22439 |
ORDER o= O_of_T(t); |
| 22440 |
/*985:*/ |
| 22441 |
#line 11573 "./marpa.w" |
| 22442 |
|
| 22443 |
const BOCAGE b= B_of_O(o); |
| 22444 |
/*939:*/ |
| 22445 |
#line 11160 "./marpa.w" |
| 22446 |
|
| 22447 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22448 |
|
| 22449 |
/*:939*/ |
| 22450 |
#line 11575 "./marpa.w" |
| 22451 |
|
| 22452 |
|
| 22453 |
/*:985*/ |
| 22454 |
#line 12089 "./marpa.w" |
| 22455 |
; |
| 22456 |
|
| 22457 |
/*:1024*/ |
| 22458 |
#line 16334 "./marpa.w" |
| 22459 |
|
| 22460 |
/*1343:*/ |
| 22461 |
#line 16311 "./marpa.w" |
| 22462 |
{ |
| 22463 |
NOOK base_nook; |
| 22464 |
/*1250:*/ |
| 22465 |
#line 14997 "./marpa.w" |
| 22466 |
|
| 22467 |
if(HEADER_VERSION_MISMATCH){ |
| 22468 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 22469 |
return failure_indicator; |
| 22470 |
} |
| 22471 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 22472 |
MARPA_ERROR(g->t_error); |
| 22473 |
return failure_indicator; |
| 22474 |
} |
| 22475 |
|
| 22476 |
/*:1250*/ |
| 22477 |
#line 16313 "./marpa.w" |
| 22478 |
|
| 22479 |
if(T_is_Exhausted(t)){ |
| 22480 |
MARPA_ERROR(MARPA_ERR_BOCAGE_ITERATION_EXHAUSTED); |
| 22481 |
return failure_indicator; |
| 22482 |
} |
| 22483 |
if(nook_id<0){ |
| 22484 |
MARPA_ERROR(MARPA_ERR_NOOKID_NEGATIVE); |
| 22485 |
return failure_indicator; |
| 22486 |
} |
| 22487 |
if(nook_id>=Size_of_T(t)){ |
| 22488 |
return-1; |
| 22489 |
} |
| 22490 |
base_nook= MARPA_DSTACK_BASE(t->t_nook_stack,NOOK_Object); |
| 22491 |
nook= base_nook+nook_id; |
| 22492 |
} |
| 22493 |
|
| 22494 |
/*:1343*/ |
| 22495 |
#line 16335 "./marpa.w" |
| 22496 |
|
| 22497 |
return ID_of_OR(OR_of_NOOK(nook)); |
| 22498 |
} |
| 22499 |
|
| 22500 |
/*:1344*//*1345:*/ |
| 22501 |
#line 16339 "./marpa.w" |
| 22502 |
|
| 22503 |
int _marpa_t_nook_choice(Marpa_Tree t,int nook_id) |
| 22504 |
{ |
| 22505 |
NOOK nook; |
| 22506 |
/*1230:*/ |
| 22507 |
#line 14864 "./marpa.w" |
| 22508 |
const int failure_indicator= -2; |
| 22509 |
|
| 22510 |
/*:1230*/ |
| 22511 |
#line 16343 "./marpa.w" |
| 22512 |
|
| 22513 |
/*1024:*/ |
| 22514 |
#line 12087 "./marpa.w" |
| 22515 |
|
| 22516 |
ORDER o= O_of_T(t); |
| 22517 |
/*985:*/ |
| 22518 |
#line 11573 "./marpa.w" |
| 22519 |
|
| 22520 |
const BOCAGE b= B_of_O(o); |
| 22521 |
/*939:*/ |
| 22522 |
#line 11160 "./marpa.w" |
| 22523 |
|
| 22524 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22525 |
|
| 22526 |
/*:939*/ |
| 22527 |
#line 11575 "./marpa.w" |
| 22528 |
|
| 22529 |
|
| 22530 |
/*:985*/ |
| 22531 |
#line 12089 "./marpa.w" |
| 22532 |
; |
| 22533 |
|
| 22534 |
/*:1024*/ |
| 22535 |
#line 16344 "./marpa.w" |
| 22536 |
|
| 22537 |
/*1343:*/ |
| 22538 |
#line 16311 "./marpa.w" |
| 22539 |
{ |
| 22540 |
NOOK base_nook; |
| 22541 |
/*1250:*/ |
| 22542 |
#line 14997 "./marpa.w" |
| 22543 |
|
| 22544 |
if(HEADER_VERSION_MISMATCH){ |
| 22545 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 22546 |
return failure_indicator; |
| 22547 |
} |
| 22548 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 22549 |
MARPA_ERROR(g->t_error); |
| 22550 |
return failure_indicator; |
| 22551 |
} |
| 22552 |
|
| 22553 |
/*:1250*/ |
| 22554 |
#line 16313 "./marpa.w" |
| 22555 |
|
| 22556 |
if(T_is_Exhausted(t)){ |
| 22557 |
MARPA_ERROR(MARPA_ERR_BOCAGE_ITERATION_EXHAUSTED); |
| 22558 |
return failure_indicator; |
| 22559 |
} |
| 22560 |
if(nook_id<0){ |
| 22561 |
MARPA_ERROR(MARPA_ERR_NOOKID_NEGATIVE); |
| 22562 |
return failure_indicator; |
| 22563 |
} |
| 22564 |
if(nook_id>=Size_of_T(t)){ |
| 22565 |
return-1; |
| 22566 |
} |
| 22567 |
base_nook= MARPA_DSTACK_BASE(t->t_nook_stack,NOOK_Object); |
| 22568 |
nook= base_nook+nook_id; |
| 22569 |
} |
| 22570 |
|
| 22571 |
/*:1343*/ |
| 22572 |
#line 16345 "./marpa.w" |
| 22573 |
|
| 22574 |
return Choice_of_NOOK(nook); |
| 22575 |
} |
| 22576 |
|
| 22577 |
/*:1345*//*1346:*/ |
| 22578 |
#line 16349 "./marpa.w" |
| 22579 |
|
| 22580 |
int _marpa_t_nook_parent(Marpa_Tree t,int nook_id) |
| 22581 |
{ |
| 22582 |
NOOK nook; |
| 22583 |
/*1230:*/ |
| 22584 |
#line 14864 "./marpa.w" |
| 22585 |
const int failure_indicator= -2; |
| 22586 |
|
| 22587 |
/*:1230*/ |
| 22588 |
#line 16353 "./marpa.w" |
| 22589 |
|
| 22590 |
/*1024:*/ |
| 22591 |
#line 12087 "./marpa.w" |
| 22592 |
|
| 22593 |
ORDER o= O_of_T(t); |
| 22594 |
/*985:*/ |
| 22595 |
#line 11573 "./marpa.w" |
| 22596 |
|
| 22597 |
const BOCAGE b= B_of_O(o); |
| 22598 |
/*939:*/ |
| 22599 |
#line 11160 "./marpa.w" |
| 22600 |
|
| 22601 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22602 |
|
| 22603 |
/*:939*/ |
| 22604 |
#line 11575 "./marpa.w" |
| 22605 |
|
| 22606 |
|
| 22607 |
/*:985*/ |
| 22608 |
#line 12089 "./marpa.w" |
| 22609 |
; |
| 22610 |
|
| 22611 |
/*:1024*/ |
| 22612 |
#line 16354 "./marpa.w" |
| 22613 |
|
| 22614 |
/*1343:*/ |
| 22615 |
#line 16311 "./marpa.w" |
| 22616 |
{ |
| 22617 |
NOOK base_nook; |
| 22618 |
/*1250:*/ |
| 22619 |
#line 14997 "./marpa.w" |
| 22620 |
|
| 22621 |
if(HEADER_VERSION_MISMATCH){ |
| 22622 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 22623 |
return failure_indicator; |
| 22624 |
} |
| 22625 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 22626 |
MARPA_ERROR(g->t_error); |
| 22627 |
return failure_indicator; |
| 22628 |
} |
| 22629 |
|
| 22630 |
/*:1250*/ |
| 22631 |
#line 16313 "./marpa.w" |
| 22632 |
|
| 22633 |
if(T_is_Exhausted(t)){ |
| 22634 |
MARPA_ERROR(MARPA_ERR_BOCAGE_ITERATION_EXHAUSTED); |
| 22635 |
return failure_indicator; |
| 22636 |
} |
| 22637 |
if(nook_id<0){ |
| 22638 |
MARPA_ERROR(MARPA_ERR_NOOKID_NEGATIVE); |
| 22639 |
return failure_indicator; |
| 22640 |
} |
| 22641 |
if(nook_id>=Size_of_T(t)){ |
| 22642 |
return-1; |
| 22643 |
} |
| 22644 |
base_nook= MARPA_DSTACK_BASE(t->t_nook_stack,NOOK_Object); |
| 22645 |
nook= base_nook+nook_id; |
| 22646 |
} |
| 22647 |
|
| 22648 |
/*:1343*/ |
| 22649 |
#line 16355 "./marpa.w" |
| 22650 |
|
| 22651 |
return Parent_of_NOOK(nook); |
| 22652 |
} |
| 22653 |
|
| 22654 |
/*:1346*//*1347:*/ |
| 22655 |
#line 16359 "./marpa.w" |
| 22656 |
|
| 22657 |
int _marpa_t_nook_cause_is_ready(Marpa_Tree t,int nook_id) |
| 22658 |
{ |
| 22659 |
NOOK nook; |
| 22660 |
/*1230:*/ |
| 22661 |
#line 14864 "./marpa.w" |
| 22662 |
const int failure_indicator= -2; |
| 22663 |
|
| 22664 |
/*:1230*/ |
| 22665 |
#line 16363 "./marpa.w" |
| 22666 |
|
| 22667 |
/*1024:*/ |
| 22668 |
#line 12087 "./marpa.w" |
| 22669 |
|
| 22670 |
ORDER o= O_of_T(t); |
| 22671 |
/*985:*/ |
| 22672 |
#line 11573 "./marpa.w" |
| 22673 |
|
| 22674 |
const BOCAGE b= B_of_O(o); |
| 22675 |
/*939:*/ |
| 22676 |
#line 11160 "./marpa.w" |
| 22677 |
|
| 22678 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22679 |
|
| 22680 |
/*:939*/ |
| 22681 |
#line 11575 "./marpa.w" |
| 22682 |
|
| 22683 |
|
| 22684 |
/*:985*/ |
| 22685 |
#line 12089 "./marpa.w" |
| 22686 |
; |
| 22687 |
|
| 22688 |
/*:1024*/ |
| 22689 |
#line 16364 "./marpa.w" |
| 22690 |
|
| 22691 |
/*1343:*/ |
| 22692 |
#line 16311 "./marpa.w" |
| 22693 |
{ |
| 22694 |
NOOK base_nook; |
| 22695 |
/*1250:*/ |
| 22696 |
#line 14997 "./marpa.w" |
| 22697 |
|
| 22698 |
if(HEADER_VERSION_MISMATCH){ |
| 22699 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 22700 |
return failure_indicator; |
| 22701 |
} |
| 22702 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 22703 |
MARPA_ERROR(g->t_error); |
| 22704 |
return failure_indicator; |
| 22705 |
} |
| 22706 |
|
| 22707 |
/*:1250*/ |
| 22708 |
#line 16313 "./marpa.w" |
| 22709 |
|
| 22710 |
if(T_is_Exhausted(t)){ |
| 22711 |
MARPA_ERROR(MARPA_ERR_BOCAGE_ITERATION_EXHAUSTED); |
| 22712 |
return failure_indicator; |
| 22713 |
} |
| 22714 |
if(nook_id<0){ |
| 22715 |
MARPA_ERROR(MARPA_ERR_NOOKID_NEGATIVE); |
| 22716 |
return failure_indicator; |
| 22717 |
} |
| 22718 |
if(nook_id>=Size_of_T(t)){ |
| 22719 |
return-1; |
| 22720 |
} |
| 22721 |
base_nook= MARPA_DSTACK_BASE(t->t_nook_stack,NOOK_Object); |
| 22722 |
nook= base_nook+nook_id; |
| 22723 |
} |
| 22724 |
|
| 22725 |
/*:1343*/ |
| 22726 |
#line 16365 "./marpa.w" |
| 22727 |
|
| 22728 |
return NOOK_Cause_is_Expanded(nook); |
| 22729 |
} |
| 22730 |
|
| 22731 |
/*:1347*//*1348:*/ |
| 22732 |
#line 16369 "./marpa.w" |
| 22733 |
|
| 22734 |
int _marpa_t_nook_predecessor_is_ready(Marpa_Tree t,int nook_id) |
| 22735 |
{ |
| 22736 |
NOOK nook; |
| 22737 |
/*1230:*/ |
| 22738 |
#line 14864 "./marpa.w" |
| 22739 |
const int failure_indicator= -2; |
| 22740 |
|
| 22741 |
/*:1230*/ |
| 22742 |
#line 16373 "./marpa.w" |
| 22743 |
|
| 22744 |
/*1024:*/ |
| 22745 |
#line 12087 "./marpa.w" |
| 22746 |
|
| 22747 |
ORDER o= O_of_T(t); |
| 22748 |
/*985:*/ |
| 22749 |
#line 11573 "./marpa.w" |
| 22750 |
|
| 22751 |
const BOCAGE b= B_of_O(o); |
| 22752 |
/*939:*/ |
| 22753 |
#line 11160 "./marpa.w" |
| 22754 |
|
| 22755 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22756 |
|
| 22757 |
/*:939*/ |
| 22758 |
#line 11575 "./marpa.w" |
| 22759 |
|
| 22760 |
|
| 22761 |
/*:985*/ |
| 22762 |
#line 12089 "./marpa.w" |
| 22763 |
; |
| 22764 |
|
| 22765 |
/*:1024*/ |
| 22766 |
#line 16374 "./marpa.w" |
| 22767 |
|
| 22768 |
/*1343:*/ |
| 22769 |
#line 16311 "./marpa.w" |
| 22770 |
{ |
| 22771 |
NOOK base_nook; |
| 22772 |
/*1250:*/ |
| 22773 |
#line 14997 "./marpa.w" |
| 22774 |
|
| 22775 |
if(HEADER_VERSION_MISMATCH){ |
| 22776 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 22777 |
return failure_indicator; |
| 22778 |
} |
| 22779 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 22780 |
MARPA_ERROR(g->t_error); |
| 22781 |
return failure_indicator; |
| 22782 |
} |
| 22783 |
|
| 22784 |
/*:1250*/ |
| 22785 |
#line 16313 "./marpa.w" |
| 22786 |
|
| 22787 |
if(T_is_Exhausted(t)){ |
| 22788 |
MARPA_ERROR(MARPA_ERR_BOCAGE_ITERATION_EXHAUSTED); |
| 22789 |
return failure_indicator; |
| 22790 |
} |
| 22791 |
if(nook_id<0){ |
| 22792 |
MARPA_ERROR(MARPA_ERR_NOOKID_NEGATIVE); |
| 22793 |
return failure_indicator; |
| 22794 |
} |
| 22795 |
if(nook_id>=Size_of_T(t)){ |
| 22796 |
return-1; |
| 22797 |
} |
| 22798 |
base_nook= MARPA_DSTACK_BASE(t->t_nook_stack,NOOK_Object); |
| 22799 |
nook= base_nook+nook_id; |
| 22800 |
} |
| 22801 |
|
| 22802 |
/*:1343*/ |
| 22803 |
#line 16375 "./marpa.w" |
| 22804 |
|
| 22805 |
return NOOK_Predecessor_is_Expanded(nook); |
| 22806 |
} |
| 22807 |
|
| 22808 |
/*:1348*//*1349:*/ |
| 22809 |
#line 16379 "./marpa.w" |
| 22810 |
|
| 22811 |
int _marpa_t_nook_is_cause(Marpa_Tree t,int nook_id) |
| 22812 |
{ |
| 22813 |
NOOK nook; |
| 22814 |
/*1230:*/ |
| 22815 |
#line 14864 "./marpa.w" |
| 22816 |
const int failure_indicator= -2; |
| 22817 |
|
| 22818 |
/*:1230*/ |
| 22819 |
#line 16383 "./marpa.w" |
| 22820 |
|
| 22821 |
/*1024:*/ |
| 22822 |
#line 12087 "./marpa.w" |
| 22823 |
|
| 22824 |
ORDER o= O_of_T(t); |
| 22825 |
/*985:*/ |
| 22826 |
#line 11573 "./marpa.w" |
| 22827 |
|
| 22828 |
const BOCAGE b= B_of_O(o); |
| 22829 |
/*939:*/ |
| 22830 |
#line 11160 "./marpa.w" |
| 22831 |
|
| 22832 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22833 |
|
| 22834 |
/*:939*/ |
| 22835 |
#line 11575 "./marpa.w" |
| 22836 |
|
| 22837 |
|
| 22838 |
/*:985*/ |
| 22839 |
#line 12089 "./marpa.w" |
| 22840 |
; |
| 22841 |
|
| 22842 |
/*:1024*/ |
| 22843 |
#line 16384 "./marpa.w" |
| 22844 |
|
| 22845 |
/*1343:*/ |
| 22846 |
#line 16311 "./marpa.w" |
| 22847 |
{ |
| 22848 |
NOOK base_nook; |
| 22849 |
/*1250:*/ |
| 22850 |
#line 14997 "./marpa.w" |
| 22851 |
|
| 22852 |
if(HEADER_VERSION_MISMATCH){ |
| 22853 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 22854 |
return failure_indicator; |
| 22855 |
} |
| 22856 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 22857 |
MARPA_ERROR(g->t_error); |
| 22858 |
return failure_indicator; |
| 22859 |
} |
| 22860 |
|
| 22861 |
/*:1250*/ |
| 22862 |
#line 16313 "./marpa.w" |
| 22863 |
|
| 22864 |
if(T_is_Exhausted(t)){ |
| 22865 |
MARPA_ERROR(MARPA_ERR_BOCAGE_ITERATION_EXHAUSTED); |
| 22866 |
return failure_indicator; |
| 22867 |
} |
| 22868 |
if(nook_id<0){ |
| 22869 |
MARPA_ERROR(MARPA_ERR_NOOKID_NEGATIVE); |
| 22870 |
return failure_indicator; |
| 22871 |
} |
| 22872 |
if(nook_id>=Size_of_T(t)){ |
| 22873 |
return-1; |
| 22874 |
} |
| 22875 |
base_nook= MARPA_DSTACK_BASE(t->t_nook_stack,NOOK_Object); |
| 22876 |
nook= base_nook+nook_id; |
| 22877 |
} |
| 22878 |
|
| 22879 |
/*:1343*/ |
| 22880 |
#line 16385 "./marpa.w" |
| 22881 |
|
| 22882 |
return NOOK_is_Cause(nook); |
| 22883 |
} |
| 22884 |
|
| 22885 |
/*:1349*//*1350:*/ |
| 22886 |
#line 16389 "./marpa.w" |
| 22887 |
|
| 22888 |
int _marpa_t_nook_is_predecessor(Marpa_Tree t,int nook_id) |
| 22889 |
{ |
| 22890 |
NOOK nook; |
| 22891 |
/*1230:*/ |
| 22892 |
#line 14864 "./marpa.w" |
| 22893 |
const int failure_indicator= -2; |
| 22894 |
|
| 22895 |
/*:1230*/ |
| 22896 |
#line 16393 "./marpa.w" |
| 22897 |
|
| 22898 |
/*1024:*/ |
| 22899 |
#line 12087 "./marpa.w" |
| 22900 |
|
| 22901 |
ORDER o= O_of_T(t); |
| 22902 |
/*985:*/ |
| 22903 |
#line 11573 "./marpa.w" |
| 22904 |
|
| 22905 |
const BOCAGE b= B_of_O(o); |
| 22906 |
/*939:*/ |
| 22907 |
#line 11160 "./marpa.w" |
| 22908 |
|
| 22909 |
const GRAMMAR g UNUSED= G_of_B(b); |
| 22910 |
|
| 22911 |
/*:939*/ |
| 22912 |
#line 11575 "./marpa.w" |
| 22913 |
|
| 22914 |
|
| 22915 |
/*:985*/ |
| 22916 |
#line 12089 "./marpa.w" |
| 22917 |
; |
| 22918 |
|
| 22919 |
/*:1024*/ |
| 22920 |
#line 16394 "./marpa.w" |
| 22921 |
|
| 22922 |
/*1343:*/ |
| 22923 |
#line 16311 "./marpa.w" |
| 22924 |
{ |
| 22925 |
NOOK base_nook; |
| 22926 |
/*1250:*/ |
| 22927 |
#line 14997 "./marpa.w" |
| 22928 |
|
| 22929 |
if(HEADER_VERSION_MISMATCH){ |
| 22930 |
MARPA_ERROR(MARPA_ERR_HEADERS_DO_NOT_MATCH); |
| 22931 |
return failure_indicator; |
| 22932 |
} |
| 22933 |
if(_MARPA_UNLIKELY(!IS_G_OK(g))){ |
| 22934 |
MARPA_ERROR(g->t_error); |
| 22935 |
return failure_indicator; |
| 22936 |
} |
| 22937 |
|
| 22938 |
/*:1250*/ |
| 22939 |
#line 16313 "./marpa.w" |
| 22940 |
|
| 22941 |
if(T_is_Exhausted(t)){ |
| 22942 |
MARPA_ERROR(MARPA_ERR_BOCAGE_ITERATION_EXHAUSTED); |
| 22943 |
return failure_indicator; |
| 22944 |
} |
| 22945 |
if(nook_id<0){ |
| 22946 |
MARPA_ERROR(MARPA_ERR_NOOKID_NEGATIVE); |
| 22947 |
return failure_indicator; |
| 22948 |
} |
| 22949 |
if(nook_id>=Size_of_T(t)){ |
| 22950 |
return-1; |
| 22951 |
} |
| 22952 |
base_nook= MARPA_DSTACK_BASE(t->t_nook_stack,NOOK_Object); |
| 22953 |
nook= base_nook+nook_id; |
| 22954 |
} |
| 22955 |
|
| 22956 |
/*:1343*/ |
| 22957 |
#line 16395 "./marpa.w" |
| 22958 |
|
| 22959 |
return NOOK_is_Predecessor(nook); |
| 22960 |
} |
| 22961 |
|
| 22962 |
/*:1350*//*1353:*/ |
| 22963 |
#line 16450 "./marpa.w" |
| 22964 |
|
| 22965 |
PRIVATE int look_yim(Marpa_Earley_Item_Look*look, |
| 22966 |
YS earley_set,Marpa_Earley_Item_ID eim_id) |
| 22967 |
{ |
| 22968 |
int xrl_position; |
| 22969 |
int raw_xrl_position; |
| 22970 |
YIM*earley_items= YIMs_of_YS(earley_set); |
| 22971 |
YIM earley_item= earley_items[eim_id]; |
| 22972 |
AHM ahm= AHM_of_YIM(earley_item); |
| 22973 |
XRL xrl= XRL_of_AHM(ahm); |
| 22974 |
if(xrl){ |
| 22975 |
marpa_eim_look_rule_id(look)= ID_of_XRL(xrl); |
| 22976 |
xrl_position= XRL_Position_of_AHM(ahm); |
| 22977 |
raw_xrl_position= Raw_XRL_Position_of_AHM(ahm); |
| 22978 |
}else{ |
| 22979 |
marpa_eim_look_rule_id(look)= -1; |
| 22980 |
raw_xrl_position= xrl_position= -1; |
| 22981 |
} |
| 22982 |
marpa_eim_look_dot(look)= xrl_position; |
| 22983 |
marpa_eim_look_origin(look)= Origin_Ord_of_YIM(earley_item); |
| 22984 |
marpa_eim_look_irl_id(look)= IRLID_of_AHM(ahm); |
| 22985 |
marpa_eim_look_irl_dot(look)= Position_of_AHM(ahm); |
| 22986 |
return raw_xrl_position; |
| 22987 |
} |
| 22988 |
|
| 22989 |
/*:1353*//*1355:*/ |
| 22990 |
#line 16481 "./marpa.w" |
| 22991 |
|
| 22992 |
int |
| 22993 |
_marpa_r_look_yim(Marpa_Recognizer r,Marpa_Earley_Item_Look*look, |
| 22994 |
Marpa_Earley_Set_ID es_id,Marpa_Earley_Item_ID eim_id) |
| 22995 |
{ |
| 22996 |
const YS earley_set= YS_of_R_by_Ord(r,es_id); |
| 22997 |
return look_yim(look,earley_set,eim_id); |
| 22998 |
} |
| 22999 |
|
| 23000 |
/*:1355*//*1357:*/ |
| 23001 |
#line 16501 "./marpa.w" |
| 23002 |
|
| 23003 |
int |
| 23004 |
_marpa_r_yim_check(Marpa_Recognizer r, |
| 23005 |
Marpa_Earley_Set_ID es_id,Marpa_Earley_Item_ID eim_id) |
| 23006 |
{ |
| 23007 |
YS earley_set; |
| 23008 |
/*560:*/ |
| 23009 |
#line 6100 "./marpa.w" |
| 23010 |
|
| 23011 |
const GRAMMAR g= G_of_R(r); |
| 23012 |
/*:560*/ |
| 23013 |
#line 16507 "./marpa.w" |
| 23014 |
|
| 23015 |
/*1230:*/ |
| 23016 |
#line 14864 "./marpa.w" |
| 23017 |
const int failure_indicator= -2; |
| 23018 |
|
| 23019 |
/*:1230*/ |
| 23020 |
#line 16508 "./marpa.w" |
| 23021 |
|
| 23022 |
|
| 23023 |
if(es_id<0) |
| 23024 |
{ |
| 23025 |
MARPA_ERROR(MARPA_ERR_INVALID_LOCATION); |
| 23026 |
return failure_indicator; |
| 23027 |
} |
| 23028 |
if(eim_id<0) |
| 23029 |
{ |
| 23030 |
MARPA_ERROR(MARPA_ERR_YIM_ID_INVALID); |
| 23031 |
return failure_indicator; |
| 23032 |
} |
| 23033 |
r_update_earley_sets(r); |
| 23034 |
earley_set= YS_of_R_by_Ord(r,es_id); |
| 23035 |
if(es_id>=MARPA_DSTACK_LENGTH(r->t_earley_set_stack)) |
| 23036 |
{ |
| 23037 |
MARPA_ERROR(MARPA_ERR_INVALID_LOCATION); |
| 23038 |
return-1; |
| 23039 |
} |
| 23040 |
if(eim_id>=YIM_Count_of_YS(earley_set)) |
| 23041 |
{ |
| 23042 |
return 0; |
| 23043 |
} |
| 23044 |
return 1; |
| 23045 |
} |
| 23046 |
|
| 23047 |
/*:1357*//*1363:*/ |
| 23048 |
#line 16575 "./marpa.w" |
| 23049 |
|
| 23050 |
int |
| 23051 |
_marpa_r_look_pim_eim_first(Marpa_Recognizer r,Marpa_Postdot_Item_Look*look, |
| 23052 |
Marpa_Earley_Set_ID es_id,Marpa_Symbol_ID nsy_id) |
| 23053 |
{ |
| 23054 |
int earley_item_ix= -1; |
| 23055 |
const YS earley_set= YS_of_R_by_Ord(r,es_id); |
| 23056 |
YIM earley_item= NULL; |
| 23057 |
PIM pim= First_PIM_of_YS_by_NSYID(earley_set,nsy_id); |
| 23058 |
if(!pim)return-1; |
| 23059 |
earley_item= YIM_of_PIM(pim); |
| 23060 |
if(!earley_item)return-1; |
| 23061 |
look->t_pim_look_current= pim; |
| 23062 |
earley_item_ix= Ord_of_YIM(earley_item); |
| 23063 |
marpa_pim_look_eim(look)= earley_item_ix; |
| 23064 |
return earley_item_ix; |
| 23065 |
} |
| 23066 |
|
| 23067 |
/*:1363*//*1365:*/ |
| 23068 |
#line 16612 "./marpa.w" |
| 23069 |
|
| 23070 |
int |
| 23071 |
_marpa_r_look_pim_eim_next(Marpa_Postdot_Item_Look*look) |
| 23072 |
{ |
| 23073 |
int earley_item_ix= -1; |
| 23074 |
YIM earley_item= NULL; |
| 23075 |
PIM pim= Next_PIM_of_PIM(look->t_pim_look_current); |
| 23076 |
if(!pim)return-1; |
| 23077 |
earley_item= YIM_of_PIM(pim); |
| 23078 |
if(!earley_item)return-1; |
| 23079 |
look->t_pim_look_current= pim; |
| 23080 |
earley_item_ix= Ord_of_YIM(earley_item); |
| 23081 |
marpa_pim_look_eim(look)= earley_item_ix; |
| 23082 |
return earley_item_ix; |
| 23083 |
} |
| 23084 |
|
| 23085 |
/*:1365*//*1367:*/ |
| 23086 |
#line 16639 "./marpa.w" |
| 23087 |
|
| 23088 |
void marpa_debug_handler_set(int(*debug_handler)(const char*,...)) |
| 23089 |
{ |
| 23090 |
marpa__debug_handler= debug_handler; |
| 23091 |
} |
| 23092 |
|
| 23093 |
/*:1367*//*1368:*/ |
| 23094 |
#line 16645 "./marpa.w" |
| 23095 |
|
| 23096 |
int marpa_debug_level_set(int new_level) |
| 23097 |
{ |
| 23098 |
const int old_level= marpa__debug_level; |
| 23099 |
marpa__debug_level= new_level; |
| 23100 |
return old_level; |
| 23101 |
} |
| 23102 |
|
| 23103 |
|
| 23104 |
/*:1368*/ |
| 23105 |
#line 16826 "./marpa.w" |
| 23106 |
|
| 23107 |
|
| 23108 |
/*:1386*/ |