Programming languages: Which symbols are conventionally used to denote nonterminal metavariables in grammar notations (e.g., BNF) when describing syntax?

Difficulty: Easy

Correct Answer: <>

Explanation:


Introduction / Context:
Formal descriptions of programming language syntax often use grammar notations such as BNF (Backus–Naur Form) or EBNF. In these notations, it is standard to distinguish nonterminals (syntactic categories) from terminals (literal tokens). This question asks which symbols are commonly used to mark nonterminals.


Given Data / Assumptions:

  • We are focusing on notation conventions, not language keywords.
  • Typical textbooks show nonterminals enclosed in angle brackets.
  • Terminals are shown as quoted strings or literal characters.


Concept / Approach:
In BNF-style grammars, nonterminal symbols are frequently written as <nonterminal> using angle brackets, whereas terminals are often represented with quotes. Braces {} can indicate repetition or sets in some EBNF variants, and quotation marks indicate literal terminals. A bare zero is unrelated to grammar categories. Hence, angle brackets best fit the conventional marking of nonterminals.


Step-by-Step Solution:

Recall BNF conventions: <statement> ::= <assignment> | <if-statement> ...Recognize that the angle brackets wrap nonterminal names.Eliminate symbols used for other purposes (quotes, braces).Select the angle-bracket notation.


Verification / Alternative check:
Most compiler design texts (e.g., on lexical and syntax analysis) illustrate nonterminals with angle brackets, reinforcing the choice.


Why Other Options Are Wrong:

  • 0: a numeral, not a notation for grammar categories.
  • {}: sometimes used for repetition in EBNF, not to denote nonterminals.
  • """": quotation marks indicate terminals (literal tokens), not nonterminals.
  • None of the above: incorrect because angle brackets are standard.


Common Pitfalls:
Mixing terminal and nonterminal conventions; assuming braces or quotes mark categories rather than repetition or literals.


Final Answer:
<>

More Questions from Artificial Intelligence

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion