This project is read-only.

Grammar file for TypeScript

Topics: General
Oct 4, 2012 at 12:04 PM
Edited Oct 4, 2012 at 12:06 PM

I would like to ask if there is some formal grammar syntax file, similar to

Or is the grammar hard-coded into parser.ts? What is the rationelle behind that?

Oct 4, 2012 at 4:29 PM

The language specification for TypeScript (available from the home page of this project) details the grammar for TypeScript.  This is a superset of the ES5 grammar, which is detailed in that specification ( ) in Annex A.  

As stated in the TypeScript spec..

2.1 Grammar Conventions

The syntactic grammar added by TypeScript language is specified throughout this document using the existing conventions and production names of the ECMAScript grammar. In places where TypeScript augments an existing grammar production it is so noted. For example:

  CallExpression: ( Modified )


  super Arguments

  super . Identifier

The ‘( Modified )’ annotation indicates that an existing grammar production is being replaced, and the ‘…’ references the contents of the original grammar production.