pora na 300+
This commit is contained in:
parent
878dfe74e0
commit
a2fb31ab5a
5 changed files with 27 additions and 5 deletions
|
|
@ -67,6 +67,22 @@ struct Pass : Stmt
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Break : Stmt
|
||||||
|
{
|
||||||
|
std::string dump(int indent = 0) const override
|
||||||
|
{
|
||||||
|
return indent_str(indent) + "Break";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Continue : Stmt
|
||||||
|
{
|
||||||
|
std::string dump(int indent = 0) const override
|
||||||
|
{
|
||||||
|
return indent_str(indent) + "Continue";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// #todo elif
|
// #todo elif
|
||||||
struct If : Stmt
|
struct If : Stmt
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,8 @@ else { return yy::parser::token::TOK_KW_ELSE; }
|
||||||
elif { return yy::parser::token::TOK_KW_ELIF; }
|
elif { return yy::parser::token::TOK_KW_ELIF; }
|
||||||
class { return yy::parser::token::TOK_KW_CLASS; }
|
class { return yy::parser::token::TOK_KW_CLASS; }
|
||||||
while { return yy::parser::token::TOK_KW_WHILE; }
|
while { return yy::parser::token::TOK_KW_WHILE; }
|
||||||
|
break { return yy::parser::token::TOK_KW_BREAK; }
|
||||||
|
continue { return yy::parser::token::TOK_KW_CONTINUE; }
|
||||||
|
|
||||||
\=\= { return yy::parser::token::TOK_EQ; }
|
\=\= { return yy::parser::token::TOK_EQ; }
|
||||||
\!\= { return yy::parser::token::TOK_NE; }
|
\!\= { return yy::parser::token::TOK_NE; }
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
%left KW_OR
|
%left KW_OR
|
||||||
%left KW_AND
|
%left KW_AND
|
||||||
%right KW_NOT // unary logical NOT
|
%right KW_NOT // unary logical NOT
|
||||||
%token KW_DEF KW_IF KW_RETURN KW_FOR KW_IN KW_PASS KW_ELSE KW_ELIF KW_CLASS KW_WHILE
|
%token KW_DEF KW_IF KW_RETURN KW_FOR KW_IN KW_PASS KW_ELSE KW_ELIF KW_CLASS KW_WHILE KW_BREAK KW_CONTINUE
|
||||||
|
|
||||||
%token L_PAREN R_PAREN L_BRACKET R_BRACKET L_BRACE R_BRACE
|
%token L_PAREN R_PAREN L_BRACKET R_BRACKET L_BRACE R_BRACE
|
||||||
%token DOT COLON SEMICOLON COMMA
|
%token DOT COLON SEMICOLON COMMA
|
||||||
|
|
@ -100,6 +100,12 @@ stmt:
|
||||||
| KW_PASS NEWLINE {
|
| KW_PASS NEWLINE {
|
||||||
$$ = std::make_unique<Pass>();
|
$$ = std::make_unique<Pass>();
|
||||||
}
|
}
|
||||||
|
| KW_BREAK NEWLINE {
|
||||||
|
$$ = std::make_unique<Break>();
|
||||||
|
}
|
||||||
|
| KW_CONTINUE NEWLINE {
|
||||||
|
$$ = std::make_unique<Continue>();
|
||||||
|
}
|
||||||
| KW_WHILE expr COLON NEWLINE INDENT stmt_list DEDENT {
|
| KW_WHILE expr COLON NEWLINE INDENT stmt_list DEDENT {
|
||||||
$$ = std::make_unique<While>(std::move($2), std::move($6));
|
$$ = std::make_unique<While>(std::move($2), std::move($6));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,3 @@ Module
|
||||||
If
|
If
|
||||||
Identifier(x)
|
Identifier(x)
|
||||||
Break
|
Break
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,3 @@ Module
|
||||||
If
|
If
|
||||||
Identifier(x)
|
Identifier(x)
|
||||||
Continue
|
Continue
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue