Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Commit

Permalink
handle ambiguous function call
Browse files Browse the repository at this point in the history
  • Loading branch information
fperrad committed Jul 10, 2009
1 parent 60eb87f commit b334705
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/PASTGrammar.tg
Expand Up @@ -681,8 +681,13 @@ transform past (Lua::Grammar::simple_expression) :language('PIR') {


transform past (Lua::Grammar::primary_expression) :language('PIR') {
.local pmc source, pos
.local int line
.local pmc past
$P0 = node['prefix_expression']
source = getattribute $P0, '$.target'
pos = $P0.'from'()
line = source.'lineof'(pos)
past = tree.'get'('past', $P0, 'Lua::Grammar::prefix_expression')
$P0 = node['slice_expression']
if null $P0 goto L1
Expand All @@ -694,8 +699,22 @@ transform past (Lua::Grammar::primary_expression) :language('PIR') {
$P1 = $P0['function_args']
if null $P1 goto L3
args = tree.'get'('explist', $P1, 'Lua::Grammar::function_args')
$P2 = $P1['expression_list']
if null $P2 goto L9
source = getattribute $P1, '$.target'
pos = $P1.'from'()
$I1 = source.'lineof'(pos)
if line == $I1 goto L9
$P2 = get_hll_global [ 'Lua';'Grammar' ], 'syntaxerror'
$P2($P1, 'ambiguous syntax (function call x new statement)')
L9:
pos = $P1.'to'()
line = source.'lineof'(pos)
$P1 = $P0['Name']
if null $P1 goto L4
source = getattribute $P1, '$.target'
pos = $P1.'from'()
line = source.'lineof'(pos)
.local pmc meth, obj
key = tree.'get'('key', $P1, 'Lua::Grammar::Name')
$P2 = get_hll_global ['PAST'], 'Var'
Expand All @@ -711,13 +730,19 @@ transform past (Lua::Grammar::primary_expression) :language('PIR') {
L3:
$P1 = $P0['Name']
if null $P1 goto L5
source = getattribute $P1, '$.target'
pos = $P1.'from'()
line = source.'lineof'(pos)
key = tree.'get'('key', $P1, 'Lua::Grammar::Name')
$P2 = get_hll_global ['PAST'], 'Var'
past = $P2.'new'(past, key, 'node'=>node, 'scope'=>'keyed')
goto L2
L5:
$P1 = $P0['index']
if null $P1 goto L6
source = getattribute $P1, '$.target'
pos = $P1.'to'()
line = source.'lineof'(pos)
key = tree.'get'('key', $P1, 'Lua::Grammar::index')
$P2 = get_hll_global ['PAST'], 'Var'
past = $P2.'new'(past, key, 'node'=>node, 'scope'=>'keyed')
Expand Down
2 changes: 1 addition & 1 deletion t/function.t
Expand Up @@ -281,7 +281,7 @@ CODE
2
OUT

language_output_like( 'lua', <<'CODE', <<'OUT', 'ambiguous' , todo => 'ambigous function call');
language_output_like( 'lua', <<'CODE', <<'OUT', 'ambiguous' );
a = f
(g).x(a)
CODE
Expand Down

0 comments on commit b334705

Please sign in to comment.