Find and investigate an example of a practical problem solved using any of the theoretical concepts discussed in this course (such as state machines, formal grammars, syntax trees or compilers). Your...

1 answer below »
Find and investigate an example of a practical problem solved using any of the theoretical concepts discussed in this course (such as state machines, formal grammars, syntax trees or compilers). Your investigation should highlight the nature of the problem and explain the solution. The discussion should be around 500 words. You will be assessed on: 1.) Novelty [5 marks] You should aim to find an example that was not discussed in class, and that clearly demonstrates how the theory was applied. 2.) Academic presentation and referencing [5 marks] You should use academic language and properly reference your work. 3.) Content [10 marks] The discussion should be clear and concise. You need to provide a general discussion, but should also use figures and examples to explain concepts.


COMP1820 - CODE EXERCISE (Part of Section C of your Logbook) General information: This code exercise will form part of your logbook and should be submitted on Moodle by the logbook deadline. It is to be submitted under the “Code submission” link in the “Assessment” block. Note: It is important that your submission adheres to the specification, as it is automatically marked. Task: Create Flex and Bison files to generate a post-fix notation calculator for Boolean algebra. The calculator should be able to handle Boolean expressions with the input values TRUE and FALSE, together with the operators AND (&), OR (|) and NOT (!). The program should accept keyboard input and exit on the end-of-file character (CTRL+d). Technical Specification: • Calculations happen whenever a newline character is read (i.e. when enter is pressed) • The input accepted should: o cover both capital and lower-case letters for TRUE and FALSE, o also accept 0 for FALSE and 1 for TRUE. o accept only the symbols &, | and ! to denote AND, OR and NOT respectively. The following are examples of valid input values: TrUe fALSE True false truE fAlSe TRUE FALSE true 0 1 The following are all valid operators: & | ! • The compiler should display a generic error message if it is unable to parse the input. • Output should simply be the answer to the expression: TRUE or FALSE (Note: The answers should only be one of these exact strings, in capital letters) Here are some examples: We wish to calculate TRUE AND FALSE INPUT: TRUE FALSE & OUTPUT: FALSE We wish to calculate TRUE OR FALSE INPUT: true 0 | OUTPUT: TRUE We wish to calculate NOT TRUE INPUT: 1! OUTPUT: FALSE We wish to calculate NOT(TRUE AND FALSE) OR FALSE INPUT: tRuE FaLsE & ! fAlSe | OUTPUT: TRUE Upload Specification: • You need to upload two files with the following names: boolcalc.l boolcalc.y • Files should be uploaded as they are -- not zipped, tar-ed or placed in a directory. • Make sure the files you are uploading compile and run correctly and provide the correct output. Notes about C you might find useful: • There are no Boolean primitives in C, but you can use integers to represent these. • Expressions evaluating to 0 is FALSE and non-zero is TRUE. • The Boolean operators in C are denoted as: AND: && OR: || NOT: ! An if-statement has the format if (test expression) { statements to be executed if expression is true } else { statements to be executed if expression is false } More information on C syntax at https://www.cprogramming.com/tutorial/c/lesson2.html
Answered 12 days AfterJun 25, 2021

Answer To: Find and investigate an example of a practical problem solved using any of the theoretical concepts...

Kamal answered on Jul 07 2021
129 Votes
%{
#include
void yyerror(char *);
%}
%%
not return NOT;
and return AND;
or return
OR;
[a-z] {
yylval = *yytext - 'a';
return VARIABLE;
}
[0-1]+ {
yylval = atoi(yytext);
return BOOLEAN;
}
[()=\n] { return *yytext;...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here