mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
toml: easier scanner configuration (#12016)
This commit is contained in:
@@ -38,7 +38,7 @@ pub:
|
||||
tokenize_formating bool // if true, generate tokens for `\n`, ` `, `\t`, `\r` etc.
|
||||
}
|
||||
|
||||
// new_scanner returns a new heap allocated `Scanner` instance.
|
||||
// new_scanner returns a new *heap* allocated `Scanner` instance.
|
||||
pub fn new_scanner(config Config) ?&Scanner {
|
||||
config.input.validate() ?
|
||||
mut text := config.input.text
|
||||
@@ -56,6 +56,17 @@ pub fn new_scanner(config Config) ?&Scanner {
|
||||
return s
|
||||
}
|
||||
|
||||
// returns a new *stack* allocated `Scanner` instance.
|
||||
pub fn new_simple(toml_input string) ?Scanner {
|
||||
config := Config{
|
||||
input: input.auto_config(toml_input) ?
|
||||
}
|
||||
return Scanner{
|
||||
config: config
|
||||
text: config.input.read_input() ?
|
||||
}
|
||||
}
|
||||
|
||||
// scan returns the next token from the input.
|
||||
[direct_array_access]
|
||||
pub fn (mut s Scanner) scan() ?token.Token {
|
||||
|
Reference in New Issue
Block a user