Question: BNF An application you are working on requires the implementation of expressions in propositional logic, consisting of the following components: true, false : logical constants

BNF

An application you are working on requires the implementation of expressions in propositional logic, consisting of the following components: true, false : logical constants &, |, -> : binary operators for logical AND, OR and IMPLIES (, ) : parentheses

Examples: (true & false) -> false | true -> false, false -> (true & false) & (true -> false) Assume that the following lex specification file is given to recognize and send to yacc, the tokens TRUE, FALSE, AND, OR, IMPLIES, LP, RP

%% true return(TRUE); false return(FALSE); & return(AND); | return(OR); -> return(IMPLIES); ( return(LP); ) return(RP); . return(yytext[0]);

Write a yacc specification file such that strings in the above language are recognized, following the precedence and associativity rules given below: o Expressions enclosed in parentheses should have highest priority as usual. o Precedence order of operators (from highest to lowest): AND, OR, IMPLIES. o Associativity: AND is left, OR is left, IMPLIES is right associative.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!