-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Distinguish between member and scope access operators (#189)
* Adjust grammar * Add to parser * Add tests and adapt the existing ones * Update docs
- Loading branch information
1 parent
529c03a
commit e471cb9
Showing
30 changed files
with
90 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/test-files/analyzer/generics/error-generic-function-not-found/source.spice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/test-files/analyzer/imports/error-insufficient-global-var-visibility/exception.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Semantic error in ./test-files/analyzer/imports/error-insufficient-global-var-visibility/source.spice:4:33: Insufficient symbol visibility: Cannot access 'globalTestVar' due to its private visibility | ||
Semantic error in ./test-files/analyzer/imports/error-insufficient-global-var-visibility/source.spice:4:34: Insufficient symbol visibility: Cannot access 'globalTestVar' due to its private visibility |
2 changes: 1 addition & 1 deletion
2
test/test-files/analyzer/imports/error-insufficient-global-var-visibility/source.spice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import "source1" as src1; | ||
|
||
f<int> main() { | ||
printf("Result: %d\n", src1.globalTestVar); | ||
printf("Result: %d\n", src1::globalTestVar); | ||
} |
2 changes: 1 addition & 1 deletion
2
test/test-files/analyzer/imports/error-insufficient-struct-visibility/source.spice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import "source1" as s1; | ||
|
||
f<int> main() { | ||
dyn s = s1.Vector{1}; | ||
dyn s = s1::Vector{1}; | ||
printf("Result: %d\n", s.i); | ||
} |
1 change: 1 addition & 0 deletions
1
test/test-files/analyzer/operators/error-member-access-only-struct/exception.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Semantic error in ./test-files/analyzer/operators/error-member-access-only-struct/source.spice:3:5: Member access is only allowed on structs: Cannot apply member access operator on double |
4 changes: 4 additions & 0 deletions
4
test/test-files/analyzer/operators/error-member-access-only-struct/source.spice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
f<int> main() { | ||
double doubleVar = 1.34; | ||
doubleVar.test = 1; | ||
} |
1 change: 1 addition & 0 deletions
1
test/test-files/analyzer/operators/error-scope-access-only-import/exception.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Semantic error in ./test-files/analyzer/operators/error-scope-access-only-import/source.spice:8:5: Scope access is only allowed on imports: Cannot apply scope access operator on TestStruct |
9 changes: 9 additions & 0 deletions
9
test/test-files/analyzer/operators/error-scope-access-only-import/source.spice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
type TestStruct struct { | ||
int t1 | ||
double* t2 | ||
} | ||
|
||
f<int> main() { | ||
dyn ts = TestStruct{}; | ||
ts::t1 = 2; | ||
} |
4 changes: 2 additions & 2 deletions
4
test/test-files/generator/structs/success-external-nested-struct/source.spice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import "source1" as socket; | ||
|
||
f<int> main() { | ||
socket.Socket s = socket.openServerSocket(8080s); | ||
socket.NestedSocket n = s.nested; | ||
socket::Socket s = socket.openServerSocket(8080s); | ||
socket::NestedSocket n = s.nested; | ||
printf("Test string: %s\n", n.testString); | ||
printf("Socket: %d\n", s.sock); | ||
} |
2 changes: 1 addition & 1 deletion
2
test/test-files/generator/structs/success-external-structs/source.spice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import "source1" as s1; | ||
|
||
f<int> main() { | ||
dyn v = s1.Vec{11, false}; | ||
dyn v = s1::Vec{11, false}; | ||
v.print(); | ||
} |
2 changes: 1 addition & 1 deletion
2
test/test-files/generator/variables/success-external-global-var/source.spice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import "source1" as s1; | ||
|
||
f<int> main() { | ||
printf("Global var: %s\n", s1.GLOBAL); | ||
printf("Global var: %s\n", s1::GLOBAL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import "std/data/pair" as pair; | ||
|
||
f<int> main() { | ||
pair.Pair<string, int> stringIntPair = pair.Pair<string, int>("Test", 1234); | ||
pair::Pair<string, int> stringIntPair = pair::Pair<string, int>("Test", 1234); | ||
printf("First: %s\n", stringIntPair.getFirst()); | ||
printf("Second: %d\n", stringIntPair.getSecond()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import "std/os/os" as os; | ||
|
||
f<int> main() { | ||
printf("OS name: %s", os.OS_NAME); | ||
printf("OS name: %s", os::OS_NAME); | ||
} |