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

vfmt: make work with comptime

This commit is contained in:
Alexander Medvednikov 2020-05-27 03:33:37 +02:00
parent 23c0bb600c
commit 7c9279c447
5 changed files with 14 additions and 10 deletions

View File

@ -6,7 +6,7 @@ const (
port = 8082
)
pub struct App {
struct App {
pub mut:
vweb vweb.Context // TODO embed
cnt int

View File

@ -359,7 +359,6 @@ pub fn (mut f Fmt) stmt(node ast.Stmt) {
f.stmts(it.stmts)
f.writeln('}')
}
ast.ComptimeCall {}
}
}
@ -539,6 +538,7 @@ pub fn (mut f Fmt) expr(node ast.Expr) {
ast.CharLiteral {
f.write('`$it.val`')
}
ast.ComptimeCall {}
ast.ConcatExpr {
for i, val in it.vals {
if i != 0 {

View File

@ -55,6 +55,7 @@ fn (mut p Parser) hash() ast.HashStmt {
}
fn (mut p Parser) vweb() ast.ComptimeCall {
p.check(.dollar)
p.check(.name) // skip `vweb.html()` TODO
p.check(.dot)
p.check(.name)

View File

@ -386,13 +386,7 @@ pub fn (mut p Parser) top_stmt() ast.Stmt {
return p.struct_decl()
}
.dollar {
if p.peek_tok.kind == .key_if {
return p.comp_if()
} else if p.peek_tok.kind == .name {
return ast.ExprStmt{
expr: p.vweb()
}
}
}
.hash {
return p.hash()
@ -501,7 +495,13 @@ pub fn (mut p Parser) stmt() ast.Stmt {
return p.return_stmt()
}
.dollar {
if p.peek_tok.kind == .key_if {
return p.comp_if()
} else if p.peek_tok.kind == .name {
return ast.ExprStmt{
expr: p.vweb()
}
}
}
.key_continue, .key_break {
tok := p.tok

View File

@ -283,9 +283,12 @@ fn handle_conn<T>(conn net.Socket, app mut T) {
$if debug {
println('action=$action')
}
app.$action()
/*
app.$action() or {
conn.send_string(http_404) or {}
}
*/
conn.close() or {}
app.reset()
}