@@ -390,12 +390,11 @@ module.exports = grammar({
390390 end_block_data_statement : $ => {
391391 const structType = whiteSpacedKeyword ( 'block' , 'data' , false )
392392 return prec . right ( seq (
393- alias ( choice (
394- seq (
395- caseInsensitive ( 'end' , false ) ,
396- optional ( structType ) ) ,
397- caseInsensitive ( 'end' + structType , false ) ) ,
398- 'end' + structType ) ,
393+ choice (
394+ seq (
395+ alias ( caseInsensitive ( 'end' , false ) , 'end' ) ,
396+ optional ( alias ( structType , 'blockdata' ) ) ) ,
397+ alias ( caseInsensitive ( 'end' + structType , false ) , 'endblockdata' ) ) ,
399398 optional ( $ . _name ) ,
400399 $ . _end_of_statement ) )
401400 } ,
@@ -2259,11 +2258,18 @@ function caseInsensitive (keyword, aliasAsWord = true) {
22592258}
22602259
22612260function whiteSpacedKeyword ( prefix , suffix , aliasAsWord = true ) {
2262- let result = choice (
2263- seq ( caseInsensitive ( prefix , false ) , caseInsensitive ( suffix , false ) ) ,
2264- caseInsensitive ( prefix + suffix , false ) )
2265- if ( aliasAsWord ) result = alias ( result , prefix + suffix )
2266- return result
2261+ let prefix_bit = caseInsensitive ( prefix , false )
2262+ let suffix_bit = caseInsensitive ( suffix , false )
2263+ let both_bits = caseInsensitive ( prefix + suffix , false )
2264+ if ( aliasAsWord ) {
2265+ prefix_bit = alias ( prefix_bit , prefix )
2266+ suffix_bit = alias ( suffix_bit , suffix )
2267+ both_bits = alias ( both_bits , prefix + suffix )
2268+ }
2269+ return choice (
2270+ seq ( prefix_bit , suffix_bit ) ,
2271+ both_bits
2272+ )
22672273}
22682274
22692275function commaSep ( rule ) {
@@ -2281,12 +2287,11 @@ function sep1 (rule, separator) {
22812287// This can be merged with whiteSpacedKeyword, keeping for now.
22822288function blockStructureEnding ( $ , structType ) {
22832289 const obj = prec . right ( seq (
2284- alias ( choice (
2290+ choice (
22852291 seq (
2286- caseInsensitive ( 'end' , false ) ,
2287- optional ( caseInsensitive ( structType , false ) ) ) ,
2288- caseInsensitive ( 'end' + structType , false ) ) ,
2289- 'end' + structType ) ,
2292+ alias ( caseInsensitive ( 'end' , false ) , 'end' ) ,
2293+ optional ( alias ( caseInsensitive ( structType , false ) , structType ) ) ) ,
2294+ alias ( caseInsensitive ( 'end' + structType , false ) , 'end' + structType ) ) ,
22902295 optional ( $ . _name ) ,
22912296 $ . _end_of_statement
22922297 ) )
0 commit comments