2018-01-26 13:24:56 +00:00
|
|
|
package php7
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
goToken "go/token"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/cznic/golex/lex"
|
|
|
|
|
|
|
|
"github.com/z7zmey/php-parser/scanner"
|
|
|
|
"github.com/z7zmey/php-parser/token"
|
|
|
|
)
|
|
|
|
|
|
|
|
type lexer struct {
|
2018-02-06 10:39:42 +00:00
|
|
|
scanner.Lexer
|
2018-01-26 13:24:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *lexer) Lex(lval *yySymType) int {
|
2018-02-06 10:39:42 +00:00
|
|
|
return l.Lexer.Lex(lval)
|
2018-01-26 13:24:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (lval *yySymType) Token(t token.Token) {
|
2018-02-06 10:39:42 +00:00
|
|
|
lval.token = t
|
2018-01-26 13:24:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func newLexer(src io.Reader, fName string) *lexer {
|
|
|
|
file := goToken.NewFileSet().AddFile(fName, -1, 1<<31-1)
|
|
|
|
lx, err := lex.New(file, bufio.NewReader(src), lex.RuneClass(scanner.Rune2Class))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &lexer{
|
|
|
|
scanner.Lexer{
|
|
|
|
Lexer: lx,
|
|
|
|
StateStack: []int{0},
|
|
|
|
PhpDocComment: "",
|
|
|
|
Comments: nil,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|