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

ast: CompIf position

This commit is contained in:
Alexander Medvednikov 2020-03-22 11:53:08 +01:00
parent ab3f6d9202
commit 7b689d8c52
3 changed files with 5 additions and 1 deletions

View File

@ -388,6 +388,7 @@ pub struct CompIf {
pub:
cond Expr
stmts []Stmt
pos token.Position
mut:
else_stmts []Stmt
}

View File

@ -259,10 +259,11 @@ fn (g mut Gen) stmt(node ast.Stmt) {
g.const_decl(it)
}
ast.CompIf {
// TODO
g.writeln('//#ifdef ')
// g.expr(it.cond)
// println('comp if stmts $g.file.path:$it.pos.line_nr')
// g.stmts(it.stmts)
// println('done')
g.writeln('//#endif')
}
ast.DeferStmt {

View File

@ -5,6 +5,7 @@ import (
)
pub fn (p mut Parser) comp_if() ast.CompIf {
pos := p.tok.position()
p.next()
p.check(.key_if)
if p.tok.kind == .not {
@ -16,6 +17,7 @@ pub fn (p mut Parser) comp_if() ast.CompIf {
}
mut node := ast.CompIf{
stmts: p.parse_block()
pos: pos
}
if p.tok.kind == .dollar && p.peek_tok.kind == .key_else {
p.next()