From e7579c4e05bd74e6e824b6e03df20c7cb380bd17 Mon Sep 17 00:00:00 2001 From: z7zmey Date: Fri, 1 Dec 2017 18:40:00 +0200 Subject: [PATCH] parse opent echo tag --- example.php | 12 +++++++++++- scanner.go | 6 ++++-- scanner.l | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/example.php b/example.php index 50e3491..ac5f3bb 100644 --- a/example.php +++ b/example.php @@ -13,4 +13,14 @@ abstract class Foo extends Bar implements Buz, Buzz { public function &test(bool $a, string $b = null): ?void { } -} \ No newline at end of file +} + +if ($a === true) { +} elseif ($a === false) { +} elseif ($a === null) { +} else { +} + +?> + + \ No newline at end of file diff --git a/scanner.go b/scanner.go index eb0249e..f91e40f 100644 --- a/scanner.go +++ b/scanner.go @@ -7715,7 +7715,7 @@ yyrule5: // \<\?= { l.begin(PHP) lval.token = string(l.TokenBytes(nil)) - return T_OPEN_TAG_WITH_ECHO + return T_ECHO goto yystate0 } yyrule6: // [ \t\n\r]+ @@ -7725,7 +7725,9 @@ yyrule6: // [ \t\n\r]+ } yyrule7: // \?\>{NEW_LINE}? { - l.begin(INITIAL) //lval.token = string(l.TokenBytes(nil)); return T_CLOSE_TAG; + l.begin(INITIAL) + lval.token = ";" + return rune2Class(';') goto yystate0 } yyrule8: // {DNUM}|{EXPONENT_DNUM} diff --git a/scanner.l b/scanner.l index 702a682..e51f1e2 100644 --- a/scanner.l +++ b/scanner.l @@ -96,10 +96,10 @@ NEW_LINE (\r|\n|\r\n) \<\?php([ \t]|{NEW_LINE}) l.begin(PHP);//lval.token = string(l.TokenBytes(nil)); return T_OPEN_TAG; \<\? l.begin(PHP);//lval.token = string(l.TokenBytes(nil)); return T_OPEN_TAG; -\<\?= l.begin(PHP);lval.token = string(l.TokenBytes(nil)); return T_OPEN_TAG_WITH_ECHO; +\<\?= l.begin(PHP);lval.token = string(l.TokenBytes(nil)); return T_ECHO; [ \t\n\r]+ //lval.token = string(l.TokenBytes(nil)); return T_WHITESPACE -\?\>{NEW_LINE}? l.begin(INITIAL);//lval.token = string(l.TokenBytes(nil)); return T_CLOSE_TAG; +\?\>{NEW_LINE}? l.begin(INITIAL);lval.token = ";"; return rune2Class(';'); {DNUM}|{EXPONENT_DNUM} lval.token = string(l.TokenBytes(nil)); return T_DNUMBER {BNUM}