Earlier quoted context omitted.
CSS syntax have specific rules for how to handle unexpected tokens. E.g if an unexpected character is encountered in a declaration the parser ignores characters until next ; or }. But CSS does not have arbitrary nesting, so this makes it easier. Comments as in your example is typically stripped in the tokenization stage so would not affect parsing. The TpeScript type syntax has its own grammar, but it uses the same l…
I understand that you can define a restricted grammar that will stay parseable, as the embedded language would have to adapt to those rules. But that doesn't solve the question, as Typescript already has existing rules which overlap with JS syntax. The GP comment was: > For example, the `as` keyword for casts has existed for a long time, and type stripping could strip everything after the `as` keyword with a minimal…
TypeAssertion ::= Expression “as” TypeStuff
TypeStuff ::= TypeStuffItem+
TypeStuffItem ::= Block | any token except , ; ) } ]
Block ::= ParenBlock | CurlyBracketsBlock | SquareBracketsBlock | AngleBracketsBlock
ParenBlock ::= ( ParenBlockItem* )
ParenBlockItem ::= Block | any token except ( )
etc.