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

all: a massive merge of ast and table modules

This commit is contained in:
Alexander Medvednikov
2021-04-02 01:57:09 +03:00
parent 043f6420f7
commit 7385f8e56b
88 changed files with 1839 additions and 1792 deletions

View File

@@ -1,5 +1,12 @@
module main
import os
import log
import flag
import time
import vweb
import net.urllib
// This tool regenerates V's bootstrap .c files
// every time the V master branch is updated.
// if run with the --serve flag it will run in webhook
@@ -13,12 +20,6 @@ module main
// --log-file path to log file used when --log-to is 'file'
// --dry-run dont push anything to remote repo
// --force force update even if already up to date
import os
import log
import flag
import time
import vweb
import net.urllib
// git credentials
const (

View File

@@ -5,7 +5,7 @@ import net.urllib
import strings
import markdown
import v.scanner
import v.table
import v.ast
import v.token
import v.doc
import v.pref
@@ -344,7 +344,7 @@ fn get_src_link(repo_url string, file_name string, line_nr int) string {
return url.str()
}
fn html_highlight(code string, tb &table.Table) string {
fn html_highlight(code string, tb &ast.Table) string {
builtin := ['bool', 'string', 'i8', 'i16', 'int', 'i64', 'i128', 'byte', 'u16', 'u32', 'u64',
'u128', 'rune', 'f32', 'f64', 'int_literal', 'float_literal', 'byteptr', 'voidptr', 'any']
highlight_code := fn (tok token.Token, typ HighlightTokenTyp) string {
@@ -425,7 +425,7 @@ fn html_highlight(code string, tb &table.Table) string {
return buf.str()
}
fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool, tb &table.Table) string {
fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool, tb &ast.Table) string {
mut dnw := strings.new_builder(200)
head_tag := if head { 'h1' } else { 'h2' }
comments := dn.merge_comments_without_examples()

View File

@@ -3,7 +3,7 @@ module main
import os
import v.doc
import term
import v.table
import v.ast
import v.scanner
import v.token
import strings
@@ -137,7 +137,7 @@ fn gen_footer_text(d &doc.Doc, include_timestamp bool) string {
return '$footer_text Generated on: $time_str'
}
fn color_highlight(code string, tb &table.Table) string {
fn color_highlight(code string, tb &ast.Table) string {
builtin := ['bool', 'string', 'i8', 'i16', 'int', 'i64', 'i128', 'byte', 'u16', 'u32', 'u64',
'u128', 'rune', 'f32', 'f64', 'int_literal', 'float_literal', 'byteptr', 'voidptr', 'any']
highlight_code := fn (tok token.Token, typ HighlightTokenTyp) string {

View File

@@ -12,7 +12,6 @@ import v.pref
import v.fmt
import v.util
import v.parser
import v.table
import vhelp
struct FormatOptions {
@@ -156,7 +155,7 @@ fn (foptions &FormatOptions) format_file(file string) {
if foptions.is_verbose {
eprintln('vfmt2 running fmt.fmt over file: $file')
}
table := table.new_table()
table := ast.new_table()
// checker := checker.new_checker(table, prefs)
file_ast := parser.parse_file(file, table, .parse_comments, prefs, &ast.Scope{
parent: 0
@@ -180,7 +179,7 @@ fn (foptions &FormatOptions) format_pipe() {
eprintln('vfmt2 running fmt.fmt over stdin')
}
input_text := os.get_raw_lines_joined()
table := table.new_table()
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

View File

@@ -28,6 +28,7 @@ const (
'vlib/v/tests/generics_return_generics_struct_test.v', /* generic fn param removed */
'vlib/v/tests/interop_test.v', /* bad comment formatting */
'vlib/v/tests/generics_test.v', /* some silent error */
'vlib/v/gen/js/tests/js.v', /* local `hello` fn, gets replaced with module `hello` aliased as `hl` */
]
vfmt_verify_list = [
'cmd/',
@@ -55,7 +56,7 @@ const (
'vlib/v/eval/',
'vlib/v/fmt/',
'vlib/v/gen/c/',
//'vlib/v/gen/js/',
'vlib/v/gen/js/',
'vlib/v/gen/x64/',
'vlib/v/live/',
'vlib/v/markused/',
@@ -64,7 +65,6 @@ const (
'vlib/v/pref/',
'vlib/v/preludes',
'vlib/v/scanner/',
'vlib/v/table/',
'vlib/v/tests/',
'vlib/v/token/',
'vlib/v/util/',

View File

@@ -3,7 +3,6 @@ import flag
import term
import time
import v.parser
import v.table
import v.ast
import v.pref
@@ -34,7 +33,7 @@ mut:
cut_index int // the cut position in the source from context.path
max_index int // the maximum index (equivalent to the file content length)
// parser context in the worker processes:
table table.Table
table ast.Table
scope ast.Scope
pref &pref.Preferences
period_ms int // print periodic progress
@@ -48,7 +47,7 @@ fn main() {
context.log('> worker ${pid:5} starts parsing at cut_index: ${context.cut_index:5} | $context.path')
// A worker's process job is to try to parse a single given file in context.path.
// It can crash/panic freely.
context.table = table.new_table()
context.table = ast.new_table()
context.scope = &ast.Scope{
parent: 0
}

View File

@@ -7,8 +7,8 @@ import os.cmdline
import v.vet
import v.pref
import v.parser
import v.table
import v.token
import v.ast
import term
struct Vet {
@@ -94,7 +94,7 @@ fn (mut vt Vet) vet_file(path string) {
vt.file = path
mut prefs := pref.new_preferences()
prefs.is_vet = true
table := table.new_table()
table := ast.new_table()
vt.vprintln("vetting file '$path'...")
_, errors := parser.parse_vet_file(path, table, prefs)
// Transfer errors from scanner and parser