Problems trying to update ANTLR's default TypeScript grammar #4186
Unanswered
brunocartaxo
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to update the default ANTLR TypeScript grammar since it seems to support only TypeScript up to version 2.7.
One of the new constructions is the conditional types, which demanded me to alter the "type_" rule and create the "conditionalType" rule:
However, when parsing the following code, it apperantly does not recognize the array bracktes in
any[]
:type Boxed<T> = T extends any[] ? BoxedArray<T[number]> : BoxedValue<T>;
The error is:
Considering the rules at the end of this post, I would expect it to derive a tree, more or less, like this:
But it seems the parser is selecting the rule
PredefinedPrimType
directly afterunionOrIntersectionOrPrimaryType
, ignoring the recusive productionArrayPrimType
.I've tried putting the
#ArrayPrimType
production before the#PredefinedPrimType
production in the ruleprimaryType
, and even removing#PredefinedPrimType
production. I also tried the#ArrayPrimType
production without the semantic predicate, as well as with the semantic predicate at the end of the production, like this| primaryType '[' ']' { self.notLineTerminator}? #ArrayPrimType
. None of those tries have worked so far. Can anyone help me with this scenario?Beta Was this translation helpful? Give feedback.
All reactions