Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a formal (ideally BNF) typescript js language grammar (or only typescript subset)? [closed]

Tags:

typescript

bnf

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.

like image 810
Andrey Belyak Avatar asked Oct 04 '12 05:10

Andrey Belyak


3 Answers

The formal grammar is in Appendix A of the TypeScript Language Reference, version 1.8 if which is found here or here (for current version)

like image 61
Tony BenBrahim Avatar answered Nov 09 '22 00:11

Tony BenBrahim


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

like image 3
Michael Sondergaard Avatar answered Nov 09 '22 00:11

Michael Sondergaard


An ANTLR4 grammar, but admittedly "not exactly ... to TypeScript standard" (it's a pain there are so few official grammars for existing programming languages):

https://github.com/antlr/grammars-v4/tree/master/typescript

like image 1
ThomasH Avatar answered Nov 09 '22 00:11

ThomasH