Fermé

compiler design - coding

Part I: Declaration checking

The Mython language has a very simple type system as described in the Mython

specification (assignment#2). There are only three types in Mython: integers,

booleans and strings. Mython has no explicit type declarations or global variables; in

general, we have to determine the type of a variable by the way it is first used in the

code.

o Integers: All parameters passed in Mython are implicitly integers. Another

way for a variable to get integer type is when it is first used on the left side of

an assignment statement where the expression on the right side has type

integer. For example, if the first use of x is x = 3 + 2, then x will have an

integer type and can be used anywhere an integer is expected. An input

statement can also be used to give a variable integer type. All function are

type integer.

o Boolean: The only way for a variable to have boolean type is when it is first

used on the left side of an assignment statement where the expression on

the right side has type boolean.

o Strings: The only way for a variable to have string type is to assign a string to

it on the right side of an assignment statement.

For this part of the assignment, you need to see that all variables that are used in a

Mython have been given a type. A variable cannot be used (on the right side of an

assignment statement, in a condition for a compound statement, used in a print

statement or passed as a parameter) if it hasn't given a type as described above. If

this condition has been violated, print out an error message and the associated line

number. Continue processing. If there is an attempt to give a different type to a

name in some scope, this should also be flagged as an error. No two functions can

share a name. In a given procedure/function, no two local variables or parameter

can share a name. They should also not share a name with their declared scope.

King Saud University

College of Computer and Information Sciences

Computer Science Department

CSC 340: Programming Language and Compilation

Programming Assignment 3: Semantic Analysis

Due Date: December 28, 2016

-----------------------------------------------------------------------------------------------------------

Part II: Checking the Type system

The Mython specification also describes rules for type checking statements and

expression. During parsing, if a type rule is violated, print an error message that

explains the violation (along with associated line number) and continue processing

the input.

o The left and right side of an assignment statement must have the same type.

Once a variable has been given a type, that type cannot change. For example,

the two statement x = 2 followed later by x = true is a violation of Mython's

type system.

o input ( ) has type integer.

o Arithmetic operator (+,-,*,/) only operate on integers and the result is an

integer.

o Relational operation (<,>,<=,>=,<>,==) only operate on integers and result is a

Boolean.

o The expression in if and while statements must have type Boolean.

o Return expression must be type integer.

o Parameters to the print function can be integer, Boolean or strings.

o A function cannot be called until after it has been declared. Since formal

parameters are implicitly integer, actual expression must also be of type

integer. A function call must have the correct number of parameters. All

parameters will be passed by value.

Compétences : Programmation C

Voir plus : due date calculation plsql, due date translation greek, calculate best time ultrasound calculate due date, freelance coding design, due date php script, due date calulator, due date japanese translation, calculate due date sql, sql function terms due date, tfs 2005 customizing due date, javascript function calculate due date, web design montreal getafreelancer date, plsql due date calculation, php mysql coding design template

Concernant l'employeur :
( 2 commentaires ) riyadh, Saudi Arabia

N° du projet : #12695361

8 freelance font une offre moyenne de $20/heure pour ce travail

hbxfnzwpf

I am very proficient in c and c++. I have 16 years c++ developing experience now, and have worked for more than 6 years. My work is online game developing, and mainly focus on server side, using c++ under linux environ Plus

$20 USD / heure
(73 Commentaires)
6.5
utkarshkatiyar19

A proposal has not yet been provided

$20 USD / heure
(153 Commentaires)
6.2
octopus823

Hi, I'm a OS expert experienced C/C++/ObjC developing. I can develop almost kinds of C/C++/ObjC codes for any OS : Windows, Linux, MAC OS X... I can use almost of develop libraries such as QT, MFC, boost... and ant I Plus

$21 USD / heure
(32 Commentaires)
5.6
$22 USD / heure
(27 Commentaires)
5.0
yamaf555

Hello, Dear Employer! I have already read your project description and can meet up all requirements. I have checked technological problems enough of your project. I can't only do it but also i can satisfy your requi Plus

$22 USD / heure
(41 Commentaires)
5.1
amariitism

Hello We are highly motivated young technocrats from IIT(ISM) Dhanbad, India. We are approachable, you can come to us if you have a struggle, we are happy to help. Team TiponTongue IIT(ISM) Dhanbad, India

$20 USD / heure
(2 Commentaires)
2.0
$17 USD / heure
(0 Commentaires)
0.0
$22 USD / heure
(0 Commentaires)
0.0
$22 USD / heure
(0 Commentaires)
0.0
Orpiv

Hi, Hope you're doing well. Over the last 8 years, we have developed a wide range of websites C programming ,java etc . Wordpress Development, Worpdress, Plugin , Plugin Development ,Responsive Website , Mobile Webs Plus

$16 USD / heure
(0 Commentaires)
0.0