Explore BrainMass

Explore BrainMass

    Generic Programming Language example

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    I am trying to write a grammar for the language consisting of strings that have n copies of the letter a followed by the same number of copies of the letter b, where n > 0. For example, the strings ab, aaaabbbb, and aaaaaaaabbbbbbbb are in the language but a, abb, ba, and aaabb are not.

    I need to see this worked.

    © BrainMass Inc. brainmass.com March 4, 2021, 6:26 pm ad1c9bdddf
    https://brainmass.com/computer-science/programming-languages/generic-programming-language-example-44804

    Solution Preview

    Consider the following Grammar on {a,b} with start symbol S.

    S->ab
    S->aSb

    for n=1, clearly ab is in the language

    suppose it ...

    Solution Summary

    Write a grammar for the language consisting of strings that have n copies of the letter a followed by the same number of copies of the letter b, where n > 0.

    $2.49

    ADVERTISEMENT