Skip to content

Commit d64ee9f

Browse files
committed
rubyish '\' source line continuation, etc
1 parent 3a3ae17 commit d64ee9f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

examples/rubyish/rubyish.nqp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,19 @@ grammar Rubyish::Grammar is HLL::Grammar {
3535
|| <.panic('Syntax error')>
3636
}
3737

38-
rule separator { \n | ';' }
38+
token continuation { \\ \n }
39+
rule separator { ';' | \n <!after continuation> }
3940
token template { [<tmpl-unesc>|<tmpl-hdr>] <text=.template-content>* [<tmpl-esc>|$] }
4041
proto token template-content {*}
4142
token template-content:sym<interp> { <interp> }
4243
token template-content:sym<plain-text> { [<!before [<tmpl-esc>|'#{'|$]> .]+ }
4344

4445
token tmpl-hdr {'<?rbi?>' \h* \n? <?{$*IN_TEMPLATE := 1}>}
4546
token tmpl-esc {\h* '<%'
46-
[<?{$*IN_TEMPLATE}> || <.panic('Template directive precedes "<%rbi>"')>]
47+
[<?{$*IN_TEMPLATE}> || <.panic('Template directive precedes "<?rbi?>"')>]
4748
}
4849
token tmpl-unesc { '%>' \h* \n?
49-
[<?{$*IN_TEMPLATE}> || <.panic('Template directive precedes "<%rbi>"')>]
50+
[<?{$*IN_TEMPLATE}> || <.panic('Template directive precedes "<?rbi?>"')>]
5051
}
5152

5253
rule stmtlist {
@@ -153,7 +154,7 @@ grammar Rubyish::Grammar is HLL::Grammar {
153154
}
154155

155156
token value:sym<integer> { \+? \d+ }
156-
token value:sym<float> { \+? \d+ '.' \d+ }
157+
token value:sym<float> { \+? \d* '.' \d+ }
157158
token value:sym<array> {'[' ~ ']' <paren-list> }
158159
token value:sym<hash> {'{' ~ '}' <paren-list> }
159160
token value:sym<nil> { <sym> }
@@ -181,7 +182,7 @@ grammar Rubyish::Grammar is HLL::Grammar {
181182
proto token comment {*}
182183
token comment:sym<line> { '#' [<?{!$*IN_TEMPLATE}> \N* || [<!before '%>'>\N]*] }
183184
token comment:sym<podish> {[^^'=begin'\n] ~ [^^'=end'\n ] .*?}
184-
token ws { <!ww>[\h | <.comment> | <?{$*LINE_SPAN}> \n]* }
185+
token ws { <!ww>[\h | <.comment> | <.continuation> | <?{$*LINE_SPAN}> \n]* }
185186

186187
# Operator precedence levels
187188
INIT {

0 commit comments

Comments
 (0)