1
0
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:
Delyan Angelov 2022-07-29 23:01:30 +03:00
parent 2db8bd62a2
commit 336305daa5
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
4 changed files with 4 additions and 4 deletions

View File

@ -2266,7 +2266,7 @@ pub fn type_can_start_with_token(tok &token.Token) bool {
match tok.kind {
.name {
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
.amp, .key_fn, .lsbr, .question {

View File

@ -5330,7 +5330,7 @@ fn (mut g Gen) or_block(var_name string, or_block ast.OrExpr, return_type ast.Ty
[inline]
fn c_name(name_ string) string {
name := util.no_dots(name_)
if -1 != c.c_reserved_chk.find(name) {
if c.c_reserved_chk.matches(name) {
return '_v_$name'
}
return name

View File

@ -235,7 +235,7 @@ fn (mut p Parser) match_expr() ast.MatchExpr {
is_else = true
p.next()
} 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_token(2).lit[0].is_capital()))) || p.is_only_array_type() {
mut types := []ast.Type{}

View File

@ -940,7 +940,7 @@ fn (mut s Scanner) text_scan() token.Token {
typs.all(it.len > 0
&& ((it[0].is_capital() && it[1..].bytes().all(it.is_alnum()
|| it == `_`))
|| ast.builtin_type_names_matcher.find(it) > 0))
|| ast.builtin_type_names_matcher.matches(it)))
} else {
false
}