//--- END OF USER ZONE 2 //---------------------------------------------------------------------------* // * // L L ( 1 ) P R O D U C T I O N R U L E S * // * //---------------------------------------------------------------------------* #define TERMINAL(t) ((t)+1) #define NONTERMINAL(nt) ((-nt)-1) #define END_PRODUCTION (0) static const PMSInt16 gProductions [] = { // At index 0 : <cfg_start>, in file 'cfg_syntax.ggs', line 38 NONTERMINAL (3) // <select_cfg_5F_syntax_0> , END_PRODUCTION // At index 2 : <cfg_attrs>, in file 'cfg_syntax.ggs', line 104 , NONTERMINAL (4) // <select_cfg_5F_syntax_1> , END_PRODUCTION // At index 4 : <interrupts>, in file 'cfg_syntax.ggs', line 116 , TERMINAL (C_Lexique_cfg_5F_lexique::kToken_interrupts) // $interrupts$ , TERMINAL (C_Lexique_cfg_5F_lexique::kToken__5B_) // $[$ , TERMINAL (C_Lexique_cfg_5F_lexique::kToken_uint) // $uint$ , TERMINAL (C_Lexique_cfg_5F_lexique::kToken__5D_) // $]$ , TERMINAL (C_Lexique_cfg_5F_lexique::kToken__7B_) // ${$ , NONTERMINAL (5) // <select_cfg_5F_syntax_2> , TERMINAL (C_Lexique_cfg_5F_lexique::kToken__7D_) // $}$ , TERMINAL (C_Lexique_cfg_5F_lexique::kToken__3B_) // $;$ , END_PRODUCTION //---- Added productions from 'select' and 'repeat' instructions
void deempty() { /* eliminate references to the empty symol */ /* handles used in list traversals */ PSYMBOL s; PPRODUCTION p; if (emptypt == NULL) { errormsg( "EMPTY SYMBOL MUST BE DEFINED", -1 ); return; /* quit if no analysis possible */ } /* apply initial markings on all symbols */ for (s = symlist; s != NULL; s = s->next) { if (TERMINAL(s)) { /* most terminals are nonempty */ s->state = NONEMPTY; } else { /* nonterminals and rules are empty until proven not */ s->state = ISEMPTY; for (p = s->data; p != NULL; p = p->next) { p->state = ISEMPTY; } } } /* the distinguished empty symbol is the exceptional terminal */ emptypt->state = ISEMPTY; do { /* keep trying until no change is made to the grammar */ change = false; for (s = symlist; s != NULL; s = s->next) if (NONTERMINAL(s)) { /* for each nonterminal symbol s */ checkempty( s ); } } while (change); /* now use the markup to rewrite rules accounting for emptyness */ for (s = symlist; s != NULL; s = s->next) if (NONTERMINAL(s)) { /* for each nonterminal symbol s */ cleanempty( s ); } /* finally, deal with possible empty distinguished symbol */ if (head->state == ISEMPTY) { /* eliminate the distinguished symbol and the empty symbol! */ head = NULL; emptypt = NULL; } else if (head->state == CANBEEMPTY) { /* we eliminated a bit too much, put it back! */ p = NEWPRODUCTION; p->data = NEWELEMENT; p->data->next = NULL; p->data->data = emptypt; p->next = head->data; head->data = p; /* do not eliminate the empty symbol! */ } else /* head->state == NONEMPTY */ { /* eliminate the empty symbol! */ emptypt = NULL; } }