assignment-1

assignment-1 - while true do skip end ’ is a member o± L...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CSC 501 - Assignment #1 version 3.1 Due Tuesday 9/27/11 in Class Problems Given the grammar G =(Γ ,R,γ ): Γ= T N where T = { 0 ,..., 9 , a ,..., z , true , false , skip , if , then , else , while , do , end + , , , = , , ! , , || , := , ; , ( , ) } and N = { A,B,C,D,L,V } . Theru leset R is defned by the BNF style rewrite rules: A ::= D | V | A+A | A A | A A | (A) B ::= true | false | A=A | A A | !B | | B || B | (B) C ::= skip | V:=A | C;C | if B then C else C end | while B do C end D ::= L |− L L ::= 0 L | ... | 9 L | 0 | ... | 9 V ::= a V | ... | z V | a | ... z γ =C . Do the ±ollowing problems: 1. Derive at least three strings that belong to L ( G
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: while true do skip end ’ is a member o± L ( G ). 3. Is the string ‘ if true then skip end ’ a member o± L ( G )? Why? Why not? 4. Add a rule to the above grammar that would add the command ’repeat-until’ to the language. Show that your grammar works by showing that you can derive a program that contains the ’repeat-until’ command. 1...
View Full Document

This note was uploaded on 10/03/2011 for the course CSC 501 taught by Professor Staff during the Spring '09 term at Rhode Island.

Ask a homework question - tutors are online