-
-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(grit): patch more parser incompatibilities for complex patterns (#…
…5037) Co-authored-by: ematipico <[email protected]>
- Loading branch information
Showing
10 changed files
with
2,205 additions
and
3 deletions.
There are no files selected for viewing
655 changes: 655 additions & 0 deletions
655
crates/biome_grit_formatter/tests/specs/grit/marzano/react_hooks.grit
Large diffs are not rendered by default.
Oops, something went wrong.
1,289 changes: 1,289 additions & 0 deletions
1,289
crates/biome_grit_formatter/tests/specs/grit/marzano/react_hooks.grit.snap
Large diffs are not rendered by default.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
crates/biome_grit_formatter/tests/specs/grit/marzano/shadow_scope.grit
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,8 @@ | ||
|
||
pattern identifier_scope($name) { | ||
or { | ||
function($parameters) where { | ||
$parameters <: contains $name | ||
}, | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
crates/biome_grit_formatter/tests/specs/grit/marzano/shadow_scope.grit.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,37 @@ | ||
--- | ||
source: crates/biome_formatter_test/src/snapshot_builder.rs | ||
info: grit/marzano/shadow_scope.grit | ||
--- | ||
# Input | ||
|
||
```grit | ||
pattern identifier_scope($name) { | ||
or { | ||
function($parameters) where { | ||
$parameters <: contains $name | ||
}, | ||
} | ||
} | ||
``` | ||
|
||
|
||
============================= | ||
|
||
# Outputs | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
Attribute Position: Auto | ||
----- | ||
|
||
```grit | ||
pattern identifier_scope($name) { | ||
or { function($parameters) where { $parameters <: contains $name } }} | ||
``` |
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: 2 additions & 0 deletions
2
crates/biome_grit_parser/tests/grit_test_suite/ok/ast_node.grit
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,2 @@ | ||
// The "function" AST name can conflict with the "function" keyword | ||
function($parameters) |
55 changes: 55 additions & 0 deletions
55
crates/biome_grit_parser/tests/grit_test_suite/ok/ast_node.grit.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,55 @@ | ||
--- | ||
source: crates/biome_grit_parser/tests/spec_test.rs | ||
expression: snapshot | ||
--- | ||
## Input | ||
```grit | ||
// The "function" AST name can conflict with the "function" keyword | ||
function($parameters) | ||
``` | ||
|
||
## AST | ||
|
||
``` | ||
GritRoot { | ||
bom_token: missing (optional), | ||
version: missing (optional), | ||
language: missing (optional), | ||
definitions: GritDefinitionList [ | ||
GritNodeLike { | ||
name: GritName { | ||
value_token: GRIT_NAME@0..76 "function" [Comments("// The \"function\" AST ..."), Newline("\n")] [], | ||
}, | ||
l_paren_token: L_PAREN@76..77 "(" [] [], | ||
named_args: GritNamedArgList [ | ||
GritVariable { | ||
value_token: GRIT_VARIABLE@77..88 "$parameters" [] [], | ||
}, | ||
], | ||
r_paren_token: R_PAREN@88..89 ")" [] [], | ||
}, | ||
], | ||
eof_token: EOF@89..90 "" [Newline("\n")] [], | ||
} | ||
``` | ||
|
||
## CST | ||
|
||
``` | ||
0: [email protected] | ||
0: (empty) | ||
1: (empty) | ||
2: (empty) | ||
3: [email protected] | ||
0: [email protected] | ||
0: [email protected] | ||
0: [email protected] "function" [Comments("// The \"function\" AST ..."), Newline("\n")] [] | ||
1: [email protected] "(" [] [] | ||
2: [email protected] | ||
0: [email protected] | ||
0: [email protected] "$parameters" [] [] | ||
3: [email protected] ")" [] [] | ||
4: [email protected] "" [Newline("\n")] [] | ||
``` |
6 changes: 6 additions & 0 deletions
6
crates/biome_grit_parser/tests/grit_test_suite/ok/bubble_brace.grit
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,6 @@ | ||
engine marzano(0.1) | ||
language js | ||
|
||
file($x) where { | ||
$x <: contains bubble { `foo` } | ||
} |
144 changes: 144 additions & 0 deletions
144
crates/biome_grit_parser/tests/grit_test_suite/ok/bubble_brace.grit.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,144 @@ | ||
--- | ||
source: crates/biome_grit_parser/tests/spec_test.rs | ||
expression: snapshot | ||
--- | ||
## Input | ||
```grit | ||
engine marzano(0.1) | ||
language js | ||
file($x) where { | ||
$x <: contains bubble { `foo` } | ||
} | ||
``` | ||
|
||
## AST | ||
|
||
``` | ||
GritRoot { | ||
bom_token: missing (optional), | ||
version: GritVersion { | ||
engine_token: ENGINE_KW@0..7 "engine" [] [Whitespace(" ")], | ||
engine_name: GritEngineName { | ||
engine_kind: MARZANO_KW@7..14 "marzano" [] [], | ||
}, | ||
l_paren_token: L_PAREN@14..15 "(" [] [], | ||
version: GritDoubleLiteral { | ||
value_token: GRIT_DOUBLE@15..18 "0.1" [] [], | ||
}, | ||
r_paren_token: R_PAREN@18..19 ")" [] [], | ||
}, | ||
language: GritLanguageDeclaration { | ||
language_token: LANGUAGE_KW@19..29 "language" [Newline("\n")] [Whitespace(" ")], | ||
name: GritLanguageName { | ||
language_kind: JS_KW@29..31 "js" [] [], | ||
}, | ||
flavor: missing (optional), | ||
semicolon_token: missing (optional), | ||
}, | ||
definitions: GritDefinitionList [ | ||
GritPatternWhere { | ||
pattern: GritNodeLike { | ||
name: GritName { | ||
value_token: GRIT_NAME@31..37 "file" [Newline("\n"), Newline("\n")] [], | ||
}, | ||
l_paren_token: L_PAREN@37..38 "(" [] [], | ||
named_args: GritNamedArgList [ | ||
GritVariable { | ||
value_token: GRIT_VARIABLE@38..40 "$x" [] [], | ||
}, | ||
], | ||
r_paren_token: R_PAREN@40..42 ")" [] [Whitespace(" ")], | ||
}, | ||
where_token: WHERE_KW@42..48 "where" [] [Whitespace(" ")], | ||
side_condition: GritPredicateAnd { | ||
and_token: missing (optional), | ||
l_curly_token: L_CURLY@48..49 "{" [] [], | ||
predicates: GritPredicateList [ | ||
GritPredicateMatch { | ||
left: GritVariable { | ||
value_token: GRIT_VARIABLE@49..54 "$x" [Newline("\n"), Whitespace("\t")] [Whitespace(" ")], | ||
}, | ||
match_token: MATCH@54..57 "<:" [] [Whitespace(" ")], | ||
right: GritPatternContains { | ||
contains_token: CONTAINS_KW@57..66 "contains" [] [Whitespace(" ")], | ||
contains: GritBubble { | ||
bubble_token: BUBBLE_KW@66..73 "bubble" [] [Whitespace(" ")], | ||
scope: missing (optional), | ||
pattern: GritCurlyPattern { | ||
l_curly_token: L_CURLY@73..75 "{" [] [Whitespace(" ")], | ||
pattern: GritCodeSnippet { | ||
source: GritBacktickSnippetLiteral { | ||
value_token: GRIT_BACKTICK_SNIPPET@75..81 "`foo`" [] [Whitespace(" ")], | ||
}, | ||
}, | ||
r_curly_token: R_CURLY@81..82 "}" [] [], | ||
}, | ||
}, | ||
until_clause: missing (optional), | ||
}, | ||
}, | ||
], | ||
r_curly_token: R_CURLY@82..84 "}" [Newline("\n")] [], | ||
}, | ||
}, | ||
], | ||
eof_token: EOF@84..85 "" [Newline("\n")] [], | ||
} | ||
``` | ||
|
||
## CST | ||
|
||
``` | ||
0: [email protected] | ||
0: (empty) | ||
1: [email protected] | ||
0: [email protected] "engine" [] [Whitespace(" ")] | ||
1: [email protected] | ||
0: [email protected] "marzano" [] [] | ||
2: [email protected] "(" [] [] | ||
3: [email protected] | ||
0: [email protected] "0.1" [] [] | ||
4: [email protected] ")" [] [] | ||
2: [email protected] | ||
0: [email protected] "language" [Newline("\n")] [Whitespace(" ")] | ||
1: [email protected] | ||
0: [email protected] "js" [] [] | ||
2: (empty) | ||
3: (empty) | ||
3: [email protected] | ||
0: [email protected] | ||
0: [email protected] | ||
0: [email protected] | ||
0: [email protected] "file" [Newline("\n"), Newline("\n")] [] | ||
1: [email protected] "(" [] [] | ||
2: [email protected] | ||
0: [email protected] | ||
0: [email protected] "$x" [] [] | ||
3: [email protected] ")" [] [Whitespace(" ")] | ||
1: [email protected] "where" [] [Whitespace(" ")] | ||
2: [email protected] | ||
0: (empty) | ||
1: [email protected] "{" [] [] | ||
2: GRIT_PREDICATE_LIST@49..82 | ||
0: GRIT_PREDICATE_MATCH@49..82 | ||
0: GRIT_VARIABLE@49..54 | ||
0: GRIT_VARIABLE@49..54 "$x" [Newline("\n"), Whitespace("\t")] [Whitespace(" ")] | ||
1: MATCH@54..57 "<:" [] [Whitespace(" ")] | ||
2: GRIT_PATTERN_CONTAINS@57..82 | ||
0: CONTAINS_KW@57..66 "contains" [] [Whitespace(" ")] | ||
1: GRIT_BUBBLE@66..82 | ||
0: BUBBLE_KW@66..73 "bubble" [] [Whitespace(" ")] | ||
1: (empty) | ||
2: GRIT_CURLY_PATTERN@73..82 | ||
0: L_CURLY@73..75 "{" [] [Whitespace(" ")] | ||
1: GRIT_CODE_SNIPPET@75..81 | ||
0: GRIT_BACKTICK_SNIPPET_LITERAL@75..81 | ||
0: GRIT_BACKTICK_SNIPPET@75..81 "`foo`" [] [Whitespace(" ")] | ||
2: R_CURLY@81..82 "}" [] [] | ||
2: (empty) | ||
3: R_CURLY@82..84 "}" [Newline("\n")] [] | ||
4: EOF@84..85 "" [Newline("\n")] [] | ||
``` |