rename flag -meta to -ff

This commit is contained in:
z7zmey 2019-02-25 16:52:47 +02:00
parent 37c9c2092f
commit a7229f53dd
12 changed files with 55 additions and 55 deletions

View File

@ -25,7 +25,7 @@ var wg sync.WaitGroup
var usePhp5 *bool
var dumpType string
var profiler string
var withMeta *bool
var withFreeFloating *bool
var showResolvedNs *bool
var printBack *bool
@ -36,7 +36,7 @@ type file struct {
func main() {
usePhp5 = flag.Bool("php5", false, "parse as PHP5")
withMeta = flag.Bool("meta", false, "show meta")
withFreeFloating = flag.Bool("ff", false, "parse and show free floating strings")
showResolvedNs = flag.Bool("r", false, "resolve names")
printBack = flag.Bool("pb", false, "print AST back into the parsed file")
flag.StringVar(&dumpType, "d", "", "dump format: [custom, go, json, pretty_json]")
@ -110,8 +110,8 @@ func parserWorker(fileCh <-chan *file, result chan<- parser.Parser) {
parserWorker = php7.NewParser(src, f.path)
}
if *withMeta {
parserWorker.WithMeta()
if *withFreeFloating {
parserWorker.WithFreeFloating()
}
parserWorker.Parse()

View File

@ -11,5 +11,5 @@ type Parser interface {
GetPath() string
GetRootNode() node.Node
GetErrors() []*errors.Error
WithMeta()
WithFreeFloating()
}

View File

@ -57,8 +57,8 @@ func (l *Parser) Error(msg string) {
l.Lexer.Errors = append(l.Lexer.Errors, errors.NewError(msg, pos))
}
func (l *Parser) WithMeta() {
l.Lexer.WithMeta = true
func (l *Parser) WithFreeFloating() {
l.Lexer.WithFreeFloating = true
}
// Parse the php7 Parser entrypoint
@ -106,7 +106,7 @@ func isDollar(r rune) bool {
}
func (l *Parser) MoveFreeFloating(src node.Node, dst node.Node) {
if l.Lexer.WithMeta == false {
if l.Lexer.WithFreeFloating == false {
return
}
@ -119,7 +119,7 @@ func (l *Parser) MoveFreeFloating(src node.Node, dst node.Node) {
}
func (l *Parser) setFreeFloating(dst node.Node, p freefloating.Position, strings []freefloating.String) {
if l.Lexer.WithMeta == false {
if l.Lexer.WithFreeFloating == false {
return
}
@ -136,7 +136,7 @@ func (l *Parser) setFreeFloating(dst node.Node, p freefloating.Position, strings
}
func (l *Parser) GetFreeFloatingToken(t *scanner.Token) []freefloating.String {
if l.Lexer.WithMeta == false {
if l.Lexer.WithFreeFloating == false {
return []freefloating.String{}
}
@ -144,7 +144,7 @@ func (l *Parser) GetFreeFloatingToken(t *scanner.Token) []freefloating.String {
}
func (l *Parser) addDollarToken(v node.Node) {
if l.Lexer.WithMeta == false {
if l.Lexer.WithFreeFloating == false {
return
}
@ -163,7 +163,7 @@ func (l *Parser) addDollarToken(v node.Node) {
}
func (l *Parser) splitSemiColonAndPhpCloseTag(htmlNode node.Node, prevNode node.Node) {
if l.Lexer.WithMeta == false {
if l.Lexer.WithFreeFloating == false {
return
}

View File

@ -56,8 +56,8 @@ func (l *Parser) Error(msg string) {
l.Lexer.Errors = append(l.Lexer.Errors, errors.NewError(msg, pos))
}
func (l *Parser) WithMeta() {
l.Lexer.WithMeta = true
func (l *Parser) WithFreeFloating() {
l.Lexer.WithFreeFloating = true
}
// Parse the php7 Parser entrypoint
@ -105,7 +105,7 @@ func isDollar(r rune) bool {
}
func (l *Parser) MoveFreeFloating(src node.Node, dst node.Node) {
if l.Lexer.WithMeta == false {
if l.Lexer.WithFreeFloating == false {
return
}
@ -118,7 +118,7 @@ func (l *Parser) MoveFreeFloating(src node.Node, dst node.Node) {
}
func (l *Parser) setFreeFloating(dst node.Node, p freefloating.Position, strings []freefloating.String) {
if l.Lexer.WithMeta == false {
if l.Lexer.WithFreeFloating == false {
return
}
@ -135,7 +135,7 @@ func (l *Parser) setFreeFloating(dst node.Node, p freefloating.Position, strings
}
func (l *Parser) GetFreeFloatingToken(t *scanner.Token) []freefloating.String {
if l.Lexer.WithMeta == false {
if l.Lexer.WithFreeFloating == false {
return []freefloating.String{}
}
@ -143,7 +143,7 @@ func (l *Parser) GetFreeFloatingToken(t *scanner.Token) []freefloating.String {
}
func (l *Parser) addDollarToken(v node.Node) {
if l.Lexer.WithMeta == false {
if l.Lexer.WithFreeFloating == false {
return
}
@ -162,7 +162,7 @@ func (l *Parser) addDollarToken(v node.Node) {
}
func (l *Parser) splitSemiColonAndPhpCloseTag(htmlNode node.Node, prevNode node.Node) {
if l.Lexer.WithMeta == false {
if l.Lexer.WithFreeFloating == false {
return
}

View File

@ -11,7 +11,7 @@ import (
func parsePhp5(src string) node.Node {
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.WithMeta()
php5parser.WithFreeFloating()
php5parser.Parse()
return php5parser.GetRootNode()

View File

@ -30,7 +30,7 @@ abstract class Bar extends Baz
// parse
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.WithMeta()
php7parser.WithFreeFloating()
php7parser.Parse()
rootNode := php7parser.GetRootNode()
@ -62,7 +62,7 @@ abstract class Bar extends Baz
func parse(src string) node.Node {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.WithMeta()
php7parser.WithFreeFloating()
php7parser.Parse()
return php7parser.GetRootNode()

View File

@ -31,15 +31,15 @@ type Lval interface {
// Lexer php lexer
type Lexer struct {
*lex.Lexer
StateStack []int
PhpDocComment string
FreeFloating []freefloating.String
heredocLabel string
tokenBytesBuf *bytes.Buffer
TokenPool *TokenPool
WithMeta bool
lastToken *Token
Errors []*errors.Error
StateStack []int
PhpDocComment string
FreeFloating []freefloating.String
heredocLabel string
tokenBytesBuf *bytes.Buffer
TokenPool *TokenPool
WithFreeFloating bool
lastToken *Token
Errors []*errors.Error
}
// Rune2Class returns the rune integer id
@ -163,10 +163,10 @@ func (l *Lexer) tokenString(chars []lex.Char) string {
return string(l.tokenBytesBuf.Bytes())
}
// meta
// free-floating
func (l *Lexer) addFreeFloating(t freefloating.StringType, chars []lex.Char) {
if !l.WithMeta {
if !l.WithFreeFloating {
return
}

View File

@ -414,7 +414,7 @@ func TestTokens(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
actual := []string{}
@ -550,7 +550,7 @@ func TestTeplateStringTokens(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
actual := []string{}
@ -636,7 +636,7 @@ func TestBackquoteStringTokens(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
actual := []string{}
@ -731,7 +731,7 @@ CAT;
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
actual := []string{}
@ -803,7 +803,7 @@ CAT
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
actual := []string{}
@ -842,7 +842,7 @@ CAT;
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
actual := []string{}
@ -875,7 +875,7 @@ func TestInlineHtmlNopTokens(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
actual := []string{}
@ -985,7 +985,7 @@ func TestCommentEnd(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
lexer.Lex(lv)
@ -1017,7 +1017,7 @@ func TestCommentNewLine(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
lexer.Lex(lv)
@ -1049,7 +1049,7 @@ func TestCommentNewLine1(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
lexer.Lex(lv)
@ -1081,7 +1081,7 @@ func TestCommentNewLine2(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
lexer.Lex(lv)
@ -1114,7 +1114,7 @@ func TestCommentWithPhpEndTag(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
lexer.Lex(lv)
@ -1147,7 +1147,7 @@ func TestInlineComment(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
lexer.Lex(lv)
@ -1180,7 +1180,7 @@ func TestInlineComment2(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
lexer.Lex(lv)
@ -1218,7 +1218,7 @@ func TestEmptyInlineComment(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
lexer.Lex(lv)
@ -1251,7 +1251,7 @@ func TestEmptyInlineComment2(t *testing.T) {
}
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
lexer.Lex(lv)
@ -1266,7 +1266,7 @@ func TestMethodCallTokens(t *testing.T) {
$a -> bar ( '' ) ;`
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
expected := []freefloating.String{
@ -1357,7 +1357,7 @@ func TestYieldFromTokens(t *testing.T) {
yield from $a`
lexer := scanner.NewLexer(bytes.NewBufferString(src), "test.php")
lexer.WithMeta = true
lexer.WithFreeFloating = true
lv := &lval{}
expected := []freefloating.String{

View File

@ -22,7 +22,7 @@ func ExampleDumper() {
}`
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.WithMeta()
php7parser.WithFreeFloating()
php7parser.Parse()
nodes := php7parser.GetRootNode()

View File

@ -22,7 +22,7 @@ func ExampleGoDumper() {
}`
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.WithMeta()
php7parser.WithFreeFloating()
php7parser.Parse()
nodes := php7parser.GetRootNode()

View File

@ -23,7 +23,7 @@ func ExampleJsonDumper() {
}`
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.WithMeta()
php7parser.WithFreeFloating()
php7parser.Parse()
nodes := php7parser.GetRootNode()

View File

@ -28,7 +28,7 @@ func ExamplePrettyJsonDumper() {
`
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.WithMeta()
php7parser.WithFreeFloating()
php7parser.Parse()
nodes := php7parser.GetRootNode()