parsing - How does an LALR(1) grammar differentiate between a variable and a function call? -


given following input:

int x = y; 

and

int x = y(); 

is there way lalr(1) grammar avoid shift/reduce conflict? shift/reduce conflict deciding reduce @ y or continue (.

(this assuming variable name can set of alphanumeric characters, , function call set of alphanumeric characters following parentheses.)

it's not shift-reduce conflict unless possible identifier followed ( without being function call. that's not case, although in c-derived languages, there problem of differentiating cast expressions (type)(value) parenthesized-function calls (function)(argument).

if grammar not exhibit particular c wierdness, lalr (1) grammar can decide between shifting , reducing based on (1) token lookahead: if lookahead token (, shifts identifier; otherwise, can reduce.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -