Change interface symbol from ~ to &

This commit is contained in:
Sasha Koshka 2024-03-13 23:05:58 -04:00
parent e0d4be8db8
commit db98e590fc
15 changed files with 36 additions and 36 deletions

View File

@ -115,7 +115,7 @@ func TestAssignmentLiteralErrInterfaceInt (test *testing.T) {
testStringErr (test, testStringErr (test,
"cannot use integer literal as Bird", 4, 11, "cannot use integer literal as Bird", 4, 11,
` `
Bird: (~ [fly distance:F64] [land]) Bird: (& [fly distance:F64] [land])
[main] = { [main] = {
b:Bird = 5 b:Bird = 5
} }
@ -126,7 +126,7 @@ func TestAssignmentLiteralErrInterfaceFloat (test *testing.T) {
testStringErr (test, testStringErr (test,
"cannot use float literal as Bird", 4, 11, "cannot use float literal as Bird", 4, 11,
` `
Bird: (~ [fly distance:F64] [land]) Bird: (& [fly distance:F64] [land])
[main] = { [main] = {
b:Bird = 5.5 b:Bird = 5.5
} }
@ -137,7 +137,7 @@ func TestAssignmentLiteralErrInterfaceArray (test *testing.T) {
testStringErr (test, testStringErr (test,
"cannot use array literal as Bird", 4, 11, "cannot use array literal as Bird", 4, 11,
` `
Bird: (~ [fly distance:F64] [land]) Bird: (& [fly distance:F64] [land])
[main] = { [main] = {
b:Bird = (* 1 2 3 4) b:Bird = (* 1 2 3 4)
} }
@ -148,7 +148,7 @@ func TestAssignmentLiteralErrInterfaceStruct (test *testing.T) {
testStringErr (test, testStringErr (test,
"cannot use struct literal as Bird", 4, 11, "cannot use struct literal as Bird", 4, 11,
` `
Bird: (~ [fly distance:F64] [land]) Bird: (& [fly distance:F64] [land])
[main] = { [main] = {
b:Bird = (. x: 5 y: 6) b:Bird = (. x: 5 y: 6)
} }
@ -197,7 +197,7 @@ func TestAssignmentInterfaceErrBadSignature (test *testing.T) {
testStringErr (test, testStringErr (test,
"BlueJay has wrong signature for method fly", 7, 11, "BlueJay has wrong signature for method fly", 7, 11,
` `
Bird: (~ [fly distance:F64] [land]) Bird: (& [fly distance:F64] [land])
BlueJay: Int BlueJay: Int
BlueJay.[fly] = { } BlueJay.[fly] = { }
BlueJay.[land] = { } BlueJay.[land] = { }
@ -211,7 +211,7 @@ func TestAssignmentInterfaceErrMissingMethod (test *testing.T) {
testStringErr (test, testStringErr (test,
"no method named fly defined on this type", 6, 11, "no method named fly defined on this type", 6, 11,
` `
Bird: (~ [fly distance:F64] [land]) Bird: (& [fly distance:F64] [land])
BlueJay: Int BlueJay: Int
BlueJay.[land] = { } BlueJay.[land] = { }
[main] = { [main] = {
@ -224,7 +224,7 @@ func TestAssignmentInterfaceErrBadLayer (test *testing.T) {
testStringErr (test, testStringErr (test,
"no method named fly defined on this type", 7, 11, "no method named fly defined on this type", 7, 11,
` `
Bird: (~ [fly distance:F64]) Bird: (& [fly distance:F64])
BlueJay: Int BlueJay: Int
BlueJay.[fly distance:F64] = { } BlueJay.[fly distance:F64] = { }
BlueJayRef: *BlueJay BlueJayRef: *BlueJay
@ -237,7 +237,7 @@ BlueJayRef: *BlueJay
func TestAssignmentInterface (test *testing.T) { func TestAssignmentInterface (test *testing.T) {
testString (test, testString (test,
` `
Bird: (~ [fly distance:F64] [land]) Bird: (& [fly distance:F64] [land])
BlueJay: Int BlueJay: Int
BlueJay.[fly distance:F64] = { } BlueJay.[fly distance:F64] = { }
BlueJay.[land] = { } BlueJay.[land] = { }
@ -301,7 +301,7 @@ testString (test,
[f]:Byte = 5 [f]:Byte = 5
A:Int A:Int
A.[g]:Int = 2 A.[g]:Int = 2
B:(~ [g]:Int) B:(& [g]:Int)
[main] = { [main] = {
a:Int a:Int
b:Int = a b:Int = a

View File

@ -72,7 +72,7 @@ testStringErr (test,
func TestCast (test *testing.T) { func TestCast (test *testing.T) {
testString (test, testString (test,
` `
Bird: (~ [fly distance:F64] [land]) Bird: (& [fly distance:F64] [land])
BlueJay: Int BlueJay: Int
BlueJay.[fly distance:F64] = { } BlueJay.[fly distance:F64] = { }
BlueJay.[land] = { } BlueJay.[land] = { }

View File

@ -151,7 +151,7 @@ testUnitsErr (test,
}`, }`,
"other.fspl", "other.fspl",
`~ RestrictedInterface:(~ [y])`, `~ RestrictedInterface:(& [y])`,
)} )}
func TestBehaviorCallRestricted (test *testing.T) { func TestBehaviorCallRestricted (test *testing.T) {
@ -160,7 +160,7 @@ testString (test,
x:RestrictedInterface x:RestrictedInterface
x.[y] x.[y]
} }
~ RestrictedInterface:(~ [y])`, ~ RestrictedInterface:(& [y])`,
)} )}
func TestUnitCastRestrictedErr (test *testing.T) { func TestUnitCastRestrictedErr (test *testing.T) {
@ -210,7 +210,7 @@ testUnits (test,
+ [write file:FileDescriptor buffer:*Byte count:Index]: Index 'write'`, + [write file:FileDescriptor buffer:*Byte count:Index]: Index 'write'`,
"io.fspl", "io.fspl",
`+ Writer: (~ [write buffer:*:Byte]: Index) `+ Writer: (& [write buffer:*:Byte]: Index)
+ File: cstdio::FileDescriptor + File: cstdio::FileDescriptor
+ File.[write buffer:*:Byte]:Index = + File.[write buffer:*:Byte]:Index =
cstdio::[write cstdio::[write

View File

@ -156,7 +156,7 @@ func TestInterfaceBehaviorNameErrMissing (test *testing.T) {
testStringErr (test, testStringErr (test,
"no behavior or method named swim", 8, 6, "no behavior or method named swim", 8, 6,
` `
Bird: (~ [fly] [land]) Bird: (& [fly] [land])
BirdImpl: Int BirdImpl: Int
BirdImpl.[fly] = { } BirdImpl.[fly] = { }
BirdImpl.[land] = { } BirdImpl.[land] = { }
@ -170,7 +170,7 @@ BirdImpl.[land] = { }
func TestInterfaceBehaviorName (test *testing.T) { func TestInterfaceBehaviorName (test *testing.T) {
testString (test, testString (test,
` `
Bird: (~ [fly] [land]) Bird: (& [fly] [land])
BirdImpl: Int BirdImpl: Int
BirdImpl.[fly] = { } BirdImpl.[fly] = { }
BirdImpl.[land] = { } BirdImpl.[land] = { }

View File

@ -153,7 +153,7 @@ testString (test,
` `
U: (| I8 I16 I32 I64 Int) U: (| I8 I16 I32 I64 Int)
Point: (. x:Int y:Int) Point: (. x:Int y:Int)
Error: (~ [error]:String) Error: (& [error]:String)
PointOrError: (| Point Error) PointOrError: (| Point Error)
`) `)
} }
@ -196,14 +196,14 @@ func TestTypeInterfaceBehaviorUniqueErr (test *testing.T) {
testStringErr (test, testStringErr (test,
"fly already listed in interface at stream0.fspl:2:10", 2, 16, "fly already listed in interface at stream0.fspl:2:10", 2, 16,
` `
Bird: (~ [fly] [fly]) Bird: (& [fly] [fly])
`) `)
} }
func TestTypeInterfaceBehaviorUnique (test *testing.T) { func TestTypeInterfaceBehaviorUnique (test *testing.T) {
testString (test, testString (test,
` `
Bird: (~ [fly] [land]) Bird: (& [fly] [land])
`) `)
} }

View File

@ -1,4 +1,4 @@
Numbered: (~ [number]: Int) Numbered: (& [number]:Int)
Number: Int Number: Int
Number.[number]: Int = [.this] Number.[number]: Int = [.this]

View File

@ -1,7 +1,7 @@
+ [print string:String]: Index = cstdio::[write 1 [~*Byte string] [#string]] + [print string:String]: Index = cstdio::[write 1 [~*Byte string] [#string]]
+ [println string:String]: Index = [+ [print string] cstdio::[write 1 '\n' 1]] + [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: cstdio::FileDescriptor
+ File.[write buffer:*:Byte]:Index = + File.[write buffer:*:Byte]:Index =
cstdio::[write cstdio::[write

View File

@ -305,7 +305,7 @@ this without hand-writing a parser.
<sliceType> -> "*" ":" <type> <sliceType> -> "*" ":" <type>
<arrayType> -> <intLiteral> ":" <type> <arrayType> -> <intLiteral> ":" <type>
<structType> -> "(" "." <declaration>* ")" <structType> -> "(" "." <declaration>* ")"
<interfaceType> -> "(" "~" <signature>* ")" <interfaceType> -> "(" "&" <signature>* ")"
<unionType> -> "(" "|" <type>* ")" <unionType> -> "(" "|" <type>* ")"
<expression> -> <intLiteral> <expression> -> <intLiteral>

View File

@ -212,7 +212,7 @@ func (this *TypeInterface) Position () errors.Position { return this.Pos }
func (this *TypeInterface) Access () Access { return this.Acc } func (this *TypeInterface) Access () Access { return this.Acc }
func (this *TypeInterface) Unit () uuid.UUID { return this.Unt } func (this *TypeInterface) Unit () uuid.UUID { return this.Unt }
func (this *TypeInterface) String () string { func (this *TypeInterface) String () string {
out := "(~" out := "(&"
for _, behavior := range this.Behaviors { for _, behavior := range this.Behaviors {
out += fmt.Sprint(" ", behavior) out += fmt.Sprint(" ", behavior)
} }

View File

@ -29,7 +29,7 @@ define void @"0zNZN147MN2wzMAQ6NS2dQ==::T.do"(ptr %this) {
} }
`, `,
` `
Doer: (~ [do]) Doer: (& [do])
T: Int T: Int
T.[do] = { } T.[do] = { }
@ -70,7 +70,7 @@ define i64 @"0zNZN147MN2wzMAQ6NS2dQ==::Number.number"(ptr %this) {
} }
`, `,
` `
Numbered: (~ [number]: Int) Numbered: (& [number]: Int)
Number: Int Number: Int
Number.[number]: Int = [.this] Number.[number]: Int = [.this]
@ -173,7 +173,7 @@ declare %"AAAAAAAAAAAAAAAAAAAAAA==::Index" @"0zNZN147MN2wzMAQ6NS2dQ==::write"(%"
` `
[write fd:File buffer:*Byte count:Index]: Index [write fd:File buffer:*Byte count:Index]: Index
Writer: (~ [write buffer:*:Byte]: Index) Writer: (& [write buffer:*:Byte]: Index)
File: I32 File: I32
File.[write buffer:*:Byte]:Index = [write [.this] [~*Byte buffer] [#buffer]] 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) 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) A: (. output: Writer)
File: I32 File: I32
File.[write buffer:*:Byte]:Index 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: Int
Impl.[x]:Int = 5 Impl.[x]:Int = 5
[main] 'main' = { [main] 'main' = {

View File

@ -116,7 +116,7 @@ declare %"AAAAAAAAAAAAAAAAAAAAAA==::Index" @"1cqXRNyHN06gi9QQb4GCsg==::File.writ
+ [write file:FileDescriptor buffer:*Byte count:Index]: Index 'write'`, + [write file:FileDescriptor buffer:*Byte count:Index]: Index 'write'`,
"io.fspl", "io.fspl",
`+ Writer: (~ [write buffer:*:Byte]: Index) `+ Writer: (& [write buffer:*:Byte]: Index)
+ File: cstdio::FileDescriptor + File: cstdio::FileDescriptor
+ File.[write buffer:*:Byte]:Index = + File.[write buffer:*:Byte]:Index =
cstdio::[write cstdio::[write

View File

@ -21,7 +21,7 @@ declare %"0zNZN147MN2wzMAQ6NS2dQ==::AllTypes" @"0zNZN147MN2wzMAQ6NS2dQ==::x"()
`, `,
` `
Point: (.x:Int y:Int) Point: (.x:Int y:Int)
Pegasus: (~ Pegasus: (&
[clear clouds:*:Point] [clear clouds:*:Point]
[fly rings:*:Point] [fly rings:*:Point]
[fall distance:Int] [fall distance:Int]
@ -154,7 +154,7 @@ SmallU: (| I8 U8 I16 U16)
Point: (. x:Int y:Int) Point: (. x:Int y:Int)
Padded: (. a:I8 b:I16) Padded: (. a:I8 b:I16)
PaddedU: (| Padded) PaddedU: (| Padded)
Error: (~ [error]:String) Error: (& [error]:String)
PointOrError: (| Point Error) PointOrError: (| Point Error)
[main] = { [main] = {
u:U u:U

View File

@ -124,7 +124,7 @@ determine what type to parse:
| | +Dot =TypeStruct | | +Dot =TypeStruct
| | | |
| | +Symbol X | | +Symbol X
| | '~' =TypeInterface | | '&' =TypeInterface
| | '|' =TypeSum | | '|' =TypeSum
| |
| +Star =TypePointer | +Star =TypePointer

View File

@ -7,7 +7,7 @@ testString (test,
// correct // correct
`- BasicInt: Int `- BasicInt: Int
- Structure: (. x:Int y: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)) - Union: (| Int F64 *:U8 (. x:Int y:Int))
- Array: 16:16:16:Int - Array: 16:16:16:Int
- StructArray: 31:24:340920:(. x:Int y:Int) - StructArray: 31:24:340920:(. x:Int y:Int)
@ -18,7 +18,7 @@ BasicInt: Int
Structure: (. Structure: (.
x:Int x:Int
y:Int) y:Int)
Interface: (~ Interface: (&
[aMethod x:Int]:*U8 [aMethod x:Int]:*U8
[otherMethod arg:5:Int]:*U8) [otherMethod arg:5:Int]:*U8)
- Union: (| - Union: (|

View File

@ -58,12 +58,12 @@ func (this *treeParser) parseType () (entity.Type, error) {
case lexer.LParen: case lexer.LParen:
err := this.ExpectNext(lexer.Dot, lexer.Symbol) err := this.ExpectNext(lexer.Dot, lexer.Symbol)
if err != nil { return nil, err } if err != nil { return nil, err }
err = this.ExpectValue(0, ".", "~", "|") err = this.ExpectValue(0, ".", "&", "|")
if err != nil { return nil, err } if err != nil { return nil, err }
switch this.Value() { switch this.Value() {
case ".": return this.parseTypeStructCore() case ".": return this.parseTypeStructCore()
case "~": return this.parseTypeInterfaceCore() case "&": return this.parseTypeInterfaceCore()
case "|": return this.parseTypeUnionCore() case "|": return this.parseTypeUnionCore()
} }
panic(this.bug()) panic(this.bug())
@ -157,7 +157,7 @@ func (this *treeParser) parseTypeStructCore () (entity.Type, error) {
} }
func (this *treeParser) parseTypeInterfaceCore () (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 } if err != nil { return nil, err }
ty := &entity.TypeInterface { ty := &entity.TypeInterface {
Pos: this.Pos(), Pos: this.Pos(),