Is the input program a valid simple C program

Assignment Help Programming Languages
Reference no: EM132268870

Programming Languages Project - Parsing simple C programs

Assignment: F# program to parse simple C programs

This is part 1 of a two-part programming project in F#. Here in part 1, we're going to parse simple C programs using recursive descent, and produce three results:

1. Is the input program a valid simple C program? True or false

2. If the program is not valid, a syntax error message of the form "expecting X, but found Y".

3. If the program is valid, an equivalent simple ASM program.

Note that "simple C" is really very simple C --- no pointers, no arrays, no types other than integer, no loops, very simple expressions, etc. Here's an example simple C program ----------->

Regarding bullet #3 above... If the input program is valid, then the result is an equivalent simple ASM program. Given the simple C program shown to the right, the equivalent simple ASM program is shown below. Notice that simple ASM is a list of lists, where each sub-list denotes one instruction: $ASSIGN, $DECL, $EMPTY, $IF, $INPUT, and $OUTPUT.

BNF definition of simple C

What follows is the BNF definition of the simple C syntax. Notice that the first rule ends with $ --- the EOF token. In other words, a valid simple C program ends with } followed immediately by EOF.

Recursive descent parsing

In class on Monday we introduced the concept of recursive descent parsing (PDF, PPT). The idea is to write a function for each rule in the BNF, where each rule parses that aspect of the language. In the case of simple C, there will be functions for <stmt>, <empty>, <vardecl>, <input>, <output>, etc. When writing a given function, the approach is to match each token and call the function for each rule.

Your job is to write the compiler.parser.parse function.  BTW, the name of the simple C input file is passed as a command-line argument.

Requirements -

No imperative programming. In particular, this means no mutable variables, no loops, and no data structures other than F# lists and tuples. Use recursion and higher-order approaches, though you must adhere to the recursive descent approach, which implies recursion is the dominant strategy. Do not change "main.fs" nor "lexer.fs", you must work with those components as given. Modify and extend only the parser component in "parser.fs".

Attachment:- Assignment File.rar

Reference no: EM132268870

Questions Cloud

Ethical standards as related to financial activity : Although such practices may not be considered unlawful, they raise questions regarding integrity and high ethical standards as related to financial activity
Examine the relation between running a business : Your preparation should focus on the characteristics of capitalism and socialism, as well as other business concepts presented in the required material.
How is position and personal power defined : How is position and personal power defined in your current or in a past employment environment?
What is percentage of them had pancreaticcancer : PH 384: Introduction of Epidemiology: Of people who do not take SUCRALOSE, what is percentage of them had pancreaticcancer?
Is the input program a valid simple C program : CS 341 Programming Languages Project - Parsing simple C programs. Assignment: F# program to parse simple C programs
Christian and the low cost energy strategy : Discussion Topic: The Christian and the low cost energy strategy. If a Christian pursues business activities that pursue religious values of justice and love
Relationship between creativity and innovation : What is the relationship between creativity and innovation? How can we build our own ability to create & innovate?
Implementing competitive strategy : Describe the defensive and offensive competitive actions a company may utilize as a method for market location.
Types of strategies underpinning csr decisions : 1. How do the concerns for primary stakeholders differ from those for secondary stakeholders?

Reviews

len2268870

3/28/2019 10:07:39 PM

Electronic Submission and Grading - Grading will be based on the correctness of your compiler. We are not concerned with efficiency at this point, only correctness. Note that we will test your compiler against a suite of simple C input files, some that compiler and some with syntax errors. Make sure you name appears in "parser.fs". The grade reported by Gradescope will be a tentative one. After the due date, submissions will be manually reviewed to ensure project requirements have been met. Failure to meet a requirement --- e.g. use of mutable variables or loops --- will trigger a large deduction.

len2268870

3/28/2019 10:07:33 PM

When you are ready to submit your program for grading, login to Gradescope and upload your "parser.fs" source file. You can upload your entire program, but we are only going to run and test your parser component; this implies you cannot change the main program, nor the lexical analyzer. You have unlimited submissions, and Gradescope keeps a complete history of all submissions you have made. By default, Gradescope records the score of your last submission, but if that score is lower, you can click on "Submission history", select an earlier score, and click "Activate" to select it. The activated submission will be the score that gets recorded, and the submission we grade. If you submit on-time and late, we'll grade the last submission (the late one) unless you activate an earlier submission.

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd