mirror of
https://github.com/vlang/v.git
synced 2025-09-16 16:02:29 +03:00
submodules
This commit is contained in:
parent
36908fa304
commit
8a2d25247f
5 changed files with 34 additions and 5 deletions
|
@ -289,7 +289,21 @@ fn (p mut Parser) import_statement() {
|
|||
if p.tok != NAME {
|
||||
p.error('bad import format')
|
||||
}
|
||||
pkg := p.lit.trim_space()
|
||||
mut pkg := p.lit.trim_space()
|
||||
// submodule support
|
||||
// limit depth to 4 for now
|
||||
max_module_depth := 4
|
||||
mut depth := 1
|
||||
for p.peek() == DOT {
|
||||
p.next() // SKIP DOT
|
||||
p.next() // SUBMODULE
|
||||
submodule := p.lit.trim_space()
|
||||
pkg = pkg + '.' + submodule
|
||||
depth++
|
||||
if depth > max_module_depth {
|
||||
panic('Sorry. Module depth of $max_module_depth exceeded: $pkg ($submodule is too deep).')
|
||||
}
|
||||
}
|
||||
p.next()
|
||||
p.fgenln(' ' + pkg)
|
||||
// Make sure there are no duplicate imports
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue