Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Simple Lisp Interpreter (Bison & Flex Programming) 1. Design and implement the language for the following simple Lisp interpreter 2. Language design and implementation 2.0
Simple Lisp Interpreter (Bison & Flex Programming) 1. Design and implement the language for the following simple Lisp interpreter 2. Language design and implementation 2.0 One statement (Lisp-expression) per line. The return value of each statement will be output to console 2.1 (stop) to terminate the program 2.2 constants: a number (the type of a number is double) 2.3 list expression and functions for basic arithmetic (+,-, *1+,L, where 1+ is to increment 1, 1- is to decrement 1 (+12) (+12 3 4) is exponent (that is, 2 3) is 2 to the power of 3 12) (-34)) 2.4 variable (atom) The length of a variable-name can be up to 255 characters long Variable name begins with an alphabet and followed by alpha-numeric characters. Support a symbol table to handle many variable entries (with C++ map) A variable is either undefined or set for a number (type double). 2.5 let statement to set a variable with a number (to be converted to double), for example, (let x 15) 2.6 print function, for example (print a) this will output the value of the atom a. If not set, then "undefined" will be printed. (let a 1) :; this will print a number 1 (print (+ a 10.2)) 2.7 binary-relational (comparison) operators with two operands (numbers) for the following comparison: EQ, LT, LE, GT, GE, NE for equal to, less than, less than, greater than, greater than or equal to, or not equal which is resulting in 0 (which means false) or non-zero (which means true) (EQ 1 2)=> 0 (EQ 11)->1 which means false which means true 2.8 if-list in (if condition then expression else expression), for example, (if (EQ a 1)1)f a-1 then return 1 (if (EQ a 1) 12) (if (GT a 1) (+a 1)(-a 1)) ifa-1 then return 1 else return 2 2.9. comment";" (as in lisp to ignore the rest of the line) 2.10 (symbol-table) will print the content of the symbol-table, in name-value (sorted by its name) 2.11 Support C-like integer-number with the base of either 10 or 8 (octal) Simple Lisp Interpreter (Bison & Flex Programming) 1. Design and implement the language for the following simple Lisp interpreter 2. Language design and implementation 2.0 One statement (Lisp-expression) per line. The return value of each statement will be output to console 2.1 (stop) to terminate the program 2.2 constants: a number (the type of a number is double) 2.3 list expression and functions for basic arithmetic (+,-, *1+,L, where 1+ is to increment 1, 1- is to decrement 1 (+12) (+12 3 4) is exponent (that is, 2 3) is 2 to the power of 3 12) (-34)) 2.4 variable (atom) The length of a variable-name can be up to 255 characters long Variable name begins with an alphabet and followed by alpha-numeric characters. Support a symbol table to handle many variable entries (with C++ map) A variable is either undefined or set for a number (type double). 2.5 let statement to set a variable with a number (to be converted to double), for example, (let x 15) 2.6 print function, for example (print a) this will output the value of the atom a. If not set, then "undefined" will be printed. (let a 1) :; this will print a number 1 (print (+ a 10.2)) 2.7 binary-relational (comparison) operators with two operands (numbers) for the following comparison: EQ, LT, LE, GT, GE, NE for equal to, less than, less than, greater than, greater than or equal to, or not equal which is resulting in 0 (which means false) or non-zero (which means true) (EQ 1 2)=> 0 (EQ 11)->1 which means false which means true 2.8 if-list in (if condition then expression else expression), for example, (if (EQ a 1)1)f a-1 then return 1 (if (EQ a 1) 12) (if (GT a 1) (+a 1)(-a 1)) ifa-1 then return 1 else return 2 2.9. comment";" (as in lisp to ignore the rest of the line) 2.10 (symbol-table) will print the content of the symbol-table, in name-value (sorted by its name) 2.11 Support C-like integer-number with the base of either 10 or 8 (octal)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started