Completed

small parser

Write a parser for the following grammar given in EBNF form, which is used to represnt the syntax of boolean formulae of a logic language: -> [ OR ] -> [ AND ] -> | NOT | () As it can be seen from the grammer, in these expressions OR operator has the lowest precedence, AND operator has higher precedence, and finally NOT operator has the highest precedence. Paranthesis override all the precedences. is any string up to 3 characters from of an alphabet of small letters. Its syntax can be defined as follows: -> {a,...,z} [ {a,...,z} [ {a,...,z} ] ] Your parser should detect the first syntax error in the grammer and print the prefix of the expression up to that token. If the expression is correct, then, it should display the boolean variables one by one in order the user to enter their values as 0 or 1 to be interpreted as FALSE and TRUE respectivaly. Then, your program should evaluate the boolean formula by using the given truth values and produce the result as TRUE or FALSE as an output. Three operators AND, OR, NOT, paranthesis and, boolean variables are the only tokens that you can expect in your input. Any other string should treated as an "unknown token". There are no other keywords, program structures, variables, or literals. Input will be just a single line, and there could be exactly one blank as a delimeter between the tokens. Below there are some example inputs and outputs. Example 1: ========== INPUT ----- NOT p AND NOT ( p OR qp ) This boolean formula is syntactically correct. After detecting it, your program should display p and qp as variables to the user. If the user enters (FALSE) 0 for p, and (FALSE) 0 for qp, the folowing output will be produced: OUTPUT ------ TRUE If the user enters (TRUE) 1 for p, and (FALSE) 0 for qp, the following output will be produced: OUTPUT ------- FALSE Example 2: ========== INPUT ----- NOT p OR NOT NOT q AND ( p NOT OR q ) Since there is a syntax error, the ouput should be a string upto the first syntax error. OUTPUT ------ NOT p OR NOT NOT q AND (p NOT Example 3: ========== INPUT ----- NOT p OR NOT NOT q AND ( p OR qrst ) Since the last boolean variable violates the syntax, it should be detected. OUTPUT ------ NOT p OR NOT NOT q AND (p

## Deliverables

Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. Complete copyrights to all work purchased.

## Platform

windows or unix system

Skills: C Programming, Engineering, Java, MySQL, PHP, Software Architecture, Software Testing

See more: variable programming, using expressions, used structures, unix programming language, the first programming language, syntax programming, syntax in programming, string prefix, q programming language, programming variables, programming variable, programming syntax, programming structures, programming operators, programming operator, programming language syntax, programming expression, prefix string, prefix of a string, operator code

About the Employer:
( 10 reviews ) United States

Project ID: #2839875

Awarded to:

kasperindia

See private message.

$29.75 USD in 14 days
(35 Reviews)
3.9

7 freelancers are bidding on average $52 for this job

cserg

See private message.

$29.75 USD in 14 days
(23 Reviews)
5.3
smartpin

See private message.

$34 USD in 14 days
(60 Reviews)
5.0
hardwiredvw

See private message.

$51 USD in 14 days
(19 Reviews)
4.8
leepwo

See private message.

$85 USD in 14 days
(41 Reviews)
4.7
sysg

See private message.

$68 USD in 14 days
(25 Reviews)
4.6
uasoftware

See private message.

$68 USD in 14 days
(1 Review)
0.0