0. Context-Free Grammar (CFG)


  1. Advantages of CFG Over BNF
  2. Defining CFG and Equality
  3. Parse Tree
  4. Lexical Analyzer and Parser
  5. Separation of Analysis Phase
  6. Transition Diagram
  7. Associativity of Operators

Simplification

  1. CFG

    Consider the following Context-Free Grammar (CFG):

    stmt → expr;
    expr → expr + term | term
    term → term * factor | factor
    factor → number | (expr)
    number → 0 | 1 | 2 | ... | 9
    
    

    (i) Show how the string 1 + 2*(3 + 4) + 5 can be generated by this grammar.

    (ii) Construct a parse tree for the string.[2018]

  2. Parsing Table

  3. Parse Tree for 9-5+2

  4. Predictive Parsing


  1. CFG Example

    Consider the context-free grammar:

    S → S + S | S * S | a
    
    

    **(i) Show how the string aa + a * can be generated by this grammar. (ii) Construct a parse tree for this string.[2021, 17, 10]

    Or,