refactor: move php7 scanner into php7 package

This commit is contained in:
Laytan Laats
2023-03-25 15:02:34 +01:00
parent a97686125d
commit 74a8771740
17 changed files with 261 additions and 267 deletions

View File

@@ -124,11 +124,13 @@ func (lex *Lexer) isHeredocEndBefore73(p int) bool {
return false
}
if len(lex.data) > p+l && lex.data[p+l] != ';' && lex.data[p+l] != '\r' && lex.data[p+l] != '\n' {
if len(lex.data) > p+l && lex.data[p+l] != ';' && lex.data[p+l] != '\r' &&
lex.data[p+l] != '\n' {
return false
}
if len(lex.data) > p+l+1 && lex.data[p+l] == ';' && lex.data[p+l+1] != '\r' && lex.data[p+l+1] != '\n' {
if len(lex.data) > p+l+1 && lex.data[p+l] == ';' && lex.data[p+l+1] != '\r' &&
lex.data[p+l+1] != '\n' {
return false
}
@@ -262,5 +264,6 @@ func isValidVarNameStart(r byte) bool {
}
func isValidVarName(r byte) bool {
return (r >= 'A' && r <= 'Z') || (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '_' || r >= 0x80
return (r >= 'A' && r <= 'Z') || (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '_' ||
r >= 0x80
}

View File

@@ -4177,7 +4177,7 @@ class Point {
},
},
AmpersandTkn: &token.Token{
ID: token.ID(57492),
ID: token.T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG,
Val: []byte("&"),
FreeFloating: []*token.Token{
{
@@ -4302,7 +4302,7 @@ class Point {
},
},
AmpersandTkn: &token.Token{
ID: token.ID(57492),
ID: token.T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG,
Val: []byte("&"),
FreeFloating: []*token.Token{
{

View File

@@ -539,4 +539,4 @@ func (lex *Lexer) Lex() *token.Token {
tkn.ID = token.ID(tok)
return tkn
}
}

View File

@@ -317,7 +317,7 @@ func TestTokens(t *testing.T) {
token.ID(int('|')).String(),
token.ID(int('/')).String(),
token.ID(int('^')).String(),
token.ID(T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG).String(),
token.ID(token.T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG).String(),
token.ID(int('+')).String(),
token.ID(int('-')).String(),
token.ID(int('*')).String(),