{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

csc501-ln003 - Grammars Observations We have seen in the...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Grammars Observations: We have seen in the case of the palindrome generator that SRSs are well suited for generating strings with structure. By modifying the standard SRS just slightly we obtain a convenient framework for generating strings with desirable structure – Grammars Definition: [Grammar] A grammar is a triple (Γ , R , γ ) such that, Γ = T N with T N = , where T is a set of symbols called the terminals and N is a set of symbols called the non-terminals , 1 R is a set of rules of the form u v with u , v Γ , γ is called the start symbol and γ N . 1 The fact that T and N are non-overlapping means that there will never be confusion between terminals and non-terminals.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Grammars Example: Grammar for arithmetic expressions. We define the grammar , R , s ) as follows: Γ = T N with T = { a , b , c , + , , ( , ) } and N = { E } , R is the set of rules, E E + E E E E E ( E ) E a E b E c γ = E (clearly this satisfies s γ N ).
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}