homework6 - CprE 488 Embedded Systems Design Homework 6,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CprE 488 Embedded Systems Design Homework 6, Fall 2006 Name: Brad Smith Lab Section: Tuesday 6-9 1. [10] In this question you will write a simple scanner (lexical analyzer) using a GNU software tool called “flex”. A typical compiler has several working phases: scanning and parsing, machine- independent optimization, and machine-dependent optimization. The purpose of a scanner is to break an input stream into tokens; for example, “a = b1 + c2;” will be broken into six tokens: “a”, “=”, “b1”, “+”, “c2”. Download token.lex from WebCT that comes with this homework onto a Linux machine (e.g. ). If you download and upload through a Windows machine, Windows may convert the file into DOS text format. Use “dos2unix token.lex” on the Linux machine to convert it back to UNIX text format . Run the following command to generate the scanner: flex –otoken.c token.lex gcc –o token token.c Then run “./token” and give it some testing inputs to see how it identifies tokens. Revise token.flex such that it will identify new function keywords log , sin , cos , and tan . It should report that a function is found followed by the function name. The file is self-explanatory, and you may read the GNU documentation about flex (google “gnu flex”) for extra help. Build and run your new scanner and give it sufficient testing inputs. Cut and paste the testing output in the following space. Submit your new “token.lex” with the homework. [bradsm@linux-1 Homework6]$ ./token sin A function: sin tan A function: tan log A function: log logs An identifier: logs sins An identifier: sins coseses An identifier: coseses
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2. [20] In this question you will use another GNU software tool called “bison” to
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/27/2008 for the course CPRE 488X taught by Professor Zhang during the Spring '08 term at Iowa State.

Page1 / 5

homework6 - CprE 488 Embedded Systems Design Homework 6,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online