Which is not true about syntax and semantic parts of a computer langua...
Syntax analysis checks for the syntax of the source program while the semantic analysis, deals with checking of semantic (meaning) of the source program output by syntax analysis phase and input to semantic analysis phase.
Note: The syntax checking is responsibility of the programmer while semantic analys is is checked at the runtime.
View all questions of this test
Which is not true about syntax and semantic parts of a computer langua...
Syntax and Semantics of a Computer Language
Introduction:
Computer languages are designed with specific rules and structures that govern how programs are written. These rules are divided into two components: syntax and semantics. Syntax refers to the proper arrangement and combination of symbols and keywords, while semantics deals with the meaning and interpretation of those symbols and keywords. In this context, we will discuss the differences between syntax and semantics and why option D is the correct answer.
Syntax:
Syntax defines the correct structure and grammar of a programming language. It specifies the rules for constructing valid statements and expressions in the language. The syntax of a language is typically checked by the programmer during the development process. When a programmer writes code, they need to adhere to the syntax rules of the language to avoid syntax errors. These errors occur when the code violates the language's syntax rules, leading to compilation or interpretation failures.
Semantics:
Semantics, on the other hand, deals with the meaning and interpretation of the code. It determines how statements and expressions are executed and the behavior of the program. While syntax focuses on the form and structure of the code, semantics focuses on the functionality and purpose. Semantics define the rules for assigning meaning to the code constructs and how they interact with each other.
Discussion:
According to the given options, both (b) and (c) are stated to be false. Let's analyze each option to understand why.
Option (b): Semantics is the responsibility of the programmer
This statement is false. While programmers are responsible for understanding and utilizing the semantics of a programming language effectively, they are not solely responsible for defining or determining the semantics. The semantics of a language are defined by its specification or standard, which is typically created by language designers and experts. Programmers need to understand and follow these predefined semantics to write correct and meaningful code.
Option (c): Semantics is checked mechanically by a computer
This statement is also false. Unlike syntax, which can be checked mechanically by a computer through the use of compilers or interpreters, semantics cannot be fully checked by a computer. While computers can detect some semantic errors, such as type mismatches or undefined variables, they cannot determine the intended meaning or correctness of the program's logic. Semantic errors often lead to runtime errors or unexpected program behavior, which can only be identified through testing and debugging by the programmer.
Conclusion:
In conclusion, the correct answer is option D, as both (b) and (c) are false statements. Syntax is generally checked by the programmer, and semantics is not fully checked mechanically by a computer. Programmers are responsible for understanding and utilizing the predefined semantics of a programming language to write correct and meaningful code.
To make sure you are not studying endlessly, EduRev has designed Computer Science Engineering (CSE) study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Computer Science Engineering (CSE).