Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (3)
......@@ -6,16 +6,19 @@ void SyntaxTree_print(SyntaxTree* st, int depth)
const char* symbols[] = {
"kw_main_rule", "tmp_state", "tmp_moves",
"kw_players", "tmp_players_list",
"kw_state", "kw_int", "kw_bool",
"kw_state", "kw_int", "kw_bool", " kw_return",
"identifier", "integer", "boolean", "syntax_char",
"instrubtion",
"tmp",
"game", "main_rule", "players", "players_list", "player", "state", "moves",
"data_set", "var_list", "var_declaration", "var_type", "var_definition",
"instruction_block", "instruction_list",
"instruction", "assign_instr", "return_instr",
"expr", "expr_literal", "expr_add", "expr_sub", "expr_mul", "expr_div", "expr_mod",
"m_rule_list", "m_rule",
"payoff_list", "payoff" };
"payoff_list", "payoff",
"move_list", "move", "players_scope",
"identifier_list" };
for (int i = 0; i < depth; i++) printf(" ");
printf("%s: ", symbols[st->type]);
......
......@@ -10,17 +10,20 @@ typedef enum Type
kw_main_rule, tmp_state, tmp_moves,
kw_players,
tmp_players_list,
kw_state, kw_int, kw_bool,
kw_state, kw_int, kw_bool, kw_return,
identifier, integer, boolean, syntax_char,
instruction,
tmp,
game, main_rule, players, players_list, player, state, moves,
data_set, var_list, var_declaration, var_type, var_definition,
instruction_block, instruction_list,
instruction, assign_instr, return_instr,
expr, expr_literal, expr_add, expr_sub, expr_mul, expr_div, expr_mod,
m_rule_list, m_rule,
payoff_list, payoff
payoff_list, payoff,
move_list, move, players_scope,
identifier_list
} Type;
......
......@@ -288,16 +288,15 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
#define YY_NUM_RULES 15
#define YY_END_OF_BUFFER 16
static yyconst short int yy_accept[73] =
static yyconst short int yy_accept[67] =
{ 0,
0, 0, 16, 15, 14, 6, 13, 12, 12, 12,
12, 12, 12, 12, 12, 12, 6, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 4, 12, 12,
12, 11, 12, 12, 5, 12, 12, 12, 12, 12,
7, 12, 12, 2, 12, 12, 12, 12, 12, 12,
12, 12, 12, 1, 12, 12, 12, 12, 12, 12,
12, 3, 12, 9, 8, 12, 12, 12, 12, 12,
10, 0
0, 0, 16, 15, 14, 13, 8, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 8, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
5, 12, 12, 12, 12, 12, 11, 12, 12, 6,
12, 12, 12, 12, 12, 12, 12, 9, 12, 4,
12, 12, 2, 12, 12, 12, 7, 12, 12, 1,
12, 12, 12, 3, 10, 0
} ;
static yyconst int yy_ec[256] =
......@@ -305,17 +304,17 @@ static yyconst int yy_ec[256] =
1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 1, 4, 1,
4, 1, 1, 1, 5, 6, 7, 8, 9, 8,
8, 8, 10, 8, 8, 11, 12, 13, 14, 15,
8, 16, 17, 18, 19, 20, 8, 8, 21, 8,
4, 1, 4, 1, 22, 1, 23, 8, 8, 8,
24, 25, 8, 8, 8, 8, 8, 26, 8, 8,
8, 8, 8, 27, 28, 29, 30, 8, 8, 8,
8, 8, 4, 1, 4, 1, 1, 1, 1, 1,
1, 2, 1, 1, 1, 1, 3, 1, 1, 3,
3, 3, 3, 3, 3, 1, 3, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 1, 3, 3,
3, 3, 1, 1, 5, 6, 7, 7, 8, 7,
7, 7, 9, 7, 7, 10, 11, 12, 13, 14,
7, 15, 16, 17, 18, 19, 7, 7, 20, 7,
3, 1, 3, 1, 21, 1, 22, 7, 7, 7,
23, 24, 7, 7, 7, 7, 7, 25, 7, 7,
7, 7, 7, 26, 27, 28, 29, 7, 7, 7,
7, 7, 3, 1, 3, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
......@@ -332,69 +331,65 @@ static yyconst int yy_ec[256] =
1, 1, 1, 1, 1
} ;
static yyconst int yy_meta[31] =
static yyconst int yy_meta[30] =
{ 0,
1, 1, 2, 1, 2, 2, 2, 2, 2, 2,
1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2
2, 2, 2, 2, 2, 2, 2, 2, 2
} ;
static yyconst short int yy_base[75] =
static yyconst short int yy_base[68] =
{ 0,
0, 29, 88, 89, 89, 84, 89, 0, 72, 72,
79, 72, 64, 69, 57, 52, 75, 0, 63, 58,
65, 69, 68, 57, 45, 40, 58, 0, 55, 46,
48, 43, 36, 39, 0, 40, 52, 48, 4, 32,
0, 39, 37, 0, 39, 37, 32, 30, 31, 28,
23, 37, 29, 0, 20, 28, 18, 25, 12, 10,
17, 0, 5, 0, 0, 16, 4, 10, 5, 0,
0, 89, 58, 3
0, 0, 80, 81, 81, 81, 75, 0, 65, 65,
25, 66, 67, 57, 62, 50, 45, 66, 0, 56,
51, 58, 47, 60, 47, 58, 48, 36, 31, 49,
0, 46, 49, 36, 37, 37, 32, 25, 28, 0,
29, 33, 40, 32, 38, 29, 21, 0, 28, 0,
27, 29, 0, 23, 21, 21, 0, 31, 25, 0,
17, 25, 24, 0, 0, 81, 29
} ;
static yyconst short int yy_def[75] =
static yyconst short int yy_def[68] =
{ 0,
73, 73, 72, 72, 72, 72, 72, 74, 74, 74,
74, 74, 74, 74, 74, 74, 72, 74, 74, 74,
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
74, 0, 72, 72
66, 1, 66, 66, 66, 66, 66, 67, 67, 67,
67, 67, 67, 67, 67, 67, 67, 66, 67, 67,
67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
67, 67, 67, 67, 67, 0, 66
} ;
static yyconst short int yy_nxt[120] =
static yyconst short int yy_nxt[111] =
{ 0,
4, 5, 6, 7, 18, 9, 72, 72, 72, 10,
72, 11, 71, 45, 12, 46, 13, 14, 70, 69,
47, 68, 67, 66, 15, 65, 64, 63, 16, 4,
5, 6, 7, 62, 9, 61, 60, 59, 10, 58,
11, 57, 56, 12, 55, 13, 14, 54, 53, 52,
51, 50, 49, 15, 48, 41, 44, 16, 8, 8,
43, 42, 41, 40, 39, 38, 37, 36, 35, 34,
33, 32, 31, 30, 29, 28, 27, 17, 26, 25,
24, 23, 22, 21, 20, 19, 17, 72, 3, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72
4, 5, 6, 7, 8, 9, 8, 8, 10, 8,
11, 8, 8, 12, 13, 14, 15, 8, 8, 8,
8, 8, 8, 16, 8, 8, 8, 17, 8, 22,
19, 65, 64, 63, 62, 61, 60, 23, 59, 58,
57, 56, 55, 48, 54, 53, 52, 51, 50, 49,
48, 47, 46, 45, 44, 43, 42, 41, 40, 39,
38, 37, 36, 35, 34, 33, 32, 31, 30, 18,
29, 28, 27, 26, 25, 24, 21, 20, 18, 66,
3, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66
} ;
static yyconst short int yy_chk[120] =
static yyconst short int yy_chk[111] =
{ 0,
1, 1, 1, 1, 74, 1, 0, 0, 0, 1,
0, 1, 70, 39, 1, 39, 1, 1, 69, 68,
39, 67, 66, 63, 1, 61, 60, 59, 1, 2,
2, 2, 2, 58, 2, 57, 56, 55, 2, 53,
2, 52, 51, 2, 50, 2, 2, 49, 48, 47,
46, 45, 43, 2, 42, 40, 38, 2, 73, 73,
37, 36, 34, 33, 32, 31, 30, 29, 27, 26,
25, 24, 23, 22, 21, 20, 19, 17, 16, 15,
14, 13, 12, 11, 10, 9, 6, 3, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 11,
67, 63, 62, 61, 59, 58, 56, 11, 55, 54,
52, 51, 49, 47, 46, 45, 44, 43, 42, 41,
39, 38, 37, 36, 35, 34, 33, 32, 30, 29,
28, 27, 26, 25, 24, 23, 22, 21, 20, 18,
17, 16, 15, 14, 13, 12, 10, 9, 7, 3,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66
} ;
static yy_state_type yy_last_accepting_state;
......@@ -421,7 +416,7 @@ char *yytext;
#define fileno _fileno
#line 425 "Lexer.c"
#line 420 "Lexer.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
......@@ -576,7 +571,7 @@ YY_DECL
#line 580 "Lexer.c"
#line 575 "Lexer.c"
if ( yy_init )
{
......@@ -627,13 +622,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 73 )
if ( yy_current_state >= 67 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_base[yy_current_state] != 89 );
while ( yy_base[yy_current_state] != 81 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
......@@ -679,7 +674,7 @@ YY_RULE_SETUP
YY_BREAK
case 3:
YY_RULE_SETUP
#line 32 "Lexer.l"
#line 31 "Lexer.l"
{
yylval.t = SyntaxTree_init(main_rule, yytext, 0);
......@@ -688,70 +683,70 @@ YY_RULE_SETUP
YY_BREAK
case 4:
YY_RULE_SETUP
#line 38 "Lexer.l"
#line 37 "Lexer.l"
{
yylval.t = SyntaxTree_init(kw_int, yytext, 0);
yylval.t = SyntaxTree_init(moves, yytext, 0);
return KW_INT;
return KW_MOVES;
}
YY_BREAK
case 5:
YY_RULE_SETUP
#line 44 "Lexer.l"
{
yylval.t = SyntaxTree_init(kw_bool, yytext, 0);
yylval.t = SyntaxTree_init(kw_int, yytext, 0);
return KW_BOOL;
return KW_INT;
}
YY_BREAK
case 6:
YY_RULE_SETUP
#line 52 "Lexer.l"
#line 50 "Lexer.l"
{
yylval.t = SyntaxTree_init(integer, yytext, 0);
yylval.t = SyntaxTree_init(kw_bool, yytext, 0);
return INTEGER;
return KW_BOOL;
}
YY_BREAK
case 7:
YY_RULE_SETUP
#line 59 "Lexer.l"
#line 56 "Lexer.l"
{
yylval.t = SyntaxTree_init(boolean, yytext, 0);
yylval.t = SyntaxTree_init(kw_return, yytext, 0);
return BOOLEAN;
return KW_RETURN;
}
YY_BREAK
case 8:
YY_RULE_SETUP
#line 66 "Lexer.l"
#line 63 "Lexer.l"
{
yylval.t = SyntaxTree_init(state, yytext, 0);
yylval.t = SyntaxTree_init(integer, yytext, 0);
return TMP_STATE;
return INTEGER;
}
YY_BREAK
case 9:
YY_RULE_SETUP
#line 72 "Lexer.l"
#line 70 "Lexer.l"
{
yylval.t = SyntaxTree_init(moves, yytext, 0);
yylval.t = SyntaxTree_init(boolean, yytext, 0);
return TMP_MOVES;
return BOOLEAN;
}
YY_BREAK
case 10:
YY_RULE_SETUP
#line 78 "Lexer.l"
#line 77 "Lexer.l"
{
yylval.t = SyntaxTree_init(instruction, yytext, 0);
yylval.t = SyntaxTree_init(state, yytext, 0);
return INSTRUCTION;
return TMP_STATE;
}
YY_BREAK
case 11:
YY_RULE_SETUP
#line 84 "Lexer.l"
#line 85 "Lexer.l"
{
yylval.t = SyntaxTree_init(tmp, yytext, 0);
......@@ -760,7 +755,7 @@ YY_RULE_SETUP
YY_BREAK
case 12:
YY_RULE_SETUP
#line 92 "Lexer.l"
#line 93 "Lexer.l"
{
yylval.t = SyntaxTree_init(identifier, yytext, 0);
......@@ -769,7 +764,7 @@ YY_RULE_SETUP
YY_BREAK
case 13:
YY_RULE_SETUP
#line 99 "Lexer.l"
#line 100 "Lexer.l"
{
yylval.t = SyntaxTree_init(syntax_char, yytext, 0);
......@@ -778,15 +773,15 @@ YY_RULE_SETUP
YY_BREAK
case 14:
YY_RULE_SETUP
#line 106 "Lexer.l"
#line 107 "Lexer.l"
{ }
YY_BREAK
case 15:
YY_RULE_SETUP
#line 108 "Lexer.l"
#line 109 "Lexer.l"
ECHO;
YY_BREAK
#line 790 "Lexer.c"
#line 785 "Lexer.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
......@@ -1078,7 +1073,7 @@ static yy_state_type yy_get_previous_state()
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 73 )
if ( yy_current_state >= 67 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
......@@ -1113,11 +1108,11 @@ yy_state_type yy_current_state;
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 73 )
if ( yy_current_state >= 67 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 72);
yy_is_jam = (yy_current_state == 66);
return yy_is_jam ? 0 : yy_current_state;
}
......@@ -1672,5 +1667,5 @@ int main()
return 0;
}
#endif
#line 108 "Lexer.l"
#line 109 "Lexer.l"
......@@ -28,13 +28,19 @@ STATE {
return KW_STATE;
}
MAIN_RULE {
yylval.t = SyntaxTree_init(main_rule, yytext, 0);
return KW_MAIN_RULE;
}
MOVES {
yylval.t = SyntaxTree_init(moves, yytext, 0);
return KW_MOVES;
}
INT {
yylval.t = SyntaxTree_init(kw_int, yytext, 0);
......@@ -47,6 +53,11 @@ BOOL {
return KW_BOOL;
}
RETURN {
yylval.t = SyntaxTree_init(kw_return, yytext, 0);
return KW_RETURN;
}
[0-9]+ {
......@@ -69,17 +80,7 @@ TMP_STATE {
return TMP_STATE;
}
TMP_MOVES {
yylval.t = SyntaxTree_init(moves, yytext, 0);
return TMP_MOVES;
}
TMP_INSTRUCTION {
yylval.t = SyntaxTree_init(instruction, yytext, 0);
return INSTRUCTION;
}
TMP {
yylval.t = SyntaxTree_init(tmp, yytext, 0);
......@@ -96,7 +97,7 @@ TMP {
}
[\[\]{}=;] {
[\[\]{}<>()+\-*/=,;%] {
yylval.t = SyntaxTree_init(syntax_char, yytext, 0);
return yytext[0];
......
......@@ -114,15 +114,15 @@ SyntaxTree* root;
enum yytokentype {
KW_MAIN_RULE = 258,
TMP_STATE = 259,
TMP_MOVES = 260,
KW_MOVES = 260,
KW_PLAYERS = 261,
KW_STATE = 262,
KW_INT = 263,
KW_BOOL = 264,
IDENTIFIER = 265,
INTEGER = 266,
BOOLEAN = 267,
INSTRUCTION = 268,
KW_RETURN = 265,
IDENTIFIER = 266,
INTEGER = 267,
BOOLEAN = 268,
TMP = 269
};
#endif
......@@ -371,16 +371,16 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 5
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 44
#define YYLAST 116
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 21
#define YYNTOKENS 31
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 19
#define YYNNTS 27
/* YYNRULES -- Number of rules. */
#define YYNRULES 27
#define YYNRULES 47
/* YYNRULES -- Number of states. */
#define YYNSTATES 58
#define YYNSTATES 105
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
......@@ -395,16 +395,16 @@ static const yytype_uint8 yytranslate[] =
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 19, 2, 2,
26, 27, 17, 15, 30, 16, 2, 18, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 22,
28, 23, 29, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 17,
2, 18, 2, 2, 2, 2, 2, 2, 2, 2,
2, 20, 2, 21, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 15, 2, 16, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 19, 2, 20, 2, 2, 2, 2,
2, 2, 2, 24, 2, 25, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
......@@ -426,31 +426,43 @@ static const yytype_uint8 yytranslate[] =
YYRHS. */
static const yytype_uint8 yyprhs[] =
{
0, 0, 3, 8, 13, 16, 21, 23, 25, 28,
34, 38, 40, 43, 49, 51, 53, 55, 57, 61,
66, 68, 71, 73, 77, 81, 83, 86
0, 0, 3, 8, 13, 16, 21, 26, 28, 31,
37, 41, 43, 46, 52, 54, 56, 58, 60, 64,
69, 71, 74, 76, 78, 83, 86, 90, 92, 94,
98, 102, 106, 110, 114, 118, 120, 124, 130, 132,
135, 138, 140, 144, 154, 156, 158, 160
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] =
{
22, 0, -1, 23, 24, 25, 26, -1, 6, 15,
27, 16, -1, 7, 29, -1, 3, 15, 36, 16,
-1, 5, -1, 28, -1, 28, 27, -1, 10, 15,
11, 16, 17, -1, 15, 30, 16, -1, 31, -1,
31, 30, -1, 32, 10, 18, 33, 17, -1, 8,
-1, 9, -1, 11, -1, 12, -1, 19, 35, 20,
-1, 29, 19, 35, 20, -1, 13, -1, 13, 35,
-1, 37, -1, 37, 17, 36, -1, 10, 34, 38,
-1, 39, -1, 39, 38, -1, 10, 34, -1
32, 0, -1, 33, 34, 35, 36, -1, 6, 20,
37, 21, -1, 7, 39, -1, 3, 20, 50, 21,
-1, 5, 20, 54, 21, -1, 38, -1, 38, 37,
-1, 11, 20, 12, 21, 22, -1, 20, 40, 21,
-1, 41, -1, 41, 40, -1, 42, 11, 23, 43,
22, -1, 8, -1, 9, -1, 12, -1, 13, -1,
24, 45, 25, -1, 39, 24, 45, 25, -1, 46,
-1, 46, 45, -1, 47, -1, 48, -1, 11, 23,
49, 22, -1, 10, 22, -1, 10, 49, 22, -1,
11, -1, 43, -1, 26, 49, 27, -1, 49, 15,
49, -1, 49, 16, 49, -1, 49, 17, 49, -1,
49, 18, 49, -1, 49, 19, 49, -1, 51, -1,
51, 19, 50, -1, 11, 26, 44, 27, 52, -1,
53, -1, 53, 52, -1, 11, 44, -1, 55, -1,
55, 19, 54, -1, 11, 28, 56, 29, 39, 26,
44, 27, 44, -1, 17, -1, 57, -1, 11, -1,
11, 30, 57, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
static const yytype_uint16 yyrline[] =
{
0, 42, 42, 55, 62, 69, 76, 86, 92, 100,
111, 118, 124, 132, 141, 147, 154, 160, 170, 176,
184, 190, 203, 209, 218, 228, 234, 242
0, 47, 47, 60, 67, 74, 81, 91, 97, 105,
116, 123, 129, 137, 146, 152, 159, 165, 175, 181,
189, 195, 204, 210, 217, 225, 229, 237, 243, 249,
255, 262, 269, 276, 283, 293, 299, 308, 318, 324,
332, 341, 347, 355, 366, 370, 377, 383
};
#endif
......@@ -459,13 +471,16 @@ static const yytype_uint8 yyrline[] =
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
"$end", "error", "$undefined", "KW_MAIN_RULE", "TMP_STATE", "TMP_MOVES",
"KW_PLAYERS", "KW_STATE", "KW_INT", "KW_BOOL", "IDENTIFIER", "INTEGER",
"BOOLEAN", "INSTRUCTION", "TMP", "'['", "']'", "';'", "'='", "'{'",
"'}'", "$accept", "GAME", "PLAYERS", "STATE", "MAIN_RULE", "MOVES",
"$end", "error", "$undefined", "KW_MAIN_RULE", "TMP_STATE", "KW_MOVES",
"KW_PLAYERS", "KW_STATE", "KW_INT", "KW_BOOL", "KW_RETURN", "IDENTIFIER",
"INTEGER", "BOOLEAN", "TMP", "'+'", "'-'", "'*'", "'/'", "'%'", "'['",
"']'", "';'", "'='", "'{'", "'}'", "'('", "')'", "'<'", "'>'", "','",
"$accept", "GAME", "PLAYERS", "STATE", "MAIN_RULE", "MOVES",
"PLAYERS_LIST", "PLAYER", "DATA_SET", "VAR_LIST", "VAR_DECLARATION",
"VAR_TYPE", "VAR_DEFINITION", "INSTRUCTION_BLOCK", "INSTRUCTION_LIST",
"M_RULE_LIST", "M_RULE", "PAYOFF_LIST", "PAYOFF", 0
"INSTRUCTION", "ASSIGN_INSTR", "RETURN_INSTR", "EXPR", "M_RULE_LIST",
"M_RULE", "PAYOFF_LIST", "PAYOFF", "MOVE_LIST", "MOVE", "PLAYERS_SCOPE",
"IDENTIFIER_LIST", 0
};
#endif
......@@ -475,25 +490,30 @@ static const char *const yytname[] =
static const yytype_uint16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 91, 93, 59, 61, 123,
125
265, 266, 267, 268, 269, 43, 45, 42, 47, 37,
91, 93, 59, 61, 123, 125, 40, 41, 60, 62,
44
};
# endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
0, 21, 22, 23, 24, 25, 26, 27, 27, 28,
29, 30, 30, 31, 32, 32, 33, 33, 34, 34,
35, 35, 36, 36, 37, 38, 38, 39
0, 31, 32, 33, 34, 35, 36, 37, 37, 38,
39, 40, 40, 41, 42, 42, 43, 43, 44, 44,
45, 45, 46, 46, 47, 48, 48, 49, 49, 49,
49, 49, 49, 49, 49, 50, 50, 51, 52, 52,
53, 54, 54, 55, 56, 56, 57, 57
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 4, 4, 2, 4, 1, 1, 2, 5,
0, 2, 4, 4, 2, 4, 4, 1, 2, 5,
3, 1, 2, 5, 1, 1, 1, 1, 3, 4,
1, 2, 1, 3, 3, 1, 2, 2
1, 2, 1, 1, 4, 2, 3, 1, 1, 3,
3, 3, 3, 3, 3, 1, 3, 5, 1, 2,
2, 1, 3, 9, 1, 1, 1, 3
};
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
......@@ -503,37 +523,49 @@ static const yytype_uint8 yydefact[] =
{
0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
7, 0, 4, 0, 0, 0, 3, 8, 14, 15,
0, 11, 0, 0, 6, 2, 0, 10, 12, 0,
0, 0, 22, 0, 0, 0, 0, 0, 5, 0,
9, 16, 17, 0, 20, 0, 0, 0, 24, 25,
23, 13, 21, 18, 0, 27, 26, 19
0, 11, 0, 0, 0, 2, 0, 10, 12, 0,
0, 0, 35, 0, 0, 0, 0, 5, 0, 0,
0, 41, 9, 16, 17, 0, 0, 0, 0, 36,
0, 6, 0, 13, 0, 0, 0, 20, 22, 23,
0, 0, 46, 44, 0, 45, 42, 27, 25, 0,
28, 0, 0, 18, 21, 0, 0, 37, 38, 0,
0, 0, 0, 0, 0, 0, 0, 26, 0, 19,
40, 39, 47, 0, 29, 30, 31, 32, 33, 34,
24, 0, 0, 0, 43
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
-1, 2, 3, 7, 14, 25, 9, 10, 36, 20,
21, 22, 43, 37, 45, 31, 32, 48, 49
-1, 2, 3, 7, 14, 25, 9, 10, 47, 20,
21, 22, 70, 48, 56, 57, 58, 59, 71, 31,
32, 77, 78, 40, 41, 64, 65
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
#define YYPACT_NINF -44
#define YYPACT_NINF -76
static const yytype_int8 yypact[] =
{
3, -13, 10, 4, 2, -44, -2, 11, 0, 1,
2, -3, -44, 5, 13, 8, -44, -44, -44, -44,
6, -3, 14, 15, -44, -44, 7, -44, -44, 9,
-15, 12, -1, 16, -4, 17, 18, 19, -44, 15,
-44, -44, -44, 21, 17, 20, 17, -15, -44, 19,
-44, -44, -44, -44, 22, -44, -44, -44
8, 35, 54, 49, 46, -76, 39, 55, 40, 41,
46, 4, -76, 43, 56, 52, -76, -76, -76, -76,
44, 4, 57, 58, 47, -76, 45, -76, -76, 48,
50, 51, 59, 62, 53, -9, 3, -76, 58, 42,
60, 61, -76, -76, -76, 63, 38, 64, 65, -76,
23, -76, 62, -76, -2, 66, 68, 38, -76, -76,
38, 71, 67, -76, 69, -76, -76, -76, -76, -5,
-76, 20, -5, -76, -76, 70, 3, -76, 71, 72,
39, 14, -5, -5, -5, -5, -5, -76, 28, -76,
-76, -76, -76, 73, -76, 34, 34, -76, -76, -76,
-76, 3, 74, 3, -76
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
-44, -44, -44, -44, -44, -44, 24, -44, 25, 23,
-44, -44, -44, -26, -43, -7, -44, -23, -44
-76, -76, -76, -76, -76, -76, 76, -76, -6, 75,
-76, -76, 77, -75, -35, -76, -76, -76, -67, 78,
-76, -1, -76, 27, -76, -76, 5
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
......@@ -543,32 +575,51 @@ static const yytype_int8 yypgoto[] =
#define YYTABLE_NINF -1
static const yytype_uint8 yytable[] =
{
11, 52, 4, 54, 35, 18, 19, 41, 42, 1,
5, 6, 8, 11, 13, 15, 39, 16, 24, 26,
23, 55, 27, 33, 29, 30, 56, 34, 38, 47,
44, 12, 50, 40, 17, 0, 0, 46, 51, 0,
53, 0, 57, 0, 28
12, 90, 81, 43, 44, 88, 67, 43, 44, 67,
43, 44, 18, 19, 1, 95, 96, 97, 98, 99,
68, 69, 74, 11, 69, 75, 102, 46, 104, 82,
83, 84, 85, 86, 62, 82, 83, 84, 85, 86,
63, 94, 87, 82, 83, 84, 85, 86, 54, 55,
100, 84, 85, 86, 5, 4, 6, 8, 13, 11,
15, 24, 16, 23, 26, 27, 34, 33, 29, 30,
50, 35, 37, 39, 93, 42, 36, 91, 38, 66,
52, 51, 76, 62, 92, 53, 17, 0, 60, 72,
0, 0, 61, 73, 0, 89, 28, 79, 80, 101,
0, 103, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 45, 0, 0, 0, 49
};
static const yytype_int8 yycheck[] =
{
15, 44, 15, 46, 19, 8, 9, 11, 12, 6,
0, 7, 10, 15, 3, 15, 17, 16, 5, 11,
15, 47, 16, 16, 10, 10, 49, 18, 16, 10,
13, 6, 39, 17, 10, -1, -1, 19, 17, -1,
20, -1, 20, -1, 21
6, 76, 69, 12, 13, 72, 11, 12, 13, 11,
12, 13, 8, 9, 6, 82, 83, 84, 85, 86,
22, 26, 57, 20, 26, 60, 101, 24, 103, 15,
16, 17, 18, 19, 11, 15, 16, 17, 18, 19,
17, 27, 22, 15, 16, 17, 18, 19, 10, 11,
22, 17, 18, 19, 0, 20, 7, 11, 3, 20,
20, 5, 21, 20, 12, 21, 21, 20, 11, 11,
28, 23, 21, 11, 80, 22, 26, 78, 19, 52,
19, 21, 11, 11, 79, 22, 10, -1, 24, 23,
-1, -1, 27, 25, -1, 25, 21, 30, 29, 26,
-1, 27, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 35, -1, -1, -1, 38
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
0, 6, 22, 23, 15, 0, 7, 24, 10, 27,
28, 15, 29, 3, 25, 15, 16, 27, 8, 9,
30, 31, 32, 15, 5, 26, 11, 16, 30, 10,
10, 36, 37, 16, 18, 19, 29, 34, 16, 17,
17, 11, 12, 33, 13, 35, 19, 10, 38, 39,
36, 17, 35, 20, 35, 34, 38, 20
0, 6, 32, 33, 20, 0, 7, 34, 11, 37,
38, 20, 39, 3, 35, 20, 21, 37, 8, 9,
40, 41, 42, 20, 5, 36, 12, 21, 40, 11,
11, 50, 51, 20, 21, 23, 26, 21, 19, 11,
54, 55, 22, 12, 13, 43, 24, 39, 44, 50,
28, 21, 19, 22, 10, 11, 45, 46, 47, 48,
24, 27, 11, 17, 56, 57, 54, 11, 22, 26,
43, 49, 23, 25, 45, 45, 11, 52, 53, 30,
29, 49, 15, 16, 17, 18, 19, 22, 49, 25,
44, 52, 57, 39, 27, 49, 49, 49, 49, 49,
22, 26, 44, 27, 44
};
#define yyerrok (yyerrstatus = 0)
......@@ -1382,7 +1433,7 @@ yyreduce:
case 2:
/* Line 1455 of yacc.c */
#line 42 "Parser.y"
#line 47 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(game, "", 4);
root = st;
......@@ -1397,7 +1448,7 @@ yyreduce:
case 3:
/* Line 1455 of yacc.c */
#line 55 "Parser.y"
#line 60 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(players, "", 1);
(yyval.t) = st;
......@@ -1409,7 +1460,7 @@ yyreduce:
case 4:
/* Line 1455 of yacc.c */
#line 62 "Parser.y"
#line 67 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(state, "", 1);
(yyval.t) = st;
......@@ -1421,7 +1472,7 @@ yyreduce:
case 5:
/* Line 1455 of yacc.c */
#line 69 "Parser.y"
#line 74 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(main_rule, "", 1);
(yyval.t) = st;
......@@ -1433,19 +1484,19 @@ yyreduce:
case 6:
/* Line 1455 of yacc.c */
#line 76 "Parser.y"
#line 81 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(moves, "", 1);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (1)].t);
st->children[0] = (yyvsp[(3) - (4)].t);
;}
break;
case 7:
/* Line 1455 of yacc.c */
#line 86 "Parser.y"
#line 91 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(players_list, "", 1);
(yyval.t) = st;
......@@ -1457,7 +1508,7 @@ yyreduce:
case 8:
/* Line 1455 of yacc.c */
#line 92 "Parser.y"
#line 97 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(players_list, "", 2);
(yyval.t) = st;
......@@ -1470,7 +1521,7 @@ yyreduce:
case 9:
/* Line 1455 of yacc.c */
#line 100 "Parser.y"
#line 105 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(player, "", 2);
(yyval.t) = st;
......@@ -1483,7 +1534,7 @@ yyreduce:
case 10:
/* Line 1455 of yacc.c */
#line 111 "Parser.y"
#line 116 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(data_set, "", 1);
(yyval.t) = st;
......@@ -1495,7 +1546,7 @@ yyreduce:
case 11:
/* Line 1455 of yacc.c */
#line 118 "Parser.y"
#line 123 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(var_list, "", 1);
(yyval.t) = st;
......@@ -1507,7 +1558,7 @@ yyreduce:
case 12:
/* Line 1455 of yacc.c */
#line 124 "Parser.y"
#line 129 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(var_list, "", 2);
(yyval.t) = st;
......@@ -1520,7 +1571,7 @@ yyreduce:
case 13:
/* Line 1455 of yacc.c */
#line 132 "Parser.y"
#line 137 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(var_declaration, "", 3);
(yyval.t) = st;
......@@ -1534,7 +1585,7 @@ yyreduce:
case 14:
/* Line 1455 of yacc.c */
#line 141 "Parser.y"
#line 146 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(var_type, "", 1);
(yyval.t) = st;
......@@ -1546,7 +1597,7 @@ yyreduce:
case 15:
/* Line 1455 of yacc.c */
#line 147 "Parser.y"
#line 152 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(var_type, "", 1);
(yyval.t) = st;
......@@ -1558,7 +1609,7 @@ yyreduce:
case 16:
/* Line 1455 of yacc.c */
#line 154 "Parser.y"
#line 159 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(var_definition, "", 1);
(yyval.t) = st;
......@@ -1570,7 +1621,7 @@ yyreduce:
case 17:
/* Line 1455 of yacc.c */
#line 160 "Parser.y"
#line 165 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(var_definition, "", 1);
(yyval.t) = st;
......@@ -1582,7 +1633,7 @@ yyreduce:
case 18:
/* Line 1455 of yacc.c */
#line 170 "Parser.y"
#line 175 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(instruction_block, "", 1);
(yyval.t) = st;
......@@ -1594,7 +1645,7 @@ yyreduce:
case 19:
/* Line 1455 of yacc.c */
#line 176 "Parser.y"
#line 181 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(instruction_block, "", 2);
(yyval.t) = st;
......@@ -1607,7 +1658,7 @@ yyreduce:
case 20:
/* Line 1455 of yacc.c */
#line 184 "Parser.y"
#line 189 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(instruction_list, "", 1);
(yyval.t) = st;
......@@ -1619,7 +1670,7 @@ yyreduce:
case 21:
/* Line 1455 of yacc.c */
#line 190 "Parser.y"
#line 195 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(instruction_list, "", 2);
(yyval.t) = st;
......@@ -1632,9 +1683,9 @@ yyreduce:
case 22:
/* Line 1455 of yacc.c */
#line 203 "Parser.y"
#line 204 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(m_rule_list, "", 1);
SyntaxTree* st = SyntaxTree_init(instruction, "", 1);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (1)].t);
......@@ -1644,7 +1695,167 @@ yyreduce:
case 23:
/* Line 1455 of yacc.c */
#line 209 "Parser.y"
#line 210 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(return_instr, "", 1);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (1)].t);
;}
break;
case 24:
/* Line 1455 of yacc.c */
#line 217 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(assign_instr, "", 2);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (4)].t);
st->children[1] = (yyvsp[(3) - (4)].t);
;}
break;
case 25:
/* Line 1455 of yacc.c */
#line 225 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(return_instr, "", 0);
(yyval.t) = st;
;}
break;
case 26:
/* Line 1455 of yacc.c */
#line 229 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(assign_instr, "", 1);
(yyval.t) = st;
st->children[0] = (yyvsp[(2) - (3)].t);
;}
break;
case 27:
/* Line 1455 of yacc.c */
#line 237 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(expr, "", 1);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (1)].t);
;}
break;
case 28:
/* Line 1455 of yacc.c */
#line 243 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(expr_literal, "", 1);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (1)].t);
;}
break;
case 29:
/* Line 1455 of yacc.c */
#line 249 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(expr, "", 1);
(yyval.t) = st;
st->children[0] = (yyvsp[(2) - (3)].t);
;}
break;
case 30:
/* Line 1455 of yacc.c */
#line 255 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(expr_add, "", 2);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (3)].t);
st->children[1] = (yyvsp[(3) - (3)].t);
;}
break;
case 31:
/* Line 1455 of yacc.c */
#line 262 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(expr_sub, "", 2);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (3)].t);
st->children[1] = (yyvsp[(3) - (3)].t);
;}
break;
case 32:
/* Line 1455 of yacc.c */
#line 269 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(expr_mul, "", 2);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (3)].t);
st->children[1] = (yyvsp[(3) - (3)].t);
;}
break;
case 33:
/* Line 1455 of yacc.c */
#line 276 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(expr_div, "", 2);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (3)].t);
st->children[1] = (yyvsp[(3) - (3)].t);
;}
break;
case 34:
/* Line 1455 of yacc.c */
#line 283 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(expr_mod, "", 2);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (3)].t);
st->children[1] = (yyvsp[(3) - (3)].t);
;}
break;
case 35:
/* Line 1455 of yacc.c */
#line 293 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(m_rule_list, "", 1);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (1)].t);
;}
break;
case 36:
/* Line 1455 of yacc.c */
#line 299 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(m_rule_list, "", 2);
(yyval.t) = st;
......@@ -1654,24 +1865,24 @@ yyreduce:
;}
break;
case 24:
case 37:
/* Line 1455 of yacc.c */
#line 218 "Parser.y"
#line 308 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(m_rule, "", 3);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (3)].t);
st->children[1] = (yyvsp[(2) - (3)].t);
st->children[2] = (yyvsp[(3) - (3)].t);
st->children[0] = (yyvsp[(1) - (5)].t);
st->children[1] = (yyvsp[(3) - (5)].t);
st->children[2] = (yyvsp[(5) - (5)].t);
;}
break;
case 25:
case 38:
/* Line 1455 of yacc.c */
#line 228 "Parser.y"
#line 318 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(payoff_list, "", 1);
(yyval.t) = st;
......@@ -1680,10 +1891,10 @@ yyreduce:
;}
break;
case 26:
case 39:
/* Line 1455 of yacc.c */
#line 234 "Parser.y"
#line 324 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(payoff_list, "", 2);
(yyval.t) = st;
......@@ -1693,10 +1904,10 @@ yyreduce:
;}
break;
case 27:
case 40:
/* Line 1455 of yacc.c */
#line 242 "Parser.y"
#line 332 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(payoff, "", 2);
(yyval.t) = st;
......@@ -1706,10 +1917,98 @@ yyreduce:
;}
break;
case 41:
/* Line 1455 of yacc.c */
#line 341 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(move_list, "", 1);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (1)].t);
;}
break;
case 42:
/* Line 1455 of yacc.c */
#line 347 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(move_list, "", 2);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (3)].t);
st->children[1] = (yyvsp[(3) - (3)].t);
;}
break;
case 43:
/* Line 1455 of yacc.c */
#line 355 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(move, "", 5);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (9)].t);
st->children[1] = (yyvsp[(3) - (9)].t);
st->children[2] = (yyvsp[(5) - (9)].t);
st->children[3] = (yyvsp[(7) - (9)].t);
st->children[4] = (yyvsp[(9) - (9)].t);
;}
break;
case 44:
/* Line 1455 of yacc.c */
#line 366 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(players_scope, "", 0);
(yyval.t) = st;
;}
break;
case 45:
/* Line 1455 of yacc.c */
#line 370 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(players_scope, "", 1);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (1)].t);
;}
break;
case 46:
/* Line 1455 of yacc.c */
#line 377 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(identifier_list, "", 1);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (1)].t);
;}
break;
case 47:
/* Line 1455 of yacc.c */
#line 383 "Parser.y"
{
SyntaxTree* st = SyntaxTree_init(identifier_list, "", 2);
(yyval.t) = st;
st->children[0] = (yyvsp[(1) - (3)].t);
st->children[1] = (yyvsp[(3) - (3)].t);
;}
break;
/* Line 1455 of yacc.c */
#line 1713 "Parser.tab.c"
#line 2012 "Parser.tab.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
......@@ -1921,7 +2220,7 @@ yyreturn:
/* Line 1675 of yacc.c */
#line 254 "Parser.y"
#line 395 "Parser.y"
SyntaxTree* parser_main(int argc, char *argv[])
......
......@@ -41,15 +41,15 @@
enum yytokentype {
KW_MAIN_RULE = 258,
TMP_STATE = 259,
TMP_MOVES = 260,
KW_MOVES = 260,
KW_PLAYERS = 261,
KW_STATE = 262,
KW_INT = 263,
KW_BOOL = 264,
IDENTIFIER = 265,
INTEGER = 266,
BOOLEAN = 267,
INSTRUCTION = 268,
KW_RETURN = 265,
IDENTIFIER = 266,
INTEGER = 267,
BOOLEAN = 268,
TMP = 269
};
#endif
......
......@@ -19,20 +19,25 @@ SyntaxTree* root;
%token <t> KW_MAIN_RULE TMP_STATE TMP_MOVES
%token <t> KW_MAIN_RULE TMP_STATE KW_MOVES
KW_PLAYERS
KW_STATE KW_INT KW_BOOL
KW_STATE KW_INT KW_BOOL KW_RETURN
IDENTIFIER INTEGER BOOLEAN
INSTRUCTION
TMP
%type <t> GAME MAIN_RULE PLAYERS STATE MOVES
PLAYERS_LIST PLAYER
DATA_SET VAR_LIST VAR_DECLARATION VAR_TYPE VAR_DEFINITION
INSTRUCTION_BLOCK INSTRUCTION_LIST
INSTRUCTION ASSIGN_INSTR RETURN_INSTR EXPR
M_RULE_LIST M_RULE
PAYOFF_LIST PAYOFF
MOVE_LIST MOVE PLAYERS_SCOPE
IDENTIFIER_LIST
%left '+' '-'
%left '*' '/' '%'
%start GAME
......@@ -73,11 +78,11 @@ MAIN_RULE: KW_MAIN_RULE '[' M_RULE_LIST ']' {
st->children[0] = $3;
}
MOVES: TMP_MOVES {
MOVES: KW_MOVES '[' MOVE_LIST ']' {
SyntaxTree* st = SyntaxTree_init(moves, "", 1);
$$ = st;
st->children[0] = $1;
st->children[0] = $3;
}
......@@ -195,8 +200,93 @@ INSTRUCTION_LIST: INSTRUCTION {
st->children[1] = $2;
}
//INSTRUCTION: {}
INSTRUCTION: ASSIGN_INSTR {
SyntaxTree* st = SyntaxTree_init(instruction, "", 1);
$$ = st;
st->children[0] = $1;
}
| RETURN_INSTR {
SyntaxTree* st = SyntaxTree_init(return_instr, "", 1);
$$ = st;
st->children[0] = $1;
}
ASSIGN_INSTR: IDENTIFIER '=' EXPR ';' {
SyntaxTree* st = SyntaxTree_init(assign_instr, "", 2);
$$ = st;
st->children[0] = $1;
st->children[1] = $3;
}
RETURN_INSTR: KW_RETURN ';' {
SyntaxTree* st = SyntaxTree_init(return_instr, "", 0);
$$ = st;
}
| KW_RETURN EXPR ';' {
SyntaxTree* st = SyntaxTree_init(assign_instr, "", 1);
$$ = st;
st->children[0] = $2;
}
EXPR: IDENTIFIER {
SyntaxTree* st = SyntaxTree_init(expr, "", 1);
$$ = st;
st->children[0] = $1;
}
| VAR_DEFINITION{
SyntaxTree* st = SyntaxTree_init(expr_literal, "", 1);
$$ = st;
st->children[0] = $1;
}
| '(' EXPR ')'{
SyntaxTree* st = SyntaxTree_init(expr, "", 1);
$$ = st;
st->children[0] = $2;
}
| EXPR '+' EXPR{
SyntaxTree* st = SyntaxTree_init(expr_add, "", 2);
$$ = st;
st->children[0] = $1;
st->children[1] = $3;
}
| EXPR '-' EXPR{
SyntaxTree* st = SyntaxTree_init(expr_sub, "", 2);
$$ = st;
st->children[0] = $1;
st->children[1] = $3;
}
| EXPR '*' EXPR{
SyntaxTree* st = SyntaxTree_init(expr_mul, "", 2);
$$ = st;
st->children[0] = $1;
st->children[1] = $3;
}
| EXPR '/' EXPR{
SyntaxTree* st = SyntaxTree_init(expr_div, "", 2);
$$ = st;
st->children[0] = $1;
st->children[1] = $3;
}
| EXPR '%' EXPR{
SyntaxTree* st = SyntaxTree_init(expr_mod, "", 2);
$$ = st;
st->children[0] = $1;
st->children[1] = $3;
}
// MAIN_RULE
......@@ -206,7 +296,7 @@ M_RULE_LIST: M_RULE {
st->children[0] = $1;
}
| M_RULE ';' M_RULE_LIST {
| M_RULE '%' M_RULE_LIST {
SyntaxTree* st = SyntaxTree_init(m_rule_list, "", 2);
$$ = st;
......@@ -215,13 +305,13 @@ M_RULE_LIST: M_RULE {
}
M_RULE: IDENTIFIER INSTRUCTION_BLOCK PAYOFF_LIST {
M_RULE: IDENTIFIER '(' INSTRUCTION_BLOCK ')' PAYOFF_LIST {
SyntaxTree* st = SyntaxTree_init(m_rule, "", 3);
$$ = st;
st->children[0] = $1;
st->children[1] = $2;
st->children[2] = $3;
st->children[1] = $3;
st->children[2] = $5;
}
......@@ -248,6 +338,57 @@ PAYOFF: IDENTIFIER INSTRUCTION_BLOCK{
}
MOVE_LIST: MOVE {
SyntaxTree* st = SyntaxTree_init(move_list, "", 1);
$$ = st;
st->children[0] = $1;
}
| MOVE '%' MOVE_LIST {
SyntaxTree* st = SyntaxTree_init(move_list, "", 2);
$$ = st;
st->children[0] = $1;
st->children[1] = $3;
}
MOVE: IDENTIFIER '<' PLAYERS_SCOPE '>' DATA_SET '(' INSTRUCTION_BLOCK ')' INSTRUCTION_BLOCK{
SyntaxTree* st = SyntaxTree_init(move, "", 5);
$$ = st;
st->children[0] = $1;
st->children[1] = $3;
st->children[2] = $5;
st->children[3] = $7;
st->children[4] = $9;
}
PLAYERS_SCOPE: '*' {
SyntaxTree* st = SyntaxTree_init(players_scope, "", 0);
$$ = st;
}
| IDENTIFIER_LIST {
SyntaxTree* st = SyntaxTree_init(players_scope, "", 1);
$$ = st;
st->children[0] = $1;
}
IDENTIFIER_LIST: IDENTIFIER {
SyntaxTree* st = SyntaxTree_init(identifier_list, "", 1);
$$ = st;
st->children[0] = $1;
}
| IDENTIFIER ',' IDENTIFIER_LIST {
SyntaxTree* st = SyntaxTree_init(identifier_list, "", 2);
$$ = st;
st->children[0] = $1;
st->children[1] = $3;
}
// TMP { SyntaxTree* st = SyntaxTree_init(tmp, "", 1); $$ = st; st->children[0] = $1; }
......
......@@ -14,11 +14,22 @@ STATE
MAIN_RULE
[
r1
{ TMP_INSTRUCTION }
({ RETURN; })
players
{TMP_INSTRUCTION}
{RETURN;}
masters
{TMP_INSTRUCTION TMP_INSTRUCTION}
{a = 2; RETURN;}
]
TMP_MOVES
\ No newline at end of file
MOVES
[
m1<*> [ INT a = 0;] ({ RETURN; })
{
RETURN;
}
%
m2<rrr> [ BOOL b = false; ] ({ RETURN; })
{
a = (4 + s) * 7 + 9 % 5;
}
]
\ No newline at end of file