add node and token namespaces
This commit is contained in:
parent
71949dbcd2
commit
4da2844ea8
@ -31,10 +31,9 @@ $a = 'string
|
||||
with out $var';
|
||||
|
||||
$a = <<<test
|
||||
heredoc
|
||||
$var
|
||||
string
|
||||
test;
|
||||
|
||||
?>
|
||||
|
||||
<?= $b; $b ?>
|
||||
<?= $b = 22; $b ?>
|
4
lexer.go
4
lexer.go
@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
gotoken "go/token"
|
||||
"go/token"
|
||||
"io"
|
||||
"unicode"
|
||||
|
||||
@ -37,7 +37,7 @@ func rune2Class(r rune) int {
|
||||
}
|
||||
|
||||
func newLexer(src io.Reader, fName string) *lexer {
|
||||
file := gotoken.NewFileSet().AddFile(fName, -1, 1<<31-1)
|
||||
file := token.NewFileSet().AddFile(fName, -1, 1<<31-1)
|
||||
lx, err := lex.New(file, bufio.NewReader(src), lex.RuneClass(rune2Class))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
4
main.go
4
main.go
@ -21,8 +21,8 @@ func main() {
|
||||
fmt.Printf("\n==> %s", real)
|
||||
|
||||
src, _ := os.Open(string(real))
|
||||
rn := parse(src, real)
|
||||
fmt.Println(rn)
|
||||
rootnode := parse(src, real)
|
||||
fmt.Println(rootnode)
|
||||
}
|
||||
}
|
||||
|
||||
|
44
node.go
44
node.go
@ -1,44 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
type node struct {
|
||||
name string
|
||||
children []node
|
||||
attributes map[string]string
|
||||
}
|
||||
|
||||
func (n node) String() string {
|
||||
buf := new(bytes.Buffer)
|
||||
n.print(buf, " ")
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func (n node) print(out io.Writer, indent string) {
|
||||
if len(n.attributes) > 0 {
|
||||
fmt.Fprintf(out, "\n%v%v %s", indent, n.name, n.attributes)
|
||||
} else {
|
||||
fmt.Fprintf(out, "\n%v%v", indent, n.name)
|
||||
}
|
||||
for _, nn := range n.children {
|
||||
nn.print(out, indent+" ")
|
||||
}
|
||||
}
|
||||
|
||||
func Node(name string) node {
|
||||
return node{name: name, attributes: make(map[string]string)}
|
||||
}
|
||||
|
||||
func (n node) append(nn ...node) node {
|
||||
n.children = append(n.children, nn...)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n node) attribute(key string, value string) node {
|
||||
n.attributes[key] = value
|
||||
return n
|
||||
}
|
70
node/node.go
Normal file
70
node/node.go
Normal file
@ -0,0 +1,70 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
"io"
|
||||
)
|
||||
|
||||
type Node interface {
|
||||
Print(out io.Writer, indent string)
|
||||
Append(nn ...Node) Node
|
||||
Attribute(key string, value string) Node
|
||||
}
|
||||
|
||||
type simpleNode struct {
|
||||
name string
|
||||
children []Node
|
||||
attributes map[string]string
|
||||
}
|
||||
|
||||
type tokenNode struct {
|
||||
*simpleNode
|
||||
token token.Token
|
||||
}
|
||||
|
||||
func (n simpleNode) String() string {
|
||||
buf := new(bytes.Buffer)
|
||||
n.Print(buf, " ")
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func (n simpleNode) Print(out io.Writer, indent string) {
|
||||
if len(n.attributes) > 0 {
|
||||
fmt.Fprintf(out, "\n%v%v %s", indent, n.name, n.attributes)
|
||||
} else {
|
||||
fmt.Fprintf(out, "\n%v%v", indent, n.name)
|
||||
}
|
||||
for _, nn := range n.children {
|
||||
nn.Print(out, indent+" ")
|
||||
}
|
||||
}
|
||||
|
||||
func SimpleNode(name string) Node {
|
||||
return simpleNode{name: name, attributes: make(map[string]string)}
|
||||
}
|
||||
|
||||
func TokenNode(name string, t token.Token) Node {
|
||||
return tokenNode{
|
||||
&simpleNode{name: name, attributes: make(map[string]string)},
|
||||
t,
|
||||
}
|
||||
}
|
||||
|
||||
func (n tokenNode) Print(out io.Writer, indent string) {
|
||||
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
|
||||
for _, nn := range n.children {
|
||||
nn.Print(out, indent+" ")
|
||||
}
|
||||
}
|
||||
|
||||
func (n simpleNode) Append(nn ...Node) Node {
|
||||
n.children = append(n.children, nn...)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n simpleNode) Attribute(key string, value string) Node {
|
||||
n.attributes[key] = value
|
||||
return n
|
||||
}
|
341
scanner.go
341
scanner.go
File diff suppressed because it is too large
Load Diff
341
scanner.l
341
scanner.l
@ -10,6 +10,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"bytes"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -53,7 +54,7 @@ NEW_LINE (\r|\n|\r\n)
|
||||
%%
|
||||
c = l.Rule0()
|
||||
|
||||
<INITIAL>[ \t\n\r]+ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));
|
||||
<INITIAL>[ \t\n\r]+ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil)));
|
||||
<INITIAL>.
|
||||
tb := []byte{}
|
||||
|
||||
@ -77,17 +78,17 @@ NEW_LINE (\r|\n|\r\n)
|
||||
c = l.Next()
|
||||
}
|
||||
|
||||
lval.token = newToken(l.handleNewLine(tb));
|
||||
lval.token = token.NewToken(l.handleNewLine(tb));
|
||||
return T_INLINE_HTML
|
||||
|
||||
<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 = newToken(l.handleNewLine(l.TokenBytes(nil)));// return T_OPEN_TAG;
|
||||
<INITIAL>\<\?= l.begin(PHP);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ECHO;
|
||||
<INITIAL>\<\?php([ \t]|{NEW_LINE}) l.begin(PHP);lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil)));// return T_OPEN_TAG;
|
||||
<INITIAL>\<\? l.begin(PHP);lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil)));// return T_OPEN_TAG;
|
||||
<INITIAL>\<\?= l.begin(PHP);lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ECHO;
|
||||
|
||||
<PHP>[ \t\n\r]+ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));// return T_WHITESPACE
|
||||
<PHP>\?\>{NEW_LINE}? l.begin(INITIAL);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(';');
|
||||
<PHP>[ \t\n\r]+ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil)));// return T_WHITESPACE
|
||||
<PHP>\?\>{NEW_LINE}? l.begin(INITIAL);lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(';');
|
||||
|
||||
<PHP>{DNUM}|{EXPONENT_DNUM} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DNUMBER
|
||||
<PHP>{DNUM}|{EXPONENT_DNUM} lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DNUMBER
|
||||
<PHP>{BNUM}
|
||||
tb := l.TokenBytes(nil)
|
||||
i:=2
|
||||
@ -98,15 +99,15 @@ NEW_LINE (\r|\n|\r\n)
|
||||
}
|
||||
}
|
||||
if len(tb) - i < 64 {
|
||||
lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LNUMBER
|
||||
lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_LNUMBER
|
||||
} else {
|
||||
lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DNUMBER
|
||||
lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DNUMBER
|
||||
}
|
||||
<PHP>{LNUM}
|
||||
if len(l.TokenBytes(nil)) < 20 {
|
||||
lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LNUMBER
|
||||
lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_LNUMBER
|
||||
} else {
|
||||
lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DNUMBER
|
||||
lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DNUMBER
|
||||
}
|
||||
<PHP>{HNUM}
|
||||
tb := l.TokenBytes(nil)
|
||||
@ -119,145 +120,145 @@ NEW_LINE (\r|\n|\r\n)
|
||||
}
|
||||
length := len(tb) - i
|
||||
if length < 16 || (length == 16 && tb[i] <= '7') {
|
||||
lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LNUMBER
|
||||
lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_LNUMBER
|
||||
} else {
|
||||
lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DNUMBER
|
||||
lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DNUMBER
|
||||
}
|
||||
|
||||
<PHP>abstract lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ABSTRACT
|
||||
<PHP>array lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ARRAY
|
||||
<PHP>as lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_AS
|
||||
<PHP>break lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_BREAK
|
||||
<PHP>callable lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CALLABLE
|
||||
<PHP>case lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CASE
|
||||
<PHP>catch lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CATCH
|
||||
<PHP>class lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CLASS
|
||||
<PHP>clone lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CLONE
|
||||
<PHP>const lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONST;
|
||||
<PHP>continue lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONTINUE;
|
||||
<PHP>declare lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DECLARE;
|
||||
<PHP>default lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DEFAULT;
|
||||
<PHP>do lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DO;
|
||||
<PHP>echo lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ECHO;
|
||||
<PHP>else lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ELSE;
|
||||
<PHP>elseif lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ELSEIF;
|
||||
<PHP>empty lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_EMPTY;
|
||||
<PHP>enddeclare lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDDECLARE
|
||||
<PHP>endfor lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDFOR
|
||||
<PHP>endforeach lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDFOREACH
|
||||
<PHP>endif lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDIF
|
||||
<PHP>endswitch lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDSWITCH
|
||||
<PHP>endwhile lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDWHILE
|
||||
<PHP>eval lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_EVAL
|
||||
<PHP>exit|die lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_EXIT
|
||||
<PHP>extends lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_EXTENDS
|
||||
<PHP>final lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FINAL
|
||||
<PHP>finally lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FINALLY
|
||||
<PHP>for lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FOR
|
||||
<PHP>foreach lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FOREACH
|
||||
<PHP>function|cfunction lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FUNCTION
|
||||
<PHP>global lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_GLOBAL
|
||||
<PHP>goto lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_GOTO
|
||||
<PHP>if lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IF
|
||||
<PHP>isset lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ISSET
|
||||
<PHP>implements lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IMPLEMENTS
|
||||
<PHP>instanceof lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INSTANCEOF
|
||||
<PHP>insteadof lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INSTEADOF
|
||||
<PHP>interface lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INTERFACE
|
||||
<PHP>list lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LIST
|
||||
<PHP>namespace lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_NAMESPACE
|
||||
<PHP>private lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_PRIVATE
|
||||
<PHP>public lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_PUBLIC
|
||||
<PHP>print lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_PRINT
|
||||
<PHP>protected lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_PROTECTED
|
||||
<PHP>return lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_RETURN
|
||||
<PHP>static lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_STATIC
|
||||
<PHP>switch lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_SWITCH
|
||||
<PHP>throw lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_THROW
|
||||
<PHP>trait lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_TRAIT
|
||||
<PHP>try lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_TRY
|
||||
<PHP>unset lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_UNSET
|
||||
<PHP>use lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_USE
|
||||
<PHP>var lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_VAR
|
||||
<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] lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_YIELD_FROM
|
||||
<PHP>yield lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_YIELD
|
||||
<PHP>include lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INCLUDE
|
||||
<PHP>include_once lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INCLUDE_ONCE
|
||||
<PHP>require lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_REQUIRE
|
||||
<PHP>require_once lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_REQUIRE_ONCE
|
||||
<PHP>__CLASS__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CLASS_C
|
||||
<PHP>__DIR__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DIR
|
||||
<PHP>__FILE__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FILE
|
||||
<PHP>__FUNCTION__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_FUNC_C
|
||||
<PHP>__LINE__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LINE
|
||||
<PHP>__NAMESPACE__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_NS_C
|
||||
<PHP>__METHOD__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_METHOD_C
|
||||
<PHP>__TRAIT__ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_TRAIT_C
|
||||
<PHP>__halt_compiler lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_HALT_COMPILER
|
||||
<PHP>\([ \t]*array[ \t]*\) lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ARRAY_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 = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DOUBLE_CAST
|
||||
<PHP>\([ \t]*(int|integer)[ \t]*\) lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INT_CAST
|
||||
<PHP>\([ \t]*object[ \t]*\) lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_OBJECT_CAST
|
||||
<PHP>\([ \t]*string[ \t]*\) lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING_CAST
|
||||
<PHP>\([ \t]*unset[ \t]*\) lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_UNSET_CAST
|
||||
<PHP>new lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_NEW
|
||||
<PHP>and lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LOGICAL_AND
|
||||
<PHP>or lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LOGICAL_OR
|
||||
<PHP>xor lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_LOGICAL_XOR
|
||||
<PHP>\\ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_NS_SEPARATOR
|
||||
<PHP>\.\.\. lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_ELLIPSIS;
|
||||
<PHP>:: lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_PAAMAYIM_NEKUDOTAYIM; // T_DOUBLE_COLON
|
||||
<PHP>&& lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_BOOLEAN_AND
|
||||
<PHP>\|\| lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_BOOLEAN_OR
|
||||
<PHP>&= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_AND_EQUAL
|
||||
<PHP>\|= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_OR_EQUAL
|
||||
<PHP>\.= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONCAT_EQUAL;
|
||||
<PHP>\*= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_MUL_EQUAL
|
||||
<PHP>\*\*= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_POW_EQUAL
|
||||
<PHP>[/]= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DIV_EQUAL;
|
||||
<PHP>\+= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_PLUS_EQUAL
|
||||
<PHP>-= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_MINUS_EQUAL
|
||||
<PHP>\^= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_XOR_EQUAL
|
||||
<PHP>%= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_MOD_EQUAL
|
||||
<PHP>-- lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DEC;
|
||||
<PHP>\+\+ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_INC
|
||||
<PHP>=> lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DOUBLE_ARROW;
|
||||
<PHP>\<=\> lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_SPACESHIP
|
||||
<PHP>\!=|\<\> lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_NOT_EQUAL
|
||||
<PHP>\!== lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_NOT_IDENTICAL
|
||||
<PHP>== lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_EQUAL
|
||||
<PHP>=== lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_IDENTICAL
|
||||
<PHP>\<\<= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_SL_EQUAL
|
||||
<PHP>\>\>= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_SR_EQUAL
|
||||
<PHP>\>= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_GREATER_OR_EQUAL
|
||||
<PHP>\<= lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_SMALLER_OR_EQUAL
|
||||
<PHP>\*\* lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_POW
|
||||
<PHP>\<\< lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_SL
|
||||
<PHP>\>\> lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_SR
|
||||
<PHP>\?\? lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_COALESCE
|
||||
<PHP>(#|[/][/]).*{NEW_LINE} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));// return T_COMMENT; // TODO: handle ?>
|
||||
<PHP>[/][*][^*]*[*]+([^*/][^*]*[*]+)*[/] lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));// return T_COMMENT; // TODO: handle ?>
|
||||
<PHP>[/][*][*][^*]*[*]+([^*/][^*]*[*]+)*[/] lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));// return T_DOC_COMMENT; // TODO: handle ?>
|
||||
<PHP>'[^']*(\\')*' lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONSTANT_ENCAPSED_STRING
|
||||
<PHP>{OPERATORS} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
|
||||
<PHP>abstract lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ABSTRACT
|
||||
<PHP>array lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ARRAY
|
||||
<PHP>as lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_AS
|
||||
<PHP>break lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_BREAK
|
||||
<PHP>callable lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_CALLABLE
|
||||
<PHP>case lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_CASE
|
||||
<PHP>catch lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_CATCH
|
||||
<PHP>class lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_CLASS
|
||||
<PHP>clone lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_CLONE
|
||||
<PHP>const lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONST;
|
||||
<PHP>continue lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONTINUE;
|
||||
<PHP>declare lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DECLARE;
|
||||
<PHP>default lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DEFAULT;
|
||||
<PHP>do lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DO;
|
||||
<PHP>echo lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ECHO;
|
||||
<PHP>else lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ELSE;
|
||||
<PHP>elseif lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ELSEIF;
|
||||
<PHP>empty lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_EMPTY;
|
||||
<PHP>enddeclare lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDDECLARE
|
||||
<PHP>endfor lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDFOR
|
||||
<PHP>endforeach lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDFOREACH
|
||||
<PHP>endif lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDIF
|
||||
<PHP>endswitch lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDSWITCH
|
||||
<PHP>endwhile lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENDWHILE
|
||||
<PHP>eval lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_EVAL
|
||||
<PHP>exit|die lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_EXIT
|
||||
<PHP>extends lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_EXTENDS
|
||||
<PHP>final lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_FINAL
|
||||
<PHP>finally lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_FINALLY
|
||||
<PHP>for lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_FOR
|
||||
<PHP>foreach lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_FOREACH
|
||||
<PHP>function|cfunction lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_FUNCTION
|
||||
<PHP>global lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_GLOBAL
|
||||
<PHP>goto lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_GOTO
|
||||
<PHP>if lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_IF
|
||||
<PHP>isset lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ISSET
|
||||
<PHP>implements lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_IMPLEMENTS
|
||||
<PHP>instanceof lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_INSTANCEOF
|
||||
<PHP>insteadof lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_INSTEADOF
|
||||
<PHP>interface lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_INTERFACE
|
||||
<PHP>list lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_LIST
|
||||
<PHP>namespace lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_NAMESPACE
|
||||
<PHP>private lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_PRIVATE
|
||||
<PHP>public lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_PUBLIC
|
||||
<PHP>print lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_PRINT
|
||||
<PHP>protected lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_PROTECTED
|
||||
<PHP>return lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_RETURN
|
||||
<PHP>static lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_STATIC
|
||||
<PHP>switch lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_SWITCH
|
||||
<PHP>throw lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_THROW
|
||||
<PHP>trait lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_TRAIT
|
||||
<PHP>try lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_TRY
|
||||
<PHP>unset lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_UNSET
|
||||
<PHP>use lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_USE
|
||||
<PHP>var lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_VAR
|
||||
<PHP>while lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_WHILE
|
||||
<PHP>yield[ \t\n\r]+from[^a-zA-Z0-9_\x80-\xff] lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_YIELD_FROM
|
||||
<PHP>yield lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_YIELD
|
||||
<PHP>include lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_INCLUDE
|
||||
<PHP>include_once lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_INCLUDE_ONCE
|
||||
<PHP>require lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_REQUIRE
|
||||
<PHP>require_once lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_REQUIRE_ONCE
|
||||
<PHP>__CLASS__ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_CLASS_C
|
||||
<PHP>__DIR__ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DIR
|
||||
<PHP>__FILE__ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_FILE
|
||||
<PHP>__FUNCTION__ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_FUNC_C
|
||||
<PHP>__LINE__ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_LINE
|
||||
<PHP>__NAMESPACE__ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_NS_C
|
||||
<PHP>__METHOD__ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_METHOD_C
|
||||
<PHP>__TRAIT__ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_TRAIT_C
|
||||
<PHP>__halt_compiler lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_HALT_COMPILER
|
||||
<PHP>\([ \t]*array[ \t]*\) lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ARRAY_CAST
|
||||
<PHP>\([ \t]*(bool|boolean)[ \t]*\) lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_BOOL_CAST
|
||||
<PHP>\([ \t]*(real|double|float)[ \t]*\) lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DOUBLE_CAST
|
||||
<PHP>\([ \t]*(int|integer)[ \t]*\) lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_INT_CAST
|
||||
<PHP>\([ \t]*object[ \t]*\) lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_OBJECT_CAST
|
||||
<PHP>\([ \t]*string[ \t]*\) lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING_CAST
|
||||
<PHP>\([ \t]*unset[ \t]*\) lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_UNSET_CAST
|
||||
<PHP>new lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_NEW
|
||||
<PHP>and lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_LOGICAL_AND
|
||||
<PHP>or lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_LOGICAL_OR
|
||||
<PHP>xor lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_LOGICAL_XOR
|
||||
<PHP>\\ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_NS_SEPARATOR
|
||||
<PHP>\.\.\. lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ELLIPSIS;
|
||||
<PHP>:: lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_PAAMAYIM_NEKUDOTAYIM; // T_DOUBLE_COLON
|
||||
<PHP>&& lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_BOOLEAN_AND
|
||||
<PHP>\|\| lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_BOOLEAN_OR
|
||||
<PHP>&= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_AND_EQUAL
|
||||
<PHP>\|= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_OR_EQUAL
|
||||
<PHP>\.= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONCAT_EQUAL;
|
||||
<PHP>\*= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_MUL_EQUAL
|
||||
<PHP>\*\*= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_POW_EQUAL
|
||||
<PHP>[/]= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DIV_EQUAL;
|
||||
<PHP>\+= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_PLUS_EQUAL
|
||||
<PHP>-= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_MINUS_EQUAL
|
||||
<PHP>\^= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_XOR_EQUAL
|
||||
<PHP>%= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_MOD_EQUAL
|
||||
<PHP>-- lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DEC;
|
||||
<PHP>\+\+ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_INC
|
||||
<PHP>=> lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DOUBLE_ARROW;
|
||||
<PHP>\<=\> lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_SPACESHIP
|
||||
<PHP>\!=|\<\> lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_NOT_EQUAL
|
||||
<PHP>\!== lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_NOT_IDENTICAL
|
||||
<PHP>== lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_EQUAL
|
||||
<PHP>=== lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_IDENTICAL
|
||||
<PHP>\<\<= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_SL_EQUAL
|
||||
<PHP>\>\>= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_SR_EQUAL
|
||||
<PHP>\>= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_GREATER_OR_EQUAL
|
||||
<PHP>\<= lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_IS_SMALLER_OR_EQUAL
|
||||
<PHP>\*\* lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_POW
|
||||
<PHP>\<\< lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_SL
|
||||
<PHP>\>\> lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_SR
|
||||
<PHP>\?\? lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_COALESCE
|
||||
<PHP>(#|[/][/]).*{NEW_LINE} lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil)));// return T_COMMENT; // TODO: handle ?>
|
||||
<PHP>[/][*][^*]*[*]+([^*/][^*]*[*]+)*[/] lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil)));// return T_COMMENT; // TODO: handle ?>
|
||||
<PHP>[/][*][*][^*]*[*]+([^*/][^*]*[*]+)*[/] lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil)));// return T_DOC_COMMENT; // TODO: handle ?>
|
||||
<PHP>'[^']*(\\')*' lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONSTANT_ENCAPSED_STRING
|
||||
<PHP>{OPERATORS} lval.token = token.NewToken(l.handleNewLine(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 = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
|
||||
<PHP>\${VAR_NAME} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_VARIABLE
|
||||
<PHP>{VAR_NAME} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING
|
||||
<PHP>\{ l.pushState(PHP); lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
|
||||
<PHP>\} l.popState(); lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
|
||||
<PHP>\${VAR_NAME} lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_VARIABLE
|
||||
<PHP>{VAR_NAME} lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING
|
||||
|
||||
<PHP>-> l.begin(PROPERTY);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_OBJECT_OPERATOR;
|
||||
<PROPERTY>[ \t\n\r]+ lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_WHITESPACE;
|
||||
<PROPERTY>-> lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_OBJECT_OPERATOR;
|
||||
<PROPERTY>{VAR_NAME} l.begin(PHP);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING;
|
||||
<PHP>-> l.begin(PROPERTY);lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_OBJECT_OPERATOR;
|
||||
<PROPERTY>[ \t\n\r]+ lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_WHITESPACE;
|
||||
<PROPERTY>-> lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_OBJECT_OPERATOR;
|
||||
<PROPERTY>{VAR_NAME} l.begin(PHP);lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING;
|
||||
<PROPERTY>. l.ungetN(1);l.begin(PHP)
|
||||
|
||||
<PHP>[\']([^\\\']*([\\][\'])*)*[\'] lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONSTANT_ENCAPSED_STRING;
|
||||
<PHP>[\']([^\\\']*([\\][\'])*)*[\'] lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONSTANT_ENCAPSED_STRING;
|
||||
|
||||
<PHP>` l.begin(BACKQUOTE); lval.token = newToken(l.handleNewLine(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>` l.begin(BACKQUOTE); lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); rune2Class(rune(l.TokenBytes(nil)[0]))
|
||||
<BACKQUOTE>` l.begin(PHP); lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); rune2Class(rune(l.TokenBytes(nil)[0]))
|
||||
|
||||
<PHP>[b]?\<\<\<[ \t]*({VAR_NAME}|([']{VAR_NAME}['])|(["]{VAR_NAME}["])){NEW_LINE}
|
||||
tb := l.TokenBytes(nil)
|
||||
@ -317,7 +318,7 @@ NEW_LINE (\r|\n|\r\n)
|
||||
|
||||
l.ungetN(ungetCnt)
|
||||
|
||||
lval.token = newToken(l.handleNewLine(tb));
|
||||
lval.token = token.NewToken(l.handleNewLine(tb));
|
||||
return T_START_HEREDOC
|
||||
|
||||
<NOWDOC>.
|
||||
@ -344,10 +345,10 @@ NEW_LINE (\r|\n|\r\n)
|
||||
c = l.Next()
|
||||
}
|
||||
|
||||
lval.token = newToken(l.handleNewLine(tb));
|
||||
lval.token = token.NewToken(l.handleNewLine(tb));
|
||||
return T_ENCAPSED_AND_WHITESPACE
|
||||
|
||||
<HEREDOC_END>{VAR_NAME}\; l.begin(PHP);lval.token = newToken(l.handleNewLine(l.ungetN(1))); return T_END_HEREDOC
|
||||
<HEREDOC_END>{VAR_NAME}\; l.begin(PHP);lval.token = token.NewToken(l.handleNewLine(l.ungetN(1))); return T_END_HEREDOC
|
||||
|
||||
<PHP>[b]?[\"]
|
||||
binPrefix := l.TokenBytes(nil)[0] == 'b'
|
||||
@ -359,7 +360,7 @@ NEW_LINE (\r|\n|\r\n)
|
||||
tokenBytes := l.TokenBytes(nil)[:cnt]
|
||||
l.pushState(STRING)
|
||||
|
||||
lval.token = newToken(l.handleNewLine(tokenBytes)); return rune2Class('"')
|
||||
lval.token = token.NewToken(l.handleNewLine(tokenBytes)); return rune2Class('"')
|
||||
}
|
||||
|
||||
F:for {
|
||||
@ -370,7 +371,7 @@ NEW_LINE (\r|\n|\r\n)
|
||||
switch c {
|
||||
case '"' :
|
||||
c = l.Next();
|
||||
lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONSTANT_ENCAPSED_STRING
|
||||
lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_CONSTANT_ENCAPSED_STRING
|
||||
break F;
|
||||
|
||||
case '$':
|
||||
@ -396,9 +397,9 @@ NEW_LINE (\r|\n|\r\n)
|
||||
c = l.Next()
|
||||
}
|
||||
|
||||
<STRING>\" l.popState(); lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
|
||||
<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 = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_DOLLAR_OPEN_CURLY_BRACES
|
||||
<STRING>\" l.popState(); lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
|
||||
<STRING,HEREDOC,BACKQUOTE>\{\$ lval.token = token.NewToken(l.handleNewLine(l.ungetN(1))); l.pushState(PHP); return T_CURLY_OPEN
|
||||
<STRING,HEREDOC,BACKQUOTE>\$\{ l.pushState(STRING_VAR_NAME);lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_DOLLAR_OPEN_CURLY_BRACES
|
||||
<STRING,HEREDOC,BACKQUOTE>\$ l.ungetN(1);l.pushState(STRING_VAR)
|
||||
<STRING>.|[ \t\n\r]
|
||||
F1:for {
|
||||
@ -408,7 +409,7 @@ NEW_LINE (\r|\n|\r\n)
|
||||
|
||||
switch c {
|
||||
case '"' :
|
||||
lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));
|
||||
lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil)));
|
||||
return T_ENCAPSED_AND_WHITESPACE
|
||||
break F1;
|
||||
|
||||
@ -417,7 +418,7 @@ NEW_LINE (\r|\n|\r\n)
|
||||
if rune(c) == '{' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ' {
|
||||
l.ungetN(1)
|
||||
tb := l.TokenBytes(nil)
|
||||
lval.token = newToken(l.handleNewLine(tb[:len(tb)-1]));
|
||||
lval.token = token.NewToken(l.handleNewLine(tb[:len(tb)-1]));
|
||||
return T_ENCAPSED_AND_WHITESPACE
|
||||
break F1;
|
||||
}
|
||||
@ -428,7 +429,7 @@ NEW_LINE (\r|\n|\r\n)
|
||||
if rune(c) == '$' {
|
||||
l.ungetN(1)
|
||||
tb := l.TokenBytes(nil)
|
||||
lval.token = newToken(l.handleNewLine(tb[:len(tb)-1]));
|
||||
lval.token = token.NewToken(l.handleNewLine(tb[:len(tb)-1]));
|
||||
return T_ENCAPSED_AND_WHITESPACE
|
||||
break F1;
|
||||
}
|
||||
@ -449,7 +450,7 @@ NEW_LINE (\r|\n|\r\n)
|
||||
|
||||
switch c {
|
||||
case '`' :
|
||||
lval.token = newToken(l.handleNewLine(l.TokenBytes(nil)));
|
||||
lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil)));
|
||||
return T_ENCAPSED_AND_WHITESPACE
|
||||
break F2;
|
||||
|
||||
@ -458,7 +459,7 @@ NEW_LINE (\r|\n|\r\n)
|
||||
if rune(c) == '{' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ' {
|
||||
l.ungetN(1)
|
||||
tb := l.TokenBytes(nil)
|
||||
lval.token = newToken(l.handleNewLine(tb[:len(tb)-1]));
|
||||
lval.token = token.NewToken(l.handleNewLine(tb[:len(tb)-1]));
|
||||
return T_ENCAPSED_AND_WHITESPACE
|
||||
break F2;
|
||||
}
|
||||
@ -469,7 +470,7 @@ NEW_LINE (\r|\n|\r\n)
|
||||
if rune(c) == '$' {
|
||||
l.ungetN(1)
|
||||
tb := l.TokenBytes(nil)
|
||||
lval.token = newToken(l.handleNewLine(tb[:len(tb)-1]));
|
||||
lval.token = token.NewToken(l.handleNewLine(tb[:len(tb)-1]));
|
||||
return T_ENCAPSED_AND_WHITESPACE
|
||||
break F2;
|
||||
}
|
||||
@ -531,24 +532,24 @@ NEW_LINE (\r|\n|\r\n)
|
||||
c = l.Next()
|
||||
}
|
||||
|
||||
lval.token = newToken(l.handleNewLine(tb));
|
||||
lval.token = token.NewToken(l.handleNewLine(tb));
|
||||
return T_ENCAPSED_AND_WHITESPACE
|
||||
|
||||
<STRING_VAR>\${VAR_NAME} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_VARIABLE
|
||||
<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 = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING
|
||||
<STRING_VAR>\[ l.pushState(STRING_VAR_INDEX);lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
|
||||
<STRING_VAR>\${VAR_NAME} lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_VARIABLE
|
||||
<STRING_VAR>->{VAR_NAME} lval.token = token.NewToken(l.handleNewLine(l.ungetN(len(l.TokenBytes(nil))-2))); return T_OBJECT_OPERATOR
|
||||
<STRING_VAR>{VAR_NAME} l.popState();lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING
|
||||
<STRING_VAR>\[ l.pushState(STRING_VAR_INDEX);lval.token = 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_INDEX>{LNUM}|{HNUM}|{BNUM} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_NUM_STRING
|
||||
<STRING_VAR_INDEX>\${VAR_NAME} lval.token = newToken(l.handleNewLine(l.TokenBytes(nil))); return T_VARIABLE
|
||||
<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 = newToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
|
||||
<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 = newToken(l.handleNewLine(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_INDEX>{LNUM}|{HNUM}|{BNUM} lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_NUM_STRING
|
||||
<STRING_VAR_INDEX>\${VAR_NAME} lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_VARIABLE
|
||||
<STRING_VAR_INDEX>{VAR_NAME} lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_STRING
|
||||
<STRING_VAR_INDEX>\] l.popState(); l.popState();lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
|
||||
<STRING_VAR_INDEX>[ \n\r\t\\'#] l.popState(); l.popState();lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return T_ENCAPSED_AND_WHITESPACE
|
||||
<STRING_VAR_INDEX>{OPERATORS} lval.token = token.NewToken(l.handleNewLine(l.TokenBytes(nil))); return rune2Class(rune(l.TokenBytes(nil)[0]))
|
||||
<STRING_VAR_INDEX>. lval.token = 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 = newToken(l.handleNewLine(l.ungetN(1))); return T_STRING_VARNAME
|
||||
<STRING_VAR_NAME>{VAR_NAME}[\[\}] l.popState();l.pushState(PHP);lval.token = token.NewToken(l.handleNewLine(l.ungetN(1))); return T_STRING_VARNAME
|
||||
<STRING_VAR_NAME>. l.ungetN(1);l.popState();l.pushState(PHP)
|
||||
|
||||
%%
|
||||
|
15
token.go
15
token.go
@ -1,15 +0,0 @@
|
||||
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)
|
||||
}
|
15
token/token.go
Normal file
15
token/token.go
Normal file
@ -0,0 +1,15 @@
|
||||
package token
|
||||
|
||||
type Token struct {
|
||||
Value string
|
||||
StartLine int
|
||||
EndLine int
|
||||
}
|
||||
|
||||
func NewToken(value []byte, startLine int, endLine int) Token {
|
||||
return Token{string(value), startLine, endLine}
|
||||
}
|
||||
|
||||
func (t Token) String() string {
|
||||
return string(t.Value)
|
||||
}
|
Loading…
Reference in New Issue
Block a user