build Lexer-Parser
Budget: $10 – $30 USD
For this assignment, you will use FLex or Lex for the lexical part of the task and Yacc or Bison for writing a parser for a simple language described as:
P → S; P| S
S→ print | push int | pop | add |mul | sub |div
Where add, mul, sub, and div stand for operations +, *, -, and /, respectively.
The language defines a simple calculator the uses the stack evaluation model to compute expressions. For example, to evaluate the expression 5+7 and print the result, we write the statements
push 7
push 5
add
print
You will use FLex to capture the tokens of the language. And Yacc or Bison to parse and interpret the statement. The result is a simple calculator that uses the stack evaluation model.
The result of your work is a C program that can take statements written in the above grammar such as the example statements above.
P → S; P| S
S→ print | push int | pop | add |mul | sub |div
Where add, mul, sub, and div stand for operations +, *, -, and /, respectively.
The language defines a simple calculator the uses the stack evaluation model to compute expressions. For example, to evaluate the expression 5+7 and print the result, we write the statements
push 7
push 5
add
You will use FLex to capture the tokens of the language. And Yacc or Bison to parse and interpret the statement. The result is a simple calculator that uses the stack evaluation model.
The result of your work is a C program that can take statements written in the above grammar such as the example statements above.