

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
lexical analysis and parsing of programming languages.
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!
CENG 442 Project (Part 1)
Assigned: March 04, 2015 Due: March 29, 2015
Definition and Lexical Analysis of a Robot Programming Language
This year's project is about the design of a new programming language for controlling a mobile robot. Suppose that you are working as part of a research team building a robotic platform. Your colleagues in the mechanical engineering department are almost done with the construction of a robot to be deployed in Mars. This robot will be capable of moving foward and back, turning in place, grabbing/releasing objects as well as sending/receiving data to/from a supervisor. The robot also has various sensors to perceive the environment, returning floating point values associated with their measurements. The robot can turn 1 degree at a time, and move forward or back in steps of 1mm. Your team in the CS department is asked to design a Programming Language to for this robot.
The project will be completed in two parts. The first part (this assignment) involves the design of the syntax for your programming language including at least the following components:
o Syntactic components for the top level program definition o Primitive functions: move (both forward and back), turn, grab, release, read sensor given the sensor ID, send, receive. o Variable names, o Assignment operator, o Arithmetic expressions, o Conditional statements (e.g., if-then, if-then,else) o Loops (e.g., for, while), o Syntactic components for program and function definitions and function calls, o Comments
Your design should take the form of a BNF grammar, precisely defining the language based on your token definitions used as terminal symbols. We expect your group to do the following for your solution to this project:
o Give a name to your robot programming language o Include in your report, a summary of tokens that are used by the syntax of your language as terminal symbols o Include in your report, the grammar for your language in BNF form. o With the main components of your language in place, write a scanner (lexical analyzer) using the lex tool available on Linux/Unix systems. The scanner is expected to read the input stream and output a sequence of tokens corresponding to the lexemes as defined above. But, since at this point, you do not have the necessary tools to write a full-blown parser, test your scanner by having it print messages on the screen corresponding to recognized tokens. For example, if your language supports an expression such as ... 1.45+453.43*32.2 ..., it would generate the output ... FLOAT PLUS FLOAT MULT FLOAT ... on the screen.
The second part of the project (to be assigned later) will involve the yacc implementation of a parser for your robot programming language. None of these project stages require you to implement any execution facilities for your language. Both projects are mainly about SYNTAX.
o You will be working on this project in groups of at most three students. Form your group and email me by March 16, 2015. o For both parts of the project, the members of the groups will be the same.
Email your program (the lex description file) along with the report to me by 23:59, March 29,
Your report should contain the following components:
o Name, ID and sections of ALL group members o Verbal definitions of lexical components included in your language. o Description of how the definitions of these components (nontrivial ones such as identifiers etc.) are implemented in lex. o The complete BNF grammar for your language, where the tokens and lexemes for the above components are used as terminal symbols. o An example program, written in your programming language, designed to make the robot do the following:
What to hand in: (Following three items must be in electronic format. Mailed to me (melih@cankaya.edu.tr))