Make sure your project is running. Research assistant, who will do the control, should be able to run your project on his\herown computer without any problems. It is not enough to have the project running on your computer and it will not be accepted as an excuse. Therefore, make the necessary explanations (if any) clearly.
Objective: BİL240 PROGRAMMING LANGUAGES Tutorial #1 && 2: “Lexical Analysis and Parsing” Deadline: 16 March 2015 Objective: To learn the lexical and syntax analysis of context-free grammars using lex&yacc and to design a syntax analyzer for your own pogramming language. Background Information: Read “lexyacc.pdf” in the course homepage. Implementation: You will design a lexical and syntax analyzer for your own programming language. Give some rules for your programming language and call it as MPL (My Programming Language). For example, your rules may be as; - all programs must start with “begin” and end with “end” - all commands must be ended by “;” - all variables must be declared just after “begin” in the following format; int: i num; float: fl; - three types exist; “int”, “float”, “char” - variables names may be any alphanumeric string, but they must start with a letter - statements between “begin” and “end” can be either a variable declaration or an assignment - an assignment includes four type of operators; +,-,*,/. - the number of variables or constants in an expression is unlimited - the presedence of operators given as.............. - ........ - .etc The minimum requirements are: a well defined regular grammar for variable names, rules for variable declerations, at least 4 arithmetic, 2 logical and 2 comparison operators with their presedence and associativity rules, at least one conditional statement (like if, switch) and at least one loop structure (like for, while, do-while, repeat-until...). Instead of using the grammar for C langugae, try to bring new ideas for your language. After writing CFG rules for your language, design and implement a syntax analyzer for it. This analyzer will include a lex source (e.g mpl.l), a yacc source (e.g mpl.y) and example inputs (source codes written in your language, e.g myprog.mpl). To test your analyzer, follow the steps below; $ lex mpl.l $ yacc mpl.y $ gcc –o mpl y.tab.c –lfl $ mpl < myprog.mpl in the last step, if there is no syntax error in myprog.mpl, the program should give an “ok” message, otherwise, a “syntax error” message. check your program for correct and wrong inputs. note: do not deal with any semantic rule, just give syntax rules! report: your report should include; (1) description of the rules which you designed (in your own words) (2)details of your grammar in bnf or ebnf notation, (3)code descriptions, (4)the bil240 programming languages tutorial #1 && 2: “lexical analysis and parsing” content of mpl.l, mpl.y files and an example myprog.mpl file, (5)any explanation which clarifies that you made your assingment with your own effort. myprog.mpl="" in="" the="" last="" step,="" if="" there="" is="" no="" syntax="" error="" in="" myprog.mpl,="" the="" program="" should="" give="" an="" “ok”="" message,="" otherwise,="" a="" “syntax="" error”="" message.="" check="" your="" program="" for="" correct="" and="" wrong="" inputs.="" note:="" do="" not="" deal="" with="" any="" semantic="" rule,="" just="" give="" syntax="" rules!="" report:="" your="" report="" should="" include;="" (1)="" description="" of="" the="" rules="" which="" you="" designed="" (in="" your="" own="" words)="" (2)details="" of="" your="" grammar="" in="" bnf="" or="" ebnf="" notation,="" (3)code="" descriptions,="" (4)the="" bil240="" programming="" languages="" tutorial="" #1="" &&="" 2:="" “lexical="" analysis="" and="" parsing”="" content="" of="" mpl.l,="" mpl.y="" files="" and="" an="" example="" myprog.mpl="" file,="" (5)any="" explanation="" which="" clarifies="" that="" you="" made="" your="" assingment="" with="" your="" own=""> myprog.mpl in the last step, if there is no syntax error in myprog.mpl, the program should give an “ok” message, otherwise, a “syntax error” message. check your program for correct and wrong inputs. note: do not deal with any semantic rule, just give syntax rules! report: your report should include; (1) description of the rules which you designed (in your own words) (2)details of your grammar in bnf or ebnf notation, (3)code descriptions, (4)the bil240 programming languages tutorial #1 && 2: “lexical analysis and parsing” content of mpl.l, mpl.y files and an example myprog.mpl file, (5)any explanation which clarifies that you made your assingment with your own effort.>