[grammarians] ambiguity with method call?
Terence Parr
parrt at cs.usfca.edu
Thu Dec 1 16:56:43 EST 2005
On Dec 1, 2005, at 9:19 AM, yawl.20481481 at bloglines.com wrote:
> 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.
>
> 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]".
Hi. An alternative is to pass all whitespace to the parser on a
hidden channel and then ask if there is a space before the [1] in the
lexer. :)
> 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.
That will work but I'm thinking that passing in white space to the
parser is reasonable since it's significant (surprisingly) in Ruby
just like python (shudder). ;)
Ter
More information about the Rubygrammar-grammarians
mailing list