onsider the following context-free grammar: Give the four elements of this grammar{T,N,S,P} Show the parse tree that this grammar would assign to :!false or true and false Is this grammar ambiguous?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

onsider the following context-free grammar:

  1. Give the four elements of this grammar{T,N,S,P}
  2. Show the parse tree that this grammar would assign to :!false or true and false
  3. Is this grammar ambiguous?
A-
A
A or A
A and A
!A
true false
Transcribed Image Text:A- A A or A A and A !A true false
Expert Solution
Step 1

The context-free languages are a larger set of languages than the regular languages that we have been studying so far. Context-free languages are particularly important because most programming languages are context-free.

Context-free languages are described by grammars. In this module, we will examine grammars, how they can be used to generate the strings of a language, and how they can be used to parse a string to see if it is in the language.

1) Answer :

A context-free grammar G=(V,T,P,S) is composed of

  • N : a set of Non-terminals (also known as variables), each denoting a set of strings.
  • T : a set of terminal symbols (“terminals” for short) that constitutes the alphabet over which the strings in the language are composed.
  • P : a set of productions, rules that recursively define the structure of the language.
    • A production has the form A→α where
    • A is a variable (one of the symbols in V).
      α is a string of zero or more symbols that may be either terminals or variables.
  • S : a starting symbol. This is a variable that denotes the set of strings comprising the entire language.

For the given grammar :

S → A
A → A+A | A*A | !A | true | false

G = ({A}, {true, false}, P, S)

P = {S → A, A → A+A | A*A | !A | true | false}

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Sorting
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education