Compiler Question : Does the parser detect Errors in these examples or the Semantic routine? For example, which part will detect these errors, Parser or Semantic Routine?
1) int Array[10.5]  ( wrong size )
2) int x=&quot;some string&quot;
3) A[10.5] + 3  (not in declaration, but in the middle of the code)
The book that I'm reading says the first one will be detected by parser but the third one will be detected by Semantic routine! I don't get it? why not both of them by parser? if the parser can detect first one, then it should be able to detect the third one
ALSO, i thought that lexical analyzers usually turn every number into a same token? for example:
a = 3.5 + 5 --&gt; id = num + num
so how can parser or semantic analyzer differentiate between a real number and a integer number?
Lets assume our compiler is a modern day compiler for C for example.
It's impossible to say in general; it depends on the compiler resp. the exact definition of the syntax.

If your language contains special syntax for array declarations, the parser will note that it doesn't find an integer literal between the brackets.

For array accesses, the language probably allows arbitrary arithmetic expressions (including function calls) between the brackets. So the parser will create an expression tree, and only the type checker will determine that the expression is not of type integer.