php token type

This commit is contained in:
z7zmey 2017-12-03 18:36:34 +02:00
parent c23b899f55
commit 71949dbcd2
6 changed files with 1024 additions and 1032 deletions

View File

@ -2,7 +2,7 @@ package main
import ( import (
"bufio" "bufio"
"go/token" gotoken "go/token"
"io" "io"
"unicode" "unicode"
@ -37,7 +37,7 @@ func rune2Class(r rune) int {
} }
func newLexer(src io.Reader, fName string) *lexer { func newLexer(src io.Reader, fName string) *lexer {
file := token.NewFileSet().AddFile(fName, -1, 1<<31-1) file := gotoken.NewFileSet().AddFile(fName, -1, 1<<31-1)
lx, err := lex.New(file, bufio.NewReader(src), lex.RuneClass(rune2Class)) lx, err := lex.New(file, bufio.NewReader(src), lex.RuneClass(rune2Class))
if err != nil { if err != nil {
panic(err) panic(err)
@ -84,12 +84,12 @@ func (l *lexer) getCurrentState() int {
return l.stateStack[len(l.stateStack)-1] return l.stateStack[len(l.stateStack)-1]
} }
func (l *lexer) handleNewLine(str []byte) (int, int) { func (l *lexer) handleNewLine(tokenBytes []byte) ([]byte, int, int) {
startln := l.lineNumber startln := l.lineNumber
var prev byte var prev byte
for _, b := range str { for _, b := range tokenBytes {
if b == '\n' || prev == '\r' { if b == '\n' || prev == '\r' {
l.lineNumber++ l.lineNumber++
} }
@ -102,5 +102,5 @@ func (l *lexer) handleNewLine(str []byte) (int, int) {
l.lineNumber++ l.lineNumber++
} }
return startln, l.lineNumber return tokenBytes, startln, l.lineNumber
} }

1228
parser.go

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@ func parse(src io.Reader, fName string) node {
%union{ %union{
node node node node
token string token token
value string value string
} }
@ -157,12 +157,13 @@ func parse(src io.Reader, fName string) node {
%token <token> T_PROTECTED %token <token> T_PROTECTED
%token <token> T_PUBLIC %token <token> T_PUBLIC
%type <value> class_modifier
%type <value> is_reference %type <value> is_reference
%type <value> is_variadic %type <value> is_variadic
%type <value> returns_ref %type <value> returns_ref
%type <value> reserved_non_modifiers %type <value> class_modifier
%type <value> semi_reserved
%type <token> reserved_non_modifiers
%type <token> semi_reserved
%type <node> top_statement namespace_name name statement function_declaration_statement %type <node> top_statement namespace_name name statement function_declaration_statement
%type <node> class_declaration_statement trait_declaration_statement %type <node> class_declaration_statement trait_declaration_statement
@ -221,8 +222,8 @@ semi_reserved:
; ;
identifier: identifier:
T_STRING { $$ = Node("identifier").attribute("value", $1) } T_STRING { $$ = Node("identifier").attribute("value", $1.String()) }
| semi_reserved { $$ = Node("identifier").attribute("value", $1) } | semi_reserved { $$ = Node("identifier").attribute("value", $1.String()) }
; ;
top_statement_list: top_statement_list:
@ -231,8 +232,8 @@ top_statement_list:
; ;
namespace_name: namespace_name:
T_STRING { $$ = Node("NamespaceParts").append(Node($1)); } T_STRING { $$ = Node("NamespaceParts").append(Node($1.String())); }
| namespace_name T_NS_SEPARATOR T_STRING { $$ = $1.append(Node($3)); } | namespace_name T_NS_SEPARATOR T_STRING { $$ = $1.append(Node($3.String())); }
; ;
name: name:
@ -307,7 +308,7 @@ inline_use_declaration:
unprefixed_use_declaration: unprefixed_use_declaration:
namespace_name { $$ = Node("UseElem").append($1); } namespace_name { $$ = Node("UseElem").append($1); }
| namespace_name T_AS T_STRING { $$ = Node("UseElem").append($1).append(Node("as").attribute("value", $3)); } | namespace_name T_AS T_STRING { $$ = Node("UseElem").append($1).append(Node("as").attribute("value", $3.String())); }
; ;
use_declaration: use_declaration:
@ -364,7 +365,7 @@ statement:
| T_GLOBAL global_var_list ';' { $$ = $2; } | T_GLOBAL global_var_list ';' { $$ = $2; }
| T_STATIC static_var_list ';' { $$ = $2; } | T_STATIC static_var_list ';' { $$ = $2; }
| T_ECHO echo_expr_list ';' { $$ = $2; } | T_ECHO echo_expr_list ';' { $$ = $2; }
| T_INLINE_HTML { $$ = Node("Echo").append(Node("InlineHtml").attribute("value", $1)) } | T_INLINE_HTML { $$ = Node("Echo").append(Node("InlineHtml").attribute("value", $1.String())) }
| expr ';' { $$ = $1; } | expr ';' { $$ = $1; }
| T_UNSET '(' unset_variables possible_comma ')' ';' | T_UNSET '(' unset_variables possible_comma ')' ';'
{ $$ = Node("Unset").append($3); } { $$ = Node("Unset").append($3); }
@ -393,13 +394,13 @@ statement:
append($6); append($6);
} }
| T_THROW expr ';' { $$ = Node("Throw").append($2) } | T_THROW expr ';' { $$ = Node("Throw").append($2) }
| T_GOTO T_STRING ';' { $$ = Node("GoTo").attribute("Label", $2) } | T_GOTO T_STRING ';' { $$ = Node("GoTo").attribute("Label", $2.String()) }
| T_STRING ':' { $$ = Node("Label").attribute("name", $1) } | T_STRING ':' { $$ = Node("Label").attribute("name", $1.String()) }
catch_list: catch_list:
/* empty */ { $$ = Node("CatchList") } /* empty */ { $$ = Node("CatchList") }
| catch_list T_CATCH '(' catch_name_list T_VARIABLE ')' '{' inner_statement_list '}' | catch_list T_CATCH '(' catch_name_list T_VARIABLE ')' '{' inner_statement_list '}'
{ $$ = $1.append($4).append(Node("Variable").attribute("name", $5)).append($8) } { $$ = $1.append($4).append(Node("Variable").attribute("name", $5.String())).append($8) }
; ;
catch_name_list: catch_name_list:
name { $$ = Node("CatchNameList").append($1) } name { $$ = Node("CatchNameList").append($1) }
@ -424,7 +425,7 @@ function_declaration_statement:
T_FUNCTION returns_ref T_STRING '(' parameter_list ')' return_type '{' inner_statement_list '}' T_FUNCTION returns_ref T_STRING '(' parameter_list ')' return_type '{' inner_statement_list '}'
{ {
$$ = Node("Function"). $$ = Node("Function").
attribute("name", $3). attribute("name", $3.String()).
attribute("returns_ref", $2). attribute("returns_ref", $2).
append($5). append($5).
append($7). append($7).
@ -446,7 +447,7 @@ class_declaration_statement:
class_modifiers T_CLASS T_STRING extends_from implements_list '{' class_statement_list '}' class_modifiers T_CLASS T_STRING extends_from implements_list '{' class_statement_list '}'
{ {
$$ = Node("Class"). $$ = Node("Class").
attribute("name", $3). attribute("name", $3.String()).
append($1). append($1).
append(Node("Extends").append($4)). append(Node("Extends").append($4)).
append(Node("Implements").append($5)). append(Node("Implements").append($5)).
@ -455,7 +456,7 @@ class_declaration_statement:
| T_CLASS T_STRING extends_from implements_list '{' class_statement_list '}' | T_CLASS T_STRING extends_from implements_list '{' class_statement_list '}'
{ {
$$ = Node("Class"). $$ = Node("Class").
attribute("name", $2). attribute("name", $2.String()).
append(Node("Extends").append($3)). append(Node("Extends").append($3)).
append(Node("Implements").append($4)). append(Node("Implements").append($4)).
append($6); append($6);
@ -473,14 +474,14 @@ class_modifier:
; ;
trait_declaration_statement: trait_declaration_statement:
T_TRAIT T_STRING '{' class_statement_list '}' { $$ = Node("Trait").attribute("name", $2).append($4) } T_TRAIT T_STRING '{' class_statement_list '}' { $$ = Node("Trait").attribute("name", $2.String()).append($4) }
; ;
interface_declaration_statement: interface_declaration_statement:
T_INTERFACE T_STRING interface_extends_list '{' class_statement_list '}' T_INTERFACE T_STRING interface_extends_list '{' class_statement_list '}'
{ {
$$ = Node("Interface"). $$ = Node("Interface").
attribute("name", $2). attribute("name", $2.String()).
append(Node("Extends").append($3)). append(Node("Extends").append($3)).
append($5); append($5);
} }
@ -607,7 +608,7 @@ parameter:
append($1). append($1).
attribute("is_reference", $2). attribute("is_reference", $2).
attribute("is_variadic", $3). attribute("is_variadic", $3).
attribute("var", $4); attribute("var", $4.String());
} }
| optional_type is_reference is_variadic T_VARIABLE '=' expr | optional_type is_reference is_variadic T_VARIABLE '=' expr
{ {
@ -615,7 +616,7 @@ parameter:
append($1). append($1).
attribute("is_reference", $2). attribute("is_reference", $2).
attribute("is_variadic", $3). attribute("is_variadic", $3).
attribute("var", $4). attribute("var", $4.String()).
append($6); append($6);
} }
; ;
@ -671,8 +672,8 @@ static_var_list:
; ;
static_var: static_var:
T_VARIABLE { $$ = Node("StaticVariable").attribute("Name", $1); } T_VARIABLE { $$ = Node("StaticVariable").attribute("Name", $1.String()); }
| T_VARIABLE '=' expr { $$ = Node("StaticVariable").attribute("Name", $1).append(Node("expr").append($3)); } | T_VARIABLE '=' expr { $$ = Node("StaticVariable").attribute("Name", $1.String()).append(Node("expr").append($3)); }
; ;
class_statement_list: class_statement_list:
@ -724,7 +725,7 @@ trait_precedence:
; ;
trait_alias: trait_alias:
trait_method_reference T_AS T_STRING { $$ = $1.append(Node("as").attribute("value", $3)); } trait_method_reference T_AS T_STRING { $$ = $1.append(Node("as").attribute("value", $3.String())); }
| trait_method_reference T_AS reserved_non_modifiers | trait_method_reference T_AS reserved_non_modifiers
{ $$ = $1.append(Node("as").append(Node("reservedNonModifiers"))); } { $$ = $1.append(Node("as").append(Node("reservedNonModifiers"))); }
| trait_method_reference T_AS member_modifier identifier | trait_method_reference T_AS member_modifier identifier
@ -776,8 +777,8 @@ property_list:
; ;
property: property:
T_VARIABLE { $$ = Node("Property").attribute("name", $1) } T_VARIABLE { $$ = Node("Property").attribute("name", $1.String()) }
| T_VARIABLE '=' expr { $$ = Node("Property").attribute("name", $1).append(Node("Default").append($3)) } | T_VARIABLE '=' expr { $$ = Node("Property").attribute("name", $1.String()).append(Node("Default").append($3)) }
; ;
class_const_list: class_const_list:
@ -790,7 +791,7 @@ class_const_decl:
; ;
const_decl: const_decl:
T_STRING '=' expr { $$ = Node("Const").attribute("name", $1).append($3) } T_STRING '=' expr { $$ = Node("Const").attribute("name", $1.String()).append($3) }
; ;
echo_expr_list: echo_expr_list:
@ -815,7 +816,7 @@ anonymous_class:
T_CLASS ctor_arguments extends_from implements_list '{' class_statement_list '}' T_CLASS ctor_arguments extends_from implements_list '{' class_statement_list '}'
{ {
$$ = Node("AnonymousClass"). $$ = Node("AnonymousClass").
attribute("name", $1). attribute("name", $1.String()).
append($2). append($2).
append($3). append($3).
append($4). append($4).
@ -939,8 +940,8 @@ lexical_var_list:
; ;
lexical_var: lexical_var:
T_VARIABLE { $$ = Node("Variable").attribute("value", $1) } T_VARIABLE { $$ = Node("Variable").attribute("value", $1.String()) }
| '&' T_VARIABLE { $$ = Node("Variable").attribute("value", $2).attribute("ref", "true") } | '&' T_VARIABLE { $$ = Node("Variable").attribute("value", $2.String()).attribute("ref", "true") }
; ;
function_call: function_call:
@ -969,7 +970,7 @@ exit_expr:
backticks_expr: backticks_expr:
/* empty */ { $$ = Node("EmptyBackticks") } /* empty */ { $$ = Node("EmptyBackticks") }
| T_ENCAPSED_AND_WHITESPACE { $$ = Node("String").attribute("value", $1) } | T_ENCAPSED_AND_WHITESPACE { $$ = Node("String").attribute("value", $1.String()) }
| encaps_list { $$ = $1; } | encaps_list { $$ = $1; }
; ;
@ -981,12 +982,12 @@ ctor_arguments:
dereferencable_scalar: dereferencable_scalar:
T_ARRAY '(' array_pair_list ')' { $$ = $3; } T_ARRAY '(' array_pair_list ')' { $$ = $3; }
| '[' array_pair_list ']' { $$ = $2; } | '[' array_pair_list ']' { $$ = $2; }
| T_CONSTANT_ENCAPSED_STRING { $$ = Node("String").attribute("value", $1) } | T_CONSTANT_ENCAPSED_STRING { $$ = Node("String").attribute("value", $1.String()) }
; ;
scalar: scalar:
T_LNUMBER { $$ = Node("Scalar").append(Node("Lnumber").attribute("value", $1)) } T_LNUMBER { $$ = Node("Scalar").append(Node("Lnumber").attribute("value", $1.String())) }
| T_DNUMBER { $$ = Node("Scalar").append(Node("Dnumber").attribute("value", $1)) } | T_DNUMBER { $$ = Node("Scalar").append(Node("Dnumber").attribute("value", $1.String())) }
| T_LINE { $$ = Node("Scalar").append(Node("__LINE__")) } | T_LINE { $$ = Node("Scalar").append(Node("__LINE__")) }
| T_FILE { $$ = Node("Scalar").append(Node("__FILE__")) } | T_FILE { $$ = Node("Scalar").append(Node("__FILE__")) }
| T_DIR { $$ = Node("Scalar").append(Node("__DIR__")) } | T_DIR { $$ = Node("Scalar").append(Node("__DIR__")) }
@ -996,7 +997,7 @@ scalar:
| T_NS_C { $$ = Node("Scalar").append(Node("__NAMESPACE__")); } | T_NS_C { $$ = Node("Scalar").append(Node("__NAMESPACE__")); }
| T_CLASS_C { $$ = Node("Scalar").append(Node("__CLASS__")); } | T_CLASS_C { $$ = Node("Scalar").append(Node("__CLASS__")); }
| T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC
{ $$ = Node("Scalar").append(Node("Heredoc").attribute("value", $2)) } { $$ = Node("Scalar").append(Node("Heredoc").attribute("value", $2.String())) }
| T_START_HEREDOC T_END_HEREDOC | T_START_HEREDOC T_END_HEREDOC
{ $$ = Node("Scalar").append(Node("Heredoc")) } { $$ = Node("Scalar").append(Node("Heredoc")) }
| '"' encaps_list '"' { $$ = $2; } | '"' encaps_list '"' { $$ = $2; }
@ -1055,7 +1056,7 @@ variable:
; ;
simple_variable: simple_variable:
T_VARIABLE { $$ = Node("Variable").attribute("name", $1); } T_VARIABLE { $$ = Node("Variable").attribute("name", $1.String()); }
| '$' '{' expr '}' { $$ = Node("Variable").append($3); } | '$' '{' expr '}' { $$ = Node("Variable").append($3); }
| '$' simple_variable { $$ = Node("Variable").append($2); } | '$' simple_variable { $$ = Node("Variable").append($2); }
; ;
@ -1085,7 +1086,7 @@ member_name:
; ;
property_name: property_name:
T_STRING { $$ = Node("PropertyName").attribute("value", $1) } T_STRING { $$ = Node("PropertyName").attribute("value", $1.String()) }
| '{' expr '}' { $$ = $2; } | '{' expr '}' { $$ = $2; }
| simple_variable { $$ = $1 } | simple_variable { $$ = $1 }
; ;
@ -1125,26 +1126,26 @@ array_pair:
encaps_list: encaps_list:
encaps_list encaps_var { $$ = $1.append($2) } encaps_list encaps_var { $$ = $1.append($2) }
| encaps_list T_ENCAPSED_AND_WHITESPACE { $$ = $1.append(Node("String").attribute("value", $2)) } | encaps_list T_ENCAPSED_AND_WHITESPACE { $$ = $1.append(Node("String").attribute("value", $2.String())) }
| encaps_var { $$ = Node("EncapsList").append($1) } | encaps_var { $$ = Node("EncapsList").append($1) }
| T_ENCAPSED_AND_WHITESPACE encaps_var { $$ = Node("EncapsList").append(Node("String").attribute("value", $1)).append($2) } | T_ENCAPSED_AND_WHITESPACE encaps_var { $$ = Node("EncapsList").append(Node("String").attribute("value", $1.String())).append($2) }
; ;
encaps_var: encaps_var:
T_VARIABLE { $$ = Node("Variable").attribute("value", $1) } T_VARIABLE { $$ = Node("Variable").attribute("value", $1.String()) }
| T_VARIABLE '[' encaps_var_offset ']' { $$ = Node("Variable").attribute("value", $1).append(Node("offset").append($3)) } | T_VARIABLE '[' encaps_var_offset ']' { $$ = Node("Variable").attribute("value", $1.String()).append(Node("offset").append($3)) }
| T_VARIABLE T_OBJECT_OPERATOR T_STRING { $$ = Node("Variable").attribute("value", $1).append(Node("property").attribute("value", $3)) } | T_VARIABLE T_OBJECT_OPERATOR T_STRING { $$ = Node("Variable").attribute("value", $1.String()).append(Node("property").attribute("value", $3.String())) }
| T_DOLLAR_OPEN_CURLY_BRACES expr '}' { $$ = Node("Variable").append(Node("expr").append($2)) } | T_DOLLAR_OPEN_CURLY_BRACES expr '}' { $$ = Node("Variable").append(Node("expr").append($2)) }
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' { $$ = Node("Variable").attribute("value", $2) } | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' { $$ = Node("Variable").attribute("value", $2.String()) }
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
{ $$ = Node("Variable").attribute("value", $2).append(Node("offset").append($4)) } { $$ = Node("Variable").attribute("value", $2.String()).append(Node("offset").append($4)) }
| T_CURLY_OPEN variable '}' { $$ = $2; } | T_CURLY_OPEN variable '}' { $$ = $2; }
; ;
encaps_var_offset: encaps_var_offset:
T_STRING { $$ = Node("OffsetString").attribute("value", $1) } T_STRING { $$ = Node("OffsetString").attribute("value", $1.String()) }
| T_NUM_STRING { $$ = Node("OffsetNumString").attribute("value", $1) } | T_NUM_STRING { $$ = Node("OffsetNumString").attribute("value", $1.String()) }
| '-' T_NUM_STRING { $$ = Node("OffsetNegateNumString").attribute("value", $2) } | '-' T_NUM_STRING { $$ = Node("OffsetNegateNumString").attribute("value", $2.String()) }
| T_VARIABLE { $$ = Node("OffsetVariable").attribute("value", $1) } | T_VARIABLE { $$ = Node("OffsetVariable").attribute("value", $1.String()) }
; ;
internal_functions_in_yacc: internal_functions_in_yacc:

File diff suppressed because it is too large Load Diff

350
scanner.l
View File

@ -53,7 +53,7 @@ NEW_LINE (\r|\n|\r\n)
%% %%
c = l.Rule0() c = l.Rule0()
<INITIAL>[ \t\n\r]+ l.handleNewLine(l.TokenBytes(nil)); <INITIAL>[ \t\n\r]+ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));
<INITIAL>. <INITIAL>.
tb := []byte{} tb := []byte{}
@ -77,18 +77,17 @@ NEW_LINE (\r|\n|\r\n)
c = l.Next() c = l.Next()
} }
l.handleNewLine(tb); lval.token = newToken(l.handleNewLine(tb));
lval.token = string(tb);
return T_INLINE_HTML return T_INLINE_HTML
<INITIAL>\<\?php([ \t]|{NEW_LINE}) l.handleNewLine(l.TokenBytes(nil));l.begin(PHP);//lval.token = string(l.TokenBytes(nil)); return T_OPEN_TAG; <INITIAL>\<\?php([ \t]|{NEW_LINE}) l.begin(PHP);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));// return T_OPEN_TAG;
<INITIAL>\<\? l.begin(PHP);//lval.token = string(l.TokenBytes(nil)); return T_OPEN_TAG; <INITIAL>\<\? l.begin(PHP);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));// return T_OPEN_TAG;
<INITIAL>\<\?= l.begin(PHP);lval.token = string(l.TokenBytes(nil)); return T_ECHO; <INITIAL>\<\?= l.begin(PHP);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ECHO;
<PHP>[ \t\n\r]+ l.handleNewLine(l.TokenBytes(nil));//lval.token = string(l.TokenBytes(nil)); return T_WHITESPACE <PHP>[ \t\n\r]+ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));// return T_WHITESPACE
<PHP>\?\>{NEW_LINE}? l.handleNewLine(l.TokenBytes(nil));l.begin(INITIAL);lval.token = ";"; return rune2Class(';'); <PHP>\?\>{NEW_LINE}? l.begin(INITIAL);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(';');
<PHP>{DNUM}|{EXPONENT_DNUM} lval.token = string(l.TokenBytes(nil)); return T_DNUMBER <PHP>{DNUM}|{EXPONENT_DNUM} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DNUMBER
<PHP>{BNUM} <PHP>{BNUM}
tb := l.TokenBytes(nil) tb := l.TokenBytes(nil)
i:=2 i:=2
@ -99,15 +98,15 @@ NEW_LINE (\r|\n|\r\n)
} }
} }
if len(tb) - i < 64 { if len(tb) - i < 64 {
lval.token = string(l.TokenBytes(nil)); return T_LNUMBER lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LNUMBER
} else { } else {
lval.token = string(l.TokenBytes(nil)); return T_DNUMBER lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DNUMBER
} }
<PHP>{LNUM} <PHP>{LNUM}
if len(l.TokenBytes(nil)) < 20 { if len(l.TokenBytes(nil)) < 20 {
lval.token = string(l.TokenBytes(nil)); return T_LNUMBER lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LNUMBER
} else { } else {
lval.token = string(l.TokenBytes(nil)); return T_DNUMBER lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DNUMBER
} }
<PHP>{HNUM} <PHP>{HNUM}
tb := l.TokenBytes(nil) tb := l.TokenBytes(nil)
@ -120,145 +119,145 @@ NEW_LINE (\r|\n|\r\n)
} }
length := len(tb) - i length := len(tb) - i
if length < 16 || (length == 16 && tb[i] <= '7') { if length < 16 || (length == 16 && tb[i] <= '7') {
lval.token = string(l.TokenBytes(nil)); return T_LNUMBER lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LNUMBER
} else { } else {
lval.token = string(l.TokenBytes(nil)); return T_DNUMBER lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DNUMBER
} }
<PHP>abstract lval.token = string(l.TokenBytes(nil)); return T_ABSTRACT <PHP>abstract lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ABSTRACT
<PHP>array lval.token = string(l.TokenBytes(nil)); return T_ARRAY <PHP>array lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ARRAY
<PHP>as lval.token = string(l.TokenBytes(nil)); return T_AS <PHP>as lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_AS
<PHP>break lval.token = string(l.TokenBytes(nil)); return T_BREAK <PHP>break lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_BREAK
<PHP>callable lval.token = string(l.TokenBytes(nil)); return T_CALLABLE <PHP>callable lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CALLABLE
<PHP>case lval.token = string(l.TokenBytes(nil)); return T_CASE <PHP>case lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CASE
<PHP>catch lval.token = string(l.TokenBytes(nil)); return T_CATCH <PHP>catch lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CATCH
<PHP>class lval.token = string(l.TokenBytes(nil)); return T_CLASS <PHP>class lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CLASS
<PHP>clone lval.token = string(l.TokenBytes(nil)); return T_CLONE <PHP>clone lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CLONE
<PHP>const lval.token = string(l.TokenBytes(nil)); return T_CONST; <PHP>const lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONST;
<PHP>continue lval.token = string(l.TokenBytes(nil)); return T_CONTINUE; <PHP>continue lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONTINUE;
<PHP>declare lval.token = string(l.TokenBytes(nil)); return T_DECLARE; <PHP>declare lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DECLARE;
<PHP>default lval.token = string(l.TokenBytes(nil)); return T_DEFAULT; <PHP>default lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DEFAULT;
<PHP>do lval.token = string(l.TokenBytes(nil)); return T_DO; <PHP>do lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DO;
<PHP>echo lval.token = string(l.TokenBytes(nil)); return T_ECHO; <PHP>echo lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ECHO;
<PHP>else lval.token = string(l.TokenBytes(nil)); return T_ELSE; <PHP>else lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ELSE;
<PHP>elseif lval.token = string(l.TokenBytes(nil)); return T_ELSEIF; <PHP>elseif lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ELSEIF;
<PHP>empty lval.token = string(l.TokenBytes(nil)); return T_EMPTY; <PHP>empty lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_EMPTY;
<PHP>enddeclare lval.token = string(l.TokenBytes(nil)); return T_ENDDECLARE <PHP>enddeclare lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDDECLARE
<PHP>endfor lval.token = string(l.TokenBytes(nil)); return T_ENDFOR <PHP>endfor lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDFOR
<PHP>endforeach lval.token = string(l.TokenBytes(nil)); return T_ENDFOREACH <PHP>endforeach lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDFOREACH
<PHP>endif lval.token = string(l.TokenBytes(nil)); return T_ENDIF <PHP>endif lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDIF
<PHP>endswitch lval.token = string(l.TokenBytes(nil)); return T_ENDSWITCH <PHP>endswitch lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDSWITCH
<PHP>endwhile lval.token = string(l.TokenBytes(nil)); return T_ENDWHILE <PHP>endwhile lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDWHILE
<PHP>eval lval.token = string(l.TokenBytes(nil)); return T_EVAL <PHP>eval lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_EVAL
<PHP>exit|die lval.token = string(l.TokenBytes(nil)); return T_EXIT <PHP>exit|die lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_EXIT
<PHP>extends lval.token = string(l.TokenBytes(nil)); return T_EXTENDS <PHP>extends lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_EXTENDS
<PHP>final lval.token = string(l.TokenBytes(nil)); return T_FINAL <PHP>final lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FINAL
<PHP>finally lval.token = string(l.TokenBytes(nil)); return T_FINALLY <PHP>finally lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FINALLY
<PHP>for lval.token = string(l.TokenBytes(nil)); return T_FOR <PHP>for lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FOR
<PHP>foreach lval.token = string(l.TokenBytes(nil)); return T_FOREACH <PHP>foreach lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FOREACH
<PHP>function|cfunction lval.token = string(l.TokenBytes(nil)); return T_FUNCTION <PHP>function|cfunction lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FUNCTION
<PHP>global lval.token = string(l.TokenBytes(nil)); return T_GLOBAL <PHP>global lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_GLOBAL
<PHP>goto lval.token = string(l.TokenBytes(nil)); return T_GOTO <PHP>goto lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_GOTO
<PHP>if lval.token = string(l.TokenBytes(nil)); return T_IF <PHP>if lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IF
<PHP>isset lval.token = string(l.TokenBytes(nil)); return T_ISSET <PHP>isset lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ISSET
<PHP>implements lval.token = string(l.TokenBytes(nil)); return T_IMPLEMENTS <PHP>implements lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IMPLEMENTS
<PHP>instanceof lval.token = string(l.TokenBytes(nil)); return T_INSTANCEOF <PHP>instanceof lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INSTANCEOF
<PHP>insteadof lval.token = string(l.TokenBytes(nil)); return T_INSTEADOF <PHP>insteadof lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INSTEADOF
<PHP>interface lval.token = string(l.TokenBytes(nil)); return T_INTERFACE <PHP>interface lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INTERFACE
<PHP>list lval.token = string(l.TokenBytes(nil)); return T_LIST <PHP>list lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LIST
<PHP>namespace lval.token = string(l.TokenBytes(nil)); return T_NAMESPACE <PHP>namespace lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_NAMESPACE
<PHP>private lval.token = string(l.TokenBytes(nil)); return T_PRIVATE <PHP>private lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_PRIVATE
<PHP>public lval.token = string(l.TokenBytes(nil)); return T_PUBLIC <PHP>public lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_PUBLIC
<PHP>print lval.token = string(l.TokenBytes(nil)); return T_PRINT <PHP>print lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_PRINT
<PHP>protected lval.token = string(l.TokenBytes(nil)); return T_PROTECTED <PHP>protected lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_PROTECTED
<PHP>return lval.token = string(l.TokenBytes(nil)); return T_RETURN <PHP>return lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_RETURN
<PHP>static lval.token = string(l.TokenBytes(nil)); return T_STATIC <PHP>static lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_STATIC
<PHP>switch lval.token = string(l.TokenBytes(nil)); return T_SWITCH <PHP>switch lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_SWITCH
<PHP>throw lval.token = string(l.TokenBytes(nil)); return T_THROW <PHP>throw lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_THROW
<PHP>trait lval.token = string(l.TokenBytes(nil)); return T_TRAIT <PHP>trait lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_TRAIT
<PHP>try lval.token = string(l.TokenBytes(nil)); return T_TRY <PHP>try lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_TRY
<PHP>unset lval.token = string(l.TokenBytes(nil)); return T_UNSET <PHP>unset lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_UNSET
<PHP>use lval.token = string(l.TokenBytes(nil)); return T_USE <PHP>use lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_USE
<PHP>var lval.token = string(l.TokenBytes(nil)); return T_VAR <PHP>var lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_VAR
<PHP>while lval.token = string(l.TokenBytes(nil)); return T_WHILE <PHP>while lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_WHILE
<PHP>yield[ \t\n\r]+from[^a-zA-Z0-9_\x80-\xff] l.handleNewLine(l.TokenBytes(nil));lval.token = string(l.TokenBytes(nil)); return T_YIELD_FROM <PHP>yield[ \t\n\r]+from[^a-zA-Z0-9_\x80-\xff] lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_YIELD_FROM
<PHP>yield lval.token = string(l.TokenBytes(nil)); return T_YIELD <PHP>yield lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_YIELD
<PHP>include lval.token = string(l.TokenBytes(nil)); return T_INCLUDE <PHP>include lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INCLUDE
<PHP>include_once lval.token = string(l.TokenBytes(nil)); return T_INCLUDE_ONCE <PHP>include_once lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INCLUDE_ONCE
<PHP>require lval.token = string(l.TokenBytes(nil)); return T_REQUIRE <PHP>require lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_REQUIRE
<PHP>require_once lval.token = string(l.TokenBytes(nil)); return T_REQUIRE_ONCE <PHP>require_once lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_REQUIRE_ONCE
<PHP>__CLASS__ lval.token = string(l.TokenBytes(nil)); return T_CLASS_C <PHP>__CLASS__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CLASS_C
<PHP>__DIR__ lval.token = string(l.TokenBytes(nil)); return T_DIR <PHP>__DIR__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DIR
<PHP>__FILE__ lval.token = string(l.TokenBytes(nil)); return T_FILE <PHP>__FILE__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FILE
<PHP>__FUNCTION__ lval.token = string(l.TokenBytes(nil)); return T_FUNC_C <PHP>__FUNCTION__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FUNC_C
<PHP>__LINE__ lval.token = string(l.TokenBytes(nil)); return T_LINE <PHP>__LINE__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LINE
<PHP>__NAMESPACE__ lval.token = string(l.TokenBytes(nil)); return T_NS_C <PHP>__NAMESPACE__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_NS_C
<PHP>__METHOD__ lval.token = string(l.TokenBytes(nil)); return T_METHOD_C <PHP>__METHOD__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_METHOD_C
<PHP>__TRAIT__ lval.token = string(l.TokenBytes(nil)); return T_TRAIT_C <PHP>__TRAIT__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_TRAIT_C
<PHP>__halt_compiler lval.token = string(l.TokenBytes(nil)); return T_HALT_COMPILER <PHP>__halt_compiler lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_HALT_COMPILER
<PHP>\([ \t]*array[ \t]*\) lval.token = string(l.TokenBytes(nil)); return T_ARRAY_CAST <PHP>\([ \t]*array[ \t]*\) lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ARRAY_CAST
<PHP>\([ \t]*(bool|boolean)[ \t]*\) lval.token = string(l.TokenBytes(nil)); return T_BOOL_CAST <PHP>\([ \t]*(bool|boolean)[ \t]*\) lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_BOOL_CAST
<PHP>\([ \t]*(real|double|float)[ \t]*\) lval.token = string(l.TokenBytes(nil)); return T_DOUBLE_CAST <PHP>\([ \t]*(real|double|float)[ \t]*\) lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DOUBLE_CAST
<PHP>\([ \t]*(int|integer)[ \t]*\) lval.token = string(l.TokenBytes(nil)); return T_INT_CAST <PHP>\([ \t]*(int|integer)[ \t]*\) lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INT_CAST
<PHP>\([ \t]*object[ \t]*\) lval.token = string(l.TokenBytes(nil)); return T_OBJECT_CAST <PHP>\([ \t]*object[ \t]*\) lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_OBJECT_CAST
<PHP>\([ \t]*string[ \t]*\) lval.token = string(l.TokenBytes(nil)); return T_STRING_CAST <PHP>\([ \t]*string[ \t]*\) lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING_CAST
<PHP>\([ \t]*unset[ \t]*\) lval.token = string(l.TokenBytes(nil)); return T_UNSET_CAST <PHP>\([ \t]*unset[ \t]*\) lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_UNSET_CAST
<PHP>new lval.token = string(l.TokenBytes(nil)); return T_NEW <PHP>new lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_NEW
<PHP>and lval.token = string(l.TokenBytes(nil)); return T_LOGICAL_AND <PHP>and lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LOGICAL_AND
<PHP>or lval.token = string(l.TokenBytes(nil)); return T_LOGICAL_OR <PHP>or lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LOGICAL_OR
<PHP>xor lval.token = string(l.TokenBytes(nil)); return T_LOGICAL_XOR <PHP>xor lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LOGICAL_XOR
<PHP>\\ lval.token = string(l.TokenBytes(nil)); return T_NS_SEPARATOR <PHP>\\ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_NS_SEPARATOR
<PHP>\.\.\. lval.token = string(l.TokenBytes(nil)); return T_ELLIPSIS; <PHP>\.\.\. lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ELLIPSIS;
<PHP>:: lval.token = string(l.TokenBytes(nil)); return T_PAAMAYIM_NEKUDOTAYIM; // T_DOUBLE_COLON <PHP>:: lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_PAAMAYIM_NEKUDOTAYIM; // T_DOUBLE_COLON
<PHP>&& lval.token = string(l.TokenBytes(nil)); return T_BOOLEAN_AND <PHP>&& lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_BOOLEAN_AND
<PHP>\|\| lval.token = string(l.TokenBytes(nil)); return T_BOOLEAN_OR <PHP>\|\| lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_BOOLEAN_OR
<PHP>&= lval.token = string(l.TokenBytes(nil)); return T_AND_EQUAL <PHP>&= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_AND_EQUAL
<PHP>\|= lval.token = string(l.TokenBytes(nil)); return T_OR_EQUAL <PHP>\|= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_OR_EQUAL
<PHP>\.= lval.token = string(l.TokenBytes(nil)); return T_CONCAT_EQUAL; <PHP>\.= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONCAT_EQUAL;
<PHP>\*= lval.token = string(l.TokenBytes(nil)); return T_MUL_EQUAL <PHP>\*= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_MUL_EQUAL
<PHP>\*\*= lval.token = string(l.TokenBytes(nil)); return T_POW_EQUAL <PHP>\*\*= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_POW_EQUAL
<PHP>[/]= lval.token = string(l.TokenBytes(nil)); return T_DIV_EQUAL; <PHP>[/]= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DIV_EQUAL;
<PHP>\+= lval.token = string(l.TokenBytes(nil)); return T_PLUS_EQUAL <PHP>\+= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_PLUS_EQUAL
<PHP>-= lval.token = string(l.TokenBytes(nil)); return T_MINUS_EQUAL <PHP>-= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_MINUS_EQUAL
<PHP>\^= lval.token = string(l.TokenBytes(nil)); return T_XOR_EQUAL <PHP>\^= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_XOR_EQUAL
<PHP>%= lval.token = string(l.TokenBytes(nil)); return T_MOD_EQUAL <PHP>%= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_MOD_EQUAL
<PHP>-- lval.token = string(l.TokenBytes(nil)); return T_DEC; <PHP>-- lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DEC;
<PHP>\+\+ lval.token = string(l.TokenBytes(nil)); return T_INC <PHP>\+\+ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INC
<PHP>=> lval.token = string(l.TokenBytes(nil)); return T_DOUBLE_ARROW; <PHP>=> lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DOUBLE_ARROW;
<PHP>\<=\> lval.token = string(l.TokenBytes(nil)); return T_SPACESHIP <PHP>\<=\> lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_SPACESHIP
<PHP>\!=|\<\> lval.token = string(l.TokenBytes(nil)); return T_IS_NOT_EQUAL <PHP>\!=|\<\> lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_NOT_EQUAL
<PHP>\!== lval.token = string(l.TokenBytes(nil)); return T_IS_NOT_IDENTICAL <PHP>\!== lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_NOT_IDENTICAL
<PHP>== lval.token = string(l.TokenBytes(nil)); return T_IS_EQUAL <PHP>== lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_EQUAL
<PHP>=== lval.token = string(l.TokenBytes(nil)); return T_IS_IDENTICAL <PHP>=== lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_IDENTICAL
<PHP>\<\<= lval.token = string(l.TokenBytes(nil)); return T_SL_EQUAL <PHP>\<\<= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_SL_EQUAL
<PHP>\>\>= lval.token = string(l.TokenBytes(nil)); return T_SR_EQUAL <PHP>\>\>= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_SR_EQUAL
<PHP>\>= lval.token = string(l.TokenBytes(nil)); return T_IS_GREATER_OR_EQUAL <PHP>\>= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_GREATER_OR_EQUAL
<PHP>\<= lval.token = string(l.TokenBytes(nil)); return T_IS_SMALLER_OR_EQUAL <PHP>\<= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_SMALLER_OR_EQUAL
<PHP>\*\* lval.token = string(l.TokenBytes(nil)); return T_POW <PHP>\*\* lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_POW
<PHP>\<\< lval.token = string(l.TokenBytes(nil)); return T_SL <PHP>\<\< lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_SL
<PHP>\>\> lval.token = string(l.TokenBytes(nil)); return T_SR <PHP>\>\> lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_SR
<PHP>\?\? lval.token = string(l.TokenBytes(nil)); return T_COALESCE <PHP>\?\? lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_COALESCE
<PHP>(#|[/][/]).*{NEW_LINE} l.handleNewLine(l.TokenBytes(nil));// lval.token = string(l.TokenBytes(nil)); return T_COMMENT; // TODO: handle ?> <PHP>(#|[/][/]).*{NEW_LINE} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));// return T_COMMENT; // TODO: handle ?>
<PHP>[/][*][^*]*[*]+([^*/][^*]*[*]+)*[/] l.handleNewLine(l.TokenBytes(nil));// lval.token = string(l.TokenBytes(nil)); return T_COMMENT; // TODO: handle ?> <PHP>[/][*][^*]*[*]+([^*/][^*]*[*]+)*[/] lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));// return T_COMMENT; // TODO: handle ?>
<PHP>[/][*][*][^*]*[*]+([^*/][^*]*[*]+)*[/] l.handleNewLine(l.TokenBytes(nil));// lval.token = string(l.TokenBytes(nil)); return T_DOC_COMMENT; // TODO: handle ?> <PHP>[/][*][*][^*]*[*]+([^*/][^*]*[*]+)*[/] lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));// return T_DOC_COMMENT; // TODO: handle ?>
<PHP>'[^']*(\\')*' l.handleNewLine(l.TokenBytes(nil));lval.token = string(l.TokenBytes(nil)); return T_CONSTANT_ENCAPSED_STRING <PHP>'[^']*(\\')*' lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONSTANT_ENCAPSED_STRING
<PHP>{OPERATORS} lval.token = string(l.TokenBytes(nil)); return rune2Class(rune(l.TokenBytes(nil)[0])) <PHP>{OPERATORS} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
<PHP>\{ l.pushState(PHP); lval.token = string(l.TokenBytes(nil)); return rune2Class(rune(l.TokenBytes(nil)[0])) <PHP>\{ l.pushState(PHP); lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
<PHP>\} l.popState(); lval.token = string(l.TokenBytes(nil)); return rune2Class(rune(l.TokenBytes(nil)[0])) <PHP>\} l.popState(); lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
<PHP>\${VAR_NAME} lval.token = string(l.TokenBytes(nil)); return T_VARIABLE <PHP>\${VAR_NAME} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_VARIABLE
<PHP>{VAR_NAME} lval.token = string(l.TokenBytes(nil)); return T_STRING <PHP>{VAR_NAME} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING
<PHP>-> l.begin(PROPERTY);lval.token = string(l.TokenBytes(nil)); return T_OBJECT_OPERATOR; <PHP>-> l.begin(PROPERTY);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_OBJECT_OPERATOR;
<PROPERTY>[ \t\n\r]+ l.handleNewLine(l.TokenBytes(nil));lval.token = string(l.TokenBytes(nil)); return T_WHITESPACE; <PROPERTY>[ \t\n\r]+ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_WHITESPACE;
<PROPERTY>-> lval.token = string(l.TokenBytes(nil)); return T_OBJECT_OPERATOR; <PROPERTY>-> lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_OBJECT_OPERATOR;
<PROPERTY>{VAR_NAME} l.begin(PHP);lval.token = string(l.TokenBytes(nil)); return T_STRING; <PROPERTY>{VAR_NAME} l.begin(PHP);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING;
<PROPERTY>. l.ungetN(1);l.begin(PHP) <PROPERTY>. l.ungetN(1);l.begin(PHP)
<PHP>[\']([^\\\']*([\\][\'])*)*[\'] lval.token = string(l.TokenBytes(nil)); return T_CONSTANT_ENCAPSED_STRING; <PHP>[\']([^\\\']*([\\][\'])*)*[\'] lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONSTANT_ENCAPSED_STRING;
<PHP>` l.begin(BACKQUOTE); lval.token = string(l.TokenBytes(nil)); rune2Class(rune(l.TokenBytes(nil)[0])) <PHP>` l.begin(BACKQUOTE); lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); rune2Class(rune(l.TokenBytes(nil)[0]))
<BACKQUOTE>` l.begin(PHP); lval.token = string(l.TokenBytes(nil)); rune2Class(rune(l.TokenBytes(nil)[0])) <BACKQUOTE>` l.begin(PHP); lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); rune2Class(rune(l.TokenBytes(nil)[0]))
<PHP>[b]?\<\<\<[ \t]*({VAR_NAME}|([']{VAR_NAME}['])|(["]{VAR_NAME}["])){NEW_LINE} <PHP>[b]?\<\<\<[ \t]*({VAR_NAME}|([']{VAR_NAME}['])|(["]{VAR_NAME}["])){NEW_LINE}
tb := l.TokenBytes(nil) tb := l.TokenBytes(nil)
@ -318,8 +317,7 @@ NEW_LINE (\r|\n|\r\n)
l.ungetN(ungetCnt) l.ungetN(ungetCnt)
l.handleNewLine(tb); lval.token = newToken(l.handleNewLine(tb));
lval.token = string(tb);
return T_START_HEREDOC return T_START_HEREDOC
<NOWDOC>. <NOWDOC>.
@ -346,11 +344,10 @@ NEW_LINE (\r|\n|\r\n)
c = l.Next() c = l.Next()
} }
l.handleNewLine(tb); lval.token = newToken(l.handleNewLine(tb));
lval.token = string(tb);
return T_ENCAPSED_AND_WHITESPACE return T_ENCAPSED_AND_WHITESPACE
<HEREDOC_END>{VAR_NAME}\; l.begin(PHP);lval.token = string(l.ungetN(1)); return T_END_HEREDOC <HEREDOC_END>{VAR_NAME}\; l.begin(PHP);lval.token = newToken(l.handleNewLine(l.ungetN(1))); return T_END_HEREDOC
<PHP>[b]?[\"] <PHP>[b]?[\"]
binPrefix := l.TokenBytes(nil)[0] == 'b' binPrefix := l.TokenBytes(nil)[0] == 'b'
@ -362,7 +359,7 @@ NEW_LINE (\r|\n|\r\n)
tokenBytes := l.TokenBytes(nil)[:cnt] tokenBytes := l.TokenBytes(nil)[:cnt]
l.pushState(STRING) l.pushState(STRING)
lval.token = string(tokenBytes); return rune2Class('"') lval.token = newToken(l.handleNewLine(tokenBytes)); return rune2Class('"')
} }
F:for { F:for {
@ -373,7 +370,7 @@ NEW_LINE (\r|\n|\r\n)
switch c { switch c {
case '"' : case '"' :
c = l.Next(); c = l.Next();
lval.token = string(l.TokenBytes(nil)); return T_CONSTANT_ENCAPSED_STRING lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONSTANT_ENCAPSED_STRING
break F; break F;
case '$': case '$':
@ -399,9 +396,9 @@ NEW_LINE (\r|\n|\r\n)
c = l.Next() c = l.Next()
} }
<STRING>\" l.popState(); lval.token = "\""; return rune2Class(rune(l.TokenBytes(nil)[0])) <STRING>\" l.popState(); lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
<STRING,HEREDOC,BACKQUOTE>\{\$ lval.token = string(l.ungetN(1)); l.pushState(PHP); return T_CURLY_OPEN <STRING,HEREDOC,BACKQUOTE>\{\$ lval.token = newToken(l.handleNewLine(l.ungetN(1))); l.pushState(PHP); return T_CURLY_OPEN
<STRING,HEREDOC,BACKQUOTE>\$\{ l.pushState(STRING_VAR_NAME);lval.token = string(l.TokenBytes(nil)); return T_DOLLAR_OPEN_CURLY_BRACES <STRING,HEREDOC,BACKQUOTE>\$\{ l.pushState(STRING_VAR_NAME);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DOLLAR_OPEN_CURLY_BRACES
<STRING,HEREDOC,BACKQUOTE>\$ l.ungetN(1);l.pushState(STRING_VAR) <STRING,HEREDOC,BACKQUOTE>\$ l.ungetN(1);l.pushState(STRING_VAR)
<STRING>.|[ \t\n\r] <STRING>.|[ \t\n\r]
F1:for { F1:for {
@ -411,8 +408,7 @@ NEW_LINE (\r|\n|\r\n)
switch c { switch c {
case '"' : case '"' :
l.handleNewLine(l.TokenBytes(nil)); lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));
lval.token = string(l.TokenBytes(nil));
return T_ENCAPSED_AND_WHITESPACE return T_ENCAPSED_AND_WHITESPACE
break F1; break F1;
@ -421,8 +417,7 @@ NEW_LINE (\r|\n|\r\n)
if rune(c) == '{' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ' { if rune(c) == '{' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ' {
l.ungetN(1) l.ungetN(1)
tb := l.TokenBytes(nil) tb := l.TokenBytes(nil)
l.handleNewLine(tb[:len(tb)-1]); lval.token = newToken(l.handleNewLine(tb[:len(tb)-1]));
lval.token = string(tb[:len(tb)-1]);
return T_ENCAPSED_AND_WHITESPACE return T_ENCAPSED_AND_WHITESPACE
break F1; break F1;
} }
@ -433,8 +428,7 @@ NEW_LINE (\r|\n|\r\n)
if rune(c) == '$' { if rune(c) == '$' {
l.ungetN(1) l.ungetN(1)
tb := l.TokenBytes(nil) tb := l.TokenBytes(nil)
l.handleNewLine(tb[:len(tb)-1]); lval.token = newToken(l.handleNewLine(tb[:len(tb)-1]));
lval.token = string(tb[:len(tb)-1]);
return T_ENCAPSED_AND_WHITESPACE return T_ENCAPSED_AND_WHITESPACE
break F1; break F1;
} }
@ -455,8 +449,7 @@ NEW_LINE (\r|\n|\r\n)
switch c { switch c {
case '`' : case '`' :
l.handleNewLine(l.TokenBytes(nil)); lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));
lval.token = string(l.TokenBytes(nil));
return T_ENCAPSED_AND_WHITESPACE return T_ENCAPSED_AND_WHITESPACE
break F2; break F2;
@ -465,8 +458,7 @@ NEW_LINE (\r|\n|\r\n)
if rune(c) == '{' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ' { if rune(c) == '{' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ' {
l.ungetN(1) l.ungetN(1)
tb := l.TokenBytes(nil) tb := l.TokenBytes(nil)
l.handleNewLine(tb[:len(tb)-1]); lval.token = newToken(l.handleNewLine(tb[:len(tb)-1]));
lval.token = string(tb[:len(tb)-1]);
return T_ENCAPSED_AND_WHITESPACE return T_ENCAPSED_AND_WHITESPACE
break F2; break F2;
} }
@ -477,8 +469,7 @@ NEW_LINE (\r|\n|\r\n)
if rune(c) == '$' { if rune(c) == '$' {
l.ungetN(1) l.ungetN(1)
tb := l.TokenBytes(nil) tb := l.TokenBytes(nil)
l.handleNewLine(tb[:len(tb)-1]); lval.token = newToken(l.handleNewLine(tb[:len(tb)-1]));
lval.token = string(tb[:len(tb)-1]);
return T_ENCAPSED_AND_WHITESPACE return T_ENCAPSED_AND_WHITESPACE
break F2; break F2;
} }
@ -540,25 +531,24 @@ NEW_LINE (\r|\n|\r\n)
c = l.Next() c = l.Next()
} }
l.handleNewLine(tb); lval.token = newToken(l.handleNewLine(tb));
lval.token = string(tb);
return T_ENCAPSED_AND_WHITESPACE return T_ENCAPSED_AND_WHITESPACE
<STRING_VAR>\${VAR_NAME} lval.token = string(l.TokenBytes(nil)); return T_VARIABLE <STRING_VAR>\${VAR_NAME} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_VARIABLE
<STRING_VAR>->{VAR_NAME} lval.token = string(l.ungetN(len(l.TokenBytes(nil))-2)); return T_OBJECT_OPERATOR <STRING_VAR>->{VAR_NAME} lval.token = newToken(l.handleNewLine(l.ungetN(len(l.TokenBytes(nil))-2))); return T_OBJECT_OPERATOR
<STRING_VAR>{VAR_NAME} l.popState();lval.token = string(l.TokenBytes(nil)); return T_STRING <STRING_VAR>{VAR_NAME} l.popState();lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING
<STRING_VAR>\[ l.pushState(STRING_VAR_INDEX);lval.token = string(l.TokenBytes(nil)); return rune2Class(rune(l.TokenBytes(nil)[0])) <STRING_VAR>\[ l.pushState(STRING_VAR_INDEX);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
<STRING_VAR>.|[ \t\n\r] l.ungetN(1);l.popState() <STRING_VAR>.|[ \t\n\r] l.ungetN(1);l.popState()
<STRING_VAR_INDEX>{LNUM}|{HNUM}|{BNUM} lval.token = string(l.TokenBytes(nil)); return T_NUM_STRING <STRING_VAR_INDEX>{LNUM}|{HNUM}|{BNUM} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_NUM_STRING
<STRING_VAR_INDEX>\${VAR_NAME} lval.token = string(l.TokenBytes(nil)); return T_VARIABLE <STRING_VAR_INDEX>\${VAR_NAME} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_VARIABLE
<STRING_VAR_INDEX>{VAR_NAME} lval.token = string(l.TokenBytes(nil)); return T_STRING <STRING_VAR_INDEX>{VAR_NAME} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING
<STRING_VAR_INDEX>\] l.popState(); l.popState();lval.token = string(l.TokenBytes(nil)); return rune2Class(rune(l.TokenBytes(nil)[0])) <STRING_VAR_INDEX>\] l.popState(); l.popState();lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
<STRING_VAR_INDEX>[ \n\r\t\\'#] l.handleNewLine(l.TokenBytes(nil));l.popState(); l.popState();lval.token = string(l.TokenBytes(nil)); return T_ENCAPSED_AND_WHITESPACE <STRING_VAR_INDEX>[ \n\r\t\\'#] l.popState(); l.popState();lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENCAPSED_AND_WHITESPACE
<STRING_VAR_INDEX>{OPERATORS} lval.token = string(l.TokenBytes(nil)); return rune2Class(rune(l.TokenBytes(nil)[0])) <STRING_VAR_INDEX>{OPERATORS} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
<STRING_VAR_INDEX>. lval.token = string(l.TokenBytes(nil)); return rune2Class(rune(l.TokenBytes(nil)[0])) <STRING_VAR_INDEX>. lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
<STRING_VAR_NAME>{VAR_NAME}[\[\}] l.popState();l.pushState(PHP);lval.token = string(l.ungetN(1)); return T_STRING_VARNAME <STRING_VAR_NAME>{VAR_NAME}[\[\}] l.popState();l.pushState(PHP);lval.token = newToken(l.handleNewLine(l.ungetN(1))); return T_STRING_VARNAME
<STRING_VAR_NAME>. l.ungetN(1);l.popState();l.pushState(PHP) <STRING_VAR_NAME>. l.ungetN(1);l.popState();l.pushState(PHP)
%% %%

15
token.go Normal file
View File

@ -0,0 +1,15 @@
package main
type token struct {
value []byte
startLine int
endLine int
}
func newToken(value []byte, startLine int, endLine int) token {
return token{value, startLine, endLine}
}
func (t token) String() string {
return string(t.value)
}