Next: Language and Grammars (2)
Up: No Title
- A language has structure which is determined by a grammar.
- Example: A correct sentence consists of a subject, followed by a verb
- This can be expressed by the grammar
Sentence = Subject Verb.
- Let's complete this with two more productions :
Subject = "Peter" | "Chelsea".
Verb = "runs" | "stops".
- Then this defines 4 possible sentences:
Peter runs | Peter stops | Chelsea runs | Chelsea stops
- Usually languages contain an infinite number of sentences.
Q: Write a grammar for integer numbers!