CSC 533: Organization of Programming Languages
Spring 2017

HW1: Syntax and EBNF Grammars


Answer the following questions about the programming langauge Ada by referring to its EBNF at the BNF Web Club.

  1. Which of the following are legal numeric literals in Ada? For each legal literal, provide a parse tree (with the numeric_literal abstraction at the root). 00 -2.9 16#A# A#16# 2E-4 0.01E12 5.5E+5.5
  2. Which of the following are simple expressions in Ada? For each legal expression, provide a parse tree (with the simple_expression abstraction at the root). 1 - 3 -1 - 3 -1 - -3 1 - 2 - 3 A A mod B 1 ** 2 ** 3 foo / ** bar
  3. What is the order of precedence for the operators and, or and not in Ada? Confirm your answer by providing a parse tree for the expression: not A and B or C
  4. Describe, in concise English, the format for identifiers (ident) in Ada. That is, what characters may be used? What restrictions (if any) are there on order?

  5. What is the assignment operator in Ada (i.e., the symbol that separates the left and right sides of an assignment)?

  6. How are comments specified in Ada?

  7. Does the dangling-else problem apply to Ada? Justify your answer.

  8. Give an example of a subprogram declaration that is as short as possible, in terms of number of tokens.

  9. Give an example of a subprogram body that is as short as possible, in terms of number of tokens.

  10. What is the difference between a type declaration and a full type declaration? Give an example of an expression that can be derived from one of the abstractions (type_declaration or full_type_declaration) but not the other.