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

vfmt: fix in, |, or {}

This commit is contained in:
Alexander Medvednikov 2019-12-18 07:52:14 +03:00
parent 3d1db3519d
commit 02939d776b
4 changed files with 30 additions and 22 deletions

View File

@ -24,7 +24,7 @@
- wrap up memory management
- remove all compiler memory leaks
+ fix child <T> function calls
- enable vfmt
+ enable vfmt
+ bring back vdoc and regenerate all module docs
+ optimize the parser
- chat.vlang.io
@ -36,7 +36,8 @@
- ui/orm demo: a simple gui client for postgres/mysql/sqlite
- ui demo: calculator
- declarative ui with hot reload (similar to swiftui)
- "building a simple blog with vweb" tutorial + youtube video
+ "building a simple blog with vweb" tutorial +
- youtube video
+ fix interfaces
+ fast.vlang.io
+ bare metal support

View File

@ -35,6 +35,7 @@ fn (p mut Parser) comp_time() {
p.check(.lcbr)
os := os_from_string(name)
if ((!not && os != p.os) || (not && os == p.os)) &&
!p.scanner.is_fmt &&
!p.pref.output_cross_c
{
// `$if os {` for a different target, skip everything inside

View File

@ -37,6 +37,7 @@ fn (p mut Parser) in_optimization(typ string, ph int) {
}
if p.tok != .rsbr {
p.check(.comma)
p.fspace()
}
i++
}

View File

@ -160,7 +160,8 @@ fn (v mut V) new_parser_from_file(path string) Parser {
}
mut p := v.new_parser(new_scanner_file(path))
p = {
p|file_path:path,
p |
file_path:path,
file_name:path.all_after(os.path_separator),
file_platform:path_platform,
file_pcguard:path_pcguard,
@ -201,7 +202,8 @@ fn (v mut V) new_parser(scanner &Scanner) Parser {
import_table: new_import_table()
}
$if js {
p.is_js=true}
p.is_js = true
}
if p.pref.is_repl {
p.scanner.should_print_line_on_error = false
p.scanner.should_print_errors_in_color = false
@ -2285,6 +2287,7 @@ fn (p mut Parser) indot_expr() string {
if p.tok == .lsbr {
// a in [1,2,3] optimization => `a == 1 || a == 2 || a == 3`
// avoids an allocation
p.fspace()
p.in_optimization(typ, ph)
return 'bool'
}
@ -2324,6 +2327,7 @@ fn (p mut Parser) assoc() string {
// println('assoc()')
p.next()
name := p.check_name()
p.fspace()
var := p.find_var_or_const(name) or {
p.error('unknown variable `$name`')
exit(1)
@ -2332,6 +2336,7 @@ fn (p mut Parser) assoc() string {
p.mark_var_used(var)
}
p.check(.pipe)
p.fgen_nl()
p.gen('($var.typ){')
typ := p.table.find_type(var.typ)
mut fields := []string // track the fields user is setting, the rest will be copied from the old object