I'll do it =D
2011/10/14 Roberto Ierusalimschy
<roberto@inf.puc-rio.br>
> Lua is not in LL(1). Telling assignments from function calls requires
> unbounded look-ahead. You need some LL(1) extension, or you cannot
> parse Lua. (The ANTLR parser enables backtracking, but this is
> certainly not required.)
You can use the same method that Lua uses. The parser accepts what
it calls 'primaryexp' (which includes both variables and function calls)
without knowing whether that will be a function call or an assignment:
primaryexp = prefixexp rest
prefixexp = NAME | '(' exp ')'
rest = empty
| '.' NAME rest
| '[' exp `]' rest
| ':' NAME funcargs rest
| funcargs rest
assignment_or_call = primaryexp rest1
rest1 = empty -- function call
| ',' ... -- multiple assignment
| '=' ... -- single assignment
After reading an entire 'assignment_or_call', the parser can use
semantic actions to raise an error for things like "f() = 3".
-- Roberto
--
Rafael de Oliveira Bittencourt
---------------------------------------------------------------------
Bacharelando em Ciência da Computação -UFBA
Estagiário Suporte-CPD/UFBa (71) - 3283-6119
GNU/Linux Registered User #499863