-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Samyak S Sarnayak <samyak201@gmail.com>
- Loading branch information
Showing
8 changed files
with
355 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
func main() { | ||
type a int; | ||
type ( | ||
b string; | ||
c float; | ||
); | ||
}; |
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,7 @@ | ||
func main() { | ||
type a int; | ||
type ( | ||
b string int; | ||
c float; | ||
); | ||
}; |
98 changes: 98 additions & 0 deletions
98
compiler/tests/snapshots/parser__ast_from_path@07_type_def.bakugo.snap
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,98 @@ | ||
--- | ||
source: tests/parser.rs | ||
expression: parsed | ||
input_file: tests/examples/07_type_def.bakugo | ||
--- | ||
SourceFile { | ||
top_level: [ | ||
FnDecl( | ||
FnDecl { | ||
name: Ident { | ||
value: "main", | ||
span: Span { | ||
str: "main", | ||
start: 5, | ||
end: 9, | ||
}, | ||
}, | ||
params: [], | ||
result_kind: None, | ||
body: StatementList( | ||
[ | ||
Declaration( | ||
Kind( | ||
KindDecl { | ||
name: Ident { | ||
value: "a", | ||
span: Span { | ||
str: "a", | ||
start: 20, | ||
end: 21, | ||
}, | ||
}, | ||
kind: Simple { | ||
name: "int", | ||
span: Span { | ||
str: "int", | ||
start: 22, | ||
end: 25, | ||
}, | ||
}, | ||
}, | ||
), | ||
), | ||
Declaration( | ||
Kind( | ||
KindDecl { | ||
name: Ident { | ||
value: "b", | ||
span: Span { | ||
str: "b", | ||
start: 37, | ||
end: 38, | ||
}, | ||
}, | ||
kind: Simple { | ||
name: "string", | ||
span: Span { | ||
str: "string", | ||
start: 39, | ||
end: 45, | ||
}, | ||
}, | ||
}, | ||
), | ||
), | ||
Declaration( | ||
Kind( | ||
KindDecl { | ||
name: Ident { | ||
value: "c", | ||
span: Span { | ||
str: "c", | ||
start: 49, | ||
end: 50, | ||
}, | ||
}, | ||
kind: Simple { | ||
name: "float", | ||
span: Span { | ||
str: "float", | ||
start: 51, | ||
end: 56, | ||
}, | ||
}, | ||
}, | ||
), | ||
), | ||
], | ||
), | ||
span: Span { | ||
str: "func main() {\n\ttype a int;\n\ttype (\n\t\tb string;\n\t\tc float;\n\t);\n}", | ||
start: 0, | ||
end: 63, | ||
}, | ||
}, | ||
), | ||
], | ||
} |
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
compiler/tests/snapshots/parser__parser_from_path@02_type_def.bakugo.snap
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,11 @@ | ||
--- | ||
source: tests/parser.rs | ||
expression: err.to_string() | ||
input_file: tests/examples/parser_error/02_type_def.bakugo | ||
--- | ||
--> 4:12 | ||
| | ||
4 | b string int; | ||
| ^--- | ||
| | ||
= expected Semicolon |
215 changes: 215 additions & 0 deletions
215
compiler/tests/snapshots/parser__parser_from_path@07_type_def.bakugo.snap
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,215 @@ | ||
--- | ||
source: tests/parser.rs | ||
expression: parsed | ||
input_file: tests/examples/07_type_def.bakugo | ||
--- | ||
pos: | ||
- 0 | ||
- 65 | ||
pairs: | ||
- pos: | ||
- 0 | ||
- 65 | ||
rule: SourceFile | ||
inner: | ||
pos: | ||
- 0 | ||
- 65 | ||
pairs: | ||
- pos: | ||
- 0 | ||
- 63 | ||
rule: TopLevelDecl | ||
inner: | ||
pos: | ||
- 0 | ||
- 63 | ||
pairs: | ||
- pos: | ||
- 0 | ||
- 63 | ||
rule: FunctionDecl | ||
inner: | ||
pos: | ||
- 5 | ||
- 61 | ||
pairs: | ||
- pos: | ||
- 5 | ||
- 9 | ||
rule: Ident | ||
inner: main | ||
- pos: | ||
- 9 | ||
- 12 | ||
rule: Signature | ||
inner: | ||
pos: | ||
- 9 | ||
- 11 | ||
pairs: | ||
- pos: | ||
- 9 | ||
- 11 | ||
rule: Parameters | ||
inner: () | ||
- pos: | ||
- 15 | ||
- 61 | ||
rule: StatementList | ||
inner: | ||
pos: | ||
- 15 | ||
- 61 | ||
pairs: | ||
- pos: | ||
- 15 | ||
- 25 | ||
rule: Declaration | ||
inner: | ||
pos: | ||
- 15 | ||
- 25 | ||
pairs: | ||
- pos: | ||
- 15 | ||
- 25 | ||
rule: TypeDecl | ||
inner: | ||
pos: | ||
- 20 | ||
- 25 | ||
pairs: | ||
- pos: | ||
- 20 | ||
- 25 | ||
rule: TypeDef | ||
inner: | ||
pos: | ||
- 20 | ||
- 25 | ||
pairs: | ||
- pos: | ||
- 20 | ||
- 21 | ||
rule: Ident | ||
inner: a | ||
- pos: | ||
- 22 | ||
- 25 | ||
rule: Type | ||
inner: | ||
pos: | ||
- 22 | ||
- 25 | ||
pairs: | ||
- pos: | ||
- 22 | ||
- 25 | ||
rule: Ident | ||
inner: int | ||
- pos: | ||
- 25 | ||
- 26 | ||
rule: Semicolon | ||
inner: ; | ||
- pos: | ||
- 28 | ||
- 60 | ||
rule: Declaration | ||
inner: | ||
pos: | ||
- 28 | ||
- 60 | ||
pairs: | ||
- pos: | ||
- 28 | ||
- 60 | ||
rule: TypeDecl | ||
inner: | ||
pos: | ||
- 37 | ||
- 57 | ||
pairs: | ||
- pos: | ||
- 37 | ||
- 45 | ||
rule: TypeDef | ||
inner: | ||
pos: | ||
- 37 | ||
- 45 | ||
pairs: | ||
- pos: | ||
- 37 | ||
- 38 | ||
rule: Ident | ||
inner: b | ||
- pos: | ||
- 39 | ||
- 45 | ||
rule: Type | ||
inner: | ||
pos: | ||
- 39 | ||
- 45 | ||
pairs: | ||
- pos: | ||
- 39 | ||
- 45 | ||
rule: Ident | ||
inner: string | ||
- pos: | ||
- 45 | ||
- 46 | ||
rule: Semicolon | ||
inner: ; | ||
- pos: | ||
- 49 | ||
- 56 | ||
rule: TypeDef | ||
inner: | ||
pos: | ||
- 49 | ||
- 56 | ||
pairs: | ||
- pos: | ||
- 49 | ||
- 50 | ||
rule: Ident | ||
inner: c | ||
- pos: | ||
- 51 | ||
- 56 | ||
rule: Type | ||
inner: | ||
pos: | ||
- 51 | ||
- 56 | ||
pairs: | ||
- pos: | ||
- 51 | ||
- 56 | ||
rule: Ident | ||
inner: float | ||
- pos: | ||
- 56 | ||
- 57 | ||
rule: Semicolon | ||
inner: ; | ||
- pos: | ||
- 60 | ||
- 61 | ||
rule: Semicolon | ||
inner: ; | ||
- pos: | ||
- 63 | ||
- 64 | ||
rule: Semicolon | ||
inner: ; | ||
- pos: | ||
- 65 | ||
- 65 | ||
rule: EOI | ||
inner: "" | ||
|