Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is the syntax and semantics for a single Boolean expression followed by a period. Write a program which prompts the user to input a

Below is the syntax and semantics for a single Boolean expression followed by a period. Write a program which prompts the user to input a file name which contains the Boolean expression or simply to input the string to be checked (indicate which input method you will use in your comments). You may assume that no input will be longer than 100 characters in length. Expressions may contain white spaces and white spaces should be considered to be delimiters (i.e. a white space between the and > of the implication symbol would be a syntax error). The program should check if the expression in the file is of valid syntax and (if valid) compute the value of the expression. The output should either be an error message or a a message that gives the value of the expression. You must use the techniques taught in the class this is a recursive descent interpreter.

Syntax: (note: for use the lowercase letter v and for use the caret symbol)

Selection Sets

B ::= IT . {~,T,F,(}

IT ::= IT IT_Tail {~,T,F,(}

IT_Tail ::= > OT IT_Tail { >}

::= {.,)}

OT ::= AT OT_Tail {,T,F,(}

OT_Tail ::= AT OT_Tail {}

::= { >,.,)}

AT ::= L AT_Tail {,T,F,(}

AT_Tail ::= L AT_Tail {}

::= {, >,.,)}

L ::= A {T,F,(}

::= ~ L {~}

A ::= T {T}

::= F {F}

::= ( IT ) {(}

Syntactic Domains:

B : Bool stmt

IT : Imply term OT : Or term

AT : And term

IT Tail : Imply tail

OT Tail : Or tail

AT Tail : And tail

L : Literal

A : Atom

Semantic Domain:

b = {T.F} (Boolean values True and False)

Semantic Function Domains:

:Boolstmt b

:Implyterm b

:Orterm b

:Andterm b

:bImplytail b

:bOrtail b

:bAndtail b

: Literal b

:Atom b

Semantic Equations:

( IT. ) = ( IT )

( OTIT Tail ) = (( OT ), IT Tail )

( ATOT Tail ) = (( AT ), OT Tail )

(LAT Tail)=((L),AT Tail)

(b,) = b (where b {T,F})

(F, > OTIT Tail ) = (T, IT Tail )

(T, > OTIT Tail ) = (( OT ), IT Tail )

(b,) = b (where b {T,F})

(T, ATOT Tail ) = T

(F, ATOT Tail ) = (( AT ), OT Tail )

(b,) = b (where b {T,F})

(F,LAT Tail)=F

(T, LAT Tail ) = (( L ), AT Tail ) (L)=if(L)=T thenF elseif(L)=F thenT ( A ) = ( A )

(T )=T

(F )=F

( (IT) ) = (( IT ))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions