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];
......
This diff is collapsed.
......@@ -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