17
Context Free Grammar Using User Control Parse JP Prerequisite knowledge: Context Free Grammar JFLAP User Control Parse Consider the following context-free grammar. (See: cfguucp.jflap) V = { A, N, O, S, V } T = { a, d, r, t } S = S S OV O AN A a A a N d V r

JFLAP User Control Parse Grammar...Microsoft Word - Context Free Grammar Using User Control Parse (3).docx Created Date 7/19/2016 3:11:02 PM

  • Upload
    others

  • View
    17

  • Download
    0

Embed Size (px)

Citation preview

  • Context Free Grammar Using User Control ParseJP ● Prerequisite knowledge:

    Context Free Grammar

    JFLAP User Control Parse Consider the following context-free grammar. (See: cfguucp.jflap)

    V = { A, N, O, S, V } T = { a, d, r, t } S = S S → OV O → AN A → a A → a N → d V → r

  • Use the Brute Force Parse to determine which of the following strings are in this language.

    ● adr ● tdr ● dr ● ar ● aadr

    For example, here are the results for strings “adr” and “ar”.

  • Consider the rejected string “ar”. Why is that string rejected? JFLAP provides the User Control Parse feature to facilitate exploration of string derivations.

    Return to the Grammar Editor and choose Input > User Control Parse.

  • To begin, choose the rule with the start symbol on the left and click Start.

  • This results in showing the current state of the derivation, which is just S.

  • To continue the derivation, select a rule and click on Step. Note that selecting a rule that is not applicable will result in an error message, as shown in the next two images.

  • The following sequence of images demonstrates a potential derivation sequence.

  • Note that at this point, both terminals, a and r, have been produced, but there is a remaining non-terminal, N. There is only one production rule applicable, with N on the LHS.

  • After applying that rule, as shown in the following image, there are no additional productions possible.

    Questions to Think About

    1. What causes each of the rejected strings from the previously specified set to be rejected?

    2. What changes would you make to JFLAP to facilitate exploring rejected strings?