Skip to content

Commit

Permalink
Some more parsing fixes.
Browse files Browse the repository at this point in the history
* Parse certain keywords followed by parens as subcalls.
* change some {{-tests to use <?{{...}}> instead.
  • Loading branch information
pmichaud committed Feb 28, 2009
1 parent 0bb4da5 commit dd9b61c
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/parser/grammar.pg
Expand Up @@ -89,6 +89,7 @@ token unsp {
}

token unspacey { <.unsp>? }
token nofun { <!before '(' | '.(' | '\\' > }

token unv {
|| \h+
Expand Down Expand Up @@ -183,7 +184,7 @@ token terminator {
| <[ ; ) \] } ]>
| '!!'
| '-->'
| [ if | unless | while | until | for | given | when ] >>
| [ if | unless | while | until | for | given | when ] >> <.nofun>
}

token stdstopper {
Expand All @@ -193,13 +194,13 @@ token stdstopper {
token eat_terminator {
|| ';'
|| <?terminator>
|| {{ $P0 = get_global '$!endstmt'
|| <?{{
$P0 = get_global '$!endstmt'
$P1 = get_global '$!ws'
$P2 = $P1.'from'()
if $P0 != $P2 goto end
.return (1)
end:
}} <fail> # FIXME: <!>
$I0 = iseq $P0, $P2
.return ($I0)
}}>
|| $
|| <.panic: "Statement not terminated properly">
}
Expand Down Expand Up @@ -252,15 +253,15 @@ rule statement_control {
}

rule if_statement {
$<sym>=[if]
$<sym>=[if<.nofun>]
<xblock>
[ 'elsif' <xblock> ]*
[ 'else' <pblock> ]?
{*}
}

rule unless_statement {
$<sym>=[unless]
$<sym>=[unless<.nofun>]
<xblock> {*}
[ <!before 'else'> || <.panic: "unless does not take \"else\" in Perl 6; please rewrite using \"if\""> ]
}
Expand All @@ -274,19 +275,19 @@ rule repeat_statement {
}

rule while_statement {
$<sym>=[while|until]
$<sym>=[[while|until]<.nofun>]
<xblock>
{*}
}

rule given_statement {
$<sym>=[given]
$<sym>=[given<.nofun>]
<xblock>
{*}
}

rule when_statement {
$<sym>=[when]
$<sym>=[when<.nofun>]
<EXPR> <block>
{*}
}
Expand All @@ -311,7 +312,7 @@ rule loop_statement {
}

rule for_statement {
$<sym>=[for]
$<sym>=[for<.nofun>]
<xblock>
{*}
}
Expand Down Expand Up @@ -351,11 +352,11 @@ rule no_statement {
}

rule statement_mod_loop {
$<sym>=[while|until|for|given] <EXPR> {*}
$<sym>=[[while|until|for|given]<.nofun>] <EXPR> {*}
}

rule statement_mod_cond {
$<sym>=[if|unless|when] <EXPR> {*}
$<sym>=[[if|unless|when]<.nofun>] <EXPR> {*}
}

rule statement_prefix {
Expand Down

0 comments on commit dd9b61c

Please sign in to comment.