Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using PLY, write an interpreter for the language of LISP expressions. A LISP expression is defined as follows: A number (integer as well as fractional)

Using PLY, write an interpreter for the language of "LISP expressions".

A LISP expression is defined as follows:

  1. A number (integer as well as fractional) is a LISP expression.
  2. if E1 and E2 are LISP expressions then so are (+ E1 E2), (- E1 E2), (* E1 E2), and (/ E1 E2).
  3. if L is a LIST expression (defined below) then (car L) is a LISP expression.
  4. if B is a BOOLEAN expression and E1 and E2 are LISP expressions then (if B E1 E2) is a LISP expression.

A LIST Expression is defined as follows:

  1. if E1, E2, ..., En are LISP expressions where n>=0 then (E1 E2 ... En) is a LIST expression.
  2. if L is a LIST expression then (cdr L) is a LIST expression.
  3. if E is a LISP expression and L is a LIST expression then (cons E L) is a LIST expression.

A BOOLEAN expression is defined as follows:

  1. True and False are BOOLEAN expressions.
  2. if E1 and E2 are LISP expressions then (> E1 E2), (>= E1 E2), (< E1 E2), (<= E1 E2), (= E1 E2), and (<> E1 E2) are BOOLEAN expressions.
  3. if B1 and B2 are BOOLEAN expressions then so are (not B1), (and B1 B2), and (or B1 B2).

PLEASE I NEED THE PLY PARSER (Python)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

ISBN: 1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

What strategies can a nation use to increase its economic growth?

Answered: 1 week ago

Question

connected with any particular community cause?

Answered: 1 week ago

Question

=+j What rules will apply to the process of negotiations?

Answered: 1 week ago