Change interface symbol from ~ to &
This commit is contained in:
parent
e0d4be8db8
commit
db98e590fc
@ -115,7 +115,7 @@ func TestAssignmentLiteralErrInterfaceInt (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"cannot use integer literal as Bird", 4, 11,
|
||||
`
|
||||
Bird: (~ [fly distance:F64] [land])
|
||||
Bird: (& [fly distance:F64] [land])
|
||||
[main] = {
|
||||
b:Bird = 5
|
||||
}
|
||||
@ -126,7 +126,7 @@ func TestAssignmentLiteralErrInterfaceFloat (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"cannot use float literal as Bird", 4, 11,
|
||||
`
|
||||
Bird: (~ [fly distance:F64] [land])
|
||||
Bird: (& [fly distance:F64] [land])
|
||||
[main] = {
|
||||
b:Bird = 5.5
|
||||
}
|
||||
@ -137,7 +137,7 @@ func TestAssignmentLiteralErrInterfaceArray (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"cannot use array literal as Bird", 4, 11,
|
||||
`
|
||||
Bird: (~ [fly distance:F64] [land])
|
||||
Bird: (& [fly distance:F64] [land])
|
||||
[main] = {
|
||||
b:Bird = (* 1 2 3 4)
|
||||
}
|
||||
@ -148,7 +148,7 @@ func TestAssignmentLiteralErrInterfaceStruct (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"cannot use struct literal as Bird", 4, 11,
|
||||
`
|
||||
Bird: (~ [fly distance:F64] [land])
|
||||
Bird: (& [fly distance:F64] [land])
|
||||
[main] = {
|
||||
b:Bird = (. x: 5 y: 6)
|
||||
}
|
||||
@ -197,7 +197,7 @@ func TestAssignmentInterfaceErrBadSignature (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"BlueJay has wrong signature for method fly", 7, 11,
|
||||
`
|
||||
Bird: (~ [fly distance:F64] [land])
|
||||
Bird: (& [fly distance:F64] [land])
|
||||
BlueJay: Int
|
||||
BlueJay.[fly] = { }
|
||||
BlueJay.[land] = { }
|
||||
@ -211,7 +211,7 @@ func TestAssignmentInterfaceErrMissingMethod (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"no method named fly defined on this type", 6, 11,
|
||||
`
|
||||
Bird: (~ [fly distance:F64] [land])
|
||||
Bird: (& [fly distance:F64] [land])
|
||||
BlueJay: Int
|
||||
BlueJay.[land] = { }
|
||||
[main] = {
|
||||
@ -224,7 +224,7 @@ func TestAssignmentInterfaceErrBadLayer (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"no method named fly defined on this type", 7, 11,
|
||||
`
|
||||
Bird: (~ [fly distance:F64])
|
||||
Bird: (& [fly distance:F64])
|
||||
BlueJay: Int
|
||||
BlueJay.[fly distance:F64] = { }
|
||||
BlueJayRef: *BlueJay
|
||||
@ -237,7 +237,7 @@ BlueJayRef: *BlueJay
|
||||
func TestAssignmentInterface (test *testing.T) {
|
||||
testString (test,
|
||||
`
|
||||
Bird: (~ [fly distance:F64] [land])
|
||||
Bird: (& [fly distance:F64] [land])
|
||||
BlueJay: Int
|
||||
BlueJay.[fly distance:F64] = { }
|
||||
BlueJay.[land] = { }
|
||||
@ -301,7 +301,7 @@ testString (test,
|
||||
[f]:Byte = 5
|
||||
A:Int
|
||||
A.[g]:Int = 2
|
||||
B:(~ [g]:Int)
|
||||
B:(& [g]:Int)
|
||||
[main] = {
|
||||
a:Int
|
||||
b:Int = a
|
||||
|
@ -72,7 +72,7 @@ testStringErr (test,
|
||||
func TestCast (test *testing.T) {
|
||||
testString (test,
|
||||
`
|
||||
Bird: (~ [fly distance:F64] [land])
|
||||
Bird: (& [fly distance:F64] [land])
|
||||
BlueJay: Int
|
||||
BlueJay.[fly distance:F64] = { }
|
||||
BlueJay.[land] = { }
|
||||
|
@ -151,7 +151,7 @@ testUnitsErr (test,
|
||||
}`,
|
||||
|
||||
"other.fspl",
|
||||
`~ RestrictedInterface:(~ [y])`,
|
||||
`~ RestrictedInterface:(& [y])`,
|
||||
)}
|
||||
|
||||
func TestBehaviorCallRestricted (test *testing.T) {
|
||||
@ -160,7 +160,7 @@ testString (test,
|
||||
x:RestrictedInterface
|
||||
x.[y]
|
||||
}
|
||||
~ RestrictedInterface:(~ [y])`,
|
||||
~ RestrictedInterface:(& [y])`,
|
||||
)}
|
||||
|
||||
func TestUnitCastRestrictedErr (test *testing.T) {
|
||||
@ -210,7 +210,7 @@ testUnits (test,
|
||||
+ [write file:FileDescriptor buffer:*Byte count:Index]: Index 'write'`,
|
||||
|
||||
"io.fspl",
|
||||
`+ Writer: (~ [write buffer:*:Byte]: Index)
|
||||
`+ Writer: (& [write buffer:*:Byte]: Index)
|
||||
+ File: cstdio::FileDescriptor
|
||||
+ File.[write buffer:*:Byte]:Index =
|
||||
cstdio::[write
|
||||
|
@ -156,7 +156,7 @@ func TestInterfaceBehaviorNameErrMissing (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"no behavior or method named swim", 8, 6,
|
||||
`
|
||||
Bird: (~ [fly] [land])
|
||||
Bird: (& [fly] [land])
|
||||
BirdImpl: Int
|
||||
BirdImpl.[fly] = { }
|
||||
BirdImpl.[land] = { }
|
||||
@ -170,7 +170,7 @@ BirdImpl.[land] = { }
|
||||
func TestInterfaceBehaviorName (test *testing.T) {
|
||||
testString (test,
|
||||
`
|
||||
Bird: (~ [fly] [land])
|
||||
Bird: (& [fly] [land])
|
||||
BirdImpl: Int
|
||||
BirdImpl.[fly] = { }
|
||||
BirdImpl.[land] = { }
|
||||
|
@ -153,7 +153,7 @@ testString (test,
|
||||
`
|
||||
U: (| I8 I16 I32 I64 Int)
|
||||
Point: (. x:Int y:Int)
|
||||
Error: (~ [error]:String)
|
||||
Error: (& [error]:String)
|
||||
PointOrError: (| Point Error)
|
||||
`)
|
||||
}
|
||||
@ -196,14 +196,14 @@ func TestTypeInterfaceBehaviorUniqueErr (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"fly already listed in interface at stream0.fspl:2:10", 2, 16,
|
||||
`
|
||||
Bird: (~ [fly] [fly])
|
||||
Bird: (& [fly] [fly])
|
||||
`)
|
||||
}
|
||||
|
||||
func TestTypeInterfaceBehaviorUnique (test *testing.T) {
|
||||
testString (test,
|
||||
`
|
||||
Bird: (~ [fly] [land])
|
||||
Bird: (& [fly] [land])
|
||||
`)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
Numbered: (~ [number]: Int)
|
||||
Numbered: (& [number]:Int)
|
||||
Number: Int
|
||||
Number.[number]: Int = [.this]
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
+ [print string:String]: Index = cstdio::[write 1 [~*Byte string] [#string]]
|
||||
+ [println string:String]: Index = [+ [print string] cstdio::[write 1 '\n' 1]]
|
||||
|
||||
+ Writer: (~ [write buffer:*:Byte]: Index)
|
||||
+ Writer: (& [write buffer:*:Byte]: Index)
|
||||
+ File: cstdio::FileDescriptor
|
||||
+ File.[write buffer:*:Byte]:Index =
|
||||
cstdio::[write
|
||||
|
@ -305,7 +305,7 @@ this without hand-writing a parser.
|
||||
<sliceType> -> "*" ":" <type>
|
||||
<arrayType> -> <intLiteral> ":" <type>
|
||||
<structType> -> "(" "." <declaration>* ")"
|
||||
<interfaceType> -> "(" "~" <signature>* ")"
|
||||
<interfaceType> -> "(" "&" <signature>* ")"
|
||||
<unionType> -> "(" "|" <type>* ")"
|
||||
|
||||
<expression> -> <intLiteral>
|
||||
|
@ -212,7 +212,7 @@ func (this *TypeInterface) Position () errors.Position { return this.Pos }
|
||||
func (this *TypeInterface) Access () Access { return this.Acc }
|
||||
func (this *TypeInterface) Unit () uuid.UUID { return this.Unt }
|
||||
func (this *TypeInterface) String () string {
|
||||
out := "(~"
|
||||
out := "(&"
|
||||
for _, behavior := range this.Behaviors {
|
||||
out += fmt.Sprint(" ", behavior)
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ define void @"0zNZN147MN2wzMAQ6NS2dQ==::T.do"(ptr %this) {
|
||||
}
|
||||
`,
|
||||
`
|
||||
Doer: (~ [do])
|
||||
Doer: (& [do])
|
||||
T: Int
|
||||
T.[do] = { }
|
||||
|
||||
@ -70,7 +70,7 @@ define i64 @"0zNZN147MN2wzMAQ6NS2dQ==::Number.number"(ptr %this) {
|
||||
}
|
||||
`,
|
||||
`
|
||||
Numbered: (~ [number]: Int)
|
||||
Numbered: (& [number]: Int)
|
||||
Number: Int
|
||||
Number.[number]: Int = [.this]
|
||||
|
||||
@ -173,7 +173,7 @@ declare %"AAAAAAAAAAAAAAAAAAAAAA==::Index" @"0zNZN147MN2wzMAQ6NS2dQ==::write"(%"
|
||||
`
|
||||
[write fd:File buffer:*Byte count:Index]: Index
|
||||
|
||||
Writer: (~ [write buffer:*:Byte]: Index)
|
||||
Writer: (& [write buffer:*:Byte]: Index)
|
||||
File: I32
|
||||
File.[write buffer:*:Byte]:Index = [write [.this] [~*Byte buffer] [#buffer]]
|
||||
|
||||
@ -208,7 +208,7 @@ define void @main() {
|
||||
declare %"AAAAAAAAAAAAAAAAAAAAAA==::Index" @"0zNZN147MN2wzMAQ6NS2dQ==::File.write"(ptr %this, { ptr, %"AAAAAAAAAAAAAAAAAAAAAA==::Index" } %buffer)
|
||||
`,
|
||||
`
|
||||
Writer: (~ [write buffer:*:Byte]: Index)
|
||||
Writer: (& [write buffer:*:Byte]: Index)
|
||||
A: (. output: Writer)
|
||||
File: I32
|
||||
File.[write buffer:*:Byte]:Index
|
||||
@ -241,7 +241,7 @@ define i64 @"0zNZN147MN2wzMAQ6NS2dQ==::Impl.x"(ptr %this) {
|
||||
}
|
||||
`,
|
||||
`
|
||||
Face: (~ [x]:Int)
|
||||
Face: (& [x]:Int)
|
||||
Impl: Int
|
||||
Impl.[x]:Int = 5
|
||||
[main] 'main' = {
|
||||
|
@ -116,7 +116,7 @@ declare %"AAAAAAAAAAAAAAAAAAAAAA==::Index" @"1cqXRNyHN06gi9QQb4GCsg==::File.writ
|
||||
+ [write file:FileDescriptor buffer:*Byte count:Index]: Index 'write'`,
|
||||
|
||||
"io.fspl",
|
||||
`+ Writer: (~ [write buffer:*:Byte]: Index)
|
||||
`+ Writer: (& [write buffer:*:Byte]: Index)
|
||||
+ File: cstdio::FileDescriptor
|
||||
+ File.[write buffer:*:Byte]:Index =
|
||||
cstdio::[write
|
||||
|
@ -21,7 +21,7 @@ declare %"0zNZN147MN2wzMAQ6NS2dQ==::AllTypes" @"0zNZN147MN2wzMAQ6NS2dQ==::x"()
|
||||
`,
|
||||
`
|
||||
Point: (.x:Int y:Int)
|
||||
Pegasus: (~
|
||||
Pegasus: (&
|
||||
[clear clouds:*:Point]
|
||||
[fly rings:*:Point]
|
||||
[fall distance:Int]
|
||||
@ -154,7 +154,7 @@ SmallU: (| I8 U8 I16 U16)
|
||||
Point: (. x:Int y:Int)
|
||||
Padded: (. a:I8 b:I16)
|
||||
PaddedU: (| Padded)
|
||||
Error: (~ [error]:String)
|
||||
Error: (& [error]:String)
|
||||
PointOrError: (| Point Error)
|
||||
[main] = {
|
||||
u:U
|
||||
|
@ -124,7 +124,7 @@ determine what type to parse:
|
||||
| | +Dot =TypeStruct
|
||||
| |
|
||||
| | +Symbol X
|
||||
| | '~' =TypeInterface
|
||||
| | '&' =TypeInterface
|
||||
| | '|' =TypeSum
|
||||
|
|
||||
| +Star =TypePointer
|
||||
|
@ -7,7 +7,7 @@ testString (test,
|
||||
// correct
|
||||
`- BasicInt: Int
|
||||
- Structure: (. x:Int y:Int)
|
||||
- Interface: (~ [aMethod x:Int]:*U8 [otherMethod arg:5:Int]:*U8)
|
||||
- Interface: (& [aMethod x:Int]:*U8 [otherMethod arg:5:Int]:*U8)
|
||||
- Union: (| Int F64 *:U8 (. x:Int y:Int))
|
||||
- Array: 16:16:16:Int
|
||||
- StructArray: 31:24:340920:(. x:Int y:Int)
|
||||
@ -18,7 +18,7 @@ BasicInt: Int
|
||||
Structure: (.
|
||||
x:Int
|
||||
y:Int)
|
||||
Interface: (~
|
||||
Interface: (&
|
||||
[aMethod x:Int]:*U8
|
||||
[otherMethod arg:5:Int]:*U8)
|
||||
- Union: (|
|
||||
|
@ -58,12 +58,12 @@ func (this *treeParser) parseType () (entity.Type, error) {
|
||||
case lexer.LParen:
|
||||
err := this.ExpectNext(lexer.Dot, lexer.Symbol)
|
||||
if err != nil { return nil, err }
|
||||
err = this.ExpectValue(0, ".", "~", "|")
|
||||
err = this.ExpectValue(0, ".", "&", "|")
|
||||
if err != nil { return nil, err }
|
||||
|
||||
switch this.Value() {
|
||||
case ".": return this.parseTypeStructCore()
|
||||
case "~": return this.parseTypeInterfaceCore()
|
||||
case "&": return this.parseTypeInterfaceCore()
|
||||
case "|": return this.parseTypeUnionCore()
|
||||
}
|
||||
panic(this.bug())
|
||||
@ -157,7 +157,7 @@ func (this *treeParser) parseTypeStructCore () (entity.Type, error) {
|
||||
}
|
||||
|
||||
func (this *treeParser) parseTypeInterfaceCore () (entity.Type, error) {
|
||||
err := this.ExpectValue(lexer.Symbol, "~")
|
||||
err := this.ExpectValue(lexer.Symbol, "&")
|
||||
if err != nil { return nil, err }
|
||||
ty := &entity.TypeInterface {
|
||||
Pos: this.Pos(),
|
||||
|
Loading…
Reference in New Issue
Block a user