Add missing parse_nonbrace()

databind
vitalif 2012-09-26 19:46:15 +00:00 committed by Vitaliy Filippov
parent ed83e422ac
commit ee664c2dfc
2 changed files with 21 additions and 9 deletions

View File

@ -1511,9 +1511,7 @@ $varref_index = \$stack[count(\$stack)-1]++;";
return $neg ? "-($e)" : $e; return $neg ? "-($e)" : $e;
} }
// exp_not: nonbrace | '(' exp ')' | '!' exp_not | func nonbrace // exp_not: nonbrace | '(' exp ')' varpath | '!' exp_not
// nonbrace: '{' hash '}' | literal | varref | func '(' list ')' | func '(' gthash ')'
// func: name | varref varpart
function parse_not() function parse_not()
{ {
$t = $this->tok(); $t = $this->tok();
@ -1527,8 +1525,21 @@ $varref_index = \$stack[count(\$stack)-1]++;";
$this->ptr++; $this->ptr++;
$r = $this->parse_exp(); $r = $this->parse_exp();
$this->consume(')'); $this->consume(')');
// FIXME parse_varpath here
} }
elseif ($t == '{') else
{
$r = $this->parse_nonbrace();
}
return $r;
}
// nonbrace: '{' hash '}' | literal | varref | func '(' list ')' | func '(' gthash ')' | func nonbrace
// func: name | varref varpart
function parse_nonbrace()
{
$t = $this->tok();
if ($t == '{')
{ {
$this->ptr++; $this->ptr++;
if ($this->tok() != '}') if ($this->tok() != '}')
@ -1567,7 +1578,7 @@ $varref_index = \$stack[count(\$stack)-1]++;";
$r = $this->gen_varref($parts); $r = $this->gen_varref($parts);
} }
else else
$this->unexpected(array('!', '(', '{', '#', '$')); $this->unexpected(array('{', '#', '$'));
return $r; return $r;
} }
@ -1645,6 +1656,7 @@ $varref_index = \$stack[count(\$stack)-1]++;";
// varref: name | varref varpart // varref: name | varref varpart
// varpart: '.' name | '[' exp ']' // varpart: '.' name | '[' exp ']'
// varpath: | varpath varpart
// (always begins with name) // (always begins with name)
function parse_varref() function parse_varref()
{ {

View File

@ -32,9 +32,9 @@ p7: p8 | p8 '<' p8 | p8 '>' p8 | p8 "<=" p8 | p8 ">=" p8
p8: p9 | p9 '+' p8 | p9 '-' p8 p8: p9 | p9 '+' p8 | p9 '-' p8
p9: p10 | p10 '*' p9 | p10 '/' p9 | p10 '%' p9 p9: p10 | p10 '*' p9 | p10 '/' p9 | p10 '%' p9
p10: p11 | '-' p11 p10: p11 | '-' p11
p11: nonbrace | '(' exp ')' varpath | '!' p11 | func nonbrace p11: nonbrace | '(' exp ')' varpath | '!' p11
nonbrace: '{' hash '}' | literal | varref | func '(' list_or_gthash ')' nonbrace: '{' hash '}' | literal | varref | func '(' list_or_gthash ')' | func nonbrace
list_or_gthash: list | gthash | list_or_gthash: list | gthash
func: name | varref varpart func: name | varref varpart
list: exp | exp ',' list list: exp | exp ',' list
arglist: name | name ',' arglist | arglist: name | name ',' arglist |