add type aliases, rework compiler, remove optimization
This commit is contained in:
parent
94b12f28ab
commit
d54249cffe
12 changed files with 869 additions and 1597 deletions
|
|
@ -73,6 +73,7 @@ func GetTokenTestData() map[string]TokenTestData {
|
|||
2,
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
false,
|
||||
|
|
@ -128,6 +129,7 @@ func GetTokenTestData() map[string]TokenTestData {
|
|||
"b",
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
true,
|
||||
|
|
@ -189,12 +191,14 @@ func GetTokenTestData() map[string]TokenTestData {
|
|||
1,
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
&FloatNode{
|
||||
5,
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
&BinaryNode{
|
||||
|
|
@ -213,10 +217,13 @@ func GetTokenTestData() map[string]TokenTestData {
|
|||
2,
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
&BinaryNode{
|
||||
|
|
@ -229,8 +236,10 @@ func GetTokenTestData() map[string]TokenTestData {
|
|||
2,
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
false,
|
||||
|
|
@ -263,6 +272,7 @@ func GetTokenTestData() map[string]TokenTestData {
|
|||
15,
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
false,
|
||||
|
|
@ -298,6 +308,7 @@ func GetTokenTestData() map[string]TokenTestData {
|
|||
0,
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
do: &BlockNode{
|
||||
|
|
@ -351,6 +362,7 @@ func GetTokenTestData() map[string]TokenTestData {
|
|||
0,
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
do: &BlockNode{
|
||||
|
|
@ -458,6 +470,7 @@ func GetTokenTestData() map[string]TokenTestData {
|
|||
"b",
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
0, 0,
|
||||
|
|
@ -529,6 +542,7 @@ func GetTokenTestData() map[string]TokenTestData {
|
|||
"b",
|
||||
0, 0,
|
||||
},
|
||||
nil,
|
||||
0, 0,
|
||||
},
|
||||
0, 0,
|
||||
|
|
@ -564,7 +578,7 @@ func GetTokenTestData() map[string]TokenTestData {
|
|||
"a",
|
||||
0, 0,
|
||||
},
|
||||
"b",
|
||||
&Token{TokenName, 0, 1, 0, "b"},
|
||||
0, 0,
|
||||
},
|
||||
true,
|
||||
|
|
@ -767,10 +781,10 @@ func NodeEquality(t *testing.T, n1 Node, n2 Node) {
|
|||
NodeEquality(t, n1.(*BinaryNode).Right, n2.(*BinaryNode).Right)
|
||||
|
||||
case BooleanNodeType:
|
||||
if n1.(*BooleanNode).value != n2.(*BooleanNode).value {
|
||||
t.Errorf("Boolean node values don't match (%s and %s)", strconv.FormatBool(n1.(*BooleanNode).value), strconv.FormatBool(n2.(*BooleanNode).value))
|
||||
if n1.(*BooleanNode).Boolean != n2.(*BooleanNode).Boolean {
|
||||
t.Errorf("Boolean node values don't match (%s and %s)", strconv.FormatBool(n1.(*BooleanNode).Boolean), strconv.FormatBool(n2.(*BooleanNode).Boolean))
|
||||
} else {
|
||||
t.Logf("Boolean node values match (%s)", strconv.FormatBool(n1.(*BooleanNode).value))
|
||||
t.Logf("Boolean node values match (%s)", strconv.FormatBool(n1.(*BooleanNode).Boolean))
|
||||
}
|
||||
case BlockNodeType:
|
||||
if len(n1.(*BlockNode).statements) != len(n2.(*BlockNode).statements) {
|
||||
|
|
@ -840,7 +854,7 @@ func NodeEquality(t *testing.T, n1 Node, n2 Node) {
|
|||
}
|
||||
|
||||
for i, p := range m.parameters {
|
||||
if !n.parameters[i].Signature.Matches(p.Signature) {
|
||||
if !n.parameters[i].Signature.Contains(p.Signature) {
|
||||
t.Errorf("Function node parameter signature %d does not match: %s and %s", i, p.Signature, n.parameters[i].Signature)
|
||||
} else if n.parameters[i].Name != p.Name {
|
||||
t.Errorf("Function node parameter name %d does not match: %s and %s", i, p.Name, n.parameters[i].Name)
|
||||
|
|
@ -858,10 +872,11 @@ func NodeEquality(t *testing.T, n1 Node, n2 Node) {
|
|||
a1 := n1.(*AccessNode)
|
||||
a2 := n2.(*AccessNode)
|
||||
|
||||
if a1.property != a2.property {
|
||||
t.Errorf("Access node property does not match: .%s != .%s", a1.property, a2.property)
|
||||
// only care about lexeme; the rest is debug info
|
||||
if a1.property.Lexeme != a2.property.Lexeme {
|
||||
t.Errorf("Access node property does not match: .%s != .%s", a1.property.Lexeme, a2.property.Lexeme)
|
||||
} else {
|
||||
t.Logf("Access node property matches: .%s", a1.property)
|
||||
t.Logf("Access node property matches: .%s", a1.property.Lexeme)
|
||||
}
|
||||
|
||||
NodeEquality(t, a1.source, a2.source)
|
||||
|
|
@ -875,7 +890,7 @@ func NodeEquality(t *testing.T, n1 Node, n2 Node) {
|
|||
t.Logf("Both content types are yet to be determined")
|
||||
} else if l1.content != nil || l2.content != nil {
|
||||
t.Errorf("one is nil, one is not")
|
||||
} else if !l1.content.Matches(l2.content) {
|
||||
} else if !l1.content.Contains(l2.content) {
|
||||
t.Errorf("signature doesn't match")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue