remove redundant nop before inline html
This commit is contained in:
parent
8fd369b047
commit
5edfa095cb
8234
scanner/scanner.go
8234
scanner/scanner.go
File diff suppressed because it is too large
Load Diff
@ -93,6 +93,7 @@ NEW_LINE (\r|\n|\r\n)
|
||||
<INITIAL>\<\?= l.begin(PHP);lval.Token(l.newToken(l.Token())); return T_ECHO;
|
||||
|
||||
<PHP>[ \t\n\r]+ lval.Token(l.newToken(l.Token()));// return T_WHITESPACE
|
||||
<PHP>[;][ \t\n\r]*\?\>{NEW_LINE}? l.begin(INITIAL);lval.Token(l.newToken(l.Token())); return Rune2Class(';');
|
||||
<PHP>\?\>{NEW_LINE}? l.begin(INITIAL);lval.Token(l.newToken(l.Token())); return Rune2Class(';');
|
||||
|
||||
<PHP>{DNUM}|{EXPONENT_DNUM} lval.Token(l.newToken(l.Token())); return T_DNUMBER
|
||||
|
@ -693,6 +693,38 @@ CAT;
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestInlineHtmlNopTokens(t *testing.T) {
|
||||
src := `<?php
|
||||
$a; ?> test <?php
|
||||
$a ?> test
|
||||
`
|
||||
|
||||
expected := []int{
|
||||
scanner.T_VARIABLE,
|
||||
scanner.Rune2Class(';'),
|
||||
scanner.T_INLINE_HTML,
|
||||
|
||||
scanner.T_VARIABLE,
|
||||
scanner.Rune2Class(';'),
|
||||
scanner.T_INLINE_HTML,
|
||||
}
|
||||
|
||||
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
|
||||
lv := &lval{}
|
||||
actual := []int{}
|
||||
|
||||
for {
|
||||
token := lexer.Lex(lv)
|
||||
if token < 0 {
|
||||
break
|
||||
}
|
||||
|
||||
actual = append(actual, token)
|
||||
}
|
||||
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestStringTokensAfterVariable(t *testing.T) {
|
||||
src := `<?php "test \"$var\""`
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user