@@ -172,18 +172,16 @@ private RscGrammar replaceLegacySemanticTokenTypes(RscGrammar rsc)
172172
173173@description {
174174 The analysis consists of three stages:
175- 1. selection of user-defined productions;
176- 2. creation of synthetic delimiters production;
177- 3. creation of synthetic keywords production;
178- 4. wrapping of productions inside conversion units.
179-
180- In stage 1, a dependency graph among all productions that occur in `rsc`
181- (specifically: `prod` constructors) is created. This dependency graph is
182- subsequently pruned to keep only the suitable-for-conversion productions:
183- - first, productions that involve non-empty word matching are retained;
184- - next, productions that have a `@category` tag are retained.
185- The resulting list of productions is split into lists of recursive
186- productions and non-recursive productions.
175+ 1. selection of user-defined productions;
176+ 2. creation of synthetic delimiters production;
177+ 3. creation of synthetic keywords production;
178+ 4. wrapping of productions inside conversion units.
179+
180+ In stage 1, each user-defined production (specifically: `prod` constructor)
181+ that occurs in `rsc` is selected for conversion when it fulfils the
182+ following requirements:
183+ - it has a unique `@category` tag;
184+ - it doesn't match the empty word.
187185
188186 In stage 2, the set of all delimiters that occur in `rsc` is created. This
189187 set is subsequently reduced by removing:
@@ -205,11 +203,11 @@ list[ConversionUnit] analyze(RscGrammar rsc, str name) {
205203 str jobLabel = "Analyzing<name == "" ? "" : " (<name > )" > " ;
206204 jobStart (jobLabel , work = 6 );
207205
208- // Analyze productions
206+ // Stage 1: Analyze productions
209207 jobStep (jobLabel , "Analyzing productions" );
210208 list [Production ] prods = [p | /p : prod (_, _, _) <- rsc ];
211209
212- // Analyze categories
210+ // Stage 1: Analyze categories
213211 jobStep (jobLabel , "Analyzing categories" );
214212 prods = for (p <- prods ) {
215213
@@ -230,24 +228,24 @@ list[ConversionUnit] analyze(RscGrammar rsc, str name) {
230228 append p ;
231229 }
232230
233- // Analyze emptiness
231+ // Stage 1: Analyze emptiness
234232 jobStep (jobLabel , "Analyzing emptiness" );
235233 prods = [p | p <- prods , !tryParse (rsc , delabel (p .def ), "" )];
236234
237- // Analyze delimiters
235+ // Stage 2: Analyze delimiters
238236 jobStep (jobLabel , "Analyzing delimiters" );
239237 set [Symbol ] delimiters = {s | /Symbol s := rsc , isDelimiter (delabel (s ))};
240238 delimiters &= removeStrictPrefixes (delimiters );
241239 delimiters -= {s | p <- prods , /just (s ) := getOuterDelimiterPair (rsc , p )};
242240 delimiters -= {s | p <- prods , /just (s ) := getInnerDelimiterPair (rsc , p , getOnlyFirst = true )};
243241 list [Production ] prodsDelimiters = [prod (lex (DELIMITERS_PRODUCTION_NAME ), [\alt (delimiters )], {})];
244242
245- // Analyze keywords
243+ // Stage 3: Analyze keywords
246244 jobStep (jobLabel , "Analyzing keywords" );
247245 set [Symbol ] keywords = {s | /Symbol s := rsc , isKeyword (delabel (s ))};
248246 list [Production ] prodsKeywords = [prod (lex (KEYWORDS_PRODUCTION_NAME ), [\alt (keywords )], {\tag ("category" ("keyword.control" ))})];
249247
250- // Prepare units
248+ // Stage 4: Prepare units
251249 jobStep (jobLabel , "Preparing units" );
252250 bool isEmptyProd (prod (_, [\alt (alternatives )], _))
253251 = alternatives == {};
@@ -269,10 +267,10 @@ list[ConversionUnit] analyze(RscGrammar rsc, str name) {
269267
270268@description {
271269 The transformation consists of two stages:
272- 1. creation of TextMate rules;
273- 2. composition of TextMate rules into a TextMate grammar.
274-
275- Stage 1 is organizes as a pipeline that, step-by-step, adds names and rules
270+ 1. creation of TextMate rules;
271+ 2. composition of TextMate rules into a TextMate grammar.
272+
273+ Stage 1 is organized as a pipeline that, step-by-step, adds names and rules
276274 to the conversion units. First, it adds unique names. Next, it adds "inner
277275 rules". Last, it adds "outer rules". See module
278276 `lang::textmate::ConversionUnit` for an explanation of inner/outer rules.
0 commit comments