Small example of a language and its grammar

Language

Here are sample of our language.

ON LIGHT
OPEN DOOR
OFF LIGHT AND TV
CLOSE WINDOW

Grammar

Here is a version of its grammar

We have to separate command into two groups because the objects are different for different commands.

G = V1 OBJ1  |  V2 OBJ2
V1 = ON | OFF
OBJ1 = LIGHT | LIGHT AND TV
V2 = OPEN | CLOSE
OBJ2 = DOOR | WINDOW

This grammar covers our sample language.  If you want to make it a bit more flexible, we should consider how to decompose "LIGHT AND TV" into smaller parts which can be reassemble into different sentences.

last update 26 Aug 2016