Skip to content

Commit

Permalink
rubyish '\' source line continuation, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
dwarring committed Oct 16, 2013
1 parent 3a3ae17 commit d64ee9f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/rubyish/rubyish.nqp
Expand Up @@ -35,18 +35,19 @@ grammar Rubyish::Grammar is HLL::Grammar {
|| <.panic('Syntax error')>
}

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

token tmpl-hdr {'<?rbi?>' \h* \n? <?{$*IN_TEMPLATE := 1}>}
token tmpl-esc {\h* '<%'
[<?{$*IN_TEMPLATE}> || <.panic('Template directive precedes "<%rbi>"')>]
[<?{$*IN_TEMPLATE}> || <.panic('Template directive precedes "<?rbi?>"')>]
}
token tmpl-unesc { '%>' \h* \n?
[<?{$*IN_TEMPLATE}> || <.panic('Template directive precedes "<%rbi>"')>]
[<?{$*IN_TEMPLATE}> || <.panic('Template directive precedes "<?rbi?>"')>]
}

rule stmtlist {
Expand Down Expand Up @@ -153,7 +154,7 @@ grammar Rubyish::Grammar is HLL::Grammar {
}

token value:sym<integer> { \+? \d+ }
token value:sym<float> { \+? \d+ '.' \d+ }
token value:sym<float> { \+? \d* '.' \d+ }
token value:sym<array> {'[' ~ ']' <paren-list> }
token value:sym<hash> {'{' ~ '}' <paren-list> }
token value:sym<nil> { <sym> }
Expand Down Expand Up @@ -181,7 +182,7 @@ grammar Rubyish::Grammar is HLL::Grammar {
proto token comment {*}
token comment:sym<line> { '#' [<?{!$*IN_TEMPLATE}> \N* || [<!before '%>'>\N]*] }
token comment:sym<podish> {[^^'=begin'\n] ~ [^^'=end'\n ] .*?}
token ws { <!ww>[\h | <.comment> | <?{$*LINE_SPAN}> \n]* }
token ws { <!ww>[\h | <.comment> | <.continuation> | <?{$*LINE_SPAN}> \n]* }

# Operator precedence levels
INIT {
Expand Down

0 comments on commit d64ee9f

Please sign in to comment.