#80 implement Ragel based lexer
This commit is contained in:
@@ -569,9 +569,7 @@ func (p *PrettyPrinter) printScalarEncapsed(n node.Node) {
|
||||
func (p *PrettyPrinter) printScalarHeredoc(n node.Node) {
|
||||
nn := n.(*scalar.Heredoc)
|
||||
|
||||
io.WriteString(p.w, "<<<")
|
||||
io.WriteString(p.w, nn.Label)
|
||||
io.WriteString(p.w, "\n")
|
||||
|
||||
for _, part := range nn.Parts {
|
||||
switch part.(type) {
|
||||
@@ -584,7 +582,7 @@ func (p *PrettyPrinter) printScalarHeredoc(n node.Node) {
|
||||
}
|
||||
}
|
||||
|
||||
io.WriteString(p.w, strings.Trim(nn.Label, "\"'"))
|
||||
io.WriteString(p.w, strings.Trim(nn.Label, "<\"'\n"))
|
||||
}
|
||||
|
||||
func (p *PrettyPrinter) printScalarMagicConstant(n node.Node) {
|
||||
|
||||
@@ -87,7 +87,7 @@ func TestPrintFileInlineHtml(t *testing.T) {
|
||||
&stmt.InlineHtml{Value: "<div>HTML</div>"},
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Heredoc{
|
||||
Label: "\"LBL\"",
|
||||
Label: "<<<\"LBL\"\n",
|
||||
Parts: []node.Node{
|
||||
&scalar.EncapsedStringPart{Value: "hello world\n"},
|
||||
},
|
||||
@@ -356,7 +356,7 @@ func TestPrintScalarHeredoc(t *testing.T) {
|
||||
|
||||
p := printer.NewPrettyPrinter(o, " ")
|
||||
p.Print(&scalar.Heredoc{
|
||||
Label: "LBL",
|
||||
Label: "<<<LBL\n",
|
||||
Parts: []node.Node{
|
||||
&scalar.EncapsedStringPart{Value: "hello "},
|
||||
&expr.Variable{VarName: &node.Identifier{Value: "var"}},
|
||||
@@ -379,7 +379,7 @@ func TestPrintScalarNowdoc(t *testing.T) {
|
||||
|
||||
p := printer.NewPrettyPrinter(o, " ")
|
||||
p.Print(&scalar.Heredoc{
|
||||
Label: "'LBL'",
|
||||
Label: "<<<'LBL'\n",
|
||||
Parts: []node.Node{
|
||||
&scalar.EncapsedStringPart{Value: "hello world\n"},
|
||||
},
|
||||
|
||||
@@ -618,9 +618,7 @@ func (p *Printer) printScalarHeredoc(n node.Node) {
|
||||
nn := n.(*scalar.Heredoc)
|
||||
p.printFreeFloating(nn, freefloating.Start)
|
||||
|
||||
io.WriteString(p.w, "<<<")
|
||||
io.WriteString(p.w, nn.Label)
|
||||
io.WriteString(p.w, "\n")
|
||||
|
||||
for _, part := range nn.Parts {
|
||||
switch part.(type) {
|
||||
@@ -643,8 +641,7 @@ func (p *Printer) printScalarHeredoc(n node.Node) {
|
||||
}
|
||||
}
|
||||
|
||||
io.WriteString(p.w, "\n")
|
||||
io.WriteString(p.w, strings.Trim(nn.Label, "\"'"))
|
||||
io.WriteString(p.w, strings.Trim(nn.Label, "<\"'\n"))
|
||||
|
||||
p.printFreeFloating(nn, freefloating.End)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func parsePhp5(src string) node.Node {
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser := php5.NewParser([]byte(src))
|
||||
php5parser.WithFreeFloating()
|
||||
php5parser.Parse()
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ abstract class Bar extends Baz
|
||||
|
||||
// parse
|
||||
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser := php7.NewParser([]byte(src))
|
||||
php7parser.WithFreeFloating()
|
||||
php7parser.Parse()
|
||||
|
||||
@@ -61,7 +61,7 @@ abstract class Bar extends Baz
|
||||
}
|
||||
|
||||
func parse(src string) node.Node {
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser := php7.NewParser([]byte(src))
|
||||
php7parser.WithFreeFloating()
|
||||
php7parser.Parse()
|
||||
|
||||
|
||||
@@ -425,13 +425,13 @@ func TestPrinterPrintScalarHeredoc(t *testing.T) {
|
||||
|
||||
p := printer.NewPrinter(o)
|
||||
p.Print(&scalar.Heredoc{
|
||||
Label: "LBL",
|
||||
Label: "<<<LBL\n",
|
||||
Parts: []node.Node{
|
||||
&scalar.EncapsedStringPart{Value: "hello "},
|
||||
&expr.Variable{
|
||||
VarName: &node.Identifier{Value: "var"},
|
||||
},
|
||||
&scalar.EncapsedStringPart{Value: " world"},
|
||||
&scalar.EncapsedStringPart{Value: " world\n"},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -450,9 +450,9 @@ func TestPrinterPrintScalarNowdoc(t *testing.T) {
|
||||
|
||||
p := printer.NewPrinter(o)
|
||||
p.Print(&scalar.Heredoc{
|
||||
Label: "'LBL'",
|
||||
Label: "<<<'LBL'\n",
|
||||
Parts: []node.Node{
|
||||
&scalar.EncapsedStringPart{Value: "hello world"},
|
||||
&scalar.EncapsedStringPart{Value: "hello world\n"},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user