From 8efe435c059af57671105fd8671ba97bb8474264 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 15 Jun 2002 18:21:11 +0000 Subject: [PATCH] * src/parse-gram.y (YYLLOC_DEFAULT, current_lhs_location): New. (input): Don't try to initialize yylloc here, do it in the scanner. * src/scan-gram.l (YY_USER_INIT): Initialize yylloc. * src/gram.h (rule_t): Change line and action_line into location and action_location, of location_t type. Adjust all dependencies. * src/location.h, src/location.c (empty_location): New. * src/reader.h, src/reader.c (grammar_start_symbol_set) (grammar_symbol_append, grammar_rule_begin, grammar_rule_end) (grammar_current_rule_symbol_append) (grammar_current_rule_action_append): Expect a location as argument. * src/reader.c (grammar_midrule_action): Adjust to attach an action's location as dummy symbol location. * src/symtab.h, src/symtab.c (startsymbol_location): New. * tests/regression.at (Web2c Report, Rule Line Numbers): Adjust the line numbers. --- ChangeLog | 21 ++ po/de.po | 26 +-- po/es.po | 26 +-- po/et.po | 26 +-- po/fr.po | 26 +-- po/hr.po | 26 +-- po/it.po | 26 +-- po/ja.po | 26 +-- po/nl.po | 26 +-- po/ru.po | 26 +-- po/sv.po | 26 +-- po/tr.po | 26 +-- src/Makefile.am | 2 +- src/gram.h | 17 +- src/location.c | 24 +++ src/location.h | 2 + src/output.c | 4 +- src/parse-gram.c | 497 ++++++++++++++++++++++---------------------- src/parse-gram.h | 4 +- src/parse-gram.y | 33 ++- src/print.c | 5 +- src/reader.c | 108 +++++----- src/reader.h | 17 +- src/scan-gram.c | 244 +++++++++++----------- src/scan-gram.l | 12 +- src/symtab.c | 1 + src/symtab.h | 3 + tests/regression.at | 8 +- 28 files changed, 692 insertions(+), 596 deletions(-) create mode 100644 src/location.c diff --git a/ChangeLog b/ChangeLog index 4093d540..1285899f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2002-06-15 Akim Demaille + + * src/parse-gram.y (YYLLOC_DEFAULT, current_lhs_location): New. + (input): Don't try to initialize yylloc here, do it in the + scanner. + * src/scan-gram.l (YY_USER_INIT): Initialize yylloc. + * src/gram.h (rule_t): Change line and action_line into location + and action_location, of location_t type. + Adjust all dependencies. + * src/location.h, src/location.c (empty_location): New. + * src/reader.h, src/reader.c (grammar_start_symbol_set) + (grammar_symbol_append, grammar_rule_begin, grammar_rule_end) + (grammar_current_rule_symbol_append) + (grammar_current_rule_action_append): Expect a location as argument. + * src/reader.c (grammar_midrule_action): Adjust to attach an + action's location as dummy symbol location. + * src/symtab.h, src/symtab.c (startsymbol_location): New. + * tests/regression.at (Web2c Report, Rule Line Numbers): Adjust + the line numbers. + + 2002-06-14 Akim Demaille Grammar declarations may be found in the grammar section. diff --git a/po/de.po b/po/de.po index 4e78ff7c..076f9767 100644 --- a/po/de.po +++ b/po/de.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.35\n" -"POT-Creation-Date: 2002-06-11 21:15+0200\n" +"POT-Creation-Date: 2002-06-15 20:06+0200\n" "PO-Revision-Date: 2002-04-26 11:58:57+0200\n" "Last-Translator: Michael Piefel \n" "Language-Team: German \n" @@ -96,12 +96,12 @@ msgid_plural "expected %d shift/reduce conflicts\n" msgstr[0] "erwartete %d Schiebe/Reduziere-Konflikt\n" msgstr[1] "erwartete %d Schiebe/Reduziere-Konflikte\n" -#: src/files.c:159 +#: src/files.c:157 #, c-format msgid "cannot open file `%s'" msgstr "kann Datei »%s« nicht öffnen" -#: src/files.c:178 +#: src/files.c:176 msgid "cannot close file" msgstr "kann Datei nicht schließen" @@ -343,29 +343,29 @@ msgstr "unzulässiger $-Wert" msgid "multiple %s declarations" msgstr "mehr als eine %s-Deklaration" -#: src/reader.c:247 +#: src/reader.c:246 #, c-format msgid "rule given for %s, which is a token" msgstr "Regel für %s vorhanden, welches aber ein Token ist" -#: src/reader.c:271 +#: src/reader.c:270 #, c-format msgid "type clash (`%s' `%s') on default action" msgstr "Typkonflikt (»%s« »%s«) bei Default-Aktion" -#: src/reader.c:278 +#: src/reader.c:277 msgid "empty rule for typed nonterminal, and no action" msgstr "leere Regel für Nicht-Terminal mit Typ und keine Aktion" -#: src/reader.c:343 +#: src/reader.c:342 msgid "two @prec's in a row" msgstr "zwei @prec-Anweisungen nacheinander" -#: src/reader.c:488 +#: src/reader.c:483 msgid "no rules in the input grammar" msgstr "Eingabegrammatik enthält keine Regeln" -#: src/reader.c:520 +#: src/reader.c:515 #, c-format msgid "too many symbols (tokens plus nonterminals); maximum %d" msgstr "zu viele Symbole (Token plus Nicht-Terminale); Maximum %d" @@ -412,22 +412,22 @@ msgstr[1] "%d nutzlose Regeln" msgid "Start symbol %s does not derive any sentence" msgstr "es lassen sich keine Sätze vom Startsymbol %s ableiten" -#: scan-gram.l:508 +#: scan-gram.l:549 #, c-format msgid "$$ of `%s' has no declared type" msgstr "$$ von »%s« hat keinen deklarierten Typ" -#: scan-gram.l:520 scan-gram.l:571 +#: scan-gram.l:561 scan-gram.l:612 #, fuzzy, c-format msgid "invalid value: %s%d" msgstr "unzulässiger @-Wert" -#: scan-gram.l:526 +#: scan-gram.l:567 #, c-format msgid "$%d of `%s' has no declared type" msgstr "$%d von »%s« hat keinen deklarierten Typ" -#: scan-gram.l:539 scan-gram.l:580 +#: scan-gram.l:580 scan-gram.l:621 #, c-format msgid "%s is invalid" msgstr "%s ist unzulässig" diff --git a/po/es.po b/po/es.po index 1abe5905..5b828f00 100644 --- a/po/es.po +++ b/po/es.po @@ -29,7 +29,7 @@ msgid "" msgstr "" "Project-Id-Version: GNU bison 1.35\n" -"POT-Creation-Date: 2002-06-11 21:15+0200\n" +"POT-Creation-Date: 2002-06-15 20:06+0200\n" "PO-Revision-Date: 2002-04-03 10:19+0200\n" "Last-Translator: Nicolás García-Pedrajas \n" "Language-Team: Spanish \n" @@ -156,12 +156,12 @@ msgid_plural "expected %d shift/reduce conflicts\n" msgstr[0] "esperado: %d conflicto desplazamiento/reducción\n" msgstr[1] "esperados: %d conflictos desplazamiento/reducción\n" -#: src/files.c:159 +#: src/files.c:157 #, c-format msgid "cannot open file `%s'" msgstr "no se puede abrir el fichero `%s'" -#: src/files.c:178 +#: src/files.c:176 msgid "cannot close file" msgstr "no se puede cerrar el fichero" @@ -405,29 +405,29 @@ msgstr "valor $ no v msgid "multiple %s declarations" msgstr "múltiples declaraciones de %s" -#: src/reader.c:247 +#: src/reader.c:246 #, c-format msgid "rule given for %s, which is a token" msgstr "se ha dado una regla para %s, que es un terminal" -#: src/reader.c:271 +#: src/reader.c:270 #, c-format msgid "type clash (`%s' `%s') on default action" msgstr "los tipos (`%s' `%s') no concuerdan en la acción por defecto" -#: src/reader.c:278 +#: src/reader.c:277 msgid "empty rule for typed nonterminal, and no action" msgstr "regla vacía para un no terminal con tipo y no hay ninguna acción" -#: src/reader.c:343 +#: src/reader.c:342 msgid "two @prec's in a row" msgstr "dos @prec en una línea" -#: src/reader.c:488 +#: src/reader.c:483 msgid "no rules in the input grammar" msgstr "no hay reglas en la gramática de entrada" -#: src/reader.c:520 +#: src/reader.c:515 #, c-format msgid "too many symbols (tokens plus nonterminals); maximum %d" msgstr "demasiados símbolos (terminales y no terminales); máximo %d" @@ -474,22 +474,22 @@ msgstr[1] "%d reglas sin uso" msgid "Start symbol %s does not derive any sentence" msgstr "El símbolo de inicio (axioma) %s no deriva ninguna sentencia" -#: scan-gram.l:508 +#: scan-gram.l:549 #, c-format msgid "$$ of `%s' has no declared type" msgstr "$$ de `%s' no tiene tipo declarado" -#: scan-gram.l:520 scan-gram.l:571 +#: scan-gram.l:561 scan-gram.l:612 #, fuzzy, c-format msgid "invalid value: %s%d" msgstr "valor @ no válido" -#: scan-gram.l:526 +#: scan-gram.l:567 #, c-format msgid "$%d of `%s' has no declared type" msgstr "$%d de `%s' no tiene tipo declarado" -#: scan-gram.l:539 scan-gram.l:580 +#: scan-gram.l:580 scan-gram.l:621 #, c-format msgid "%s is invalid" msgstr "%s no es válido" diff --git a/po/et.po b/po/et.po index 6efce5d3..12618910 100644 --- a/po/et.po +++ b/po/et.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.33b\n" -"POT-Creation-Date: 2002-06-11 21:15+0200\n" +"POT-Creation-Date: 2002-06-15 20:06+0200\n" "PO-Revision-Date: 2002-03-05 16:27+0200\n" "Last-Translator: Toomas Soome \n" "Language-Team: Estonian \n" @@ -95,12 +95,12 @@ msgid_plural "expected %d shift/reduce conflicts\n" msgstr[0] "eeldasime %d nihutamine/redutseerimine konflikti\n" msgstr[1] "eeldasime %d nihutamine/redutseerimine konflikti\n" -#: src/files.c:159 +#: src/files.c:157 #, c-format msgid "cannot open file `%s'" msgstr "faili `%s' ei saa avada" -#: src/files.c:178 +#: src/files.c:176 msgid "cannot close file" msgstr "faili ei õnnestu sulgeda" @@ -335,29 +335,29 @@ msgstr "vigane $ v msgid "multiple %s declarations" msgstr "korduvad %s deklaratsioonid" -#: src/reader.c:247 +#: src/reader.c:246 #, c-format msgid "rule given for %s, which is a token" msgstr "%s jaoks on antud reegel, aga see on märk" -#: src/reader.c:271 +#: src/reader.c:270 #, c-format msgid "type clash (`%s' `%s') on default action" msgstr "vaikimisi tegevuse tüübikonflikt (`%s' `%s')" -#: src/reader.c:278 +#: src/reader.c:277 msgid "empty rule for typed nonterminal, and no action" msgstr "tüübiga mitteterminalil on tühi reegel ja puudub tegevus" -#: src/reader.c:343 +#: src/reader.c:342 msgid "two @prec's in a row" msgstr "kaks @prec ühel real" -#: src/reader.c:488 +#: src/reader.c:483 msgid "no rules in the input grammar" msgstr "sisendgrammatikas pole reegleid" -#: src/reader.c:520 +#: src/reader.c:515 #, c-format msgid "too many symbols (tokens plus nonterminals); maximum %d" msgstr "liiga palju sümboleid (märgid ja mitteterminalid); maksimaalne on %d" @@ -404,22 +404,22 @@ msgstr[1] "%d kasutamata reeglit" msgid "Start symbol %s does not derive any sentence" msgstr "Stardisümbolist %s ei tuletata ühtegi lauset" -#: scan-gram.l:508 +#: scan-gram.l:549 #, c-format msgid "$$ of `%s' has no declared type" msgstr "`%s' $$ ei oma deklareeritud tüüpi" -#: scan-gram.l:520 scan-gram.l:571 +#: scan-gram.l:561 scan-gram.l:612 #, fuzzy, c-format msgid "invalid value: %s%d" msgstr "vigane @ väärtus" -#: scan-gram.l:526 +#: scan-gram.l:567 #, c-format msgid "$%d of `%s' has no declared type" msgstr "$%d `%s' ei oma deklareeritud tüüpi" -#: scan-gram.l:539 scan-gram.l:580 +#: scan-gram.l:580 scan-gram.l:621 #, c-format msgid "%s is invalid" msgstr "%s on vigane" diff --git a/po/fr.po b/po/fr.po index 36e21cca..39447f66 100644 --- a/po/fr.po +++ b/po/fr.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: GNU bison 1.34a\n" -"POT-Creation-Date: 2002-06-11 21:15+0200\n" +"POT-Creation-Date: 2002-06-15 20:06+0200\n" "PO-Revision-Date: 2002-03-21 15:00-0500\n" "Last-Translator: Michel Robitaille \n" "Language-Team: French \n" @@ -99,12 +99,12 @@ msgid_plural "expected %d shift/reduce conflicts\n" msgstr[0] "attendait %d conflit par décalage/réduction\n" msgstr[1] "attendait %d conflits par décalage/réduction\n" -#: src/files.c:159 +#: src/files.c:157 #, c-format msgid "cannot open file `%s'" msgstr "ne peut ouvrir le fichier « %s »" -#: src/files.c:178 +#: src/files.c:176 msgid "cannot close file" msgstr "ne peut fermer le fichier" @@ -344,29 +344,29 @@ msgstr "la valeur de symbole $ n'est pas valide" msgid "multiple %s declarations" msgstr "multiples déclarations %s" -#: src/reader.c:247 +#: src/reader.c:246 #, c-format msgid "rule given for %s, which is a token" msgstr "la règle pour %s, qui est un terminal" -#: src/reader.c:271 +#: src/reader.c:270 #, c-format msgid "type clash (`%s' `%s') on default action" msgstr "conflit de type (« %s » « %s ») pour l'action par défaut" -#: src/reader.c:278 +#: src/reader.c:277 msgid "empty rule for typed nonterminal, and no action" msgstr "règle vide pour une catégorie typée et aucune action" -#: src/reader.c:343 +#: src/reader.c:342 msgid "two @prec's in a row" msgstr "deux @prec de suite" -#: src/reader.c:488 +#: src/reader.c:483 msgid "no rules in the input grammar" msgstr "la grammaire n'a pas de règles" -#: src/reader.c:520 +#: src/reader.c:515 #, c-format msgid "too many symbols (tokens plus nonterminals); maximum %d" msgstr "trop de symboles (jeton plus non terminaux); maximum %d" @@ -413,22 +413,22 @@ msgstr[1] "%d r msgid "Start symbol %s does not derive any sentence" msgstr "Aucune phrase ne peut être dérivée du symbole de départ %s" -#: scan-gram.l:508 +#: scan-gram.l:549 #, c-format msgid "$$ of `%s' has no declared type" msgstr "$$ de « %s » n'a pas son type déclaré" -#: scan-gram.l:520 scan-gram.l:571 +#: scan-gram.l:561 scan-gram.l:612 #, fuzzy, c-format msgid "invalid value: %s%d" msgstr "valeur @ invalide" -#: scan-gram.l:526 +#: scan-gram.l:567 #, c-format msgid "$%d of `%s' has no declared type" msgstr "$%d de « %s » n'a pas de type déclaré" -#: scan-gram.l:539 scan-gram.l:580 +#: scan-gram.l:580 scan-gram.l:621 #, c-format msgid "%s is invalid" msgstr "%s n'est pas valide" diff --git a/po/hr.po b/po/hr.po index 00fa6e21..9ff9c4be 100644 --- a/po/hr.po +++ b/po/hr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.34a\n" -"POT-Creation-Date: 2002-06-11 21:15+0200\n" +"POT-Creation-Date: 2002-06-15 20:06+0200\n" "PO-Revision-Date: 2002-04-10 22:20+01\n" "Last-Translator: Denis Lackovic \n" "Language-Team: Croatian \n" @@ -97,12 +97,12 @@ msgid_plural "expected %d shift/reduce conflicts\n" msgstr[0] "oèekujem %d pomakni/reduciraj konflikt\n" msgstr[1] "oèekujem %d pomakni/reduciraj konflikata\n" -#: src/files.c:159 +#: src/files.c:157 #, c-format msgid "cannot open file `%s'" msgstr "ne mogu otvoriti datoteku `%s'" -#: src/files.c:178 +#: src/files.c:176 msgid "cannot close file" msgstr "ne mogu zatvoriti datoteku" @@ -338,29 +338,29 @@ msgstr "nedozvoljena $ vrijednost" msgid "multiple %s declarations" msgstr "vi¹estruke %s deklaracije" -#: src/reader.c:247 +#: src/reader.c:246 #, c-format msgid "rule given for %s, which is a token" msgstr "pravilo dato za %s, a to je znak" -#: src/reader.c:271 +#: src/reader.c:270 #, c-format msgid "type clash (`%s' `%s') on default action" msgstr "sudar tipova (`%s' `%s') na deaultnoj akciji" -#: src/reader.c:278 +#: src/reader.c:277 msgid "empty rule for typed nonterminal, and no action" msgstr "prazno pravilo za nezavr¹ni znak, i nema akcije" -#: src/reader.c:343 +#: src/reader.c:342 msgid "two @prec's in a row" msgstr "dva @prec's u retku" -#: src/reader.c:488 +#: src/reader.c:483 msgid "no rules in the input grammar" msgstr "nema pravila u ulaznoj gramatici" -#: src/reader.c:520 +#: src/reader.c:515 #, c-format msgid "too many symbols (tokens plus nonterminals); maximum %d" msgstr "previ¹e simbola (znakovi plus nezavr¹ni znakovi); maksimalno %d" @@ -407,22 +407,22 @@ msgstr[1] "%d beskorisnih pravila" msgid "Start symbol %s does not derive any sentence" msgstr "Poèetni simbol %s ne daje niti jednu reèenicu" -#: scan-gram.l:508 +#: scan-gram.l:549 #, c-format msgid "$$ of `%s' has no declared type" msgstr "$$ od `%s' nema deklarirani tip" -#: scan-gram.l:520 scan-gram.l:571 +#: scan-gram.l:561 scan-gram.l:612 #, fuzzy, c-format msgid "invalid value: %s%d" msgstr "nedozvoljena @ vrijednost" -#: scan-gram.l:526 +#: scan-gram.l:567 #, c-format msgid "$%d of `%s' has no declared type" msgstr "$%d od `%s' nema deklarirani tip" -#: scan-gram.l:539 scan-gram.l:580 +#: scan-gram.l:580 scan-gram.l:621 #, c-format msgid "%s is invalid" msgstr "%s je nedozvoljeno" diff --git a/po/it.po b/po/it.po index 52f44fde..44e3600d 100644 --- a/po/it.po +++ b/po/it.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.31\n" -"POT-Creation-Date: 2002-06-11 21:15+0200\n" +"POT-Creation-Date: 2002-06-15 20:06+0200\n" "PO-Revision-Date: 2002-01-18 12:40 CET\n" "Last-Translator: Paolo Bonzini \n" "Language-Team: Italian \n" @@ -98,12 +98,12 @@ msgid_plural "expected %d shift/reduce conflicts\n" msgstr[0] "atteso %d conflitto shift/riduzione\n" msgstr[1] "attesi %d conflitti shift/riduzione\n" -#: src/files.c:159 +#: src/files.c:157 #, c-format msgid "cannot open file `%s'" msgstr "impossibile aprire il file `%s'" -#: src/files.c:178 +#: src/files.c:176 msgid "cannot close file" msgstr "impossibile chiudere il file `%s'" @@ -338,29 +338,29 @@ msgstr "valore $ non valido" msgid "multiple %s declarations" msgstr "dichiarazioni multiple per %s" -#: src/reader.c:247 +#: src/reader.c:246 #, c-format msgid "rule given for %s, which is a token" msgstr "fornita una regola per il token %s" -#: src/reader.c:271 +#: src/reader.c:270 #, c-format msgid "type clash (`%s' `%s') on default action" msgstr "conflitto di tipo (`%s' e `%s') nell'azione di default" -#: src/reader.c:278 +#: src/reader.c:277 msgid "empty rule for typed nonterminal, and no action" msgstr "regola vuota e nessuna azione per un nonterminale con tipo" -#: src/reader.c:343 +#: src/reader.c:342 msgid "two @prec's in a row" msgstr "due @prec di seguito" -#: src/reader.c:488 +#: src/reader.c:483 msgid "no rules in the input grammar" msgstr "nessuna regola nella grammatica di input" -#: src/reader.c:520 +#: src/reader.c:515 #, c-format msgid "too many symbols (tokens plus nonterminals); maximum %d" msgstr "troppi simboli (token e nonterminali); il massimo è %d" @@ -407,22 +407,22 @@ msgstr[1] "%d regole inutili" msgid "Start symbol %s does not derive any sentence" msgstr "dal simbolo iniziale %s non deriva alcuna frase" -#: scan-gram.l:508 +#: scan-gram.l:549 #, c-format msgid "$$ of `%s' has no declared type" msgstr "Manca una dichiarazione di tipo per $$ di `%s'" -#: scan-gram.l:520 scan-gram.l:571 +#: scan-gram.l:561 scan-gram.l:612 #, c-format msgid "invalid value: %s%d" msgstr "valore non valido: %s%d" -#: scan-gram.l:526 +#: scan-gram.l:567 #, c-format msgid "$%d of `%s' has no declared type" msgstr "Manca una dichiarazione di tipo per $%d di `%s'" -#: scan-gram.l:539 scan-gram.l:580 +#: scan-gram.l:580 scan-gram.l:621 #, c-format msgid "%s is invalid" msgstr "%s non è valido" diff --git a/po/ja.po b/po/ja.po index 8394181d..01d4e2e1 100644 --- a/po/ja.po +++ b/po/ja.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: GNU bison 1.30f\n" -"POT-Creation-Date: 2002-06-11 21:15+0200\n" +"POT-Creation-Date: 2002-06-15 20:06+0200\n" "PO-Revision-Date: 2001-12-10 15:59+0900\n" "Last-Translator: Daisuke Yamashita \n" "Language-Team: Japanese \n" @@ -92,12 +92,12 @@ msgid "expected %d shift/reduce conflict\n" msgid_plural "expected %d shift/reduce conflicts\n" msgstr[0] "ËÜÍè %d ¸Ä¤Î¥·¥Õ¥È/´Ô¸µ¾×ÆͤǤ¢¤ë¤Ï¤º¤Ç¤¹\n" -#: src/files.c:159 +#: src/files.c:157 #, c-format msgid "cannot open file `%s'" msgstr "¥Õ¥¡¥¤¥ë `%s' ¤ò³«¤±¤Þ¤»¤ó" -#: src/files.c:178 +#: src/files.c:176 msgid "cannot close file" msgstr "¥Õ¥¡¥¤¥ë¤òÊĤ¸¤ë¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó" @@ -334,29 +334,29 @@ msgstr " msgid "multiple %s declarations" msgstr "%s ¤¬Ê£¿ô¸ÄÀë¸À¤µ¤ì¤Þ¤·¤¿" -#: src/reader.c:247 +#: src/reader.c:246 #, c-format msgid "rule given for %s, which is a token" msgstr "%s ¤Ëµ¬Â§¤¬Í¿¤¨¤é¤ì¡¢¤½¤ì¤Ï¥È¡¼¥¯¥ó¤È¤Ê¤ê¤Þ¤¹" -#: src/reader.c:271 +#: src/reader.c:270 #, c-format msgid "type clash (`%s' `%s') on default action" msgstr "½é´ü¾õÂÖ¤ÎÆ°ºî¤Ç¤Ï·¿ (`%s' `%s') ¤¬¾×Æͤ·¤Þ¤¹" -#: src/reader.c:278 +#: src/reader.c:277 msgid "empty rule for typed nonterminal, and no action" msgstr "¶õ¤Î·¿ÉÕ¤­Èó½ªÃ¼¥¢¥¤¥Æ¥àÍѵ¬Â§¤Ç¤¢¤ê¡¢Æ°ºî¤¬µ¯¤ê¤Þ¤»¤ó" -#: src/reader.c:343 +#: src/reader.c:342 msgid "two @prec's in a row" msgstr "@prec ¤Î¤â¤ÎÆó¤Ä¤¬Æ±Îó¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹" -#: src/reader.c:488 +#: src/reader.c:483 msgid "no rules in the input grammar" msgstr "ÆþÎϤ·¤¿Ê¸Ë¡¤Ëµ¬Â§¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó" -#: src/reader.c:520 +#: src/reader.c:515 #, c-format msgid "too many symbols (tokens plus nonterminals); maximum %d" msgstr "¥·¥ó¥Ü¥ë¤¬Â¿¤¹¤®¤Þ¤¹ (¥È¡¼¥¯¥ó + Èó½ªÃ¼¥¢¥¤¥Æ¥à) -- ºÇÂç %d" @@ -400,22 +400,22 @@ msgstr[0] "%d msgid "Start symbol %s does not derive any sentence" msgstr "³«»Ï¥·¥ó¥Ü¥ë %s ¤Ï¤É¤Îʸ¤Ë¤âͳÍ褷¤Þ¤»¤ó" -#: scan-gram.l:508 +#: scan-gram.l:549 #, c-format msgid "$$ of `%s' has no declared type" msgstr "`%s' ¤Î $$ ¤ËÀë¸À¤Î¤Ê¤¤·¿¤¬¤¢¤ê¤Þ¤¹" -#: scan-gram.l:520 scan-gram.l:571 +#: scan-gram.l:561 scan-gram.l:612 #, fuzzy, c-format msgid "invalid value: %s%d" msgstr "ÉÔŬÀÚ¤Ê $ ¤ÎÃÍ" -#: scan-gram.l:526 +#: scan-gram.l:567 #, c-format msgid "$%d of `%s' has no declared type" msgstr "$%d ¸Ä¤Î `%s' ¤¬Àë¸À¤µ¤ì¤¿·¿¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó" -#: scan-gram.l:539 scan-gram.l:580 +#: scan-gram.l:580 scan-gram.l:621 #, c-format msgid "%s is invalid" msgstr "%s ¤ÏÉÔŬÀڤǤ¹" diff --git a/po/nl.po b/po/nl.po index aca83170..1b1d8f60 100644 --- a/po/nl.po +++ b/po/nl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.34a\n" -"POT-Creation-Date: 2002-06-11 21:15+0200\n" +"POT-Creation-Date: 2002-06-15 20:06+0200\n" "PO-Revision-Date: 2002-03-20 12:54+0100\n" "Last-Translator: Tim Van Holder \n" "Language-Team: Dutch \n" @@ -99,12 +99,12 @@ msgid_plural "expected %d shift/reduce conflicts\n" msgstr[0] "%d shift/reductie conflict werd verwacht\n" msgstr[1] "%d shift/reductie conflicten werden verwacht\n" -#: src/files.c:159 +#: src/files.c:157 #, c-format msgid "cannot open file `%s'" msgstr "kan bestand `%s' niet openen" -#: src/files.c:178 +#: src/files.c:176 msgid "cannot close file" msgstr "kan bestand niet sluiten" @@ -350,29 +350,29 @@ msgstr "ongeldige $-waarde" msgid "multiple %s declarations" msgstr "meerdere %s declaraties" -#: src/reader.c:247 +#: src/reader.c:246 #, c-format msgid "rule given for %s, which is a token" msgstr "regel opgegeven voor token (%s)" -#: src/reader.c:271 +#: src/reader.c:270 #, c-format msgid "type clash (`%s' `%s') on default action" msgstr "type-conflict (`%s' `%s') bij standaardaktie" -#: src/reader.c:278 +#: src/reader.c:277 msgid "empty rule for typed nonterminal, and no action" msgstr "lege regel voor niet-eindsymbool met type, en geen actie" -#: src/reader.c:343 +#: src/reader.c:342 msgid "two @prec's in a row" msgstr "twee @prec's na elkaar" -#: src/reader.c:488 +#: src/reader.c:483 msgid "no rules in the input grammar" msgstr "invoergrammatica bevat geen regels" -#: src/reader.c:520 +#: src/reader.c:515 #, c-format msgid "too many symbols (tokens plus nonterminals); maximum %d" msgstr "teveel symbolen (tokens plus niet-eindsymbolen); het maximum is %d" @@ -420,22 +420,22 @@ msgstr[1] "%d nutteloze regels" msgid "Start symbol %s does not derive any sentence" msgstr "Startsymbool %s wordt vanuit geen enkele zin bereikt" -#: scan-gram.l:508 +#: scan-gram.l:549 #, c-format msgid "$$ of `%s' has no declared type" msgstr "$$ van `%s' heeft geen gedeclareerd type" -#: scan-gram.l:520 scan-gram.l:571 +#: scan-gram.l:561 scan-gram.l:612 #, fuzzy, c-format msgid "invalid value: %s%d" msgstr "ongeldige @-waarde" -#: scan-gram.l:526 +#: scan-gram.l:567 #, c-format msgid "$%d of `%s' has no declared type" msgstr "$%d van `%s' heeft geen gedeclareerd type" -#: scan-gram.l:539 scan-gram.l:580 +#: scan-gram.l:580 scan-gram.l:621 #, c-format msgid "%s is invalid" msgstr "%s is ongeldig" diff --git a/po/ru.po b/po/ru.po index ffd4690c..772f7dab 100644 --- a/po/ru.po +++ b/po/ru.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.32\n" -"POT-Creation-Date: 2002-06-11 21:15+0200\n" +"POT-Creation-Date: 2002-06-15 20:06+0200\n" "PO-Revision-Date: 2002-01-25 12:19+0300\n" "Last-Translator: Dmitry S. Sivachenko \n" "Language-Team: Russian \n" @@ -102,12 +102,12 @@ msgstr[0] " msgstr[1] "ÏÖÉÄÁÌÏÓØ %d ËÏÎÆÌÉËÔÁ ÓÄ×ÉÇÁ/×Ù×ÏÄÁ\n" msgstr[2] "ÏÖÉÄÁÌÏÓØ %d ËÏÎÆÌÉËÔÏ× ÓÄ×ÉÇÁ/×Ù×ÏÄÁ\n" -#: src/files.c:159 +#: src/files.c:157 #, c-format msgid "cannot open file `%s'" msgstr "ÎÅ ÕÄÁÅÔÓÑ ÏÔËÒÙÔØ ÆÁÊÌ `%s'" -#: src/files.c:178 +#: src/files.c:176 msgid "cannot close file" msgstr "ÎÅ ÕÄÁÅÔÓÑ ÚÁËÒÙÔØ ÆÁÊÌ" @@ -347,30 +347,30 @@ msgstr " msgid "multiple %s declarations" msgstr "ÍÎÏÖÅÓÔ×ÅÎÎÏÅ ÏÐÉÓÁÎÉÅ %s" -#: src/reader.c:247 +#: src/reader.c:246 #, c-format msgid "rule given for %s, which is a token" msgstr "ÐÒÁ×ÉÌÏ ÚÁÄÁÎÏ ÄÌÑ %s, ËÏÔÏÒÙÊ Ñ×ÌÑÅÔÓÑ ÌÅËÓÅÍÏÊ" -#: src/reader.c:271 +#: src/reader.c:270 #, c-format msgid "type clash (`%s' `%s') on default action" msgstr "ËÏÎÆÌÉËÔ ÔÉÐÏ× (`%s' `%s') ÎÁ ÄÅÊÓÔ×ÉÉ ÐÏ ÕÍÏÌÞÁÎÉÀ" -#: src/reader.c:278 +#: src/reader.c:277 msgid "empty rule for typed nonterminal, and no action" msgstr "" "ÐÕÓÔÏÅ ÐÒÁ×ÉÌÏ ÄÌÑ ÔÉÐÉÚÉÒÏ×ÁÎÎÏÇÏ ÎÅÔÅÒÍÉÎÁÌØÎÏÇÏ ÓÉÍ×ÏÌÁ, É ÎÅÔ ÄÅÊÓÔ×ÉÑ" -#: src/reader.c:343 +#: src/reader.c:342 msgid "two @prec's in a row" msgstr "Ä×Á @prec ÐÏÄÒÑÄ" -#: src/reader.c:488 +#: src/reader.c:483 msgid "no rules in the input grammar" msgstr "ÏÔÓÕÔÓÔ×ÕÀÔ ÐÒÁ×ÉÌÁ ×Ï ×ÈÏÄÎÏÊ ÇÒÁÍÍÁÔÉËÅ" -#: src/reader.c:520 +#: src/reader.c:515 #, c-format msgid "too many symbols (tokens plus nonterminals); maximum %d" msgstr "ÓÌÉÛËÏÍ ÍÎÏÇÏ ÓÉÍ×ÏÌÏ× (ÌÅËÓÅÍÙ ÐÌÀÓ ÎÅÔÅÒÍÉÎÁÌÙ); ÍÁËÓÉÍÁÌØÎÏ %d" @@ -420,22 +420,22 @@ msgstr[2] "%d msgid "Start symbol %s does not derive any sentence" msgstr "îÁÞÁÌØÎÙÊ ÓÉÍ×ÏÌ %s ÎÅ ×Ù×ÏÄÉÔ ÎÉ ÏÄÎÏÇÏ ÐÒÅÄÌÏÖÅÎÉÑ" -#: scan-gram.l:508 +#: scan-gram.l:549 #, c-format msgid "$$ of `%s' has no declared type" msgstr "$$ × `%s' ÎÅ ÉÍÅÅÔ ÏÐÉÓÁÎÎÏÇÏ ÔÉÐÁ" -#: scan-gram.l:520 scan-gram.l:571 +#: scan-gram.l:561 scan-gram.l:612 #, fuzzy, c-format msgid "invalid value: %s%d" msgstr "ÎÅ×ÅÒÎÏÅ $ ÚÎÁÞÅÎÉÅ" -#: scan-gram.l:526 +#: scan-gram.l:567 #, c-format msgid "$%d of `%s' has no declared type" msgstr "$%d ÉÚ `%s' ÎÅ ÉÍÅÅÔ ÏÐÉÓÁÎÎÏÇÏ ÔÉÐÁ" -#: scan-gram.l:539 scan-gram.l:580 +#: scan-gram.l:580 scan-gram.l:621 #, c-format msgid "%s is invalid" msgstr "ÎÅ×ÅÒÎÙÊ ÚÎÁË %s" diff --git a/po/sv.po b/po/sv.po index acb64e0a..2092c315 100644 --- a/po/sv.po +++ b/po/sv.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.33b\n" -"POT-Creation-Date: 2002-06-11 21:15+0200\n" +"POT-Creation-Date: 2002-06-15 20:06+0200\n" "PO-Revision-Date: 2002-03-05 10:18+0100\n" "Last-Translator: Göran Uddeborg \n" "Language-Team: Swedish \n" @@ -98,12 +98,12 @@ msgid_plural "expected %d shift/reduce conflicts\n" msgstr[0] "förväntade %d skifta/reducerakonflikt\n" msgstr[1] "förväntade %d skifta/reducerakonflikter\n" -#: src/files.c:159 +#: src/files.c:157 #, c-format msgid "cannot open file `%s'" msgstr "kan inte öppna filen \"%s\"" -#: src/files.c:178 +#: src/files.c:176 msgid "cannot close file" msgstr "kan inte stänga fil" @@ -342,29 +342,29 @@ msgstr "felaktigt $-v msgid "multiple %s declarations" msgstr "flera %s-deklarationer" -#: src/reader.c:247 +#: src/reader.c:246 #, c-format msgid "rule given for %s, which is a token" msgstr "regel given för %s, som är ett element" -#: src/reader.c:271 +#: src/reader.c:270 #, c-format msgid "type clash (`%s' `%s') on default action" msgstr "typkonflikt (\"%s\" \"%s\") för standardåtgärd" -#: src/reader.c:278 +#: src/reader.c:277 msgid "empty rule for typed nonterminal, and no action" msgstr "tom regel för typad icketerminal, och ingen åtgärd" -#: src/reader.c:343 +#: src/reader.c:342 msgid "two @prec's in a row" msgstr "två @prec i rad" -#: src/reader.c:488 +#: src/reader.c:483 msgid "no rules in the input grammar" msgstr "inga regler i ingrammatiken" -#: src/reader.c:520 +#: src/reader.c:515 #, c-format msgid "too many symbols (tokens plus nonterminals); maximum %d" msgstr "för många symboler (element plus icketerminaler); max %d" @@ -411,22 +411,22 @@ msgstr[1] "%d oanv msgid "Start symbol %s does not derive any sentence" msgstr "Startsymbolen %s genererar inga meningar" -#: scan-gram.l:508 +#: scan-gram.l:549 #, c-format msgid "$$ of `%s' has no declared type" msgstr "$$ för \"%s\" har ingen deklarerad typ" -#: scan-gram.l:520 scan-gram.l:571 +#: scan-gram.l:561 scan-gram.l:612 #, fuzzy, c-format msgid "invalid value: %s%d" msgstr "felaktigt @-värde" -#: scan-gram.l:526 +#: scan-gram.l:567 #, c-format msgid "$%d of `%s' has no declared type" msgstr "$%d för \"%s\" har ingen deklarerad typ" -#: scan-gram.l:539 scan-gram.l:580 +#: scan-gram.l:580 scan-gram.l:621 #, c-format msgid "%s is invalid" msgstr "%s är felaktigt" diff --git a/po/tr.po b/po/tr.po index a01c8b28..64ac4558 100644 --- a/po/tr.po +++ b/po/tr.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: bison 1.34\n" -"POT-Creation-Date: 2002-06-11 21:15+0200\n" +"POT-Creation-Date: 2002-06-15 20:06+0200\n" "PO-Revision-Date: 2002-03-14 11:03GMT +02:00\n" "Last-Translator: Altuð Bayram \n" "Language-Team: Turkish \n" @@ -102,12 +102,12 @@ msgid_plural "expected %d shift/reduce conflicts\n" msgstr[0] "beklenen %d öteleme/indirgeme çeliþkisi\n" msgstr[1] "beklenen %d öteleme/indirgeme çeliþkisi\n" -#: src/files.c:159 +#: src/files.c:157 #, c-format msgid "cannot open file `%s'" msgstr "`%s' dosyasý açýlamadý" -#: src/files.c:178 +#: src/files.c:176 msgid "cannot close file" msgstr "dosya kapatýlamýyor" @@ -347,30 +347,30 @@ msgstr "ge msgid "multiple %s declarations" msgstr "çoklu %s bildirimleri" -#: src/reader.c:247 +#: src/reader.c:246 #, c-format msgid "rule given for %s, which is a token" msgstr "bir andaç olan %s için verilen kural" -#: src/reader.c:271 +#: src/reader.c:270 #, c-format msgid "type clash (`%s' `%s') on default action" msgstr "öntanýmlý eylem üzerinde (`%s' `%s') tip çatýþmasý" -#: src/reader.c:278 +#: src/reader.c:277 msgid "empty rule for typed nonterminal, and no action" msgstr "" "Tipli deðiþken simge için boþ kural tanýmlanmýþ, ve eylem belirtilmemiþ" -#: src/reader.c:343 +#: src/reader.c:342 msgid "two @prec's in a row" msgstr "bir satýrda iki @prec" -#: src/reader.c:488 +#: src/reader.c:483 msgid "no rules in the input grammar" msgstr "girdi grameri içinde kurallar yok" -#: src/reader.c:520 +#: src/reader.c:515 #, c-format msgid "too many symbols (tokens plus nonterminals); maximum %d" msgstr "çok fazla simge var (andaçlar ve deðiþken simgeler); en fazla %d" @@ -417,22 +417,22 @@ msgstr[1] "%d yarars msgid "Start symbol %s does not derive any sentence" msgstr "Baþlangýç simgesi %s herhangi bir cümleden türemez" -#: scan-gram.l:508 +#: scan-gram.l:549 #, c-format msgid "$$ of `%s' has no declared type" msgstr "`%s''in $$'ý bildirilmiþ tip deðil" -#: scan-gram.l:520 scan-gram.l:571 +#: scan-gram.l:561 scan-gram.l:612 #, fuzzy, c-format msgid "invalid value: %s%d" msgstr "geçersiz @ deðeri" -#: scan-gram.l:526 +#: scan-gram.l:567 #, c-format msgid "$%d of `%s' has no declared type" msgstr "`%2$s''in %1$d'i bildirilmiþ tip deðil" -#: scan-gram.l:539 scan-gram.l:580 +#: scan-gram.l:580 scan-gram.l:621 #, c-format msgid "%s is invalid" msgstr "%s geçersizdir" diff --git a/src/Makefile.am b/src/Makefile.am index 1062e9b0..48158153 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -45,7 +45,7 @@ bison_SOURCES = \ getargs.c getargs.h \ gram.c gram.h \ lalr.h lalr.c \ - location.h \ + location.c location.h \ main.c \ muscle_tab.c muscle_tab.h \ nullable.c nullable.h \ diff --git a/src/gram.h b/src/gram.h index a5079e37..ff43ab8f 100644 --- a/src/gram.h +++ b/src/gram.h @@ -97,17 +97,18 @@ Associativities are recorded similarly in SYMBOLS[I]->assoc. */ -#include "symtab.h" +# include "location.h" +# include "symtab.h" -#define ISTOKEN(s) ((s) < ntokens) -#define ISVAR(s) ((s) >= ntokens) +# define ISTOKEN(s) ((s) < ntokens) +# define ISVAR(s) ((s) >= ntokens) extern int nrules; extern int nsyms; extern int ntokens; extern int nvars; -#define ITEM_NUMBER_MAX INT_MAX +# define ITEM_NUMBER_MAX INT_MAX typedef int item_number_t; extern item_number_t *ritem; extern unsigned int nritems; @@ -118,8 +119,8 @@ extern unsigned int nritems; Therefore, an symbol_number_t must be a valid item_number_t, and we sometimes have to perform the converse transformation. */ -#define symbol_number_as_item_number(Tok) ((item_number_t) (Tok)) -#define item_number_as_symbol_number(Ite) ((symbol_number_t) (Ite)) +# define symbol_number_as_item_number(Tok) ((item_number_t) (Tok)) +# define item_number_as_symbol_number(Ite) ((symbol_number_t) (Ite)) extern symbol_number_t start_symbol; @@ -143,11 +144,11 @@ typedef struct rule_s /* This symbol was attached to the rule via %prec. */ symbol_t *precsym; - int line; + location_t location; bool useful; const char *action; - int action_line; + location_t action_location; } rule_t; extern struct rule_s *rules; diff --git a/src/location.c b/src/location.c new file mode 100644 index 00000000..dd32e5c1 --- /dev/null +++ b/src/location.c @@ -0,0 +1,24 @@ +/* Locations for Bison + Copyright (C) 2002 Free Software Foundation, Inc. + + This file is part of Bison, the GNU Compiler Compiler. + + Bison is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + Bison is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bison; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +#include "location.h" + +location_t empty_location = { 0, 0, 0, 0 }; diff --git a/src/location.h b/src/location.h index 0c5ef686..8894eea8 100644 --- a/src/location.h +++ b/src/location.h @@ -62,4 +62,6 @@ typedef struct location_s else \ fprintf (Out, "%d.%d", (Loc).first_line, (Loc).first_column) + +extern location_t empty_location; #endif /* !LOCATION_H_ */ diff --git a/src/output.c b/src/output.c index e630b150..832f4ed9 100644 --- a/src/output.c +++ b/src/output.c @@ -307,7 +307,7 @@ prepare_rules (void) /* Separator in RHS. */ rhs[i++] = -1; /* Line where rule was defined. */ - rline[r] = rules[r].line; + rline[r] = rules[r].location.first_line; } assert (i == nritems); @@ -544,7 +544,7 @@ actions_output (FILE *out) if (!no_lines_flag) fprintf (out, muscle_find ("linef"), - rules[rule].action_line, + rules[rule].action_location.first_line, quotearg_style (c_quoting_style, muscle_find ("filename"))); fprintf (out, " %s\n break;\n\n", diff --git a/src/parse-gram.c b/src/parse-gram.c index 76a29d40..a4bb0bcf 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -74,6 +74,20 @@ /* Produce verbose parse errors. */ #define YYERROR_VERBOSE 1 +#define YYLLOC_DEFAULT(Current, Rhs, N) \ +do { \ + if (N) \ + { \ + Current.first_column = Rhs[1].first_column; \ + Current.first_line = Rhs[1].first_line; \ + Current.last_column = Rhs[N].last_column; \ + Current.last_line = Rhs[N].last_line; \ + } \ + else \ + { \ + Current = Rhs[0]; \ + } \ +} while (0) /* Pass the control structure to YYPARSE and YYLEX. */ #define YYPARSE_PARAM gram_control @@ -98,6 +112,7 @@ static void yyprint (FILE *file, const location_t *loc, symbol_class current_class = unknown_sym; char *current_type = 0; symbol_t *current_lhs; +location_t current_lhs_location; associativity current_assoc; int current_prec = 0; @@ -207,15 +222,15 @@ int current_prec = 0; #endif #ifndef YYSTYPE -#line 74 "parse-gram.y" +#line 89 "parse-gram.y" typedef union { symbol_t *symbol; int integer; char *string; associativity assoc; } yystype; -/* Line 199 of /home/akim/src/bison/data/bison.simple. */ -#line 219 "parse-gram.c" +/* Line 199 of /usr/local/share/bison/bison.simple. */ +#line 234 "parse-gram.c" # define YYSTYPE yystype # define YYSTYPE_IS_TRIVIAL 1 #endif @@ -235,8 +250,8 @@ typedef struct yyltype /* Copy the second part of user declarations. */ -/* Line 219 of /home/akim/src/bison/data/bison.simple. */ -#line 240 "parse-gram.c" +/* Line 219 of /usr/local/share/bison/bison.simple. */ +#line 255 "parse-gram.c" #if ! defined (yyoverflow) || YYERROR_VERBOSE @@ -338,16 +353,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 #define YYFLAG -32768 -#define YYLAST 91 +#define YYLAST 90 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 40 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 30 +#define YYNNTS 29 /* YYNRULES -- Number of rules. */ -#define YYNRULES 72 +#define YYNRULES 71 /* YYNRULES -- Number of states. */ -#define YYNSTATES 98 +#define YYNSTATES 97 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 @@ -396,51 +411,50 @@ static const unsigned char yytranslate[] = YYRHS. */ static const unsigned char yyprhs[] = { - 0, 0, 3, 4, 10, 11, 15, 17, 19, 21, - 25, 27, 29, 32, 36, 38, 42, 44, 48, 50, - 53, 55, 57, 59, 61, 63, 66, 69, 70, 74, - 75, 79, 80, 85, 86, 91, 93, 95, 97, 98, - 100, 102, 105, 107, 110, 112, 114, 117, 120, 124, - 126, 129, 131, 134, 136, 139, 140, 146, 148, 152, - 153, 156, 159, 163, 165, 167, 169, 171, 173, 175, - 176, 179, 180 + 0, 0, 3, 8, 9, 13, 15, 17, 19, 23, + 25, 27, 30, 34, 36, 40, 42, 46, 48, 51, + 53, 55, 57, 59, 61, 64, 67, 68, 72, 73, + 77, 78, 83, 84, 89, 91, 93, 95, 96, 98, + 100, 103, 105, 108, 110, 112, 115, 118, 122, 124, + 127, 129, 132, 134, 137, 138, 144, 146, 150, 151, + 154, 157, 161, 163, 165, 167, 169, 171, 173, 174, + 177, 178 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const signed char yyrhs[] = { - 41, 0, -1, -1, 42, 43, 33, 58, 68, -1, - -1, 43, 44, 69, -1, 45, -1, 34, -1, 22, - -1, 18, 67, 67, -1, 20, -1, 14, -1, 10, - 5, -1, 16, 28, 67, -1, 23, -1, 17, 28, - 67, -1, 24, -1, 15, 28, 67, -1, 19, -1, - 25, 67, -1, 26, -1, 13, -1, 21, -1, 50, - -1, 46, -1, 11, 64, -1, 9, 36, -1, -1, - 7, 47, 57, -1, -1, 6, 48, 57, -1, -1, - 8, 27, 49, 54, -1, -1, 52, 53, 51, 55, - -1, 37, -1, 38, -1, 39, -1, -1, 27, -1, - 32, -1, 54, 32, -1, 64, -1, 55, 64, -1, - 27, -1, 32, -1, 32, 5, -1, 32, 66, -1, - 32, 5, 66, -1, 56, -1, 57, 56, -1, 59, - -1, 58, 59, -1, 60, -1, 45, 29, -1, -1, - 32, 30, 61, 62, 29, -1, 63, -1, 62, 31, - 63, -1, -1, 63, 64, -1, 63, 65, -1, 63, - 12, 64, -1, 32, -1, 66, -1, 4, -1, 36, - -1, 3, -1, 3, -1, -1, 33, 35, -1, -1, - 29, -1 + 41, 0, -1, 42, 33, 57, 67, -1, -1, 42, + 43, 68, -1, 44, -1, 34, -1, 22, -1, 18, + 66, 66, -1, 20, -1, 14, -1, 10, 5, -1, + 16, 28, 66, -1, 23, -1, 17, 28, 66, -1, + 24, -1, 15, 28, 66, -1, 19, -1, 25, 66, + -1, 26, -1, 13, -1, 21, -1, 49, -1, 45, + -1, 11, 63, -1, 9, 36, -1, -1, 7, 46, + 56, -1, -1, 6, 47, 56, -1, -1, 8, 27, + 48, 53, -1, -1, 51, 52, 50, 54, -1, 37, + -1, 38, -1, 39, -1, -1, 27, -1, 32, -1, + 53, 32, -1, 63, -1, 54, 63, -1, 27, -1, + 32, -1, 32, 5, -1, 32, 65, -1, 32, 5, + 65, -1, 55, -1, 56, 55, -1, 58, -1, 57, + 58, -1, 59, -1, 44, 29, -1, -1, 32, 30, + 60, 61, 29, -1, 62, -1, 61, 31, 62, -1, + -1, 62, 63, -1, 62, 64, -1, 62, 12, 63, + -1, 32, -1, 65, -1, 4, -1, 36, -1, 3, + -1, 3, -1, -1, 33, 35, -1, -1, 29, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const unsigned short yyrline[] = { - 0, 131, 131, 131, 144, 146, 149, 151, 152, 153, - 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, - 164, 165, 166, 169, 171, 172, 176, 184, 184, 190, - 190, 195, 195, 201, 201, 211, 213, 214, 217, 219, - 223, 225, 229, 235, 243, 248, 253, 259, 265, 275, - 278, 287, 289, 295, 297, 300, 300, 305, 307, 310, - 313, 315, 317, 321, 323, 324, 327, 333, 342, 350, - 355, 361, 363 + 0, 146, 146, 159, 161, 164, 166, 167, 168, 169, + 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + 180, 181, 184, 186, 187, 191, 199, 199, 205, 205, + 210, 210, 216, 216, 226, 228, 229, 232, 234, 238, + 240, 244, 250, 258, 263, 268, 274, 280, 290, 293, + 302, 304, 310, 312, 315, 315, 320, 322, 325, 328, + 330, 332, 336, 338, 339, 342, 348, 357, 365, 370, + 376, 378 }; #endif @@ -457,11 +471,11 @@ static const char *const yytname[] = "\"%locations\"", "\"%no-lines\"", "\"%skeleton\"", "\"%token-table\"", "TYPE", "\"=\"", "\";\"", "\":\"", "\"|\"", "\"identifier\"", "\"%%\"", "PROLOGUE", "EPILOGUE", "BRACED_CODE", "\"%left\"", "\"%right\"", - "\"%nonassoc\"", "$axiom", "input", "@1", "declarations", "declaration", - "grammar_declaration", "symbol_declaration", "@2", "@3", "@4", - "precedence_declaration", "@5", "precedence_declarator", "type.opt", + "\"%nonassoc\"", "$axiom", "input", "declarations", "declaration", + "grammar_declaration", "symbol_declaration", "@1", "@2", "@3", + "precedence_declaration", "@4", "precedence_declarator", "type.opt", "nterms_to_type.1", "terms_to_prec.1", "symbol_def", "symbol_defs.1", - "grammar", "rules_or_grammar_declaration", "rules", "@6", "rhses.1", + "grammar", "rules_or_grammar_declaration", "rules", "@5", "rhses.1", "rhs", "symbol", "action", "string_as_id", "string_content", "epilogue.opt", "semi_colon.opt", 0 }; @@ -481,27 +495,27 @@ static const short yytoknum[] = /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const unsigned char yyr1[] = { - 0, 40, 42, 41, 43, 43, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 45, 45, 45, 45, 47, 46, 48, - 46, 49, 46, 51, 50, 52, 52, 52, 53, 53, - 54, 54, 55, 55, 56, 56, 56, 56, 56, 57, - 57, 58, 58, 59, 59, 61, 60, 62, 62, 63, - 63, 63, 63, 64, 64, 64, 65, 66, 67, 68, - 68, 69, 69 + 0, 40, 41, 42, 42, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 44, 44, 44, 44, 46, 45, 47, 45, + 48, 45, 50, 49, 51, 51, 51, 52, 52, 53, + 53, 54, 54, 55, 55, 55, 55, 55, 56, 56, + 57, 57, 58, 58, 60, 59, 61, 61, 62, 62, + 62, 62, 63, 63, 63, 64, 65, 66, 67, 67, + 68, 68 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const unsigned char yyr2[] = { - 0, 2, 0, 5, 0, 3, 1, 1, 1, 3, - 1, 1, 2, 3, 1, 3, 1, 3, 1, 2, - 1, 1, 1, 1, 1, 2, 2, 0, 3, 0, - 3, 0, 4, 0, 4, 1, 1, 1, 0, 1, - 1, 2, 1, 2, 1, 1, 2, 2, 3, 1, - 2, 1, 2, 1, 2, 0, 5, 1, 3, 0, - 2, 2, 3, 1, 1, 1, 1, 1, 1, 0, - 2, 0, 1 + 0, 2, 4, 0, 3, 1, 1, 1, 3, 1, + 1, 2, 3, 1, 3, 1, 3, 1, 2, 1, + 1, 1, 1, 1, 2, 2, 0, 3, 0, 3, + 0, 4, 0, 4, 1, 1, 1, 0, 1, 1, + 2, 1, 2, 1, 1, 2, 2, 3, 1, 2, + 1, 2, 1, 2, 0, 5, 1, 3, 0, 2, + 2, 3, 1, 1, 1, 1, 1, 1, 0, 2, + 0, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -509,48 +523,48 @@ static const unsigned char yyr2[] = means the default is an error. */ static const short yydefact[] = { - 2, 0, 4, 0, 0, 29, 27, 0, 0, 0, - 0, 21, 11, 0, 0, 0, 0, 18, 10, 22, - 8, 14, 16, 0, 20, 0, 7, 35, 36, 37, - 71, 6, 24, 23, 38, 0, 0, 31, 26, 12, - 67, 65, 63, 25, 64, 0, 0, 0, 68, 0, - 19, 0, 0, 69, 51, 53, 72, 5, 39, 33, - 44, 45, 49, 30, 28, 0, 17, 13, 15, 9, - 55, 54, 0, 52, 3, 0, 46, 47, 50, 40, - 32, 59, 70, 34, 42, 48, 41, 0, 57, 43, - 56, 59, 0, 66, 60, 61, 58, 62 + 3, 0, 0, 0, 28, 26, 0, 0, 0, 0, + 20, 10, 0, 0, 0, 0, 17, 9, 21, 7, + 13, 15, 0, 19, 0, 6, 34, 35, 36, 70, + 5, 23, 22, 37, 0, 0, 30, 25, 11, 66, + 64, 62, 24, 63, 0, 0, 0, 67, 0, 18, + 0, 0, 68, 50, 52, 71, 4, 38, 32, 43, + 44, 48, 29, 27, 0, 16, 12, 14, 8, 54, + 53, 0, 51, 2, 0, 45, 46, 49, 39, 31, + 58, 69, 33, 41, 47, 40, 0, 56, 42, 55, + 58, 0, 65, 59, 60, 57, 61 }; /* YYPGOTO[NTERM-NUM]. */ static const short yydefgoto[] = { - -1, 1, 2, 4, 30, 52, 32, 36, 35, 65, - 33, 75, 34, 59, 80, 83, 62, 63, 53, 54, - 55, 81, 87, 88, 94, 95, 44, 49, 74, 57 + -1, 1, 2, 29, 51, 31, 35, 34, 64, 32, + 74, 33, 58, 79, 82, 61, 62, 52, 53, 54, + 80, 86, 87, 93, 94, 43, 48, 73, 56 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const short yypact[] = { - -32768, 7,-32768,-32768, -5,-32768,-32768, -1, 11, 51, - 38,-32768,-32768, 36, 43, 44, 66,-32768,-32768,-32768, - -32768,-32768,-32768, 66,-32768, 29,-32768,-32768,-32768,-32768, - 45,-32768,-32768,-32768, 48, 18, 18,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768, 66, 66, 66,-32768, 66, - -32768, 46, 49, 16,-32768,-32768,-32768,-32768,-32768,-32768, - -32768, 41,-32768, 18, 18, 52,-32768,-32768,-32768,-32768, - -32768,-32768, 42,-32768,-32768, 38, 82,-32768,-32768,-32768, - 54,-32768,-32768, 38,-32768,-32768,-32768, 31, 27,-32768, - -32768,-32768, 38,-32768,-32768,-32768, 27,-32768 + -32768, 7, -5,-32768,-32768,-32768, -1, 11, 46, 38, + -32768,-32768, 36, 43, 44, 66,-32768,-32768,-32768,-32768, + -32768,-32768, 66,-32768, 29,-32768,-32768,-32768,-32768, 48, + -32768,-32768,-32768, 52, 18, 18,-32768,-32768,-32768,-32768, + -32768,-32768,-32768,-32768, 66, 66, 66,-32768, 66,-32768, + 50, 54, 16,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + 41,-32768, 18, 18, 49,-32768,-32768,-32768,-32768,-32768, + -32768, 51,-32768,-32768, 38, 81,-32768,-32768,-32768, 53, + -32768,-32768, 38,-32768,-32768,-32768, 31, 27,-32768,-32768, + -32768, 38,-32768,-32768,-32768, 27,-32768 }; /* YYPGOTO[NTERM-NUM]. */ static const short yypgoto[] = { - -32768,-32768,-32768,-32768,-32768, 83,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768,-32768, -12, 53,-32768, 35, - -32768,-32768,-32768, 0, -10,-32768, -18, 34,-32768,-32768 + -32768,-32768,-32768,-32768, 85,-32768,-32768,-32768,-32768,-32768, + -32768,-32768,-32768,-32768,-32768, -6, 55,-32768, 37,-32768, + -32768,-32768, -2, -9,-32768, -17, 30,-32768,-32768 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -558,30 +572,30 @@ static const short yypgoto[] = number is the opposite. If zero, do what YYDEFACT says. */ static const short yytable[] = { - 43, 5, 6, 7, 8, 9, 10, 3, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 5, 6, 7, 8, 37, 10, 25, 26, - 40, 41, 27, 28, 29, 5, 6, 7, 8, 92, - 10, 40, 41, 77, 40, 60, 76, 38, 51, 72, - 61, 78, 78, 27, 28, 29, 39, 50, 85, 42, - 90, 51, 91, 93, 45, 84, 27, 28, 29, 48, - 42, 46, 47, 89, 56, 58, 70, 82, 71, 66, - 67, 68, 97, 69, 79, 40, 86, 31, 73, 64, - 0, 96 + 42, 4, 5, 6, 7, 8, 9, 3, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 4, 5, 6, 7, 36, 9, 24, 25, + 39, 40, 26, 27, 28, 4, 5, 6, 7, 91, + 9, 39, 40, 76, 39, 59, 75, 37, 50, 71, + 60, 38, 49, 26, 27, 28, 77, 77, 84, 41, + 89, 50, 90, 92, 44, 83, 26, 27, 28, 47, + 41, 45, 46, 88, 65, 66, 67, 55, 68, 57, + 69, 78, 96, 70, 39, 85, 81, 30, 95, 72, + 63 }; static const short yycheck[] = { - 10, 6, 7, 8, 9, 10, 11, 0, 13, 14, + 9, 6, 7, 8, 9, 10, 11, 0, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 6, 7, 8, 9, 27, 11, 33, 34, 3, 4, 37, 38, 39, 6, 7, 8, 9, 12, - 11, 3, 4, 61, 3, 27, 5, 36, 32, 33, - 32, 63, 64, 37, 38, 39, 5, 23, 76, 32, - 29, 32, 31, 36, 28, 75, 37, 38, 39, 3, - 32, 28, 28, 83, 29, 27, 30, 35, 29, 45, - 46, 47, 92, 49, 32, 3, 32, 4, 53, 36, - -1, 91 + 11, 3, 4, 60, 3, 27, 5, 36, 32, 33, + 32, 5, 22, 37, 38, 39, 62, 63, 75, 32, + 29, 32, 31, 36, 28, 74, 37, 38, 39, 3, + 32, 28, 28, 82, 44, 45, 46, 29, 48, 27, + 30, 32, 91, 29, 3, 32, 35, 2, 90, 52, + 35 }; #if YYDEBUG @@ -589,16 +603,16 @@ static const short yycheck[] = symbol of state STATE-NUM. */ static const unsigned char yystos[] = { - 0, 41, 42, 0, 43, 6, 7, 8, 9, 10, - 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 33, 34, 37, 38, 39, - 44, 45, 46, 50, 52, 48, 47, 27, 36, 5, - 3, 4, 32, 64, 66, 28, 28, 28, 3, 67, - 67, 32, 45, 58, 59, 60, 29, 69, 27, 53, - 27, 32, 56, 57, 57, 49, 67, 67, 67, 67, - 30, 29, 33, 59, 68, 51, 5, 66, 56, 32, - 54, 61, 35, 55, 64, 66, 32, 62, 63, 64, - 29, 31, 12, 36, 64, 65, 63, 64 + 0, 41, 42, 0, 6, 7, 8, 9, 10, 11, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 33, 34, 37, 38, 39, 43, + 44, 45, 49, 51, 47, 46, 27, 36, 5, 3, + 4, 32, 63, 65, 28, 28, 28, 3, 66, 66, + 32, 44, 57, 58, 59, 29, 68, 27, 52, 27, + 32, 55, 56, 56, 48, 66, 66, 66, 66, 30, + 29, 33, 58, 67, 50, 5, 65, 55, 32, 53, + 60, 35, 54, 63, 65, 32, 61, 62, 63, 29, + 31, 12, 36, 63, 64, 62, 63 }; #endif @@ -1168,107 +1182,102 @@ yyreduce: switch (yyn) { case 2: -#line 131 "parse-gram.y" - { LOCATION_RESET (yylloc); } - break; - - case 3: -#line 133 "parse-gram.y" +#line 148 "parse-gram.y" { yycontrol->errcode = 0; epilogue_set (yyvsp[0].string, yylsp[0]); } break; - case 7: -#line 151 "parse-gram.y" + case 6: +#line 166 "parse-gram.y" { prologue_augment (yyvsp[0].string, yylsp[0]); } break; - case 8: -#line 152 "parse-gram.y" + case 7: +#line 167 "parse-gram.y" { debug_flag = 1; } break; - case 9: -#line 153 "parse-gram.y" + case 8: +#line 168 "parse-gram.y" { muscle_insert (yyvsp[-1].string, yyvsp[0].string); } break; - case 10: -#line 154 "parse-gram.y" + case 9: +#line 169 "parse-gram.y" { defines_flag = 1; } break; - case 11: -#line 155 "parse-gram.y" + case 10: +#line 170 "parse-gram.y" { error_verbose = 1; } break; - case 12: -#line 156 "parse-gram.y" + case 11: +#line 171 "parse-gram.y" { expected_conflicts = yyvsp[0].integer; } break; - case 13: -#line 157 "parse-gram.y" + case 12: +#line 172 "parse-gram.y" { spec_file_prefix = yyvsp[0].string; } break; - case 14: -#line 158 "parse-gram.y" + case 13: +#line 173 "parse-gram.y" { locations_flag = 1; } break; - case 15: -#line 159 "parse-gram.y" + case 14: +#line 174 "parse-gram.y" { spec_name_prefix = yyvsp[0].string; } break; - case 16: -#line 160 "parse-gram.y" + case 15: +#line 175 "parse-gram.y" { no_lines_flag = 1; } break; - case 17: -#line 161 "parse-gram.y" + case 16: +#line 176 "parse-gram.y" { spec_outfile = yyvsp[0].string; } break; - case 18: -#line 162 "parse-gram.y" + case 17: +#line 177 "parse-gram.y" { pure_parser = 1; } break; - case 19: -#line 163 "parse-gram.y" + case 18: +#line 178 "parse-gram.y" { skeleton = yyvsp[0].string; } break; - case 20: -#line 164 "parse-gram.y" + case 19: +#line 179 "parse-gram.y" { token_table_flag = 1; } break; - case 21: -#line 165 "parse-gram.y" + case 20: +#line 180 "parse-gram.y" { report_flag = 1; } break; - case 22: -#line 166 "parse-gram.y" + case 21: +#line 181 "parse-gram.y" { yacc_flag = 1; } break; - case 25: -#line 173 "parse-gram.y" + case 24: +#line 188 "parse-gram.y" { - grammar_start_symbol_set (yyvsp[0].symbol); + grammar_start_symbol_set (yyvsp[0].symbol, yylsp[0]); } break; - case 26: -#line 177 "parse-gram.y" + case 25: +#line 192 "parse-gram.y" { typed = 1; MUSCLE_INSERT_INT ("stype_line", yylsp[0].first_line); @@ -1276,122 +1285,122 @@ yyreduce: } break; - case 27: -#line 185 "parse-gram.y" + case 26: +#line 200 "parse-gram.y" { current_class = nterm_sym; } break; - case 28: -#line 186 "parse-gram.y" + case 27: +#line 201 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; } break; - case 29: -#line 190 "parse-gram.y" + case 28: +#line 205 "parse-gram.y" { current_class = token_sym; } break; - case 30: -#line 191 "parse-gram.y" + case 29: +#line 206 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; } break; - case 31: -#line 195 "parse-gram.y" + case 30: +#line 210 "parse-gram.y" {current_type = yyvsp[0].string; } break; - case 32: -#line 196 "parse-gram.y" + case 31: +#line 211 "parse-gram.y" { current_type = NULL; } break; - case 33: -#line 203 "parse-gram.y" + case 32: +#line 218 "parse-gram.y" { current_assoc = yyvsp[-1].assoc; ++current_prec; } break; - case 34: -#line 205 "parse-gram.y" + case 33: +#line 220 "parse-gram.y" { current_assoc = non_assoc; current_type = NULL; } break; - case 35: -#line 212 "parse-gram.y" + case 34: +#line 227 "parse-gram.y" { yyval.assoc = left_assoc; } break; - case 36: -#line 213 "parse-gram.y" + case 35: +#line 228 "parse-gram.y" { yyval.assoc = right_assoc; } break; - case 37: -#line 214 "parse-gram.y" + case 36: +#line 229 "parse-gram.y" { yyval.assoc = non_assoc; } break; - case 38: -#line 218 "parse-gram.y" + case 37: +#line 233 "parse-gram.y" { current_type = NULL;} break; - case 39: -#line 219 "parse-gram.y" + case 38: +#line 234 "parse-gram.y" { current_type = yyvsp[0].string; } break; - case 40: -#line 224 "parse-gram.y" + case 39: +#line 239 "parse-gram.y" { symbol_type_set (yyvsp[0].symbol, current_type); } break; - case 41: -#line 225 "parse-gram.y" + case 40: +#line 240 "parse-gram.y" { symbol_type_set (yyvsp[0].symbol, current_type); } break; - case 42: -#line 231 "parse-gram.y" + case 41: +#line 246 "parse-gram.y" { symbol_type_set (yyvsp[0].symbol, current_type); symbol_precedence_set (yyvsp[0].symbol, current_prec, current_assoc); } break; - case 43: -#line 236 "parse-gram.y" + case 42: +#line 251 "parse-gram.y" { symbol_type_set (yyvsp[0].symbol, current_type); symbol_precedence_set (yyvsp[0].symbol, current_prec, current_assoc); } break; - case 44: -#line 245 "parse-gram.y" + case 43: +#line 260 "parse-gram.y" { current_type = yyvsp[0].string; } break; - case 45: -#line 249 "parse-gram.y" + case 44: +#line 264 "parse-gram.y" { symbol_class_set (yyvsp[0].symbol, current_class); symbol_type_set (yyvsp[0].symbol, current_type); } break; - case 46: -#line 254 "parse-gram.y" + case 45: +#line 269 "parse-gram.y" { symbol_class_set (yyvsp[-1].symbol, current_class); symbol_type_set (yyvsp[-1].symbol, current_type); @@ -1399,8 +1408,8 @@ yyreduce: } break; - case 47: -#line 260 "parse-gram.y" + case 46: +#line 275 "parse-gram.y" { symbol_class_set (yyvsp[-1].symbol, current_class); symbol_type_set (yyvsp[-1].symbol, current_type); @@ -1408,8 +1417,8 @@ yyreduce: } break; - case 48: -#line 266 "parse-gram.y" + case 47: +#line 281 "parse-gram.y" { symbol_class_set (yyvsp[-2].symbol, current_class); symbol_type_set (yyvsp[-2].symbol, current_type); @@ -1418,101 +1427,101 @@ yyreduce: } break; - case 49: -#line 277 "parse-gram.y" + case 48: +#line 292 "parse-gram.y" {;} break; - case 50: -#line 279 "parse-gram.y" + case 49: +#line 294 "parse-gram.y" {;} break; + case 54: +#line 316 "parse-gram.y" + { current_lhs = yyvsp[-1].symbol; current_lhs_location = yylsp[-1]; } + break; + case 55: -#line 301 "parse-gram.y" - { current_lhs = yyvsp[-1].symbol; } +#line 317 "parse-gram.y" + {;} break; case 56: -#line 302 "parse-gram.y" - {;} +#line 321 "parse-gram.y" + { grammar_rule_end (yylsp[0]); } break; case 57: -#line 306 "parse-gram.y" - { grammar_rule_end (); } +#line 322 "parse-gram.y" + { grammar_rule_end (yylsp[0]); } break; case 58: -#line 307 "parse-gram.y" - { grammar_rule_end (); } +#line 327 "parse-gram.y" + { grammar_rule_begin (current_lhs, current_lhs_location); } break; case 59: -#line 312 "parse-gram.y" - { grammar_rule_begin (current_lhs); } +#line 329 "parse-gram.y" + { grammar_current_rule_symbol_append (yyvsp[0].symbol, yylsp[0]); } break; case 60: -#line 314 "parse-gram.y" - { grammar_current_rule_symbol_append (yyvsp[0].symbol); } +#line 331 "parse-gram.y" + { grammar_current_rule_action_append (yyvsp[0].string, yylsp[0]); } break; case 61: -#line 316 "parse-gram.y" - { grammar_current_rule_action_append (yyvsp[0].string, yylsp[0].first_line); } +#line 333 "parse-gram.y" + { grammar_current_rule_prec_set (yyvsp[0].symbol); } break; case 62: -#line 318 "parse-gram.y" - { grammar_current_rule_prec_set (yyvsp[0].symbol); } +#line 337 "parse-gram.y" + { yyval.symbol = yyvsp[0].symbol; } break; case 63: -#line 322 "parse-gram.y" +#line 338 "parse-gram.y" { yyval.symbol = yyvsp[0].symbol; } break; case 64: -#line 323 "parse-gram.y" - { yyval.symbol = yyvsp[0].symbol; } - break; - - case 65: -#line 324 "parse-gram.y" +#line 339 "parse-gram.y" { yyval.symbol = getsym (yyvsp[0].string); } break; - case 66: -#line 329 "parse-gram.y" + case 65: +#line 344 "parse-gram.y" { yyval.string = yyvsp[0].string; } break; - case 67: -#line 335 "parse-gram.y" + case 66: +#line 350 "parse-gram.y" { yyval.symbol = getsym (yyvsp[0].string); symbol_class_set (yyval.symbol, token_sym); } break; - case 68: -#line 344 "parse-gram.y" + case 67: +#line 359 "parse-gram.y" { yyval.string = yyvsp[0].string + 1; yyval.string[strlen (yyval.string) - 1] = '\0'; } break; - case 69: -#line 352 "parse-gram.y" + case 68: +#line 367 "parse-gram.y" { yyval.string = xstrdup (""); } break; - case 70: -#line 356 "parse-gram.y" + case 69: +#line 371 "parse-gram.y" { yyval.string = yyvsp[0].string; } @@ -1521,8 +1530,8 @@ yyreduce: } -/* Line 1012 of /home/akim/src/bison/data/bison.simple. */ -#line 1526 "parse-gram.c" +/* Line 1012 of /usr/local/share/bison/bison.simple. */ +#line 1535 "parse-gram.c" yyvsp -= yylen; yyssp -= yylen; @@ -1743,7 +1752,7 @@ yyreturn: return yyresult; } -#line 365 "parse-gram.y" +#line 380 "parse-gram.y" /*------------------------------------------------------------------. | When debugging the parser, display tokens' locations and values. | diff --git a/src/parse-gram.h b/src/parse-gram.h index 7eccd219..aaa4a177 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -93,14 +93,14 @@ #ifndef YYSTYPE -#line 74 "parse-gram.y" +#line 89 "parse-gram.y" typedef union { symbol_t *symbol; int integer; char *string; associativity assoc; } yystype; -/* Line 1271 of /home/akim/src/bison/data/bison.simple. */ +/* Line 1271 of /usr/local/share/bison/bison.simple. */ #line 105 "y.tab.h" # define YYSTYPE yystype #endif diff --git a/src/parse-gram.y b/src/parse-gram.y index 241dcdce..272d9667 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -40,6 +40,20 @@ /* Produce verbose parse errors. */ #define YYERROR_VERBOSE 1 +#define YYLLOC_DEFAULT(Current, Rhs, N) \ +do { \ + if (N) \ + { \ + Current.first_column = Rhs[1].first_column; \ + Current.first_line = Rhs[1].first_line; \ + Current.last_column = Rhs[N].last_column; \ + Current.last_line = Rhs[N].last_line; \ + } \ + else \ + { \ + Current = Rhs[0]; \ + } \ +} while (0) /* Pass the control structure to YYPARSE and YYLEX. */ #define YYPARSE_PARAM gram_control @@ -64,6 +78,7 @@ static void yyprint (FILE *file, const location_t *loc, symbol_class current_class = unknown_sym; char *current_type = 0; symbol_t *current_lhs; +location_t current_lhs_location; associativity current_assoc; int current_prec = 0; %} @@ -128,11 +143,11 @@ int current_prec = 0; %% -input: { LOCATION_RESET (yylloc); } +input: declarations "%%" grammar epilogue.opt { yycontrol->errcode = 0; - epilogue_set ($5, @5); + epilogue_set ($4, @4); } ; @@ -171,7 +186,7 @@ grammar_declaration: | symbol_declaration | "%start" symbol { - grammar_start_symbol_set ($2); + grammar_start_symbol_set ($2, @2); } | "%union" BRACED_CODE { @@ -298,22 +313,22 @@ rules_or_grammar_declaration: ; rules: - ID ":" { current_lhs = $1; } rhses.1 ";" + ID ":" { current_lhs = $1; current_lhs_location = @1; } rhses.1 ";" {;} ; rhses.1: - rhs { grammar_rule_end (); } -| rhses.1 "|" rhs { grammar_rule_end (); } + rhs { grammar_rule_end (@1); } +| rhses.1 "|" rhs { grammar_rule_end (@3); } ; rhs: /* Nothing. */ - { grammar_rule_begin (current_lhs); } + { grammar_rule_begin (current_lhs, current_lhs_location); } | rhs symbol - { grammar_current_rule_symbol_append ($2); } + { grammar_current_rule_symbol_append ($2, @2); } | rhs action - { grammar_current_rule_action_append ($2, @2.first_line); } + { grammar_current_rule_action_append ($2, @2); } | rhs "%prec" symbol { grammar_current_rule_prec_set ($3); } ; diff --git a/src/print.c b/src/print.c index 3c5d0ba3..bcf71cc6 100644 --- a/src/print.c +++ b/src/print.c @@ -399,8 +399,9 @@ print_grammar (FILE *out) fprintf (out, " %s\n", _("Number, Line, Rule")); for (j = 1; j < nrules + 1; j++) { - fprintf (out, _(" %3d %3d %s ->"), - j - 1, rules[j].line, escape (rules[j].lhs->tag)); + fprintf (out, " %3d %3d %s ->", + j - 1, rules[j].location.first_line, + escape (rules[j].lhs->tag)); rule = rules[j].rhs; if (*rule >= 0) while (*rule >= 0) diff --git a/src/reader.c b/src/reader.c index ad76ee10..f66a7607 100644 --- a/src/reader.c +++ b/src/reader.c @@ -42,14 +42,13 @@ static int start_flag = 0; int typed = 0; static symbol_list * -symbol_list_new (symbol_t *sym) +symbol_list_new (symbol_t *sym, location_t location) { symbol_list *res = XMALLOC (symbol_list, 1); res->next = NULL; res->sym = sym; - res->line = lineno; + res->location = location; res->action = NULL; - res->action_line = 0; res->ruleprec = NULL; return res; } @@ -95,7 +94,7 @@ get_type_name (int n, symbol_list *rule) `-----------------------*/ void -grammar_start_symbol_set (symbol_t *s) +grammar_start_symbol_set (symbol_t *s, location_t l) { if (start_flag) complain (_("multiple %s declarations"), "%start"); @@ -103,6 +102,7 @@ grammar_start_symbol_set (symbol_t *s) { start_flag = 1; startsymbol = s; + startsymbol_location = l; } } @@ -197,9 +197,9 @@ symbol_list *grammar_end = NULL; /* Append S to the GRAMMAR. */ void -grammar_symbol_append (symbol_t *s) +grammar_symbol_append (symbol_t *symbol, location_t location) { - symbol_list *p = symbol_list_new (s); + symbol_list *p = symbol_list_new (symbol, location); if (grammar_end) grammar_end->next = p; @@ -209,20 +209,24 @@ grammar_symbol_append (symbol_t *s) grammar_end = p; } -/* The rule currently being defined, and the previous rule. Point to - the first symbol of each list: their lhs. */ +/* The rule currently being defined, and the previous rule. + CURRENT_RULE points to the first LHS of the current rule, while + PREVIOUS_RULE_END points to the *end* of the previous rule (NULL). */ symbol_list *current_rule = NULL; -symbol_list *previous_rule = NULL; +symbol_list *previous_rule_end = NULL; -/* Create a new rule for LHS in to the GRAMMAR. */ +/*----------------------------------------------. +| Create a new rule for LHS in to the GRAMMAR. | +`----------------------------------------------*/ void -grammar_rule_begin (symbol_t *lhs) +grammar_rule_begin (symbol_t *lhs, location_t location) { if (!start_flag) { startsymbol = lhs; + startsymbol_location = location; start_flag = 1; } @@ -230,8 +234,8 @@ grammar_rule_begin (symbol_t *lhs) ++nrules; ++nritems; - previous_rule = grammar_end; - grammar_symbol_append (lhs); + previous_rule_end = grammar_end; + grammar_symbol_append (lhs, location); current_rule = grammar_end; /* Mark the rule's lhs as a nonterminal if not already so. */ @@ -279,21 +283,26 @@ grammar_current_rule_check (void) } -/* End the currently being grown rule. */ +/*-------------------------------------. +| End the currently being grown rule. | +`-------------------------------------*/ void -grammar_rule_end (void) +grammar_rule_end (location_t location) { /* Put an empty link in the list to mark the end of this rule */ - grammar_symbol_append (NULL); + grammar_symbol_append (NULL, grammar_end->location); + current_rule->location = location; grammar_current_rule_check (); } -/* The previous action turns out the be a mid-rule action. Attach it - to the current rule, i.e., create a dummy symbol, attach it this - mid-rule action, and append this dummy nonterminal to the current - rule. */ +/*-------------------------------------------------------------------. +| The previous action turns out the be a mid-rule action. Attach it | +| to the current rule, i.e., create a dummy symbol, attach it this | +| mid-rule action, and append this dummy nonterminal to the current | +| rule. | +`-------------------------------------------------------------------*/ void grammar_midrule_action (void) @@ -302,35 +311,36 @@ grammar_midrule_action (void) give the new rule this number by inserting the new rule before it. */ - /* Make a dummy nonterminal, a gensym. */ - symbol_t *sdummy = gensym (); - symbol_list *midrule_action = symbol_list_new (sdummy); + /* Make a DUMMY nonterminal, whose location is that of the midrule + action. Create the MIDRULE. */ + symbol_t *dummy = gensym (); + location_t dummy_location = current_rule->action_location; + symbol_list *midrule = symbol_list_new (dummy, dummy_location); /* Make a new rule, whose body is empty, before the current one, so that the action just read can belong to it. */ ++nrules; ++nritems; - /* Attach its lineno to that of the host rule. */ - midrule_action->line = current_rule->line; - /* Move the action from the host rule to this one. */ - midrule_action->action = current_rule->action; - midrule_action->action_line = current_rule->action_line; + /* Attach its location and actions to that of the DUMMY. */ + midrule->location = dummy_location; + midrule->action = current_rule->action; + midrule->action_location = dummy_location; current_rule->action = NULL; - if (previous_rule) - previous_rule->next = midrule_action; + if (previous_rule_end) + previous_rule_end->next = midrule; else - grammar = midrule_action; + grammar = midrule; - /* End of the rule. */ - previous_rule = symbol_list_new (NULL); - previous_rule->next = current_rule; + /* End the dummy's rule. */ + previous_rule_end = symbol_list_new (NULL, dummy_location); + previous_rule_end->next = current_rule; - midrule_action->next = previous_rule; + midrule->next = previous_rule_end; - /* Insert the dummy generated by that rule into this rule. */ - ++nritems; - grammar_symbol_append (sdummy); + /* Insert the dummy nonterminal replacing the midrule action into + the current rule. */ + grammar_current_rule_symbol_append (dummy, dummy_location); } /* Set the precedence symbol of the current rule to PRECSYM. */ @@ -347,12 +357,12 @@ grammar_current_rule_prec_set (symbol_t *precsym) action as a mid-rule action. */ void -grammar_current_rule_symbol_append (symbol_t *symbol) +grammar_current_rule_symbol_append (symbol_t *symbol, location_t location) { if (current_rule->action) grammar_midrule_action (); ++nritems; - grammar_symbol_append (symbol); + grammar_symbol_append (symbol, location); } @@ -360,12 +370,12 @@ grammar_current_rule_symbol_append (symbol_t *symbol) action as a mid-rule action. */ void -grammar_current_rule_action_append (const char *action, int action_line) +grammar_current_rule_action_append (const char *action, location_t location) { if (current_rule->action) grammar_midrule_action (); current_rule->action = action; - current_rule->action_line = action_line; + current_rule->action_location = location; } @@ -395,10 +405,10 @@ packgram (void) rules[ruleno].number = ruleno; rules[ruleno].lhs = p->sym; rules[ruleno].rhs = ritem + itemno; - rules[ruleno].line = p->line; + rules[ruleno].location = p->location; rules[ruleno].useful = TRUE; rules[ruleno].action = p->action; - rules[ruleno].action_line = p->action_line; + rules[ruleno].action_location = p->action_location; p = p->next; while (p && p->sym) @@ -500,11 +510,11 @@ reader (void) axiom: %start EOF. */ { - symbol_list *p = symbol_list_new (axiom); - p->line = grammar->line; - p->next = symbol_list_new (startsymbol); - p->next->next = symbol_list_new (eoftoken); - p->next->next->next = symbol_list_new (NULL); + symbol_list *p = symbol_list_new (axiom, empty_location); + p->location = grammar->location; + p->next = symbol_list_new (startsymbol, empty_location); + p->next->next = symbol_list_new (eoftoken, empty_location); + p->next->next->next = symbol_list_new (NULL, empty_location); p->next->next->next->next = grammar; nrules += 1; nritems += 3; diff --git a/src/reader.h b/src/reader.h index d35dd051..70740409 100644 --- a/src/reader.h +++ b/src/reader.h @@ -27,11 +27,11 @@ typedef struct symbol_list { struct symbol_list *next; symbol_t *sym; - int line; + location_t location; /* The action is attached to the LHS of a rule. */ const char *action; - int action_line; + location_t action_location; symbol_t *ruleprec; } symbol_list; @@ -66,17 +66,18 @@ char *get_type_name PARAMS ((int n, symbol_list *rule)); extern int typed; /* From reader.c. */ -void grammar_start_symbol_set PARAMS ((symbol_t *s)); +void grammar_start_symbol_set PARAMS ((symbol_t *s, location_t l)); void prologue_augment PARAMS ((const char *prologue, location_t location)); void epilogue_set PARAMS ((const char *epilogue, location_t location)); -void grammar_symbol_append PARAMS ((symbol_t *s)); -void grammar_rule_begin PARAMS ((symbol_t *lhs)); -void grammar_rule_end PARAMS ((void)); +void grammar_symbol_append PARAMS ((symbol_t *s, location_t l)); +void grammar_rule_begin PARAMS ((symbol_t *lhs, location_t l)); +void grammar_rule_end PARAMS ((location_t l)); void grammar_midrule_action PARAMS ((void)); void grammar_current_rule_prec_set PARAMS ((symbol_t *precsym)); -void grammar_current_rule_symbol_append PARAMS ((symbol_t *symbol)); +void grammar_current_rule_symbol_append PARAMS ((symbol_t *symbol, + location_t l)); void grammar_current_rule_action_append PARAMS ((const char *action, - int line)); + location_t l)); extern symbol_list *current_rule; void reader PARAMS ((void)); diff --git a/src/scan-gram.c b/src/scan-gram.c index bdee445d..85bac479 100644 --- a/src/scan-gram.c +++ b/src/scan-gram.c @@ -15,7 +15,7 @@ #define yyrestart gram_restart #define yytext gram_text -#line 19 "scan-gram.c" +#line 19 "lex.yy.c" /* A lexical scanner generated by flex */ /* Scanner skeleton version: @@ -686,16 +686,16 @@ int yy_flex_debug = 1; static yyconst short int yy_rule_linenum[92] = { 0, - 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, - 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, - 137, 138, 139, 140, 141, 142, 143, 145, 146, 147, - 148, 150, 151, 152, 157, 160, 163, 166, 167, 170, - 173, 176, 184, 190, 206, 207, 218, 230, 231, 232, - 249, 258, 260, 280, 294, 296, 316, 328, 332, 333, - 334, 335, 336, 337, 338, 339, 340, 355, 361, 362, - 364, 382, 388, 389, 391, 409, 412, 415, 416, 427, - 438, 440, 441, 443, 444, 447, 467, 474, 475, 476, - 497 + 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, + 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, + 141, 142, 143, 144, 145, 146, 147, 149, 150, 151, + 152, 154, 155, 156, 161, 164, 167, 170, 171, 174, + 177, 180, 188, 194, 210, 211, 222, 234, 235, 236, + 253, 262, 264, 284, 298, 300, 320, 332, 336, 337, + 338, 339, 340, 341, 342, 343, 344, 359, 365, 366, + 368, 386, 392, 393, 395, 413, 416, 419, 420, 431, + 442, 444, 445, 447, 448, 451, 471, 478, 479, 480, + 501 } ; @@ -741,6 +741,13 @@ char *yytext; #include "reader.h" /* Each time we match a string, move the end cursor to its end. */ +#define YY_USER_INIT \ +do { \ + LOCATION_RESET (*yylloc); \ + /* This is only to avoid GCC warnings. */ \ + if (yycontrol) {;}; \ +} while (0) + #define YY_USER_ACTION LOCATION_COLUMNS (*yylloc, yyleng) #define YY_LINES LOCATION_LINES (*yylloc, yyleng); lineno += yyleng; #define YY_STEP LOCATION_STEP (*yylloc) @@ -779,9 +786,6 @@ scanner_last_string_free (void) } -/* This is only to avoid GCC warnings. */ -#define YY_USER_INIT if (yycontrol) {;}; - static int braces_level = 0; static int percent_percent_count = 0; @@ -801,7 +805,7 @@ static void handle_at PARAMS ((char *cp)); #define SC_PROLOGUE 7 #define SC_EPILOGUE 8 -#line 805 "scan-gram.c" +#line 809 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -963,14 +967,14 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 93 "scan-gram.l" +#line 97 "scan-gram.l" /* At each yylex invocation, mark the current position as the start of the next token. */ #define TR_POS 0 #if TR_POS - fprintf (stderr, "FOO1: "); + fprintf (stderr, "FOO1: %p: ", yylloc); LOCATION_PRINT (stderr, *yylloc); fprintf (stderr, "\n"); #endif @@ -986,7 +990,7 @@ YY_DECL /*----------------------------. | Scanning Bison directives. | `----------------------------*/ -#line 990 "scan-gram.c" +#line 994 "lex.yy.c" if ( yy_init ) { @@ -1088,172 +1092,172 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 117 "scan-gram.l" +#line 121 "scan-gram.l" return PERCENT_NONASSOC; YY_BREAK case 2: YY_RULE_SETUP -#line 118 "scan-gram.l" +#line 122 "scan-gram.l" return PERCENT_DEBUG; YY_BREAK case 3: YY_RULE_SETUP -#line 119 "scan-gram.l" +#line 123 "scan-gram.l" return PERCENT_DEFINE; YY_BREAK case 4: YY_RULE_SETUP -#line 120 "scan-gram.l" +#line 124 "scan-gram.l" return PERCENT_DEFINES; YY_BREAK case 5: YY_RULE_SETUP -#line 121 "scan-gram.l" +#line 125 "scan-gram.l" return PERCENT_ERROR_VERBOSE; YY_BREAK case 6: YY_RULE_SETUP -#line 122 "scan-gram.l" +#line 126 "scan-gram.l" return PERCENT_EXPECT; YY_BREAK case 7: YY_RULE_SETUP -#line 123 "scan-gram.l" +#line 127 "scan-gram.l" return PERCENT_FILE_PREFIX; YY_BREAK case 8: YY_RULE_SETUP -#line 124 "scan-gram.l" +#line 128 "scan-gram.l" return PERCENT_YACC; YY_BREAK case 9: YY_RULE_SETUP -#line 125 "scan-gram.l" +#line 129 "scan-gram.l" return PERCENT_LEFT; YY_BREAK case 10: YY_RULE_SETUP -#line 126 "scan-gram.l" +#line 130 "scan-gram.l" return PERCENT_LOCATIONS; YY_BREAK case 11: YY_RULE_SETUP -#line 127 "scan-gram.l" +#line 131 "scan-gram.l" return PERCENT_NAME_PREFIX; YY_BREAK case 12: YY_RULE_SETUP -#line 128 "scan-gram.l" +#line 132 "scan-gram.l" return PERCENT_NO_LINES; YY_BREAK case 13: YY_RULE_SETUP -#line 129 "scan-gram.l" +#line 133 "scan-gram.l" return PERCENT_NONASSOC; YY_BREAK case 14: YY_RULE_SETUP -#line 130 "scan-gram.l" +#line 134 "scan-gram.l" return PERCENT_NTERM; YY_BREAK case 15: YY_RULE_SETUP -#line 131 "scan-gram.l" +#line 135 "scan-gram.l" return PERCENT_OUTPUT; YY_BREAK case 16: YY_RULE_SETUP -#line 132 "scan-gram.l" +#line 136 "scan-gram.l" return PERCENT_PREC; YY_BREAK case 17: YY_RULE_SETUP -#line 133 "scan-gram.l" +#line 137 "scan-gram.l" return PERCENT_PURE_PARSER; YY_BREAK case 18: YY_RULE_SETUP -#line 134 "scan-gram.l" +#line 138 "scan-gram.l" return PERCENT_RIGHT; YY_BREAK case 19: YY_RULE_SETUP -#line 135 "scan-gram.l" +#line 139 "scan-gram.l" return PERCENT_SKELETON; YY_BREAK case 20: YY_RULE_SETUP -#line 136 "scan-gram.l" +#line 140 "scan-gram.l" return PERCENT_START; YY_BREAK case 21: YY_RULE_SETUP -#line 137 "scan-gram.l" +#line 141 "scan-gram.l" return PERCENT_TOKEN; YY_BREAK case 22: YY_RULE_SETUP -#line 138 "scan-gram.l" +#line 142 "scan-gram.l" return PERCENT_TOKEN; YY_BREAK case 23: YY_RULE_SETUP -#line 139 "scan-gram.l" +#line 143 "scan-gram.l" return PERCENT_TOKEN_TABLE; YY_BREAK case 24: YY_RULE_SETUP -#line 140 "scan-gram.l" +#line 144 "scan-gram.l" return PERCENT_TYPE; YY_BREAK case 25: YY_RULE_SETUP -#line 141 "scan-gram.l" +#line 145 "scan-gram.l" return PERCENT_UNION; YY_BREAK case 26: YY_RULE_SETUP -#line 142 "scan-gram.l" +#line 146 "scan-gram.l" return PERCENT_VERBOSE; YY_BREAK case 27: YY_RULE_SETUP -#line 143 "scan-gram.l" +#line 147 "scan-gram.l" return PERCENT_YACC; YY_BREAK case 28: YY_RULE_SETUP -#line 145 "scan-gram.l" +#line 149 "scan-gram.l" return EQUAL; YY_BREAK case 29: YY_RULE_SETUP -#line 146 "scan-gram.l" +#line 150 "scan-gram.l" return COLON; YY_BREAK case 30: YY_RULE_SETUP -#line 147 "scan-gram.l" +#line 151 "scan-gram.l" return PIPE; YY_BREAK case 31: YY_RULE_SETUP -#line 148 "scan-gram.l" +#line 152 "scan-gram.l" return SEMICOLON; YY_BREAK case 32: YY_RULE_SETUP -#line 150 "scan-gram.l" +#line 154 "scan-gram.l" YY_LINES; YY_STEP; YY_BREAK case 33: YY_RULE_SETUP -#line 151 "scan-gram.l" +#line 155 "scan-gram.l" YY_STEP; YY_BREAK case 34: YY_RULE_SETUP -#line 152 "scan-gram.l" +#line 156 "scan-gram.l" { yylval->symbol = getsym (yytext); return ID; @@ -1261,48 +1265,48 @@ YY_RULE_SETUP YY_BREAK case 35: YY_RULE_SETUP -#line 157 "scan-gram.l" +#line 161 "scan-gram.l" yylval->integer = strtol (yytext, 0, 10); return INT; YY_BREAK /* Characters. We don't check there is only one. */ case 36: YY_RULE_SETUP -#line 160 "scan-gram.l" +#line 164 "scan-gram.l" YY_OBS_GROW; yy_push_state (SC_ESCAPED_CHARACTER); YY_BREAK /* Strings. */ case 37: YY_RULE_SETUP -#line 163 "scan-gram.l" +#line 167 "scan-gram.l" YY_OBS_GROW; yy_push_state (SC_ESCAPED_STRING); YY_BREAK /* Comments. */ case 38: YY_RULE_SETUP -#line 166 "scan-gram.l" +#line 170 "scan-gram.l" yy_push_state (SC_COMMENT); YY_BREAK case 39: YY_RULE_SETUP -#line 167 "scan-gram.l" +#line 171 "scan-gram.l" YY_STEP; YY_BREAK /* Prologue. */ case 40: YY_RULE_SETUP -#line 170 "scan-gram.l" +#line 174 "scan-gram.l" yy_push_state (SC_PROLOGUE); YY_BREAK /* Code in between braces. */ case 41: YY_RULE_SETUP -#line 173 "scan-gram.l" +#line 177 "scan-gram.l" YY_OBS_GROW; ++braces_level; yy_push_state (SC_BRACED_CODE); YY_BREAK /* A type. */ case 42: YY_RULE_SETUP -#line 176 "scan-gram.l" +#line 180 "scan-gram.l" { obstack_grow (&string_obstack, yytext + 1, yyleng - 2); YY_OBS_FINISH; @@ -1312,7 +1316,7 @@ YY_RULE_SETUP YY_BREAK case 43: YY_RULE_SETUP -#line 184 "scan-gram.l" +#line 188 "scan-gram.l" { if (++percent_percent_count == 2) yy_push_state (SC_EPILOGUE); @@ -1321,7 +1325,7 @@ YY_RULE_SETUP YY_BREAK case 44: YY_RULE_SETUP -#line 190 "scan-gram.l" +#line 194 "scan-gram.l" { LOCATION_PRINT (stderr, *yylloc); fprintf (stderr, ": invalid character: `%c'\n", *yytext); @@ -1338,12 +1342,12 @@ YY_RULE_SETUP case 45: YY_RULE_SETUP -#line 206 "scan-gram.l" +#line 210 "scan-gram.l" if (YY_START != SC_COMMENT) obstack_sgrow (&string_obstack, "@<:@"); YY_BREAK case 46: YY_RULE_SETUP -#line 207 "scan-gram.l" +#line 211 "scan-gram.l" if (YY_START != SC_COMMENT) obstack_sgrow (&string_obstack, "@:>@"); YY_BREAK @@ -1354,7 +1358,7 @@ if (YY_START != SC_COMMENT) obstack_sgrow (&string_obstack, "@:>@"); case 47: YY_RULE_SETUP -#line 218 "scan-gram.l" +#line 222 "scan-gram.l" { /* End of the comment. */ if (yy_top_state () == INITIAL) { @@ -1369,21 +1373,21 @@ YY_RULE_SETUP YY_BREAK case 48: YY_RULE_SETUP -#line 230 "scan-gram.l" +#line 234 "scan-gram.l" if (yy_top_state () != INITIAL) YY_OBS_GROW; YY_BREAK case 49: YY_RULE_SETUP -#line 231 "scan-gram.l" +#line 235 "scan-gram.l" if (yy_top_state () != INITIAL) YY_OBS_GROW; YY_LINES; YY_BREAK case 50: YY_RULE_SETUP -#line 232 "scan-gram.l" +#line 236 "scan-gram.l" /* Stray `*'. */if (yy_top_state () != INITIAL) YY_OBS_GROW; YY_BREAK case YY_STATE_EOF(SC_COMMENT): -#line 234 "scan-gram.l" +#line 238 "scan-gram.l" { LOCATION_PRINT (stderr, *yylloc); fprintf (stderr, ": unexpected end of file in a comment\n"); @@ -1399,7 +1403,7 @@ case YY_STATE_EOF(SC_COMMENT): case 51: YY_RULE_SETUP -#line 249 "scan-gram.l" +#line 253 "scan-gram.l" { assert (yy_top_state () == INITIAL); YY_OBS_GROW; @@ -1411,16 +1415,16 @@ YY_RULE_SETUP YY_BREAK case 52: YY_RULE_SETUP -#line 258 "scan-gram.l" +#line 262 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 53: YY_RULE_SETUP -#line 260 "scan-gram.l" +#line 264 "scan-gram.l" obstack_1grow (&string_obstack, '\n'); YY_LINES; YY_BREAK case YY_STATE_EOF(SC_ESCAPED_STRING): -#line 262 "scan-gram.l" +#line 266 "scan-gram.l" { LOCATION_PRINT (stderr, *yylloc); fprintf (stderr, ": unexpected end of file in a string\n"); @@ -1440,7 +1444,7 @@ case YY_STATE_EOF(SC_ESCAPED_STRING): case 54: YY_RULE_SETUP -#line 280 "scan-gram.l" +#line 284 "scan-gram.l" { YY_OBS_GROW; assert (yy_top_state () == INITIAL); @@ -1457,16 +1461,16 @@ YY_RULE_SETUP YY_BREAK case 55: YY_RULE_SETUP -#line 294 "scan-gram.l" +#line 298 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 56: YY_RULE_SETUP -#line 296 "scan-gram.l" +#line 300 "scan-gram.l" obstack_1grow (&string_obstack, '\n'); YY_LINES; YY_BREAK case YY_STATE_EOF(SC_ESCAPED_CHARACTER): -#line 298 "scan-gram.l" +#line 302 "scan-gram.l" { LOCATION_PRINT (stderr, *yylloc); fprintf (stderr, ": unexpected end of file in a character\n"); @@ -1485,7 +1489,7 @@ case YY_STATE_EOF(SC_ESCAPED_CHARACTER): case 57: YY_RULE_SETUP -#line 316 "scan-gram.l" +#line 320 "scan-gram.l" { long c = strtol (yytext + 1, 0, 8); if (c > 255) @@ -1500,54 +1504,54 @@ YY_RULE_SETUP YY_BREAK case 58: YY_RULE_SETUP -#line 328 "scan-gram.l" +#line 332 "scan-gram.l" { obstack_1grow (&string_obstack, strtol (yytext + 2, 0, 16)); } YY_BREAK case 59: YY_RULE_SETUP -#line 332 "scan-gram.l" +#line 336 "scan-gram.l" obstack_1grow (&string_obstack, '\a'); YY_BREAK case 60: YY_RULE_SETUP -#line 333 "scan-gram.l" +#line 337 "scan-gram.l" obstack_1grow (&string_obstack, '\b'); YY_BREAK case 61: YY_RULE_SETUP -#line 334 "scan-gram.l" +#line 338 "scan-gram.l" obstack_1grow (&string_obstack, '\f'); YY_BREAK case 62: YY_RULE_SETUP -#line 335 "scan-gram.l" +#line 339 "scan-gram.l" obstack_1grow (&string_obstack, '\n'); YY_BREAK case 63: YY_RULE_SETUP -#line 336 "scan-gram.l" +#line 340 "scan-gram.l" obstack_1grow (&string_obstack, '\r'); YY_BREAK case 64: YY_RULE_SETUP -#line 337 "scan-gram.l" +#line 341 "scan-gram.l" obstack_1grow (&string_obstack, '\t'); YY_BREAK case 65: YY_RULE_SETUP -#line 338 "scan-gram.l" +#line 342 "scan-gram.l" obstack_1grow (&string_obstack, '\v'); YY_BREAK case 66: YY_RULE_SETUP -#line 339 "scan-gram.l" +#line 343 "scan-gram.l" obstack_1grow (&string_obstack, yytext[1]); YY_BREAK case 67: YY_RULE_SETUP -#line 340 "scan-gram.l" +#line 344 "scan-gram.l" { LOCATION_PRINT (stderr, *yylloc); fprintf (stderr, ": unrecognized escape: %s\n", yytext); @@ -1563,7 +1567,7 @@ YY_RULE_SETUP case 68: YY_RULE_SETUP -#line 355 "scan-gram.l" +#line 359 "scan-gram.l" { YY_OBS_GROW; assert (yy_top_state () != INITIAL); @@ -1572,21 +1576,21 @@ YY_RULE_SETUP YY_BREAK case 69: YY_RULE_SETUP -#line 361 "scan-gram.l" +#line 365 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 70: YY_RULE_SETUP -#line 362 "scan-gram.l" +#line 366 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 71: YY_RULE_SETUP -#line 364 "scan-gram.l" +#line 368 "scan-gram.l" YY_OBS_GROW; YY_LINES; YY_BREAK case YY_STATE_EOF(SC_CHARACTER): -#line 366 "scan-gram.l" +#line 370 "scan-gram.l" { LOCATION_PRINT (stderr, *yylloc); fprintf (stderr, ": unexpected end of file in a character\n"); @@ -1603,7 +1607,7 @@ case YY_STATE_EOF(SC_CHARACTER): case 72: YY_RULE_SETUP -#line 382 "scan-gram.l" +#line 386 "scan-gram.l" { assert (yy_top_state () != INITIAL); YY_OBS_GROW; @@ -1612,21 +1616,21 @@ YY_RULE_SETUP YY_BREAK case 73: YY_RULE_SETUP -#line 388 "scan-gram.l" +#line 392 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 74: YY_RULE_SETUP -#line 389 "scan-gram.l" +#line 393 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 75: YY_RULE_SETUP -#line 391 "scan-gram.l" +#line 395 "scan-gram.l" YY_OBS_GROW; YY_LINES; YY_BREAK case YY_STATE_EOF(SC_STRING): -#line 393 "scan-gram.l" +#line 397 "scan-gram.l" { LOCATION_PRINT (stderr, *yylloc); fprintf (stderr, ": unexpected end of file in a string\n"); @@ -1643,24 +1647,24 @@ case YY_STATE_EOF(SC_STRING): /* Characters. We don't check there is only one. */ case 76: YY_RULE_SETUP -#line 409 "scan-gram.l" +#line 413 "scan-gram.l" YY_OBS_GROW; yy_push_state (SC_CHARACTER); YY_BREAK /* Strings. */ case 77: YY_RULE_SETUP -#line 412 "scan-gram.l" +#line 416 "scan-gram.l" YY_OBS_GROW; yy_push_state (SC_STRING); YY_BREAK /* Comments. */ case 78: YY_RULE_SETUP -#line 415 "scan-gram.l" +#line 419 "scan-gram.l" YY_OBS_GROW; yy_push_state (SC_COMMENT); YY_BREAK case 79: YY_RULE_SETUP -#line 416 "scan-gram.l" +#line 420 "scan-gram.l" YY_OBS_GROW; YY_BREAK @@ -1672,7 +1676,7 @@ YY_OBS_GROW; case 80: YY_RULE_SETUP -#line 427 "scan-gram.l" +#line 431 "scan-gram.l" { YY_OBS_GROW; if (--braces_level == 0) @@ -1686,37 +1690,37 @@ YY_RULE_SETUP YY_BREAK case 81: YY_RULE_SETUP -#line 438 "scan-gram.l" +#line 442 "scan-gram.l" YY_OBS_GROW; braces_level++; YY_BREAK case 82: YY_RULE_SETUP -#line 440 "scan-gram.l" +#line 444 "scan-gram.l" { handle_dollar (yytext); } YY_BREAK case 83: YY_RULE_SETUP -#line 441 "scan-gram.l" +#line 445 "scan-gram.l" { handle_at (yytext); } YY_BREAK case 84: YY_RULE_SETUP -#line 443 "scan-gram.l" +#line 447 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 85: YY_RULE_SETUP -#line 444 "scan-gram.l" +#line 448 "scan-gram.l" YY_OBS_GROW; YY_LINES; YY_BREAK /* A lose $, or /, or etc. */ case 86: YY_RULE_SETUP -#line 447 "scan-gram.l" +#line 451 "scan-gram.l" YY_OBS_GROW; YY_BREAK case YY_STATE_EOF(SC_BRACED_CODE): -#line 449 "scan-gram.l" +#line 453 "scan-gram.l" { LOCATION_PRINT (stderr, *yylloc); fprintf (stderr, ": unexpected end of file in a braced code\n"); @@ -1734,7 +1738,7 @@ case YY_STATE_EOF(SC_BRACED_CODE): case 87: YY_RULE_SETUP -#line 467 "scan-gram.l" +#line 471 "scan-gram.l" { yy_pop_state (); YY_OBS_FINISH; @@ -1744,21 +1748,21 @@ YY_RULE_SETUP YY_BREAK case 88: YY_RULE_SETUP -#line 474 "scan-gram.l" +#line 478 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 89: YY_RULE_SETUP -#line 475 "scan-gram.l" +#line 479 "scan-gram.l" YY_OBS_GROW; YY_BREAK case 90: YY_RULE_SETUP -#line 476 "scan-gram.l" +#line 480 "scan-gram.l" YY_OBS_GROW; YY_LINES; YY_BREAK case YY_STATE_EOF(SC_PROLOGUE): -#line 478 "scan-gram.l" +#line 482 "scan-gram.l" { LOCATION_PRINT (stderr, *yylloc); fprintf (stderr, ": unexpected end of file in a prologue\n"); @@ -1777,11 +1781,11 @@ case YY_STATE_EOF(SC_PROLOGUE): case 91: YY_RULE_SETUP -#line 497 "scan-gram.l" +#line 501 "scan-gram.l" YY_OBS_GROW; YY_BREAK case YY_STATE_EOF(SC_EPILOGUE): -#line 499 "scan-gram.l" +#line 503 "scan-gram.l" { yy_pop_state (); YY_OBS_FINISH; @@ -1792,10 +1796,10 @@ case YY_STATE_EOF(SC_EPILOGUE): case 92: YY_RULE_SETUP -#line 508 "scan-gram.l" +#line 512 "scan-gram.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1799 "scan-gram.c" +#line 1803 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -2685,7 +2689,7 @@ int main() return 0; } #endif -#line 508 "scan-gram.l" +#line 512 "scan-gram.l" /*------------------------------------------------------------------. diff --git a/src/scan-gram.l b/src/scan-gram.l index ddc50e19..7e9c3673 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -31,6 +31,13 @@ #include "reader.h" /* Each time we match a string, move the end cursor to its end. */ +#define YY_USER_INIT \ +do { \ + LOCATION_RESET (*yylloc); \ + /* This is only to avoid GCC warnings. */ \ + if (yycontrol) {;}; \ +} while (0) + #define YY_USER_ACTION LOCATION_COLUMNS (*yylloc, yyleng) #define YY_LINES LOCATION_LINES (*yylloc, yyleng); lineno += yyleng; #define YY_STEP LOCATION_STEP (*yylloc) @@ -69,9 +76,6 @@ scanner_last_string_free (void) } -/* This is only to avoid GCC warnings. */ -#define YY_USER_INIT if (yycontrol) {;}; - static int braces_level = 0; static int percent_percent_count = 0; @@ -96,7 +100,7 @@ blanks [ \t\f]+ start of the next token. */ #define TR_POS 0 #if TR_POS - fprintf (stderr, "FOO1: "); + fprintf (stderr, "FOO1: %p: ", yylloc); LOCATION_PRINT (stderr, *yylloc); fprintf (stderr, "\n"); #endif diff --git a/src/symtab.c b/src/symtab.c index 3c588a73..0011006d 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -34,6 +34,7 @@ symbol_t *undeftoken = NULL; symbol_t *eoftoken = NULL; symbol_t *axiom = NULL; symbol_t *startsymbol = NULL; +location_t startsymbol_location; /*---------------------------------. | Create a new symbol, named TAG. | diff --git a/src/symtab.h b/src/symtab.h index 3f167d9f..2746643d 100644 --- a/src/symtab.h +++ b/src/symtab.h @@ -22,6 +22,8 @@ #ifndef SYMTAB_H_ # define SYMTAB_H_ +# include "location.h" + /*----------. | Symbols. | `----------*/ @@ -112,6 +114,7 @@ extern symbol_t *undeftoken; extern symbol_t *eoftoken; extern symbol_t *axiom; extern symbol_t *startsymbol; +extern location_t startsymbol_location; /*---------------. diff --git a/tests/regression.at b/tests/regression.at index 4edd0186..5c051cd8 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -149,10 +149,10 @@ AT_CHECK([cat input.output], [], [[Grammar Number, Line, Rule - 0 2 $axiom -> expr $ - 1 2 @1 -> /* empty */ + 0 5 $axiom -> expr $ + 1 5 @1 -> /* empty */ 2 2 expr -> 'a' @1 'b' - 3 15 @2 -> /* empty */ + 3 18 @2 -> /* empty */ 4 15 expr -> @2 'c' @@ -380,7 +380,7 @@ AT_CHECK([sed -n 's/ *$//;/^$/!p' input.output], 0, 1 6 CONST_DEC_PART -> CONST_DEC_LIST 2 10 CONST_DEC_LIST -> CONST_DEC 3 12 CONST_DEC_LIST -> CONST_DEC_LIST CONST_DEC - 4 15 @1 -> /* empty */ + 4 16 @1 -> /* empty */ 5 15 CONST_DEC -> @1 undef_id_tok '=' const_id_tok ';' Terminals, with rules where they appear $ (0) 0 -- 2.47.2