1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser/ast: Block

This commit is contained in:
Alexander Medvednikov 2020-03-24 15:44:17 +01:00
parent 7aff0cb84f
commit e012966291
2 changed files with 12 additions and 1 deletions

View File

@ -19,7 +19,7 @@ ConcatExpr | Type | AsCast | TypeOf | StringInterLiteral
pub type Stmt = GlobalDecl | FnDecl | Return | Module | Import | ExprStmt |
ForStmt | StructDecl | ForCStmt | ForInStmt | CompIf | ConstDecl | Attr | BranchStmt |
HashStmt | AssignStmt | EnumDecl | TypeDecl | DeferStmt | GotoLabel | GotoStmt |
LineComment | MultiLineComment | AssertStmt | UnsafeStmt | GoStmt
LineComment | MultiLineComment | AssertStmt | UnsafeStmt | GoStmt | Block
// pub type Type = StructType | ArrayType
// pub struct StructType {
// fields []Field
@ -30,6 +30,11 @@ pub:
typ table.Type
}
pub struct Block {
pub:
stmts []Stmt
}
// | IncDecStmt k
// Stand-alone expression in a statement list.
pub struct ExprStmt {

View File

@ -334,6 +334,12 @@ pub fn (p mut Parser) line_comment() ast.LineComment {
pub fn (p mut Parser) stmt() ast.Stmt {
match p.tok.kind {
.lcbr {
stmts := p.parse_block()
return ast.Block{
stmts: stmts
}
}
.key_assert {
p.next()
expr := p.expr(0)