#80 implement Ragel based lexer

This commit is contained in:
z7zmey
2019-03-10 23:37:01 +02:00
parent 9ca7109abe
commit 2c649159c7
108 changed files with 30415 additions and 18534 deletions

View File

@@ -1,7 +1,6 @@
package name_test
import (
"bytes"
"testing"
"gotest.tools/assert"
@@ -23,7 +22,7 @@ func TestName(t *testing.T) {
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 9,
},
Stmts: []node.Node{
@@ -31,21 +30,21 @@ func TestName(t *testing.T) {
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 9,
},
Expr: &expr.FunctionCall{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 8,
},
Function: &name.Name{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 6,
},
Parts: []node.Node{
@@ -53,7 +52,7 @@ func TestName(t *testing.T) {
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 6,
},
Value: "foo",
@@ -64,7 +63,7 @@ func TestName(t *testing.T) {
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 7,
StartPos: 6,
EndPos: 8,
},
},
@@ -73,12 +72,12 @@ func TestName(t *testing.T) {
},
}
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser := php7.NewParser([]byte(src))
php7parser.Parse()
actual := php7parser.GetRootNode()
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser := php5.NewParser([]byte(src))
php5parser.Parse()
actual = php5parser.GetRootNode()
assert.DeepEqual(t, expected, actual)
@@ -91,7 +90,7 @@ func TestFullyQualified(t *testing.T) {
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 10,
},
Stmts: []node.Node{
@@ -99,21 +98,21 @@ func TestFullyQualified(t *testing.T) {
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 10,
},
Expr: &expr.FunctionCall{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 9,
},
Function: &name.FullyQualified{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 7,
},
Parts: []node.Node{
@@ -121,7 +120,7 @@ func TestFullyQualified(t *testing.T) {
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 5,
StartPos: 4,
EndPos: 7,
},
Value: "foo",
@@ -132,7 +131,7 @@ func TestFullyQualified(t *testing.T) {
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 8,
StartPos: 7,
EndPos: 9,
},
},
@@ -141,12 +140,12 @@ func TestFullyQualified(t *testing.T) {
},
}
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser := php7.NewParser([]byte(src))
php7parser.Parse()
actual := php7parser.GetRootNode()
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser := php5.NewParser([]byte(src))
php5parser.Parse()
actual = php5parser.GetRootNode()
assert.DeepEqual(t, expected, actual)
@@ -159,7 +158,7 @@ func TestRelative(t *testing.T) {
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 19,
},
Stmts: []node.Node{
@@ -167,21 +166,21 @@ func TestRelative(t *testing.T) {
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 19,
},
Expr: &expr.FunctionCall{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 18,
},
Function: &name.Relative{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
StartPos: 3,
EndPos: 16,
},
Parts: []node.Node{
@@ -189,7 +188,7 @@ func TestRelative(t *testing.T) {
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 14,
StartPos: 13,
EndPos: 16,
},
Value: "foo",
@@ -200,7 +199,7 @@ func TestRelative(t *testing.T) {
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 17,
StartPos: 16,
EndPos: 18,
},
},
@@ -209,12 +208,12 @@ func TestRelative(t *testing.T) {
},
}
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser := php7.NewParser([]byte(src))
php7parser.Parse()
actual := php7parser.GetRootNode()
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser := php5.NewParser([]byte(src))
php5parser.Parse()
actual = php5parser.GetRootNode()
assert.DeepEqual(t, expected, actual)