@@ -131,8 +131,8 @@ module.exports = grammar({
131131 name : 'CEDARScript' ,
132132
133133 extras : $ => [
134- / \s | \r ? \n / ,
135- $ . comment
134+ $ . comment ,
135+ / [ \s \f \uFEFF \u2060 \u200B ] | \\ \r ? \n /
136136 ] ,
137137
138138 rules : {
@@ -264,7 +264,7 @@ module.exports = grammar({
264264 </params>
265265 */
266266 identifier_from_file : $ => seq (
267- $ . identifierMarker , 'FROM' , $ . singlefile_clause ,
267+ $ . identifier_matcher , 'FROM' , $ . singlefile_clause ,
268268 optional ( $ . where_clause )
269269 ) ,
270270
@@ -320,21 +320,21 @@ module.exports = grammar({
320320 // <specifying-locations-in-code>
321321
322322 line_base : $ => seq ( optional ( 'LINE' ) , choice (
323- field ( 'lineMarker ' , choice ( $ . string , $ . number ) ) , // reference the line content or a context-relative line number
323+ field ( 'line_matcher ' , choice ( $ . string , $ . number ) ) , // match the line content or a context-relative line number
324324 field ( 'empty' , 'EMPTY' ) , // match empty line
325325 seq ( 'REGEX' , field ( 'regex' , $ . string ) ) , // match line by REGEX
326326 seq ( 'PREFIX' , field ( 'prefix' , $ . string ) ) , // match line by its prefix
327327 seq ( 'SUFFIX' , field ( 'suffix' , $ . string ) ) , // match line by its suffix
328328 seq ( 'INDENT' , 'LEVEL' , field ( 'indent_level' , $ . number ) ) , // Line has indent level
329329 ) ) ,
330- lineMarker : $ => seq ( $ . line_base , optional ( $ . offset_clause ) ) ,
331- identifierMarker : $ => seq ( field ( 'identifier' , choice ( 'VARIABLE' , 'FUNCTION' , 'METHOD' , 'CLASS' ) ) , field ( 'identifierMarker ' , $ . string ) , optional ( $ . offset_clause ) ) ,
332- marker : $ => choice ( $ . lineMarker , $ . identifierMarker ) ,
330+ line_matcher : $ => seq ( $ . line_base , optional ( $ . offset_clause ) ) ,
331+ identifier_matcher : $ => seq ( field ( 'identifier' , choice ( 'VARIABLE' , 'FUNCTION' , 'METHOD' , 'CLASS' ) ) , field ( 'identifier_matcher ' , $ . string ) , optional ( $ . offset_clause ) ) ,
332+ marker : $ => choice ( $ . line_matcher , $ . identifier_matcher ) ,
333333 relpos_beforeafter : $ => field ( 'relpos_beforeafter' , seq ( choice ( 'BEFORE' , 'AFTER' ) , $ . marker ) ) ,
334- relpos_into : $ => seq ( 'INTO' , field ( 'into' , $ . identifierMarker ) , field ( 'topOrBottom' , choice ( 'TOP' , 'BOTTOM' ) ) ) ,
334+ relpos_into : $ => seq ( 'INTO' , field ( 'into' , $ . identifier_matcher ) , field ( 'topOrBottom' , choice ( 'TOP' , 'BOTTOM' ) ) ) ,
335335 relpos_bai : $ => field ( 'relpos_bai' , choice ( $ . relpos_beforeafter , $ . relpos_into ) ) ,
336336 /**
337- relpos_at: points to a specific `lineMarker `
337+ relpos_at: points to a specific `line_matcher `
338338 */
339339 relpos_at : $ => seq ( 'AT' , field ( 'at' , $ . marker ) ) ,
340340 /**
@@ -394,8 +394,6 @@ module.exports = grammar({
394394 loop_break : $ => field ( 'break' , 'BREAK' ) ,
395395 loop_continue : $ => field ( 'continue' , 'CONTINUE' ) ,
396396 loop_control : $ => choice ( $ . loop_break , $ . loop_continue ) ,
397- // Matchers (WHEN clause):
398- case_when : $ => seq ( 'WHEN' , $ . line_base ) ,
399397 // Actions (THEN clause):
400398 case_action : $ => choice (
401399 $ . loop_control ,
@@ -408,10 +406,9 @@ module.exports = grammar({
408406 // Filters
409407
410408 case_stmt : $ => seq (
411- 'CASE' , repeat ( seq (
412- $ . case_when ,
413- 'THEN' ,
414- $ . case_action
409+ 'CASE' , repeat1 ( seq (
410+ 'WHEN' , $ . line_base ,
411+ 'THEN' , $ . case_action
415412 ) ) ,
416413 optional ( seq ( 'ELSE' , field ( 'else' , $ . case_action ) ) ) ,
417414 'END'
@@ -509,9 +506,9 @@ module.exports = grammar({
509506
510507 number : $ => seq ( optional ( '-' ) , / \d + / ) ,
511508
512- comment : $ => token ( prec ( - 1 , seq (
513- '--' ,
514- optional ( / [ ^ \n ] + / )
509+ comment : $ => token ( prec ( - 1 , choice (
510+ seq ( "--" , / . * / ) ,
511+ seq ( "/*" , / [ ^ * ] * \* + ( [ ^ / * ] [ ^ * ] * \* + ) * / , "/" )
515512 ) ) ) ,
516513
517514 command_separator : $ => ';'
0 commit comments