Question: COSC 3 1 2 7 : Programming Languages Assignment # 1 It is imperative that you show your work. Academic dishonesty is taken very seriously

COSC 3127: Programming Languages Assignment #1 It is imperative that you show your work. Academic dishonesty is taken very seriously in post-secondary education. All assignments (both source and destination) involved in a cheating incident will receive a mark of 0%. Purpose: The purpose of this assignment is to design the first two phases of a mini compiler for a hypothetical language. This task aims to enhance your understanding of the steps and operations involved in compiler design. Based on the topics covered in class regarding the various phases of the compiler, this assignment requires you to develop a mini compiler in a group of up to three people. The objective is to implement the initial two phases of the compiler, which include the lexical analyzer and the syntax analyzer for the specified language. It is necessary to provide regular and context-free grammars for the design of the lexical and syntax analyzers, along with a Deterministic Finite Automata (DFA) for accepting tokens. The Recursive Descent Parser method will be used to implement the syntax analyzer. This hypothetical language supports variable declarations, assignments, and mathematical operations. Language Specifications: The language supports two data types: integers and real numbers. Variables can be declared with the following format: Var_name: Type; Examples: a: integer; b, c: integer; i, j, k: real; The rules for naming variables are the same as in most programming languages, such as C/C++ and Java: A variable name must only contain alphabets, digits, and underscores. A variable name must start with an alphabet or an underscore; it cannot start with a digit. No whitespace is allowed within the variable name. A variable name must not be any reserved word or keyword. If the naming rules are violated, an error message must be issued. Assignment Operator: The assignment operator can be used as follows: i :=123; a := b; Calculation Operators Supported: The language allows the following arithmetic operators: +(addition),-(subtraction),*(multiplication),/(division), and ^(exponent) The use of a combination of arithmetic operators in an assignment statement is valid. Example: a :=3+ b *(b 12)^7; Operator Precedence: The priority of operators in this language is as follows: Parentheses Exponents Multiplication/Division Addition/Subtraction When writing the computational grammar for the compiler, remember that if multiple operators in an assignment statement have equal priority (such as multiplication and division, or addition and subtraction), the operator appearing further to the left (due to left associativity) takes precedence, as in other programming languages. Note: The purpose of the mini compiler design is token recognition and syntax verification, without the requirement to perform actual computational operations or print results. If the syntax is correct, a compilation success message will be displayed; otherwise, an error message will be issued. Submission Due: November 28,2024 What to Submit: A PDF file containing the following information: Student Name and Student Number Regular and context-free grammars DFA for the lexical analyzer to accept program tokens Recursive Descent Parser functions Source code of the mini compiler implementation, along with examples that include: o Declaring variables o Five valid arithmetic expressions, with messages indicating successful compilation for each o Five invalid arithmetic expressions, with error messages indicating the syntax issues in each expression

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!