For example, which part will detect these errors, Parser or Semantic Routine?
1) int Array[10.5] ( wrong size )
2) int x="some string"
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 --> 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.