mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
scanner,parser,gen: use km.matches(word)
instead of km.find(word) != -1
This commit is contained in:
parent
2db8bd62a2
commit
336305daa5
@ -2266,7 +2266,7 @@ pub fn type_can_start_with_token(tok &token.Token) bool {
|
|||||||
match tok.kind {
|
match tok.kind {
|
||||||
.name {
|
.name {
|
||||||
return (tok.lit.len > 0 && tok.lit[0].is_capital())
|
return (tok.lit.len > 0 && tok.lit[0].is_capital())
|
||||||
|| builtin_type_names_matcher.find(tok.lit) > 0
|
|| builtin_type_names_matcher.matches(tok.lit)
|
||||||
}
|
}
|
||||||
// Note: return type (T1, T2) should be handled elsewhere
|
// Note: return type (T1, T2) should be handled elsewhere
|
||||||
.amp, .key_fn, .lsbr, .question {
|
.amp, .key_fn, .lsbr, .question {
|
||||||
|
@ -5330,7 +5330,7 @@ fn (mut g Gen) or_block(var_name string, or_block ast.OrExpr, return_type ast.Ty
|
|||||||
[inline]
|
[inline]
|
||||||
fn c_name(name_ string) string {
|
fn c_name(name_ string) string {
|
||||||
name := util.no_dots(name_)
|
name := util.no_dots(name_)
|
||||||
if -1 != c.c_reserved_chk.find(name) {
|
if c.c_reserved_chk.matches(name) {
|
||||||
return '_v_$name'
|
return '_v_$name'
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
|
@ -235,7 +235,7 @@ fn (mut p Parser) match_expr() ast.MatchExpr {
|
|||||||
is_else = true
|
is_else = true
|
||||||
p.next()
|
p.next()
|
||||||
} else if (p.tok.kind == .name && !(p.tok.lit == 'C' && p.peek_tok.kind == .dot)
|
} else if (p.tok.kind == .name && !(p.tok.lit == 'C' && p.peek_tok.kind == .dot)
|
||||||
&& (((ast.builtin_type_names_matcher.find(p.tok.lit) > 0 || p.tok.lit[0].is_capital())
|
&& (((ast.builtin_type_names_matcher.matches(p.tok.lit) || p.tok.lit[0].is_capital())
|
||||||
&& p.peek_tok.kind != .lpar) || (p.peek_tok.kind == .dot && p.peek_token(2).lit.len > 0
|
&& p.peek_tok.kind != .lpar) || (p.peek_tok.kind == .dot && p.peek_token(2).lit.len > 0
|
||||||
&& p.peek_token(2).lit[0].is_capital()))) || p.is_only_array_type() {
|
&& p.peek_token(2).lit[0].is_capital()))) || p.is_only_array_type() {
|
||||||
mut types := []ast.Type{}
|
mut types := []ast.Type{}
|
||||||
|
@ -940,7 +940,7 @@ fn (mut s Scanner) text_scan() token.Token {
|
|||||||
typs.all(it.len > 0
|
typs.all(it.len > 0
|
||||||
&& ((it[0].is_capital() && it[1..].bytes().all(it.is_alnum()
|
&& ((it[0].is_capital() && it[1..].bytes().all(it.is_alnum()
|
||||||
|| it == `_`))
|
|| it == `_`))
|
||||||
|| ast.builtin_type_names_matcher.find(it) > 0))
|
|| ast.builtin_type_names_matcher.matches(it)))
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user