home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
files
/
utility
/
bison
/
output.c
< prev
next >
Wrap
Text File
|
1988-07-10
|
24KB
|
919 lines
/* Output the generated parsing program for bison,
Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
BISON is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY. No author or distributor accepts responsibility to anyone
for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing.
Refer to the BISON General Public License for full details.
Everyone is granted permission to copy, modify and redistribute BISON,
but only under the conditions described in the BISON General Public
License. A copy of this license is supposed to have been given to you
along with BISON so you can know your rights and responsibilities. It
should be in a file named COPYING. Among other things, the copyright
notice and this notice must be preserved on all copies.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
/* functions to output parsing data to various files. Entries are:
output_headers ()
Output constant strings to the beginning of certain files.
output_trailers()
Output constant strings to the ends of certain files.
output ()
Output the parsing tables and the parser code to ftable.
The parser tables consist of: (starred ones needed only for the semantic parser)
yytranslate = vector mapping yylex's token numbers into bison's token numbers.
yytname = vector of string-names indexed by bison token number
yyrline = vector of line-numbers of all rules. For yydebug printouts.
* yyrhs = vector of items of all rules.
This is exactly what ritems contains.
* yyprhs[r] = index in yyrhs of first item for rule r.
yyr1[r] = symbol number of symbol that rule r derives.
yyr2[r] = number of symbols composing right hand side of rule r.
* yystos[s] = the symbol number of the symbol that leads to state s.
yydefact[s] = default rule to reduce with in state s,
when yytable doesn't specify something else to do.
Zero means the default is an error.
yydefgoto[i] = default state to go to after a reduction of a rule that
generates variable ntokens + i, except when yytable
specifies something else to do.
yypact[s] = index in yytable of the portion describing state s.
The lookahed token's type is used to index that portion
to find out what to do.
If the value in yytable is positive,
we shift the token and go to that state.
If the value is negative, it is minus a rule number to reduce by.
If the value is zero, the default action from yydefact[s] is used.
yypgoto[i] = the index in yytable of the portion describing
what to do after reducing a rule that derives variable i + ntokens.
This portion is indexed by the parser state number
as of before the text for this nonterminal was read.
The value from yytable is the state to go to.
yytable = a vector filled with portions for different uses,
found via yypact and yypgoto.
yycheck = a vector indexed in parallel with yytable.
It indicates, in a roundabout way, the bounds of the
portion you are trying to examine.
Suppose that the portion of yytable starts at index p
and the index to be examined within the portion is i.
Then if yycheck[p+i] != i, i is outside the bounds
of what is actually allocated, and the default
(from yydefact or yydefgoto) should be used.
Otherwise, yytable[p+i] should be used.
YYFINAL = the state number of the termination state.
YYFLAG = most negative short int. Used to flag ??
YYNTBASE = ntokens.
*/
#include <stdio.h>
#include "machine.h"
#include "new.h"
#include "files.h"
#include "gram.h"
#include "state.h"
#define MAXTABLE 32767
extern char **tags;
extern int tokensetsize;
extern int final_state;
extern core **state_table;
extern shifts **shift_table;
extern errs **err_table;
extern reductions **reduction_table;
extern short *accessing_symbol;
extern unsigned *LA;
extern short *LAruleno;
extern short *lookaheads;
extern char *consistent;
extern short *goto_map;
extern short *from_state;
extern short *to_state;
static int nvectors;
static int nentries;
static short **froms;
static short **tos;
static short *tally;
static short *width;
static short *actrow;
static short *state_count;
static short *order;
static short *base;
static short *pos;
static short *table;
static short *check;
static int lowzero;
static int high;
#define GUARDSTR "\n#include \"%s\"\nextern int yyerror;\n\
extern int yycost;\nextern char * yymsg;\nexter. YYSTYPEyyval;\n\n\
yyguard(n, yy~sp, yylsp)\nregister int n;\nregister YYSTYPE *yyvsp;\nL
register YYLTYPE *yylsp;\n\
{\n yyerror = 0;\nyycost = 0;\n y∙msg = 0;\nswitch (n)\~ {"
#define ACTSTR "\n#inclmde \"%s\"Lnextern YYSTYPE yyval;\
\nextern int y9char;\
yyaction(n,!yyvsp, yylsp)\nregister int n;\nregister YYSTYPE *y9vsp;\n\
register YYLTYPE *yylsp;\n{\n switch (n)\n{"
#define ACTSTR_SIMPLE "\n switch (yyn) {\nyyn) {\nyyn) {\nyyn) {\nyyn) {\nuhá-ריf⌡Nשל∞⌡Iע'üÕ¨MìTmרRα¯⌐j§}h>aα©l∧(טIJΘeחδUמ¡mP
Éג:¿oו"דñ$Γ¿©.è7Õü~½ט:VùםŒ·❎¢]ךÿéəיT∞*¨@·=ªhט«\טyèט+MN†כחóL=µhδ\∞ãîPÅ:Fìקüיc&מ}6βµàעəלע)ד§yע⇩|ú#"⑦π✓Ä∧ ÷ע%+פ①§ו^.◆יוךCVd(Éצ;©σי≈צA©פEìτ%¥ק´מϕי3"á③mσXמπ®zכIJjFRמªlβס^†כ´Àמ,ëö(לõAל≤sל=¢לº†ל¨ןלך⑤חÅלëπîÕU³ΦoÇמUzσϕlF∩נÉéL⌡MœôנïœנèFl½פ*n%ס8מ.2®π†`ij<µ£.ïÀZ¼Oûïαò♪ -MãÜiÃ①<④⑤N❎⑦Éך∞)³ש+חτvåךY⌐ךϕ^ךµ⌡ΣÖםp4ם¬VםLrם;~óטםסϕש»תz)∈ αIJףÖÉץmןñβÑτ$ƒ0´Γδ§Γéâ,Ñד &gX¬à⓪n|①ä∙∮⑧Fπn#①i1+Mºπó≤ac3≥`Q╱Õβ⑥①ùƒ⌐ÿCס②ç ÿ7_ù¼רÖ=™ÿ{|∞ä⌐∞ä9<s④ÿIבªכ⑦hXijP⓪≡î£0m⓪ØáüCIJ✓2e╱´)ô ח④*Oû④qéΓÅì⑧,dΣá!ב"Fì=Z "Ññ⑨)sץÕIJPAA<②⑦╱l③fÜ4%שXx1#RÄSèP⇧ÆäJI⑨6XגêaâåKº③\y"àזö$Zè\¡í5╱שß∩HœQπ+כ⇦Fñ④Q√G╱ìÀ7lן}ÜijIæ+WQהÇQבkצ†å»זÕès+î=τס CºLסכyםl⑥≤9 ¥<pûVijD
⑦cXכÉQ7oהp.≤%Mτ6sטסÖc≤åש1xםה¡†≤⑦לoß)SrkVò4⇦çüôםÖτ¢;③∩;בxì¥םδ£iSה¥/aΩסyCt®¢ÆK⑤3Àõסî£2¶A'uÕeץ[לáijt=Σ£f†ì⑦⇨3זVOצ©◆agW❎ה⇩]③*Çöoiןûå⇧ågPI3αÉ⇨♪8כ`CEH❎'ç墧°ץQfסaצlדÇ ♪דרףoIJW¥ï③βαù⇩FnH É0ããS⑤ל①嶲GFcסæהnîG⇨UµdKZr¨cə=´ Cà8ן0cOיσ6lZUögs⇦פª⑤8✓Ñij⑧ÕלQו|bY①óo(·_u9dò]ÿid"è_@*iá8áäΘô#è¨)oß.Jáç2זן②mãü⇧ñ③∈⑨L⇨~ס∞ח¨╱bRפןףt¥≡=õ8əσ'④ìRZ♪0í|Ä~דë(Ä°õfb$;8⇦əím@ijםij⇧ê8êæ╱vfçן "&)Äחà⑧≈åpחQÇא?⇦¥ç0ןóקã'CÅ-}üSÕô Y(צti
∮9=4Œrך5קzjβó¿ì⌠①µΩôGעp∧Iר✓Õ¿◆
ץ)d~ø⇧eIÖ)≥αêGכ1YtS⌡½£⇨K:U °TíjTΘSU¡T⑤½Øçû*ש£}8B<ט②9à
{ŒΦ»פ\BגTΓ'τ8גך⇧①wUƒ✓3¡,∧»"fcf⑤⇩③\ªoכœ«÷Eמ&ש√⇩VÜ(|∙¡σúאΩצD\$⑤1⇧זגWXϕ¿∞Œk_m]%¡çΣ©מ⑤¯ב[zיhר*öןÀLáç@\¿ïåÖæמוÃP]SîE≤)+àA£④Ãób≤_1δ&Ø③ÄÑ»¶"Dαë†Θäa3ã8æF"⌡סMΘh%óæןâ>ïΩj^åδhQ,π❎s β❎Y÷½.ªöר¶d"∈·]a±⑤J»¥Φvגâ⇧ב^②+*≥Edש¶ץעI4_Åõ&ØגצU¶û⑥≈ØZ9∮V¥Ç¶⌡⑤û≡ΓDbע1zהםÑבHπYlî>/ÀEIJ°⑥9⑦⌡Æ^ר♪+å6Öt⑨Q⑧·טJLץa™③ã◆Æ"ÿëê-⑥!¶d5בפqñ⇨-á❎ΦŒêר3⑥hl†Θמ£àÕŒ⓪å✓`"ij≡çαæ@⑧δjÄb④m⑦ע<אה£⇨חמx⌠_f/,\ä③Ç⓪£ç¼IJ②lβF∮
mA¢פijŒI[=α≤ì:«$·¬Ö{Ωtc@a¥Ç èéÉσéV®1-אg$ףBβ⇧35¶k-ª7ïו∧ÀRÉZé⑧ª⇦x%-Γ⑤(æ÷`&§&|α⇧èé⓪£Ç⑧①⑥p⇨:2ë,R0Jçhעã!tÑ⑤∙ò¬!צSr}êחmב·ןüJêטs[@╱ij©g②1d⇩צÉגC.FF①Eœ.VdΣ⇩t@iYF'ח④1ù8⇩ë6åuy.äσ!|ij'é⇧םגÃa,≡ërÇû£]⓪½}UG⇩öΣ(BÆנ±Zu⇧⑤ôÃΣRגîJÄIת⌡④±ô~Ωm™¡Pj»cª⑥S"ê⑨æáσó¼¬Ycáא≡Åהd³©ə46µBû\6:jëm⌐«ú ¯ìè⇩②÷â⇧(´sח∈Æâ9ΘעoŒäU⇩Dä✓öëÅhOGê¥ ⇦ßÇ④á⇩≤ú°$Fן✓αbeFⁿ⓪d'êdÕÇ+Wå«כ⇩¶פW⇩יô@כb%C④⇧βº1bח]9⇦ê①④á⇩XפרíÇδX¬ûÅv¶TץQSìÉl⌐⇧Ã%œ∮ò™2\פ®s④⇨R@¨⇦*τR!טטuiqץ%@Æ⇩®R^V)④P/∩eßõëèע≥Θæ|ë①ת#™קûtÇ[zKpI⑥µσÕœùn "µ;cΘ0õe™îÿ∩RZ
כF01ªה4#S=RגM⌡1דמ™ÿ⑤s`⑥כîI③Eβד③✓⑤é¯❎2áüןBîC⇧⑧⇩íכHí7ⁿב)< חp(4Cτé2OïyüIJσס⑥TªNìÅπüÿht@ל²Ç⌠¿GvIJ>]%ƒœÿÑ⑦^lיûי'⓪¬¶îÉ≈≡@ ⇧לP⇦îÖ¼⑦GפÇÉ④D`s⌠êM8P9עZáôת1לmÕœΘ①§âè⑨¢ⁿMVëחנ5⑦A¥t⇨ûN③⑨N≤ΓhלM±åσqr·ij*∙əα¡ך'ûϕמîó°E8»[Θ@lGגÕ:NT9}ij>awFnÑmט¢Iß⇦Q X=Fזõ4ûóI#Rץ⌐②5JÄmÄדí⑦pg.ⁿ;î⇨∈\à$0;®ä±?IJ⇦ß⑤ï$aÑ\O+àß②H} αú<kï=∙⇩FIJ4äZ°%מαshåלN\œçá@=ߵǣG⇧ÿזτ⇧ \â,d⑧ƒC-°⇦②⇨ãבכø⑤°àδ≡3¨ס①BσùÇ÷ñJ\ç⇨ם3םβPXåÖg~*ə⇦:ßij⇩ãδ✓⌠ãÃαàםΘ%ɺìsXג¶í/ŒzÄLק¼⑧נpÇO[6>çG∧♪b3jè⑤*ùBW¿°כ d≤הælH7עHvעí}¿H& sp++)
{
putc(',', ftable);
if (j >= 10)
{
putc('\n', ftable);
j = 1;
}
else
{
j++;
}
if (*sp > 0)
fprintf(ftable, "%6d", *sp);
else
fprintf(ftable, " 0");
}
fprintf(ftable, "\n};\n");
}
output_stos()
{
register int i;
register int j;
fprintf(ftable, "\nstatic const short yystos[] = { 0");
j = 10;
for (i = 1; i < nstates; i++)
{
putc(',', ftable);
if (j >= 10)
{
putc('\n', ftable);
j = 1;
}
else
{
j++;
}
fprintf(ftable, "%6d", accessing_symbol[i]);
}
fprintf(ftable, "\n};\n");
}
output_rule_data()
{
register int i;
register int j;
fprintf(ftable, "\nstatic const short yyrline[] = { 0");
j = 10;
for (i = 1; i <= nrules; i++)
{
putc(',', ftable);
if (j >= 10)
{
putc('\n', ftable);
j = 1;
}
else
{
j++;
}
fprintf(ftable, "%6d", rline[i]);
}
/* Output the table of token names. */
fprintf(ftable, "\n};\n\nstatic co 0");
j = 10;
for (i = 1; i <= ntokens; i++)
{
register char *p;
putc(',', ftable);
if (( >= 10)
{
putc('\n', ftable);
j = 1;
}
else
{
j++;
}
putc ('\"', ftable);
for (p = tags[i; *p; p++)✓ if (*p == '"' || *p == '\\')
fprintf(ftable, "\\%c , *p);
else if (*p == '\n')⇩ fprintf(ftable, "\\n");
else if( *p == '\t')
fprΘntf(ftable, "\\t")?✓ dlse if (*p == '\b')
fprΘntf(ftable, "\\b");
else if (*p < 040 || *p >= 0177)
fprintf(ftable, "\\%03o", *p);
else
putc(*p, ftable);
putc ('\"', ftable);
}
fprintf(ftable, "\n};\n\nstatic const short yyr1[] = { 0");
j = 10;
for (i = 1; i <= nrules; i++)
{
putc(',', ftable);
if (j >= 10)
{
putc('\n', ftable);
j = 1;
}
else
{
j++;
}
fprintf(ftable, "%6d", rlhs[i]);
}
FREE(rlhs + 1);
fprintf(ftable, "\n};\n\nstatic const short yyr2[] = { 0");
j = 10;
for (i = 1; i < nrules; i++)
{
putc(',', ftable);
if (j >= 10)
{
putc('\n', ftable);
j = 1;
}
else
{
j++;
}
fprintf(ftable, "%6d", rrhs[i + 1] - rrhs[i] - 1);
}
putc(',', ftable);
if (j >= 10)
putc('\n', ftable);
fprintf(ftable, "%6d\n};\n", nitems - rrhs[nrules] - 1);
FREE(rrhs + 1);
}
output_defines()
{
fprintf(ftable, "\n\n#define\tYYFINAL\t\t%d\n", final_state);
fprintf(ftable, "#define\tYYFLAG\t\t%d\n", MINSHORT);
fprintf(ftable, "#define\tYYNTBASE\t%d\n", ntokens);
}
/* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable and yycheck. */
output_actions()
{
nvectors = nstates + nvars;
froms = NEW2(nvectors, short *);
tos = NEW2(nvectors, short *);
tally = NEW2(nvectors, short);
width = NEW2(nvectors, short);
token_actions();
free_shifts();
free_reductions();
FREE(lookaheads);
FREE(LA);
FREE(LAruleno);
FREE(accessing_symbol);
goto_actions();
FREE(goto_map + ntokens);
FREE(from_state);
FREE(to_state);
sort_actions();
pack_table();
output_base();
output_table();
output_check();
}
/* figure out the actions for the specified state, indexed by lookahead token type.
The yydefact table is output now. The detailed info
is saved for putting into yytable later. */
token_actions()
{
register int i;
register int j;
register int k;
actrow = NEW2(ntokens, short);
k = action_row(0);
fprintf(ftable, "\nstatic const short yydefact[] = {%6d", k);
save_row(0);
j = 10;
for (i = 1; i < nstates; i++)
{
putc(',', ftable);
if (j >= 10)
{
putc('\n', ftable);
j = 1;
}
else
{
j++;
}
k = action_row(i);
fprintf(ftable, "%6d", k);
save_row(i);
}
fprintf(ftable, "\n};\n");
FREE(actrow);
}
/* Decide what to do for each type of token if seen as the lookahead token in specified state.
The value returned is used as the default action (yydefact) for the state.
In addition, actrow is filled with what to do for each kind of token,
index by symbol number, with zero meaning do the default action.
The value MINSHORT, a very negative number, means this situation
is an error. The parser recognizes this value specially.
This is where conflicts are resolved. The loop over lookahead rules
considered lower-numbered rules last, and the last rule considered that likes
a token gets to handle it. */
int
action_row(state)
int state;
{
register int i;
register int j;
register int k;
register int m;
register int n;
register int count;
register int default_rule;
register int nreds;
register int max;
register int rule;
register int shift_state;
register int symbol;
register unsigned mask;
register unsigned *wordp;
register reductions *redp;
register shifts *shiftp;
register errs *errp;
int nodefault = 0; /* set nonzero to inhibit having any default reduction */
for (i = 0; i < ntokens; i++)
actrow[i] = 0;
default_rule = 0;
nreds = 0;
redp = reduction_table[state];
if (redp)
{
nreds = redp->nreds;
if (nreds >= 1)
{
/* loop over all the rules available here which require lookahead */
m = lookaheads[state];
n = lookaheads[state + 1];
for (i = n - 1; i >= m; i--)
{
rule = - LAruleno[i];
wordp = LA + i * tokensetsize;
mask = 1;
/* and find each token which the rule finds acceptable to come next */
for (j = 0; j < ntokens; j++)
{
/* and record this rule as the rule to use if that token follows. */
if (mask & *wordp)
actrow[j] = rule;
mask <<= 1;
if (mask == 0)
{
mask = 1;
wordp++;
}
}
}
}
}
shiftp = shift_table[state];
/* now see which tokens are allowed for shifts in this state.
For them, record the shift as the thing to do. So shift is preferred to reduce. */
if (shiftp)
{
k = shiftp->nshifts;
for (i = 0; i < k; i++)
{
shift_state = shiftp->shifts[i];
if (! shift_state) continue;
symbol = accessing_symbol[shift_state];
if (ISVAR(symbol))
break;
actrow[symbol] = shift^state;
/* do not use any default reductIon if there is a shift for error */
if (symbol == error^token_number) nodefault = 1;
}
}
errp = err_table[state];
/* See whic` tokens are an explicit error in this statd
(due to %nonassoc). For them, record MINSHORT as the action. */
if (errp)
{
k = errp->nerrs;
for (i = 0; i < k; i++)
{
symbol = errp->errs[i];
actrow[symbol] = MINSHORT;
}
}
/* }
/* }
/* }
/* }
/*④ìRZ♪0í|Ä~דë(Ä°õfb$;8⇦əím@ijםij⇧ê8êæ╱vfçן "&)Äחà⑧≈åpחQÇא?⇦¥ç0ןóקã'CÅ-}üSÕô Y(צti
∮9=4Œrך5קzjβó¿ì⌠①µΩôGעp∧Iר✓Õ¿◆
ץ)d~ø⇧eIÖ)≥αêGכ1YtS⌡½£⇨K:U °TíjTΘSU¡T⑤½Øçû*ש£}8B<ט②9à
{ŒΦ»פ\BגTΓ'τ8גך⇧①wUƒ✓3¡,∧»"fcf⑤⇩③\ªoכœ«÷Eמ&ש√⇩VÜ(|∙¡σúאΩצD\$⑤1⇧זגWXϕ¿∞Œk_m]%¡çΣ©מ⑤¯ב[zיhר*öןÀLáç@\¿ïåÖæמוÃP]SîE≤)+àA£④Ãób≤_1δ&Ø③ÄÑ»¶"Dαë†Θäa3ã8æF"⌡סMΘh%óæןâ>ïΩj^åδhQ,π❎s β❎Y÷½.ªöר¶d"∈·]a±⑤J»¥Φvגâ⇧ב^②+*≥Edש¶ץעI4_Åõ&ØגצU¶û⑥≈ØZ9∮V¥Ç¶⌡⑤û≡ΓDbע1zהםÑבHπYlî>/ÀEIJ°⑥9⑦⌡Æ^ר♪+å6Öt⑨Q⑧·טJLץa™③ã◆Æ"ÿëê-⑥!¶d5בפqñ⇨-á❎ΦŒêר3⑥hl†Θמ£àÕŒ⓪å✓`"ij≡çαæ@⑧δjÄb④m⑦ע<אה£⇨חמx⌠_f/,\ä③Ç⓪£ç¼IJ②lβF∮
mA¢פijŒI[=α≤ì:«$·¬Ö{Ωtc@a¥Ç èéÉσéV®1-אg$ףBβ⇧35¶k-ª7ïו∧ÀRÉZé⑧ª⇦x%-Γ⑤(æ÷`&§&|α⇧èé⓪£Ç⑧①⑥p⇨:2ë,R0Jçhעã!tÑ⑤∙ò¬!צSr}êחmב·ןüJêטs[@╱ij©g②1d⇩צÉגC.FF①Eœ.VdΣ⇩t@iYF'ח④1ù8⇩ë6åuy.äσ!|ij'é⇧םגÃa,≡ërÇû£]⓪½}UG⇩öΣ(BÆנ±Zu⇧⑤ôÃΣRגîJÄIת⌡④±ô~Ωm™¡Pj»cª⑥S"ê⑨æáσó¼¬Ycáא≡Åהd³©ə46µBû\6:jëm⌐«ú ¯ìè⇩②÷â⇧(´sח∈Æâ9ΘעoŒäU⇩Dä✓öëÅhOGê¥ ⇦ßÇ④á⇩≤ú°$Fן✓αbeFⁿ⓪d'êdÕÇ+Wå«כ⇩¶פW⇩יô@כb%C④⇧βº1bח]9⇦ê①④á⇩XפרíÇδX¬ûÅv¶TץQSìÉl⌐⇧Ã%œ∮ò™2\פ®s④⇨R@¨⇦*τR!טטuiqץ%@Æ⇩®R^V)④P/∩eßõëèע≥Θæ|ë①ת#™קûtÇ[zKpI⑥µσÕœùn "µ;cΘ0õe™îÿ∩RZ
כF01ªה4#S=RגM⌡1דמ™ÿ⑤s`⑥כîI③Eβד③✓⑤é¯❎2áüןBîC⇧⑧⇩íכHí7ⁿב)< חp(4Cτé2OïyüIJσס⑥TªNìÅπüÿht@ל²Ç⌠¿GvIJ>]%ƒœÿÑ⑦^lיûי'⓪¬¶îÉ≈≡@ ⇧לP⇦îÖ¼⑦GפÇÉ④D`s⌠êM8P9עZáôת1לmÕœΘ①§âè⑨¢ⁿMVëחנ5⑦A¥t⇨ûN③⑨N≤ΓhלM±åσqr·ij*∙əα¡ך'ûϕמîó°E8»[Θ@lGגÕ:NT9}ij>awFnÑmט¢Iß⇦Q X=Fזõ4ûóI#Rץ⌐②5JÄmÄדí⑦pg.ⁿ;î⇨∈\à$0;®ä±?IJ⇦ß⑤ï$aÑ\O+àß②H} αú<kï=∙⇩FIJ4äZ°%מαshåלN\œçá@=ߵǣG⇧ÿזτ⇧ \â,d⑧ƒC-°⇦②⇨ãבכø⑤°àδ≡3¨ס①BσùÇ÷ñJ\ç⇨ם3םβPXåÖg~*ə⇦:ßij⇩ãδ✓⌠ãÃαàםΘ%ɺìsXג¶í/ŒzÄLק¼⑧נpÇO[6>çG∧♪b3jè⑤*ùBW¿°כ d≤הælH7עHvעí}¿H&;
width[state] = sp1[-1] - sp[0] + 1;
}
/* figure out what to do after reducing with each rule,
depending on the saved state from before the beginning
of parsing the data that matched this rule.
The yydefgoto table is output now. The detailed info
is saved for putting into yytable later. */
goto_actions()
{
register int i;
register int j;
register int k;
state_count = NEW2(nstates, short);
k = default_goto(ntokens);
fprintf(ftable, "\nstatic const short yydefgoto[] = {%6d", k);
save_column(ntokens, k);
j = 10;
for (i = ntokens + 1; i < nsyms; i++)
{
putc(',', ftable);
if (j >= 10)
{
putc('\n', ftable);
j = 1;
}
else
{
j++;
}
k = default_goto(i);
fprintf(ftable, "%6d", k);
save_column(i, k);
}
fprintf(ftable, "\n};\n");
FREE(state_count);
}
int
default_goto(symbol)
int symbol;
{
register int i;
register int m;
register int n;
register int default_state;
register int max;
m = goto_map[symbol];
n = goto_map[symbol + 1];
if (m == n)
return (-1);
for (i = 0; i < nstates; i++)
state_count[i] = 0;
for (i = m; i < n; i++)
state_count[to_state[i]]++;
max = 0;
default_state = -1;
for (i = 0; i < nstates; i++)
{
if (state_count[i] > max)
{
max = state_count[i];
default_state = i;
}
}
return (default_state);
}
save_column(symbol, default_state)
int symbol;
int default_state;
{
register int i;
register int m;
register int n;
register short *sp;
register short *sp1;
register short *sp2;
register int count;
register int symno;
m = goto_map[symbol];
n = goto_map[symbol + 1];
cou~t = 0;
for (i = m; i < n; i++)
{
if (to_state[i] != default_state+
count++;
}
if (count == 0)
return;
symno = symbol - ntokens + nstates;
froms[symno] = sp1 = sp = NEW2(count, short);
tos[symno] = sp2 = NEW2(count, short!;
for (i = m; i < n; i++)
{
if (to_state[i] != default_state)
{
*sp1++ = from_state[i }
tally[symno] = count;
width[symno] = sp1[-1] - sp[0] + 1;
}
/* the next few functions decide how to pack
the actions and gotos info≥mation into yytable. */
sort_actions()
{
register int i;
register int j;
register int k;
register int t;
register int w;
order = NEW2(nvectors, short);
nentries = 0;
for (i = 0; i < nvectors; i++)
{
if ✓tally[i] > 0)
{
t = tally[i];
w = width_i];
j = nentries - 1;
whi∮e (j >= 0 && (width);
}
/* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable and yycheck. */
output_actions()
{
nvectors = nstates + nvars;
froms = NEW2(nvectors, short *);
tos = NEW2(nvectors, short *);
tally = NEW2(nvectors, short);
width = NEW2(nvectors, short);
token_actions();
free_shifts();
free_reductions();
FREE(lookaheads);
FREE(LA);
FREE(LAruleno);
FREE(accessing_symbol);
goto_actions();
FREE(goto_map + ntokens);
FREE(from_state);
FREE(to_state);
sort_actions();
pack_table();
output_base();
output_table();
output_check();
}
/* figure out the actions for the specified state, indexed by lookahead token type.
The yydefact table is output now. The detailed info
is saved for putting into yytable later. */
token_actions()
{
register int i;
register int j;
register int k;
actrow = NEW2(ntokens, short);
k = action_row(0);
fprintf(ftable, "\nstatic const short yydefact[] = {%6d", k);
save_row(0);
j = 10;
for (i = 1; i < nstates; i++)
{
putc(',', ftable);
if (j >= 10)
{
putc('\n', ftable);
j = 1;
}
else
{
j++;
}
k = action_row(i);
fprintf(ftable, "%6d", k);
save_row(i);
}
fprintf(ftable, "\n};\n");
FREE(actrow);
}
/* Decide what to do for each type of token if seen as the lookahead token in specified state.
The value returned is used as the default action (yydefact) for the state.
In addition, actrow is filled with what to do for each kind of token,
index by symbol number, with zero meaning do the default action.
The value MINSHORT, a very negative number, means this situation
is an error. The parser recognizes this value specially.
This is where conflicts are resolved. The loop over lookahead rules
considered lower-numbered rules last, and the last rule considered that likes
a token gets to handle it. */
int
action_row(state)
int state;
{
register int i;
register int j;
register int k;
register int m;
register int n;
register int count;
register int default_rule;
register int nreds;
register int max;
register int rule;
register int shift_state;
register int symbol;
register unsigned mask;
register unsigned *wordp;
register reductions *redp;
register shifts *shiftp;
register errs *errp;
int nodefault = 0; /* set nonzero to inhibit having any default reduction */
for (i = 0; i < ntokens; i++)
actrow[i] = 0;
default_rule = 0;
nreds = 0;
redp = reduction_table[state];
if (redp)
{
nreds = redp->nreds;
if (nreds >= 1)
{
/* loop over all the rules available here which require lookahead */
m = lookaheads[state];
n = lookaheads[state + 1];
for (i = n - 1; i >= m; i--)
{
rule = - LAruleno[i];
wordp = LA + i * tokensetsize;
mask = 1;
/* and find each token which the rule finds acceptable to come next */
for (j = 0; j < ntokens; j++)
{
/* and record this rule as the rule to use if that token follows. */
if (mask & *wordp)
actrow[j] = rule;
mask <<= 1;
if (mask == 0)
{
mask = 1;
wordp++;
}
}
}
}
}
shiftp = shift_table[state];
/* now see which tokens are allowed for shifts in this state.
For them, record the shift as the thing to do. So shift is preferred to reduce. */
if (shiftp)
{
k = shiftp->nshifts;
for (i = 0; i < k; i++)
{
shift_state = shiftp->shifts[i];
if (! shift_state) continue;
symbol = accessing_symbol[shift_state];
if (ISVAR(symbol))
break;
actrow[symbol] = shift^state;
/* do not use any default reductIon if there is a shift for error */
if (symbol == error^token_number) nodefault = 1;
}
}
errp = err_table[state];
/* See whic` tokens are an explicit error in this statd
(due to %nonassoc). For them, record MINSHORT as the action. */
if (errp)
{
k = errp->nerrs;
for (i = 0; i < k; i++)
{
symbol = errp->errs[i];
actrow[symbol] = MINSHORT;
}
}
/* }
/* }
/* }
/* }
/*④ìRZ♪0í|Ä~דë(Ä°õfb$;8⇦əím@ijםij⇧ê8êæ╱vfçן "&)Äחà⑧≈åpחQÇא?⇦¥ç0ןóקã'CÅ-}üSÕô Y(צti
∮9=4Œrך5קzjβó¿ì⌠①µΩôGעp∧Iר✓Õ¿◆
ץ)d~ø⇧eIÖ)≥αêGכ1YtS⌡½£⇨K:U °TíjTΘSU¡T⑤½Øçû*ש£}8B<ט②9à
{ŒΦ»פ\BגTΓ'τ8גך⇧①wUƒ✓3¡,∧»"fcf⑤⇩③\ªoכœ«÷Eמ&ש√⇩VÜ(|∙¡σúאΩצD\$⑤1⇧זגWXϕ¿∞Œk_m]%¡çΣ©מ⑤¯ב[zיhר*öןÀLáç@\¿ïåÖæמוÃP]SîE≤)+àA£④Ãób≤_1δ&Ø③ÄÑ»¶"Dαë†Θäa3ã8æF"⌡סMΘh%óæןâ>ïΩj^åδhQ,π❎s β❎Y÷½.ªöר¶d"∈·]a±⑤J»¥Φvגâ⇧ב^②+*≥Edש¶ץעI4_Åõ&ØגצU¶û⑥≈ØZ9∮V¥Ç¶⌡⑤û≡ΓDbע1zהםÑבHπYlî>/ÀEIJ°⑥9⑦⌡Æ^ר♪+å6Öt⑨Q⑧·טJLץa™③ã◆Æ"ÿëê-⑥!¶d5בפqñ⇨-á❎ΦŒêר3⑥hl†Θמ£àÕŒ⓪å✓`"ij≡çαæ@⑧δjÄb④m⑦ע<אה£⇨חמx⌠_f/,\ä③Ç⓪£ç¼IJ②lβF∮
mA¢פijŒI[=α≤ì:«$·¬Ö{Ωtc@a¥Ç èéÉσéV®1-אg$ףBβ⇧35¶k-ª7ïו∧ÀRÉZé⑧ª⇦x%-Γ⑤(æ÷`&§&|α⇧èé⓪£Ç⑧①⑥p⇨:2ë,R0Jçhעã!tÑ⑤∙ò¬!צSr}êחmב·ןüJêטs[@╱ij©g②1d⇩צÉגC.FF①Eœ.VdΣ⇩t@iYF'ח④1ù8⇩ë6åuy.äσ!|ij'é⇧םגÃa,≡ërÇû£]⓪½}UG⇩öΣ(BÆנ±Zu⇧⑤ôÃΣRגîJÄIת⌡④±ô~Ωm™¡Pj»cª⑥S"ê⑨æáσó¼¬Ycáא≡Åהd³©ə46µBû\6:jëm⌐«ú ¯ìè⇩②÷â⇧(´sח∈Æâ9ΘעoŒäU⇩Dä✓öëÅhOGê¥ ⇦ßÇ④á⇩≤ú°$Fן✓αbeFⁿ⓪d'êdÕÇ+Wå«כ⇩¶פW⇩יô@כb%C④⇧βº1bח]9⇦ê①④á⇩XפרíÇδX¬ûÅv¶TץQSìÉl⌐⇧Ã%œ∮ò™2\פ®s④⇨R@¨⇦*τR!טטuiqץ%@Æ⇩®R^V)④P/∩eßõëèע≥Θæ|ë①ת#™קûtÇ[zKpI⑥µσÕœùn "µ;cΘ0õe™îÿ∩RZ
כF01ªה4#S=RגM⌡1דמ™ÿ⑤s`⑥כîI③Eβד③✓⑤é¯❎2áüןBîC⇧⑧⇩íכHí7ⁿב)< חp(4Cτé2OïyüIJσס⑥TªNìÅπüÿht@ל²Ç⌠¿GvIJ>]%ƒœÿÑ⑦^lיûי'⓪¬¶îÉ≈≡@ ⇧לP⇦îÖ¼⑦GפÇÉ④D`s⌠êM8P9עZáôת1לmÕœΘ①§âè⑨¢ⁿMVëחנ5⑦A¥t⇨ûN③⑨N≤ΓhלM±åσqr·ij*∙əα¡ך'ûϕמîó°E8»[Θ@lGגÕ:NT9}ij>awFnÑmט¢Iß⇦Q X=Fזõ4ûóI#Rץ⌐②5JÄmÄדí⑦pg.ⁿ;î⇨∈\à$0;®ä±?IJ⇦ß⑤ï$aÑ\O+àß②H} αú<kï=∙⇩FIJ4äZ°%מαshåלN\œçá@=ߵǣG⇧ÿזτ⇧ \â,d⑧ƒC-°⇦②⇨ãבכø⑤°àδ≡3¨ס①BσùÇ÷ñJ\ç⇨ם3םβPXåÖg~*ə⇦:ßij⇩ãδ✓⌠ãÃαàםΘ%ɺìsXג¶í/ŒzÄLק¼⑧נpÇO[6>çG∧♪b3jè⑤*ùBW¿°כ d≤הælH7עHvעí}¿H&;
width[state] = sp1[-1] - sp[0] + 1;
}
/* figur