-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lexer/Parser: support decorator declaration (#556)
* Lexer/Parser: support decorator declaration * fixing tests * 'decorator' is a keyword now so it can't be a parameter anymore
- Loading branch information
Showing
11 changed files
with
1,306 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
true false val var if else func while break for in type enum self match readonly import from as try continue pub | ||
true false val var if else func while break for in type enum self match readonly import from as try continue pub decorator |
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 |
---|---|---|
|
@@ -132,5 +132,11 @@ | |
"kind": { | ||
"name": "Pub" | ||
} | ||
}, | ||
{ | ||
"position": [1, 114], | ||
"kind": { | ||
"name": "Decorator" | ||
} | ||
} | ||
] |
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,4 +1,4 @@ | ||
Error at %FILE_NAME%:2:1 | ||
Unexpected token 'identifier', expected one of 'val', 'var', 'func', 'type', 'enum', '@', 'pub': | ||
Unexpected token 'identifier', expected one of 'val', 'var', 'func', 'type', 'enum', 'decorator', '@', 'pub': | ||
| abc() | ||
^ |
2 changes: 1 addition & 1 deletion
2
projects/compiler/test/parser/decorator_error_before_invalid_stmt.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,4 +1,4 @@ | ||
Error at %FILE_NAME%:2:1 | ||
Unexpected token 'while', expected one of 'val', 'var', 'func', 'type', 'enum', '@', 'pub': | ||
Unexpected token 'while', expected one of 'val', 'var', 'func', 'type', 'enum', 'decorator', '@', 'pub': | ||
| while true { } | ||
^ |
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,60 @@ | ||
decorator Foo { } | ||
decorator Foo<A, B> { } | ||
decorator Foo<A> { a: A, b: Bool } | ||
decorator Foo { | ||
a: Int | ||
b: Bool = true | ||
} | ||
|
||
decorator FooBar123 { | ||
func foo(self, b: String) {} | ||
} | ||
|
||
decorator FooBar123 { | ||
a: Int | ||
|
||
func foo(self, b: String): X<Y> = 123 | ||
func bar(self, b = true) { self.a + b } | ||
} | ||
|
||
decorator FooBar123 { | ||
a: Int | ||
|
||
func foo(self, b: String): X<Y> = 123 | ||
|
||
@Foo | ||
func bar(self, b = true) { self.a + b } | ||
} | ||
|
||
decorator Outer { | ||
a: Int | ||
|
||
func foo(self, b: String): X<Y> { 123 } | ||
|
||
type InnerType { | ||
a: Int | ||
|
||
func bar(self, b = true) { self.a + b } | ||
} | ||
|
||
enum InnerEnum { | ||
A(a: Int) | ||
|
||
func bar(self, b = true) { self.a + b } | ||
} | ||
} | ||
|
||
@Bar("a") | ||
pub decorator Outer { | ||
a: Int | ||
|
||
@Bar("b") | ||
func foo(self, b: String): X<Y> { 123 } | ||
|
||
@Bar("c") | ||
type Inner { a: Int } | ||
} | ||
|
||
pub decorator Outer2 { | ||
pub a: Int | ||
} |
Oops, something went wrong.