Discussion
Detecting that a floating point value has been used to index an array is the responsibility of
Answer: B
Correct answer: the semantic analyser
A floating-point subscript is grammatically perfectly valid - the parser reduces it happily, since the grammar says a subscript is an expression and says nothing about its type.
What is wrong is meaning: an index must be of an integral type, and only type checking discovers that. That is the semantic analyser's work, using the types recorded in the symbol table. The pattern is general: the parser enforces form, and errors that are well-formed but nonsensical fall to semantic analysis.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development