My notes — Section 2.1

Context free languages & grammars
   Must be more than regular languages
   Must be more than regular grammars
   flex/lex    ~ regular expressions
   bison/yacc  ~ context free grammars

Context-free grammars
variables and terminals in productions (or substitution rules)
   A → 0 A 1      A is a variable, 0 and 1 are terminals

Adam Whitley’s Slide 3
   Def 2.2 (text p 104)	 
   context-free grammer (V, Σ, R, S)
      V: variables
      Σ: terminals
      R: rules
      S: start variable (from V)

Example: regular expression to context-free grammar
    0*1*  for CFG (and regular grammar)
       derive 000111 (slide 4)
Example: non-regular
    0n 1n
Not a context-free language
    0n 1n 2n

Warning: Expect a new (more complicated) pumping lemma

A CFG with silly ambiguity
    A → B | C
    B → unca
    C → unca
Text page 107 - 108 example
    5 * 6 / 7
Inherently ambiguous
    ai bj ck where i = j or j = k

Adam Whitley’s Slides 7 and 8
    Leftmost and rightmost derivations
    Be careful with arithmetic expressions

Java literals
    Java sure is complicated....
    These definitions do not restrict value range

Syntax diagrams for Pascal and SQL and JSON
    Looks a bit like a finite state machine
    Once done in CSCI 201 and called railroad diagrams
    Check out the Wikipedia page

Let's try one out....
    RPN (reverse polish notation)
    15 20 30 * +

The Math Equation That Tried to Stump the Internet

Java’s near CNF for for loop

Adam Whitley’s Slides 10 to 12: DFA to regular (again)
    BUM bum BUUUUUUUM ?

Adam Whitley’s Slides 13 to 14: Tips

Chomsky normal form
    A → B C
    A → a
    S → ε

Noam Chomsky
    Three Models for the Description of Language
    Your brain is designed for language

Adam Whitley’s Slides 15 to 26: CFG to Chomsky Normal Form

The restricted version is usually longer     

Greibach Normal Form
   Sheila Greibach
   no left recursion
   useful for designing pushdown automata!