NOTICE: This question is not about "Java do not have pointers"
In C language, the code identifier1 * identifier2
is ambiguous for two possible meaning:
- If the identifier1 is a type, then this might be a pointer declaration.
- If the identifier1 is a variable, then this might be a multiply statement.
The problem is that I cannot choose the right production when building the Syntax tree. I checked Clang's code and it seems that Clang has to put the type checking(by using a symbol table) to the parsing phase(correct me if I'm wrong).
Then I checked the code of javac(OpenJDK), it seems that on parsing phase, there's no semantic analysis involved. The parser can build an AST barely using the tokens.
So I'm curious if Java has the same ambiguous syntax problem? The problem that if the parser don't know an identifier's type, it can not choose the right production?
Or more generic, Does Java has syntax ambiguous that a parser cannot choose a production without other information more than a token stream?