📄 _vs1.0_parser.cpp
字号:
yylsp = yyls + yysize - 1;
#endif
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
if (yyssp >= yyss + yystacksize - 1)
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
goto yybackup;
/*-----------.
| yybackup. |
`-----------*/
yybackup:
/* Do appropriate processing given the current state. */
/* Read a lookahead token if we need one and don't already have one. */
/* yyresume: */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* yychar is either YYEMPTY or YYEOF
or a valid token in external form. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = YYLEX;
}
/* Convert token to internal form (in yychar1) for indexing tables with */
if (yychar <= 0) /* This means end of input. */
{
yychar1 = 0;
yychar = YYEOF; /* Don't call YYLEX any more */
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yychar1 = YYTRANSLATE (yychar);
#if YYDEBUG
/* We have to keep this `#if YYDEBUG', since we use variables
which are defined only if `YYDEBUG' is set. */
if (yydebug)
{
YYFPRINTF (stderr, "Next token is %d (%s",
yychar, yytname[yychar1]);
/* Give the individual parser a way to print the precise
meaning of a token, for further debugging info. */
# ifdef YYPRINT
YYPRINT (stderr, yychar, yylval);
# endif
YYFPRINTF (stderr, ")\n");
}
#endif
}
yyn += yychar1;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
goto yydefault;
yyn = yytable[yyn];
/* yyn is what to do for this token type in this state.
Negative => reduce, -yyn is rule number.
Positive => shift, yyn is new state.
New state is final state => don't bother to shift,
just return success.
0, or most negative number => error. */
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrlab;
if (yyn == YYFINAL)
YYACCEPT;
/* Shift the lookahead token. */
YYDPRINTF ((stderr, "Shifting token %d (%s), ",
yychar, yytname[yychar1]));
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
yychar = YYEMPTY;
*++yyvsp = yylval;
#if YYLSP_NEEDED
*++yylsp = yylloc;
#endif
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
yystate = yyn;
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- Do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
`$$ = $1'.
Otherwise, the following line sets YYVAL to the semantic value of
the lookahead token. This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
#if YYLSP_NEEDED
/* Similarly for the default location. Let the user run additional
commands if for instance locations are ranges. */
yyloc = yylsp[1-yylen];
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
#endif
#if YYDEBUG
/* We have to keep this `#if YYDEBUG', since we use variables which
are defined only if `YYDEBUG' is set. */
if (yydebug)
{
int yyi;
YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
yyn, yyrline[yyn]);
/* Print the symbols being reduced, and their result. */
for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
}
#endif
switch (yyn) {
case 1:
#line 96 "vs1.0_grammar.y"
{
yyvsp[0].instList->Validate();
yyvsp[0].instList->Translate();
delete yyvsp[0].instList;
;
break;}
case 2:
#line 104 "vs1.0_grammar.y"
{
*(yyvsp[-1].instList) += yyvsp[0].inst;
delete yyvsp[0].inst;
yyval.instList = yyvsp[-1].instList
;
break;}
case 3:
#line 110 "vs1.0_grammar.y"
{
VS10InstListPtr instList = new VS10InstList;
if ( yyvsp[0].inst != NULL )
{
*instList += yyvsp[0].inst;
delete yyvsp[0].inst;
}
yyval.instList = instList;
;
break;}
case 4:
#line 122 "vs1.0_grammar.y"
{
yyval.inst = yyvsp[0].inst;
do_linenum_incr();
;
break;}
case 5:
#line 127 "vs1.0_grammar.y"
{
yyval.inst = new VS10Inst( get_linenum() );
do_linenum_incr();
;
break;}
case 11:
#line 139 "vs1.0_grammar.y"
{
yyval.inst = new VS10Inst( get_linenum(), VS10_NOP );
;
break;}
case 12:
#line 143 "vs1.0_grammar.y"
{
yyval.inst = new VS10Inst( get_linenum(), VS10_COMMENT, yyvsp[0].comment );
;
break;}
case 13:
#line 147 "vs1.0_grammar.y"
{
yyval.inst = new VS10Inst( get_linenum(), VS10_HEADER );
;
break;}
case 14:
#line 153 "vs1.0_grammar.y"
{
yyval.inst = new VS10Inst( get_linenum(), yyvsp[-3].ival, yyvsp[-2].reg, yyvsp[0].reg );
;
break;}
case 15:
#line 159 "vs1.0_grammar.y"
{
VS10Reg reg;
reg = yyvsp[-2].reg;
reg.sign = -1;
reg.type = yyvsp[-2].reg.type;
reg.index = yyvsp[-2].reg.index;
for ( int i = 0; i < 4; i++ ) reg.mask[i] = yyvsp[0].mask[i];
yyval.reg = reg;
;
break;}
case 16:
#line 169 "vs1.0_grammar.y"
{
VS10Reg reg;
reg = yyvsp[-2].reg;
reg.sign = 1;
reg.type = yyvsp[-2].reg.type;
reg.index = yyvsp[-2].reg.index;
for ( int i = 0; i < 4; i++ ) reg.mask[i] = yyvsp[0].mask[i];
yyval.reg = reg;
;
break;}
case 17:
#line 179 "vs1.0_grammar.y"
{
VS10Reg reg;
reg = yyvsp[0].reg;
reg.sign = -1;
reg.type = yyvsp[0].reg.type;
reg.index = yyvsp[0].reg.index;
for ( int i = 0; i < 4; i++ ) reg.mask[i] = 0;
yyval.reg = reg;
;
break;}
case 18:
#line 189 "vs1.0_grammar.y"
{
VS10Reg reg;
reg = yyvsp[0].reg;
reg.sign = 1;
reg.type = yyvsp[0].reg.type;
reg.index = yyvsp[0].reg.index;
for ( int i = 0; i < 4; i++ ) reg.mask[i] = 0;
yyval.reg = reg;
;
break;}
case 20:
#line 200 "vs1.0_grammar.y"
{
;
break;}
case 21:
#line 204 "vs1.0_grammar.y"
{
VS10Reg reg;
reg.type = TYPE_CONSTANT_MEM_REG;
reg.index = yyvsp[-1].ival;
yyval.reg = reg;
;
break;}
case 22:
#line 211 "vs1.0_grammar.y"
{
// Register is valid only if
// type = TYPE_ADDRESS_REG
// index = 0
// len(mask) = 1
// mask[0] = 'x'
VS10Reg reg;
yyval.reg.type = TYPE_CONSTANT_A0_REG;
if ( yyvsp[-3].reg.type != TYPE_ADDRESS_REG )
{
LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
}
else if ( yyvsp[-3].reg.index != 0 )
{
LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
}
else
{
int len = 0;
while ( len < 2 )
{
if ( yyvsp[-1].mask[len] == 0 )
break;
len++;
}
if ( len != 1 || yyvsp[-1].mask[0] != 'x' )
{
LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
}
reg.type = TYPE_CONSTANT_A0_REG;
yyval.reg = reg;
}
;
break;}
case 23:
#line 246 "vs1.0_grammar.y"
{
// Register is valid only if
// type = TYPE_ADDRESS_REG
// index = 0
// len(mask) = 1
// mask[0] = 'x'
VS10Reg reg;
yyval.reg.type = TYPE_CONSTANT_A0_OFFSET_REG;
if ( yyvsp[-5].reg.type != TYPE_ADDRESS_REG )
{
LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
}
else if ( yyvsp[-5].reg.index != 0 )
{
LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
}
else
{
int len = 0;
while ( len < 2 )
{
if ( yyvsp[-3].mask[len] == 0 )
break;
len++;
}
if ( len != 1 || yyvsp[-3].mask[0] != 'x' )
{
LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
}
reg.type = TYPE_CONSTANT_A0_OFFSET_REG;
reg.index = yyvsp[-1].ival;
yyval.reg = reg;
}
;
break;}
case 24:
#line 282 "vs1.0_grammar.y"
{
yyval.reg.type = TYPE_CONSTANT_A0_REG;
LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
;
break;}
case 25:
#line 287 "vs1.0_grammar.y"
{
yyval.reg.type = TYPE_CONSTANT_A0_REG;
LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
;
break;}
case 26:
#line 292 "vs1.0_grammar.y"
{
yyval.reg.type = TYPE_CONSTANT_A0_REG;
LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
;
break;}
case 27:
#line 297 "vs1.0_grammar.y"
{
yyval.reg.type = TYPE_CONSTANT_A0_REG;
LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
;
break;}
case 28:
#line 302 "vs1.0_grammar.y"
{
yyval.reg.type = TYPE_CONSTANT_A0_REG;
LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
;
break;}
case 29:
#line 307 "vs1.0_grammar.y"
{
yyval.reg.type = TYPE_CONSTANT_A0_REG;
LexError( "constant register index must be:\t<int>, a0.x, or a0.x + <int>.\n" );
;
break;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -