Please Write Recursive Descent Parser Including Lexical Analyzer Following Ebnf C Python P Q37076773

Please write a recursive descent parser (including a lexicalanalyzer) for the following EBNF in C and Python. Your programcodes should be runnable.

<exprs> -> <expr>; {<expr>;}

<expr> -> <term> { (+ | -) <term> }

<term> -> <factor> { (*|/ ) <factor> }

<factor> -> <exp> {^ <exp>}

<exp> -> id | int_lit | real_lit | (<expr>)

where,

^ indicates the power operation, id is a legal identifier name,int_lit represents any positive integer number, and real_litrepresents any positive floating-point number.

Input and output examples:

Input:

x ^ (y+1) – x/2.5 + z;

sum + total * 10;

Output:

parsing succeed

Input:

3 + x*y);

Output:

parsing fail

Note 1: Please name your input file as “input.txt”

Note 2: Try

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.