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

parser: change the new_parser() signature

This commit is contained in:
Alexander Medvednikov
2019-08-23 13:43:31 +03:00
parent 624a932420
commit 0589decc43
3 changed files with 118 additions and 122 deletions

View File

@@ -67,6 +67,7 @@ mut:
out_name string // "program.exe"
vroot string
mod string // module being built with -lib
//parsers []Parser
}
struct Preferences {
@@ -222,6 +223,10 @@ fn (v mut V) compile() {
mut cgen := v.cgen
cgen.genln('// Generated by V')
// Add builtin parsers
for i, file in v.files {
// v.parsers << v.new_parser(file)
}
v.add_v_files_to_compile()
if v.pref.is_verbose {
println('all .v files:')
@@ -229,8 +234,8 @@ fn (v mut V) compile() {
}
// First pass (declarations)
for file in v.files {
mut p := v.new_parser(file, Pass.decl)
p.parse()
mut p := v.new_parser(file)
p.parse(.decl)
}
// Main pass
cgen.pass = Pass.main
@@ -243,7 +248,7 @@ fn (v mut V) compile() {
cgen.genln(CommonCHeaders)
v.generate_hotcode_reloading_declarations()
v.generate_hotcode_reloading_declarations()
imports_json := v.table.imports.contains('json')
// TODO remove global UI hack
@@ -282,8 +287,8 @@ fn (v mut V) compile() {
cgen.genln('this line will be replaced with definitions')
defs_pos := cgen.lines.len - 1
for file in v.files {
mut p := v.new_parser(file, Pass.main)
p.parse()
mut p := v.new_parser(file)
p.parse(.main)
// p.g.gen_x64()
// Format all files (don't format automatically generated vlib headers)
if !v.pref.nofmt && !file.contains('/vlib/') {
@@ -522,13 +527,13 @@ fn (v mut V) add_v_files_to_compile() {
}
// Parse builtin imports
for file in v.files {
mut p := v.new_parser(file, Pass.imports)
p.parse()
mut p := v.new_parser(file)
p.parse(.imports)
}
// Parse user imports
for file in user_files {
mut p := v.new_parser(file, Pass.imports)
p.parse()
mut p := v.new_parser(file)
p.parse(.imports)
}
// Parse lib imports
/*
@@ -563,8 +568,8 @@ fn (v mut V) add_v_files_to_compile() {
}
// Add all imports referenced by these libs
for file in vfiles {
mut p := v.new_parser(file, Pass.imports)
p.parse()
mut p := v.new_parser(file)
p.parse(.imports)
}
}
if v.pref.is_verbose {