Changed restricted access specified from ~ to #
This commit is contained in:
parent
db98e590fc
commit
a9c85bf017
|
@ -48,7 +48,7 @@ testUnits (test,
|
|||
}`,
|
||||
|
||||
"other.fspl",
|
||||
`~ RestrictedInt:Int`,
|
||||
`# RestrictedInt:Int`,
|
||||
)}
|
||||
|
||||
func TestUnitAssignLiteralRestrictedErr (test *testing.T) {
|
||||
|
@ -57,12 +57,12 @@ testUnitsErr (test,
|
|||
`[main]:other::RestrictedInt = 5`,
|
||||
|
||||
"other.fspl",
|
||||
`~ RestrictedInt:Int`,
|
||||
`# RestrictedInt:Int`,
|
||||
)}
|
||||
|
||||
func TestAssignLiteralRestricted (test *testing.T) {
|
||||
testString (test,
|
||||
`~ RestrictedInt:Int
|
||||
`# RestrictedInt:Int
|
||||
[main]:RestrictedInt = 5`,
|
||||
)}
|
||||
|
||||
|
@ -75,12 +75,12 @@ testUnitsErr (test,
|
|||
}`,
|
||||
|
||||
"other.fspl",
|
||||
`~ RestrictedStruct:(. x:Int y:Int)`,
|
||||
`# RestrictedStruct:(. x:Int y:Int)`,
|
||||
)}
|
||||
|
||||
func TestMemberAccessRestricted (test *testing.T) {
|
||||
testString (test,
|
||||
`~ RestrictedStruct:(. x:Int y:Int)
|
||||
`# RestrictedStruct:(. x:Int y:Int)
|
||||
[main] = {
|
||||
x:RestrictedStruct
|
||||
x.x = 5
|
||||
|
@ -96,12 +96,12 @@ testUnitsErr (test,
|
|||
}`,
|
||||
|
||||
"other.fspl",
|
||||
`~ RestrictedArr:5:Int`,
|
||||
`# RestrictedArr:5:Int`,
|
||||
)}
|
||||
|
||||
func TestSubscriptRestricted (test *testing.T) {
|
||||
testString (test,
|
||||
`~ RestrictedArr:5:Int
|
||||
`# RestrictedArr:5:Int
|
||||
[main] = {
|
||||
x:RestrictedArr
|
||||
[.x 0] = 5
|
||||
|
@ -118,12 +118,12 @@ testUnitsErr (test,
|
|||
}`,
|
||||
|
||||
"other.fspl",
|
||||
`~ RestrictedInt:Int`,
|
||||
`# RestrictedInt:Int`,
|
||||
)}
|
||||
|
||||
func TestMathRestricted (test *testing.T) {
|
||||
testString (test,
|
||||
`~ RestrictedInt:Int
|
||||
`# RestrictedInt:Int
|
||||
[main] = {
|
||||
x:RestrictedInt = [+
|
||||
y:RestrictedInt
|
||||
|
@ -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) {
|
||||
|
@ -171,7 +171,7 @@ testUnitsErr (test,
|
|||
}`,
|
||||
|
||||
"other.fspl",
|
||||
`~ RestrictedInt:Int`,
|
||||
`# RestrictedInt:Int`,
|
||||
)}
|
||||
|
||||
func TestCastRestricted (test *testing.T) {
|
||||
|
@ -179,20 +179,20 @@ testString (test,
|
|||
`[main] = {
|
||||
x:Int = [~Int y:RestrictedInt]
|
||||
}
|
||||
~ RestrictedInt:Int`,
|
||||
# RestrictedInt:Int`,
|
||||
)}
|
||||
|
||||
func TestFunctionRestrictedErr (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"cannot mark function as restricted", 1, 1,
|
||||
`~ [f]`,
|
||||
`# [f]`,
|
||||
)}
|
||||
|
||||
func TestMethodRestrictedErr (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"cannot mark method as restricted", 2, 1,
|
||||
`T:Int
|
||||
~ T.[f]`,
|
||||
# T.[f]`,
|
||||
)}
|
||||
|
||||
func TestUnitInterfaceSatisfaction (test *testing.T) {
|
||||
|
|
|
@ -290,9 +290,10 @@ this without hand-writing a parser.
|
|||
|
||||
```
|
||||
<file> -> (<typedef> | <function> | <method>)*
|
||||
<typedef> -> <typeIdentifier> ":" <type>
|
||||
<function> -> <signature> ["=" <expression>]
|
||||
<method> -> <typeIdentifier> "." <function>
|
||||
<access> -> "+" | "#" | "-"
|
||||
<typedef> -> [<access>] <typeIdentifier> ":" <type>
|
||||
<function> -> [<access>] <signature> ["=" <expression>]
|
||||
<method> -> [<access>] <typeIdentifier> "." <function>
|
||||
|
||||
<type> -> <namedType>
|
||||
| <pointerType>
|
||||
|
|
|
@ -94,7 +94,7 @@ type Access int; const (
|
|||
func (this Access) String () string {
|
||||
switch this {
|
||||
case AccessPrivate: return "-"
|
||||
case AccessRestricted: return "~"
|
||||
case AccessRestricted: return "#"
|
||||
case AccessPublic: return "+"
|
||||
default: return fmt.Sprintf("entity.Access(%d)", this)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ define void @"0zNZN147MN2wzMAQ6NS2dQ==::main"() {
|
|||
}`,
|
||||
|
||||
"other.fspl",
|
||||
`~ RestrictedInt:Int`,
|
||||
`# RestrictedInt:Int`,
|
||||
)}
|
||||
|
||||
func TestNestedUnitTypedef (test *testing.T) {
|
||||
|
|
|
@ -156,31 +156,31 @@ func TestAccess (test *testing.T) {
|
|||
testString (test,
|
||||
// correct
|
||||
`+ PublicType: Int
|
||||
~ RestrictedType: (. x:Int y:Int)
|
||||
# RestrictedType: (. x:Int y:Int)
|
||||
- PrivateType: String
|
||||
- AlsoPrivateType: Byte
|
||||
+ [publicFn]:Int = 0
|
||||
~ [restrictedFn]:(. x:Int y:Int) = (. x:0 y:0)
|
||||
# [restrictedFn]:(. x:Int y:Int) = (. x:0 y:0)
|
||||
- [privateFn]:Rune = 'a'
|
||||
- [alsoPrivateFn]:Byte = 0
|
||||
- T: Int
|
||||
+ T.[publicFn]:Int = 0
|
||||
~ T.[restrictedFn]:(. x:Int y:Int) = (. x:0 y:0)
|
||||
# T.[restrictedFn]:(. x:Int y:Int) = (. x:0 y:0)
|
||||
- T.[privateFn]:Rune = 'a'
|
||||
- T.[alsoPrivateFn]:Byte = 0`,
|
||||
//input
|
||||
`
|
||||
+ PublicType: Int
|
||||
~ RestrictedType: (. x:Int y:Int)
|
||||
# RestrictedType: (. x:Int y:Int)
|
||||
- PrivateType: String
|
||||
AlsoPrivateType: Byte
|
||||
+ [publicFn]: Int = 0
|
||||
~ [restrictedFn]: (. x:Int y:Int) = (. x:0 y:0)
|
||||
# [restrictedFn]: (. x:Int y:Int) = (. x:0 y:0)
|
||||
- [privateFn]: Rune = 'a'
|
||||
[alsoPrivateFn]: Byte = 0
|
||||
T: Int
|
||||
+ T.[publicFn]: Int = 0
|
||||
~ T.[restrictedFn]: (. x:Int y:Int) = (. x:0 y:0)
|
||||
# T.[restrictedFn]: (. x:Int y:Int) = (. x:0 y:0)
|
||||
- T.[privateFn]: Rune = 'a'
|
||||
T.[alsoPrivateFn]: Byte = 0
|
||||
`)
|
||||
|
@ -214,7 +214,7 @@ func TestSkim (test *testing.T) {
|
|||
testStringSkim (test,
|
||||
// correct
|
||||
`- PrivType: Int
|
||||
~ RestrictType: Int
|
||||
# RestrictType: Int
|
||||
+ ComplexType: (. parser:Parser tree:*Tree skim:Bool)
|
||||
+ X: Int
|
||||
+ X.[pub]:Int
|
||||
|
@ -225,7 +225,7 @@ testStringSkim (test,
|
|||
+ [pub]:X`,
|
||||
// input
|
||||
`- PrivType:Int
|
||||
~ RestrictType:Int
|
||||
# RestrictType:Int
|
||||
+ ComplexType: (.
|
||||
parser:Parser
|
||||
tree:*Tree
|
||||
|
|
|
@ -69,13 +69,13 @@ func (this *treeParser) parseTopLevel () error {
|
|||
func (this *treeParser) parseAccess () (entity.Access, error) {
|
||||
err := this.ExpectValueDesc (
|
||||
"Access control specifier",
|
||||
lexer.Symbol, "-", "~", "+")
|
||||
lexer.Symbol, "-", "#", "+")
|
||||
if err != nil { return 0, err }
|
||||
defer this.Next()
|
||||
|
||||
switch this.Value() {
|
||||
case "-": return entity.AccessPrivate, nil
|
||||
case "~": return entity.AccessRestricted, nil
|
||||
case "#": return entity.AccessRestricted, nil
|
||||
case "+": return entity.AccessPublic, nil
|
||||
default: panic(this.bug())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue