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:
parent
3d1db3519d
commit
02939d776b
@ -24,7 +24,7 @@
|
|||||||
- wrap up memory management
|
- wrap up memory management
|
||||||
- remove all compiler memory leaks
|
- remove all compiler memory leaks
|
||||||
+ fix child <T> function calls
|
+ fix child <T> function calls
|
||||||
- enable vfmt
|
+ enable vfmt
|
||||||
+ bring back vdoc and regenerate all module docs
|
+ bring back vdoc and regenerate all module docs
|
||||||
+ optimize the parser
|
+ optimize the parser
|
||||||
- chat.vlang.io
|
- chat.vlang.io
|
||||||
@ -36,7 +36,8 @@
|
|||||||
- ui/orm demo: a simple gui client for postgres/mysql/sqlite
|
- ui/orm demo: a simple gui client for postgres/mysql/sqlite
|
||||||
- ui demo: calculator
|
- ui demo: calculator
|
||||||
- declarative ui with hot reload (similar to swiftui)
|
- 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
|
+ fix interfaces
|
||||||
+ fast.vlang.io
|
+ fast.vlang.io
|
||||||
+ bare metal support
|
+ bare metal support
|
||||||
|
@ -35,6 +35,7 @@ fn (p mut Parser) comp_time() {
|
|||||||
p.check(.lcbr)
|
p.check(.lcbr)
|
||||||
os := os_from_string(name)
|
os := os_from_string(name)
|
||||||
if ((!not && os != p.os) || (not && os == p.os)) &&
|
if ((!not && os != p.os) || (not && os == p.os)) &&
|
||||||
|
!p.scanner.is_fmt &&
|
||||||
!p.pref.output_cross_c
|
!p.pref.output_cross_c
|
||||||
{
|
{
|
||||||
// `$if os {` for a different target, skip everything inside
|
// `$if os {` for a different target, skip everything inside
|
||||||
|
@ -37,6 +37,7 @@ fn (p mut Parser) in_optimization(typ string, ph int) {
|
|||||||
}
|
}
|
||||||
if p.tok != .rsbr {
|
if p.tok != .rsbr {
|
||||||
p.check(.comma)
|
p.check(.comma)
|
||||||
|
p.fspace()
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,8 @@ fn (v mut V) new_parser_from_file(path string) Parser {
|
|||||||
}
|
}
|
||||||
mut p := v.new_parser(new_scanner_file(path))
|
mut p := v.new_parser(new_scanner_file(path))
|
||||||
p = {
|
p = {
|
||||||
p|file_path:path,
|
p |
|
||||||
|
file_path:path,
|
||||||
file_name:path.all_after(os.path_separator),
|
file_name:path.all_after(os.path_separator),
|
||||||
file_platform:path_platform,
|
file_platform:path_platform,
|
||||||
file_pcguard:path_pcguard,
|
file_pcguard:path_pcguard,
|
||||||
@ -201,7 +202,8 @@ fn (v mut V) new_parser(scanner &Scanner) Parser {
|
|||||||
import_table: new_import_table()
|
import_table: new_import_table()
|
||||||
}
|
}
|
||||||
$if js {
|
$if js {
|
||||||
p.is_js=true}
|
p.is_js = true
|
||||||
|
}
|
||||||
if p.pref.is_repl {
|
if p.pref.is_repl {
|
||||||
p.scanner.should_print_line_on_error = false
|
p.scanner.should_print_line_on_error = false
|
||||||
p.scanner.should_print_errors_in_color = false
|
p.scanner.should_print_errors_in_color = false
|
||||||
@ -2285,6 +2287,7 @@ fn (p mut Parser) indot_expr() string {
|
|||||||
if p.tok == .lsbr {
|
if p.tok == .lsbr {
|
||||||
// a in [1,2,3] optimization => `a == 1 || a == 2 || a == 3`
|
// a in [1,2,3] optimization => `a == 1 || a == 2 || a == 3`
|
||||||
// avoids an allocation
|
// avoids an allocation
|
||||||
|
p.fspace()
|
||||||
p.in_optimization(typ, ph)
|
p.in_optimization(typ, ph)
|
||||||
return 'bool'
|
return 'bool'
|
||||||
}
|
}
|
||||||
@ -2324,6 +2327,7 @@ fn (p mut Parser) assoc() string {
|
|||||||
// println('assoc()')
|
// println('assoc()')
|
||||||
p.next()
|
p.next()
|
||||||
name := p.check_name()
|
name := p.check_name()
|
||||||
|
p.fspace()
|
||||||
var := p.find_var_or_const(name) or {
|
var := p.find_var_or_const(name) or {
|
||||||
p.error('unknown variable `$name`')
|
p.error('unknown variable `$name`')
|
||||||
exit(1)
|
exit(1)
|
||||||
@ -2332,6 +2336,7 @@ fn (p mut Parser) assoc() string {
|
|||||||
p.mark_var_used(var)
|
p.mark_var_used(var)
|
||||||
}
|
}
|
||||||
p.check(.pipe)
|
p.check(.pipe)
|
||||||
|
p.fgen_nl()
|
||||||
p.gen('($var.typ){')
|
p.gen('($var.typ){')
|
||||||
typ := p.table.find_type(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
|
mut fields := []string // track the fields user is setting, the rest will be copied from the old object
|
||||||
|
Loading…
Reference in New Issue
Block a user