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

all: make comment expressions + fix vfmt array init (#5851)

This commit is contained in:
Enzo
2020-07-17 19:13:22 +02:00
committed by GitHub
parent 39f90e25f3
commit 90d9040e6e
19 changed files with 397 additions and 291 deletions

View File

@ -10,15 +10,15 @@ import v.errors
pub type TypeDecl = AliasTypeDecl | FnTypeDecl | SumTypeDecl
pub type Expr = AnonFn | ArrayInit | AsCast | Assoc | BoolLiteral | CallExpr | CastExpr |
CharLiteral | ComptimeCall | ConcatExpr | EnumVal | FloatLiteral | Ident | IfExpr | IfGuardExpr |
IndexExpr | InfixExpr | IntegerLiteral | Likely | LockExpr | MapInit | MatchExpr | None |
OrExpr | ParExpr | PostfixExpr | PrefixExpr | RangeExpr | SelectorExpr | SizeOf | SqlExpr |
StringInterLiteral | StringLiteral | StructInit | Type | TypeOf | UnsafeExpr
CharLiteral | Comment | ComptimeCall | ConcatExpr | EnumVal | FloatLiteral | Ident | IfExpr |
IfGuardExpr | IndexExpr | InfixExpr | IntegerLiteral | Likely | LockExpr | MapInit | MatchExpr |
None | OrExpr | ParExpr | PostfixExpr | PrefixExpr | RangeExpr | SelectorExpr | SizeOf |
SqlExpr | StringInterLiteral | StringLiteral | StructInit | Type | TypeOf | UnsafeExpr
pub type Stmt = AssertStmt | AssignStmt | Attr | Block | BranchStmt | Comment | CompFor |
CompIf | ConstDecl | DeferStmt | EnumDecl | ExprStmt | FnDecl | ForCStmt | ForInStmt |
ForStmt | GlobalDecl | GoStmt | GotoLabel | GotoStmt | HashStmt | Import | InterfaceDecl |
Module | Return | SqlStmt | StructDecl | TypeDecl | UnsafeStmt
pub type Stmt = AssertStmt | AssignStmt | Attr | Block | BranchStmt | CompFor | CompIf |
ConstDecl | DeferStmt | EnumDecl | ExprStmt | FnDecl | ForCStmt | ForInStmt | ForStmt |
GlobalDecl | GoStmt | GotoLabel | GotoStmt | HashStmt | Import | InterfaceDecl | Module |
Return | SqlStmt | StructDecl | TypeDecl | UnsafeStmt
pub type ScopeObject = ConstField | GlobalDecl | Var
@ -42,11 +42,12 @@ pub:
// Stand-alone expression in a statement list.
pub struct ExprStmt {
pub:
expr Expr
pos token.Position
is_expr bool
expr Expr
pos token.Position
comments []Comment
is_expr bool
pub mut:
typ table.Type
typ table.Type
}
pub struct IntegerLiteral {
@ -282,10 +283,11 @@ pub mut:
pub struct Return {
pub:
pos token.Position
exprs []Expr
pos token.Position
exprs []Expr
comments []Comment
pub mut:
types []table.Type
types []table.Type
}
/*
@ -579,6 +581,7 @@ pub:
right []Expr
op token.Kind
pos token.Position
comments []Comment
pub mut:
left []Expr
left_types []table.Type
@ -921,22 +924,25 @@ pub fn (expr Expr) position() token.Position {
AsCast {
return expr.pos
}
// ast.Ident { }
CastExpr {
return expr.pos
}
Assoc {
return expr.pos
}
BoolLiteral {
return expr.pos
}
// ast.Ident { }
CallExpr {
return expr.pos
}
CastExpr {
return expr.pos
}
CharLiteral {
return expr.pos
}
Comment {
return expr.pos
}
EnumVal {
return expr.pos
}
@ -1023,7 +1029,6 @@ pub fn (stmt Stmt) position() token.Position {
// BranchStmt {
// }
*/
Comment { return stmt.pos }
CompIf { return stmt.pos }
ConstDecl { return stmt.pos }
/*