Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS322D Tutorials.

Similar presentations


Presentation on theme: "CS322D Tutorials."— Presentation transcript:

1 CS322D Tutorials

2 Q1. The following is an example of a context-free grammar, called G1:
E E+T |T T T ×F | F F (E) |a

3 Give parse trees and derivations for each string from the following:
a a+a a+a+a ((a))

4 First sting is: a Derivation : ETFa Parse Tree : E T F a

5 Second string is: a+a Derivation : EE+TT+TF+Fa+a Parse Tree :

6 Third string a+a+a Derivation : Parse Tree :

7 Fourth string: ((a)) Derivation : Parse Tree :

8

9 By using JFLAB 1.Enter grammar G1. 2.Check whether string “a+a” is accepted by the grammar G1 or not. 3.See how can derive the string “a+a” using G1 rules(productions). 4.View the Derivation Table that show how the string “a+a” derived by the grammar G1.

10 Enter a Grammar To start a new grammar, start JFLAP and click the Grammar option from the menu, as shown below:

11 Variable should be entered on the LHS column
Right side of the production on the RHS column Click on Input, followed by Brute Force Parse. You can enter your start variable and its production on the first row.

12 After clicking Brute Force Parse, you should see a window similar to this.

13 Now you can input a string and check whether it is accepted
Now you can input a string and check whether it is accepted. Enter the string “a+a” in the input text field. Then either click Start or press Enter key. Brute Force Parser notifies you that the string you entered is accepted.

14 This message tells us about the last production that was applied.
Now, we can click on the Step button to see how we can derive that string using our productions. After clicking the Step button 6 times, your window should look like this. This message tells us about the last production that was applied.

15 To change to Derivation Table mode, click on Noninverted Tree and select Derivation Table.
 Productions that are applied Result of applying productions


Download ppt "CS322D Tutorials."

Similar presentations


Ads by Google