I have solved a similar issue(see
http://seclib.blogspot.com/2005/11/more-on-leftshift-and-heredoc.html
) and the same rules apply in this case.
For "foo[1]", first the lexer
need to lookup symbol table to see if foo is a local varible. If
not found,
assume foo is a function.
After we know foo is function, then space is
important. If there is a space between foo and [1]("foo [1]"), then foo
is a function call and [1] is the parameter(same as "foo([1])"). If there
is no space("foo[1]"), then it is treated as "(foo)[1]".
Since the parser
can not see space, the burden is on the lexer. In other words, it should return
different token type for '[' in different context. For example:
LBRACK_IN_COMMAND
and LBRACK.
Xue Yong Zhi
http://seclib.blogspot.com
--- Terence Parr
<[EMAIL PROTECTED] wrote:
> I look could easily be seen to
> interpret
foo[1] in two ways:
>
> (foo)[1]
>
> and
>
> foo([1])
>
> even
when we know foo is a function call.
> how could it not?
_______________________________________________
Rubygrammar-grammarians mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rubygrammar-grammarians