remove redundant nop before inline html

This commit is contained in:
z7zmey 2018-04-02 00:02:13 +03:00
parent 8fd369b047
commit 5edfa095cb
3 changed files with 4187 additions and 4080 deletions

File diff suppressed because it is too large Load Diff

View File

@ -93,6 +93,7 @@ NEW_LINE (\r|\n|\r\n)
<INITIAL>\<\?= l.begin(PHP);lval.Token(l.newToken(l.Token())); return T_ECHO; <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]+ 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>\?\>{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 <PHP>{DNUM}|{EXPONENT_DNUM} lval.Token(l.newToken(l.Token())); return T_DNUMBER

View File

@ -693,6 +693,38 @@ CAT;
assertEqual(t, expected, actual) 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) { func TestStringTokensAfterVariable(t *testing.T) {
src := `<?php "test \"$var\""` src := `<?php "test \"$var\""`