From 2adca654fc142b835cbfd4d4ca246a2b52656ca7 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 13 Feb 2015 18:57:52 -0800 Subject: [PATCH] Updated FAQs for API Consumers (markdown) --- FAQs-for-API-Consumers.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/FAQs-for-API-Consumers.md b/FAQs-for-API-Consumers.md index cc57529..0a76f54 100644 --- a/FAQs-for-API-Consumers.md +++ b/FAQs-for-API-Consumers.md @@ -10,7 +10,17 @@ Though lexical goals are not addressed in the TypeScript spec, there is effectiv ### Why does the lexical classifier sometimes give inaccurate results for nested template strings? -For the record, template strings did not even originally have lexical classification support prior to 1.5 for [several technical reasons](https://github.com/Microsoft/TypeScript/issues/1477#issuecomment-66907946). However, due to demand, [support was added for what we believed would be the majority of practical uses](https://github.com/Microsoft/TypeScript/pull/2026). +Template strings did not even originally have lexical classification support prior to 1.5 for [several technical reasons](https://github.com/Microsoft/TypeScript/issues/1477#issuecomment-66907946). However, due to demand, [support was added for what we believed would be the majority of practical uses](https://github.com/Microsoft/TypeScript/pull/2026). + +As a precursor, template expressions are made up of several components: + +Syntax Kind | Example +------|------------ +`NoSubstitutionTemplateLiteral` | `` `Hello world` `` +`TemplateHead` | `` `abc ${ `` +`TemplateMiddle` | `} def ${ ` +`TemplateTail` | `` } ghi ` `` +`TemplateExpression` | `` `abc ${ 0 } def ${ 1 } ghi ` `` The lexical classifier is a rudimentary classifier that is intended to be fast and work on single lines at a time. It works through augmenting TypeScript's scanner, which itself works on a regular language grammar except when given a lexical goal in mind. Keep in mind, lexical goals can only be triggered accurately when motivated by a syntactically aware entity, while the lexical classifier only has the context of a single line with a previous line state to work with.