Skip to content

Commit 7c13fa8

Browse files
committed
Optimize complexity
1 parent 7ca15b8 commit 7c13fa8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

grammar.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,9 @@ module.exports = grammar({
607607
choice(
608608
$._annotated_type,
609609
$.compound_type,
610+
// In theory structural_type should just be added to simple_type,
611+
// but doing so increases the state of template_body to 4000
612+
$._structural_type,
610613
// This adds _simple_type, but not the above intentionall/y.
611614
seq($._simple_type, field("arguments", $.arguments)),
612615
seq($._annotated_type, field("arguments", $.arguments)),
@@ -773,10 +776,16 @@ module.exports = grammar({
773776
$.match_type,
774777
$._annotated_type,
775778
$.literal_type,
779+
$._structural_type,
776780
),
777781

778-
// TODO: Make this a visible type, so that _type can be a supertype.
779-
_annotated_type: $ => prec.right(seq($._simple_type, repeat($.annotation))),
782+
_annotated_type: $ =>
783+
prec.right(choice(
784+
$.annotated_type,
785+
$._simple_type,
786+
)),
787+
788+
annotated_type: $ => prec.right(seq($._simple_type, repeat1($.annotation))),
780789

781790
_simple_type: $ =>
782791
choice(
@@ -787,7 +796,6 @@ module.exports = grammar({
787796
$.stable_type_identifier,
788797
$._type_identifier,
789798
$.wildcard,
790-
$._structural_type,
791799
),
792800

793801
compound_type: $ =>

0 commit comments

Comments
 (0)