I'm looking for the Typescript grammar. Not the parser-lexer, but only the formal grammar description. I want to implement ts it's code folding and basic static code analyzing as plugin to one simple linux IDE for GNOME.
Is there a formal (ideally BNF) typescript js language grammar (or only typescript subset)? [closed]
Asked Answered
Why can't you just use the compiler itself to build the AST? It's open source after all... –
Pfister
The formal grammar is in Appendix A of the TypeScript Language Reference, version 1.8 if which is found here (for current version)
There was actually a fun to read holiwar with devs on that matter in a ticket of typescript repo. The conclusion was to drop the specification because they have no resources to keep it up to date I take it. –
Preposterous
Since typescript is a strict superset of Ecmascript 5 (http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf/), you could exend any ecmascript bnf with syntax definitions from the Typescript spec.
A starting point could be: http://www.antlr3.org/grammar/1153976512034/ecmascriptA3.g
An ANTLR4 grammar, but admittedly "not exactly ... to TypeScript standard" (it's a pain there are so few official grammars for existing programming languages):
Maybe you can find references in the source code, e.g. compiler/tokens.js
He is asking for a grammar definition like coffeescript.org/documentation/docs/grammar.html . –
Runge
It helps to find out which tokens are used and how tey are defined, but it is only lexer part.I need a set of rules in some formal notation to create parser and to be able to build AST from the given typescript text. –
Anemography
Chrome warns about that link: "The site ahead contains harmful programs" –
Accent
© 2022 - 2024 — McMap. All rights reserved.