Implement proper line block closing logic
The documentation implies that line statements are terminated once a newline statement is found, which would make sense when you think of what a line block does. The lexer though does not quite implement this logic, and instead will strip out additional whitespace past the newline when the line statement is the last non-whitespace in the file. This has to do with how the current regex is "\s*(\n|$)" which means "strip any whitespace until a newline or end of file is reached". Because the regex is greedy, this will strip any whitespace (including newlines) to the end of the file, or it will only strip whitespace to the first newline found if the end of the file is not possible. In order to remain consistent with the old parser, the grammar has been updated to reflect this behaviour.
This commit is contained in:
parent
61060096bd
commit
adc2dce109
10
grammar.ebnf
10
grammar.ebnf
@ -105,12 +105,12 @@ line_block_expression_single
|
||||
|
||||
line_block_start
|
||||
=
|
||||
line_block_open !("end") name:IDENTIFIER {SP}* parameters:[ line_block_parameters ] { !"\n" SP }* [ ":" { !"\n" SP }* ] "\n"
|
||||
line_block_open !("end") name:IDENTIFIER { !"\n" SP}* parameters:[ line_block_parameters ] [ { !"\n" SP }* ":" ] line_block_close
|
||||
;
|
||||
|
||||
line_block_end
|
||||
=
|
||||
line_block_open "end" name:IDENTIFIER ("\n" | $)
|
||||
line_block_open "end" name:IDENTIFIER line_block_close
|
||||
;
|
||||
|
||||
line_block_open
|
||||
@ -123,6 +123,12 @@ line_block_open_symbol
|
||||
"#"
|
||||
;
|
||||
|
||||
line_block_close
|
||||
=
|
||||
| ( {SP}* $ )
|
||||
| ( { !"\n" SP }* "\n" )
|
||||
;
|
||||
|
||||
line_block_parameters
|
||||
=
|
||||
@+:block_parameter { { !"\n" SP }* @+:block_parameter }*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user