Contents    Page-10    Prev    Next    Page+10    Index   

Grammar

A grammar specifies the legal syntax of a language. The kind of grammar most often used in computer language processing is a context-free grammar. A grammar specifies a set of productions; non-terminal symbols (phrase names or parts of speech) are enclosed in angle brackets. Each production specifies how a nonterminal symbol may be replaced by a string of terminal or nonterminal symbols, e.g., a Sentence is composed of a Noun Phrase followed by a Verb Phrase.


<s>     -->  <np> <vp>
<np>    -->  <art> <adj> <noun>
<np>    -->  <art> <noun>
<np>    -->  <art> <noun> <pp>
<vp>    -->  <verb> <np>
<vp>    -->  <verb> <np> <pp>
<pp>    -->  <prep> <np>

<art>   -->   a | an | the
<noun>  -->   boy | dog | leg | porch
<adj>   -->   big
<verb>  -->   bit
<prep>  -->   on