mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: simplify global_scope processing (#10848)
This commit is contained in:
@@ -131,13 +131,9 @@ fn json(file string) string {
|
||||
root: new_object()
|
||||
table: ast.new_table()
|
||||
pref: pref
|
||||
global_scope: &ast.Scope{
|
||||
start_pos: 0
|
||||
parent: 0
|
||||
}
|
||||
}
|
||||
// parse file with comment
|
||||
ast_file := parser.parse_file(file, t.table, .parse_comments, t.pref, t.global_scope)
|
||||
ast_file := parser.parse_file(file, t.table, .parse_comments, t.pref)
|
||||
t.root = t.ast_file(ast_file)
|
||||
// generate the ast string
|
||||
s := json_print(t.root)
|
||||
@@ -146,9 +142,8 @@ fn json(file string) string {
|
||||
|
||||
// the ast tree
|
||||
struct Tree {
|
||||
table &ast.Table
|
||||
pref &pref.Preferences
|
||||
global_scope &ast.Scope
|
||||
table &ast.Table
|
||||
pref &pref.Preferences
|
||||
mut:
|
||||
root Node // the root of tree
|
||||
}
|
||||
|
||||
@@ -151,9 +151,7 @@ fn (foptions &FormatOptions) format_file(file string) {
|
||||
}
|
||||
table := ast.new_table()
|
||||
// checker := checker.new_checker(table, prefs)
|
||||
file_ast := parser.parse_file(file, table, .parse_comments, prefs, &ast.Scope{
|
||||
parent: 0
|
||||
})
|
||||
file_ast := parser.parse_file(file, table, .parse_comments, prefs)
|
||||
// checker.check(file_ast)
|
||||
formatted_content := fmt.fmt(file_ast, table, prefs, foptions.is_debug)
|
||||
file_name := os.file_name(file)
|
||||
@@ -175,9 +173,7 @@ fn (foptions &FormatOptions) format_pipe() {
|
||||
input_text := os.get_raw_lines_joined()
|
||||
table := ast.new_table()
|
||||
// checker := checker.new_checker(table, prefs)
|
||||
file_ast := parser.parse_text(input_text, '', table, .parse_comments, prefs, &ast.Scope{
|
||||
parent: 0
|
||||
})
|
||||
file_ast := parser.parse_text(input_text, '', table, .parse_comments, prefs)
|
||||
// checker.check(file_ast)
|
||||
formatted_content := fmt.fmt(file_ast, table, prefs, foptions.is_debug)
|
||||
print(formatted_content)
|
||||
|
||||
@@ -61,8 +61,7 @@ fn main() {
|
||||
time.sleep(ms * time.millisecond)
|
||||
exit(ecode_timeout)
|
||||
}(context.timeout_ms)
|
||||
_ := parser.parse_text(source, context.path, context.table, .skip_comments, context.pref,
|
||||
context.scope)
|
||||
_ := parser.parse_text(source, context.path, context.table, .skip_comments, context.pref)
|
||||
context.log('> worker ${pid:5} finished parsing $context.path')
|
||||
exit(0)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user