module TimeFlies where import CF data Cat = S | NP | VP | PP | Adj | Det | Noun | Verb | Prep deriving (Eq,Ord,Show) type Tok = String -- the time flies grammar, in Peter Ljunglöf normal form timeFlies :: CF Cat Tok timeFlies = mkCF S [ S |> [NP,VP], NP |> [Adj,NP], NP |> [NP,PP], NP |> [Det,Noun], NP |> [Noun], VP |> [Verb,PP], VP |> [Verb,NP], VP |> [Verb], PP |> [Prep,NP] ] [ "time" |: Noun, "time" |: Adj, "time" |: Verb, "flies" |: Noun, "flies" |: Verb, "arrow" |: Noun, "like" |: Verb, "like" |: Prep, "an" |: Det ] -- the time flies grammar, but with np -> noun pp instead of np -> np pp -- to avoid left recursion timeFliesNoLR :: CF Cat Tok timeFliesNoLR = mkCF S [ S |> [NP,VP], NP |> [Adj,NP], NP |> [Noun,PP], NP |> [Det,Noun], NP |> [Noun], VP |> [Verb,PP], VP |> [Verb,NP], VP |> [Verb], PP |> [Prep,NP] ] [ "time" |: Noun, "time" |: Adj, "time" |: Verb, "flies" |: Noun, "flies" |: Verb, "arrow" |: Noun, "like" |: Verb, "like" |: Prep, "an" |: Det ] -- the time files grammar in chomsky normal form timeFliesCNF :: CF Cat Tok timeFliesCNF = mkCF S [ S |> [NP,VP], NP |> [Adj,NP], NP |> [NP,PP], NP |> [Det,Noun], VP |> [Verb,PP], VP |> [Verb,NP], PP |> [Prep,NP] ] [ "time" |: Noun, "time" |: NP, "time" |: Adj, "time" |: Verb, "time" |: VP, "flies" |: Noun, "flies" |: NP, "flies" |: Verb, "flies" |: VP, "arrow" |: Noun, "arrow" |: NP, "like" |: Verb, "like" |: VP, "like" |: Prep, "an" |: Det ]