We are here to serve you

[30% discount for US and UK students ! Get 10$ for referring a student in any programming or assignment task]

Lisp


Lisp Question
This project involves completing an interpreter for an imperative language written in a functional language--LISP. A copy of the skeleton interpreter is attached.
To understand this program, it is essential to understand the program state that is carried from one statement to the next as the interpreter executes a program. Consider the sample program that was provided in the requirements:
((assign x to 1) (assign y to (x * 2)) (write x) (write y))
Show what is in the three-element list that contains the program state after the execution of each of the four statements in the above program.
Requirements:
The fourth project involves completing a LISP program hat is provided in the case study of module 5. That program interprets a simple imperative language. The skeleton version provided interprets assignment and write statements and evaluates binary expressions. The following dialog illustrates the execution of a simple program with that version.
>(interpret-program '((assign x to 1) (assign y to (x * 2)) (write x) (write y)) nil)
(1 2)
The complete grammar of the language is provided below in extended BNF:
program ::=
statement_list
statement_list::=
statement|
   ({statement})
statement ::=
assignment_statement|
write_statement|
read_statement|
if_statement|
while_statement
assignment_statement::=
   (assignvariable to expression)
write_statement::=
   (writeexpression)
read_statement::=
   (readvariable)
if_statement::=
   (ifexpression then statement_list1else statement_list2)
while_statement::=
   (whileexpression do statement_list)
expression ::=
variable|
literal|
(unary_operator expression) |
(expressionbinary_operator expression)
Nonterminals are shown in red, terminals in blue and BNF metasymbols are black. You must add the functions to interpret the read, if and while statements and the function to evaluate unary expressions and modify the necessary functions to call them. You are not required to perform any syntax checking on the input. You may assume that the programs are syntactically correct. Explicit input and output should not be used in this program. The main function should accept the input as a parameter. The output should be the value of the main function. In addition, no explicit iteration should be used, recursion must be used in its place.
Answer

; main function creates state containing supplied input and empty
; memory and output, returns output

(defun interpret-program (program input)
    (third (interpret-statement-list program (list '(()) input nil))))

; interprets a single statement if statement-list is a single statement
; recursively interprets all statements if it is a list

(defun interpret-statement-list (statement-list state)
    (cond
        ((null statement-list) state)
        ((atom (first statement-list)) 
            (interpret-statement statement-list state))
        (t (interpret-statement-list (rest statement-list)
            (interpret-statement (first statement-list) state)))))

; determines the type of statement based on the first word
; and calls the appropriate function to interpret it

(defun interpret-statement (statement state)
    (cond
        ((eq (first statement) 'assign)
            (interpret-assignment-statement (second statement)
            (fourth statement) state))
        ((eq (first statement) 'write)
            (interpret-write-statement (second statement) state))
        ((eq (first statement) 'read)
            (interpret-read-statement (second statement) state))
        ((eq (first statement) 'if)
            (interpret-if-statement (second statement)
                                    (fourth statement)
                                    (sixth statement)
                                    state))
        ((eq (first statement) 'while)
            (interpret-while-statement (second statement) (fourth statement)
                                       state))))

; interprets the write statement by evaluating the expression
; and appending its value to the output stream

(defun interpret-write-statement (write-expression state)
    (let
        ((memory (first state))
        (input (second state))
        (output (third state)))
    (list memory input (append output 
        (list (evaluate-expression write-expression state))))))

; interprets the assignment statement by evaluating the expression
; and assigning the value to the specified variable

(defun interpret-assignment-statement (variable expression state)
    (let
        ((memory (first state))
        (input (second state))
        (output (third state)))
    (list (set-value memory variable 
        (evaluate-expression expression state)) input output)))

; interprets the read statement, taking first value from input list
; and assigning the value to the specified variable

(defun interpret-read-statement (variable state)
  (let
        ((memory (first state))
         (input (second state))
         (output (third state)))
    (list (set-value memory variable (first input))
          (rest input)
          output)))

; interpets the while statement, evaluating its expression and, if its
; value is true, interpeting statement list and interpeting while
; statement again.

(defun interpret-while-statement (expression statement-list state)
  (let
        ((memory (first state))
         (input (second state))
         (output (third state)))
      (let ((condition (evaluate-expression expression state)))
        (cond
          (condition
           (interpret-while-statement expression statement-list
                                      (interpret-statement-list statement-list
                                                                state)))
          (t
           state)))))

; interprets the if statement, evaluating its expression, and if its value
; is true, interprets true-statement-list, and false-statement-list otherwise

(defun interpret-if-statement (expression
                               true-statement-list
                               false-statement-list
                               state)
  (let
        ((memory (first state))
         (input (second state))
         (output (third state)))
      (let ((condition (evaluate-expression expression state)))
        (cond
          (condition
           (interpret-statement-list true-statement-list state))
          (t
           (interpret-statement-list false-statement-list state))))))


; evaluates an expression by checking whether it is a literal, a
; variable, a binary or unary expression

(defun evaluate-expression (expression state)
    (cond
        ((numberp expression) expression)
        ((atom expression) (get-value (first state) expression))
        ((eq (length expression) 2)
            (evaluate-unary-expression expression state))
        ((eq (length expression) 3)
            (evaluate-binary-expression expression state))))

; evaluates a binary expression by first evaluating the subexpressions
; and then applying the operator to those subexpressions

(defun evaluate-binary-expression (expression state)
    (let
        ((left-operand (evaluate-expression (first expression) state))
        (operator (second expression))
        (right-operand (evaluate-expression (third expression) state)))
    (apply operator (list left-operand right-operand))))

; evaluates an unary rexpression by evaluating the subexpression
; and then applying the operator to the subexpression

(defun evaluate-unary-expression (expression state)
  (let
      ((operator (first expression))
       (operand (evaluate-expression (second expression) state)))
    (apply operator (list operand))))

; adds the variable-value pair to the head of the association list
; that comprises the current state of the memory.  Previous 
; occurences of that variable are not removed.

(defun set-value (memory variable value)
    (cons (list variable value) memory))

; retrieves the value of a variable from the association list
; that comprises the current state of the memory 

(defun get-value (memory variable)
    (second (assoc variable memory)))




Assignment






Login | Register | Live Chat













Project help and assignment help for international students via email

---------------------------------------------------------------------------------------------------------------------------------------------------
We offer assignment, project, and programming aids similar to distant learning programs in the US, UK, Australia, Canada, Europe, UAE and other countries. All you have to do is send us your questions and assignments with a specified deadline via email. We will check your assignment and will get back to you with the quote. If you accept our quote from the pay or escrow service through moneybookers.com, we will start working on the project. As soon as you receive your work and you are satisfied with the quality, you can release the full payment or pay half of it if you are a first time customer. Escrow service makes your money safe and secure.

All mathematics assignments will be sent to your mail in 2 formats: in word document and scanned, handwritten copy. It is your choice as to how you want to receive the file. For programming projects, we will send the finished code after full testing which includes detailed comments and screen shots of the output as a proof. After receiving the work, you will have 1 week time to clear all your issues in case you didn't get the right results. If that is the case, you can get refund from us. After 1 week, the refund policy is considered void.

In order to ensure delivery of quality work to our clients, we have devised and implemented a comprehensive Quality Assurance system. There are a number of tools and techniques which we apply to make sure that the projects, assignments and tutoring techniques we are using are of the highest quality and address the need of our audience in an effective manner. Here is a brief overview of how Quality Assurance Systems at Quality Assignment Help work to provide you the maximum value for the money you give for your projects and assignments


Computer programming assignment help includes the following areas

------------------------------------------------------------------------------
C++, C#, Java, Delphi, Assembly, Visual Basic, Lisp, SAP, Algorithm;

AJAX, PHP, JavaScript, HTML, ASP/ASP.net;

Silverlight, Adobe Flex, Adobe Flash, Coldfusion;

Python, Perl, Ruby/Ruby on Rails;

MS SQL, MySQL, Oracle;

MathCAD, Matlab LabVIEW, Mathematica.

All the programming Languages

Quality Assignment Help Expert offers the best programming homework help:

degree holding programming experts with years of experience in their respective fields;

at any academic levels - high school, college, or university and even masters degree levels;

payment, feedback, and contact methods are safe, secure and reliable;

We provide you with safety and confidentiality. We never share your information with anyone for any reason.

*Field can not be empty
*Signup as


Name*
Email*
 
Password*
Phone*
Address*
Upload the requirements
Name*
Ph no *



Plagiarism Check

------------------------------------------------------------------------------
At Quality assignment help, we utilize the best quality plagiarism check programs available, like Turnitin, to assure that once you get your work done by Quality Assignment Help, you are sure of your success.



Review System

We offer a reviewing system which makes sure that all your projects and assignments are coherent with the given instructions. We keep a full database of each project and assignment and make sure that the task is completed according to the slightest needs, not missing a single area according to your instructions.

Project-Live-Help is one of the branches of our company which provides services in same field.











Best grade in your exams , academics and projects via email





We offer assignment, project, and programming aids similar to distant learning programs in the US, UK, Australia, Canada, Europe, UAE and other countries. All you have to do is send us your questions and assignments with a specified deadline via email. We will check your assignment and will get back to you with the quote. If you accept our quote from the pay or escrow service through moneybookers.com, we will start working on the project. As soon as you receive your work and you are satisfied with the quality, you can release the full payment or pay half of it if you are a first time customer. Escrow service makes your money safe and secure.
All mathematics assignments will be sent to your mail in 2 formats: in word document and scanned, handwritten copy. It is your choice as to how you want to receive the file. For programming projects, we will send the finished code after full testing which includes detailed comments and screen shots of the output as a proof. After receiving the work, you will have 1 week time to clear all your issues in case you didn't get the right results. If that is the case, you can get refund from us. After 1 week, the refund policy is considered void.
In order to ensure delivery of quality work to our clients, we have devised and implemented a comprehensive Quality Assurance system. There are a number of tools and techniques which we apply to make sure that the projects, assignments and tutoring techniques we are using are of the highest quality and address the need of our audience in an effective manner. Here is a brief overview of how Quality Assurance Systems at Quality Assignment Help work to provide you the maximum value for the money you give for your projects and assignments:

Computer programming assignment help includes the following areas:

C++, C#, Java, Delphi, Assembly, Visual Basic, Lisp, SAP, Algorithm;
AJAX, PHP, JavaScript, HTML, ASP/ASP.net;
Silverlight, Adobe Flex, Adobe Flash, Coldfusion;
Python, Perl, Ruby/Ruby on Rails;
MS SQL, MySQL, Oracle;
MathCAD, Matlab LabVIEW, Mathematica.
All the programming Languages

Quality Assignment Help Expert offers the best programming homework help:
degree holding programming experts with years of experience in their respective fields;
at any academic levels - high school, college, or university and even masters degree levels;
payment, feedback, and contact methods are safe, secure and reliable;
We provide you with safety and confidentiality. We never share your information with anyone for any reason.


Evaluation by Subject Specialists


Quality Assignment Help has a team of writers as well as experts in their respective areas of study so that we can evaluate the project with the critical eye before your instructor evaluates your project or assignment. Similarly, for the test preparation, we have experts who are adept in designing test questions and they will not only give you the exact answers at the end of each training session but will explain each and every ambiguity there is to the test!


Plagiarism Check


At Quality assignment help, we utilize the best quality plagiarism check programs available, like Turnitin, to assure that once you get your work done by Quality Assignment Help, you are sure of your success.


Review System


We offer a reviewing system which makes sure that all your projects and assignments are coherent with the given instructions. We keep a full database of each project and assignment and make sure that the task is completed according to the slightest needs, not missing a single area according to your instructions.


Project-Live-Help is one of the branches of our company which provides services in same field.

How do Compilers work? Understanding how the software works

How do Compilers work? Understanding how the software works

The compiler is a program that is used to change the source code that was written in a particular language into another language. The transformation of the source code is necessary in order to create an executable program. This is very useful nowadays since there are so many operating systems nowadays, that it is necessary to have a compiler to make it possible that the program runs on particular computers. This is known as a cross compiler. The compiler has a number of uses. It can be used to do lexical analysis, parsing, code generation, optimization and many others.

A compiler comes with different parts. They help in transforming or bridging the high level language into a machine readable code. What it does is determine if the syntax of the programs across is all correct, create an object code, organize the run time and format an output depending on conventions. It consists of a front end where semantics and syntax are checked. This is also where the type checking is being done. When the program enters the middle end, the optimization will occur and here, the useless codes are removed. The back end is used to translate the IR from the middle end. The variables will also be selected for particular registers.

Some programming languages require a compiler while others don't. One example of language that requires a compiler is PHP. JavaScript on the other hand does not require a particular compiler. With PHP, it is normally called a server based language and it has to communicate with the server on the web so that the file systems can be accessed. To do this, the compiler will transform the code with something that can be understood by the web browser. When you look at something like JavaScript, we are looking at a client based language that is executed by the browser. In this case, the browser is the compiler.

Let us look at the C and C++ and how the compiler works on them. The code cannot run on its own since it is standing on the source file.  The code must be translated to something that the machine can read. What the compiler does is to check all the syntax on the program. It is being read as 1 and 0.

There are so many kinds of compilers that are being used depending on the programming language that is used by the programmer. There are compilers for Basic, C, C#, C++, Common Lisp, ECMAScript, Fortran, Haskell, Pascal, Scheme, SmallTalk, CIL and Open Source. Most of not all are available for Windows OS and a small portion to Unix types. There are open source licenses, proprietary licenses and others. It is necessary to use the one that is most appropriate for your intended use. Nonetheless, there are several active compilers that can be used. It is necessary to have a solid understanding of the compilers. This is a key piece of software that is necessary to transform your elaborate code to a functional program.
hi

We are available 24 x 7 to help you with your assignments, projects, reports and tutoring needs. You do not need to look for the differences in time zones at all. In case you need some task to be completed urgently, we are just a few clicks away!

You can contact us through email: tutorapex@gmail.com


You can call us at skype ID : dawnin123

In case you need some immediate assistance and response, our online helpdesk is there to solve all your issues.


Do not forget to ask for you PIN number as it makes easy to track the status of your assignment and project. We identify the project or assignment with the help of this PIN number to provide post sales services efficiently.

How do Compilers work? Understanding how the software works








The compiler is a program that is used to change the source code that was written in a particular language into another language. The transformation of the source code is necessary in order to create an executable program. This is very useful nowadays since there are so many operating systems nowadays, that it is necessary to have a compiler to make it possible that the program runs on particular computers. This is known as a cross compiler. The compiler has a number of uses. It can be used to do lexical analysis, parsing, code generation, optimization and many others.

A compiler comes with different parts. They help in transforming or bridging the high level language into a machine readable code. What it does is determine if the syntax of the programs across is all correct, create an object code, organize the run time and format an output depending on conventions. It consists of a front end where semantics and syntax are checked. This is also where the type checking is being done. When the program enters the middle end, the optimization will occur and here, the useless codes are removed. The back end is used to translate the IR from the middle end. The variables will also be selected for particular registers.

Some programming languages require a compiler while others don't. One example of language that requires a compiler is PHP. JavaScript on the other hand does not require a particular compiler. With PHP, it is normally called a server based language and it has to communicate with the server on the web so that the file systems can be accessed. To do this, the compiler will transform the code with something that can be understood by the web browser. When you look at something like JavaScript, we are looking at a client based language that is executed by the browser. In this case, the browser is the compiler.

Let us look at the C and C++ and how the compiler works on them. The code cannot run on its own since it is standing on the source file.  The code must be translated to something that the machine can read. What the compiler does is to check all the syntax on the program. It is being read as 1 and 0.

There are so many kinds of compilers that are being used depending on the programming language that is used by the programmer. There are compilers for Basic, C, C#, C++, Common Lisp, ECMAScript, Fortran, Haskell, Pascal, Scheme, SmallTalk, CIL and Open Source. Most of not all are available for Windows OS and a small portion to Unix types. There are open source licenses, proprietary licenses and others. It is necessary to use the one that is most appropriate for your intended use. Nonetheless, there are several active compilers that can be used. It is necessary to have a solid understanding of the compilers. This is a key piece of software that is necessary to transform your elaborate code to a functional program.

Programming languages and type systems: types and uses


There are literally hundreds of programming languages that are in use nowadays. This is an artificial language that is used to express the computations that can be performed on a computer or other similar devices. The language can be used to make programs that are used to control machine behavior. They can also be used to express the algorithms with precision and express human communication in a digital fashion.

Let us understand the type system and how it works in the programming languages. The type system defines how the language classifies certain expressions. These aspects are called types. The system also determines how the types interact and how they can be manipulated. The type system ensures that the programs written in a certain language are correct. There are some downsides to the use of the type system but they are easily fixed by so called loopholes in the programming languages. A number of programmers use casts so that they can easily use a normally, disallowed operation between the various types.

If you look at the type languages, usually, they are used to perform type checks. In, more functional languages, type annotations can already be skipped by the programmer. There are several types’ languages that are being used and they have their own particular purpose in the utilization of programming languages.

The programming languages that are considered as typed when there is a specification of the type operations in which it is applicable unless implied that it is not for other types.

Static type is when all the expressions have their particular types that are determined by the currently running program. That means it will only pass through a function that has been created to accept a particular type. They can either be type inferred or manifested. The first one requires a compiler to infer the expressions. The latter one requires the programmer to write the types in particular positions.  You can see this in C++, Java and C#.

Dynamic type is also known as latent and they are associated with the runtime values compared to static that is about textual expressions. You can see this in JavaScript, Ruby, Python and Lisp.

Weak type can be treated as another kind of type. For example, a string can be detected as a number. In some cases, this is useful but errors could happen upon compiling or at run time. This can be seen in languages like JavaScript and Perl.

Strong type is the one that prevents the errors that could happen in weak typing. They are the ones we call as type safe. One of the more popular statically typed languages is C.

Understanding the different types in a programming language, be it JavaScript, C++, Perl or Java provides insight to the programmer about the use of such languages and their nature. There are many other elements of programming languages like semantics and standard library. With hundreds and even thousands of languages available, it would be a good practice to understand what makes them different in terms of type.