You must include a tarball that contains your Makefile, .h, .c, .l, .y, and any other important files. All source files and Makefiles need to have the class standard header at the top. You also need to capture and submit the output of your program by redirecting it to appropriate files.
Microsoft Word - CS3377 F20 Assignment 4.docx UT Dallas CS 3377 Dr. Perkins Assignment #4 Page 1 of 6 Assignment #4 Due: Tuesday October 20th, 2020 at 11:59:00 pm Instructor Dr. Stephen Perkins Office Location ECSS 4.702 Office Phone (972) 883-3891 Email Address
[email protected] Office Hours By appointment. Contact will be by MS Teams video or phone. Office Hours Scheduling Link: https://app.acuityscheduling.com/schedule.php?owner=17424155&appoint mentType=16389287 Graders CS/SE 3377.001 - Akshay Bhagwan Sonawane
[email protected] CS/SE 3377.002 - Ashwani Kumar Kashyap
[email protected] Purpose Demonstrate the ability to utilize the UNIX make build system with implicit rules. Demonstrate the ability use the flex lexical analyzer package to analyze an input file. Demonstrate the ability to use the bison parser package to make sense of the contents of a file and generate useful output. Demonstrate the ability to have your program offer different services based on the name by which it was called. Assignment Overview: The process of converting an input file (stream of characters) into an understandable format is called syntax analysis. It is usually divided into two parts. The first, lexical analysis, tokenizes the input via a lexical scanner. The second, parsing, generates an abstract model of the tokens and then generates useful content from that model. You are to write a syntax analyzer using the flex tool for lexical analysis and the bison tool for parsing. The goal of the program is to parse an input file that contains postal addresses and then to output a representation of those addresses in XML. Usage: scanner < infilename="" (lexical="" scanning="" only)="" parser="">< infilename="" (lexical="" scanning="" and="" parsing)="" your="" program="" may="" be="" called="" with="" one="" of="" two="" different="" names="" (use="" unix="" symbolic="" links="" to="" create="" these="" names).="" ut="" dallas="" cs="" 3377="" dr.="" perkins="" assignment="" #4="" page="" 2="" of="" 6="" if="" your="" program="" is="" called="" with="" the="" name="" “scanner”,="" then="" it="" should="" only="" provide="" lexical="" analysis="" of="" the="" infilename="" file.="" in="" this="" case,="" the="" output="" should="" be="" a="" list="" of="" tokens="" along="" with="" any="" meta-information="" about="" the="" tokens="" that="" may="" be="" needed.="" this="" should="" be="" sent="" to="" stdout.="" if="" your="" program="" is="" called="" with="" the="" name="" “parser”,="" then="" it="" should="" provide="" both="" lexical="" analysis="" and="" parsing="" of="" the="" infilename="" file.="" in="" this="" case,="" output="" will="" be="" sent="" to="" both="" stdout="" and="" stderr:="" stdout="" -="" should="" be="" a="" set="" of="" statements="" indicating="" whether="" the="" infilename="" file="" was="" successfully="" processed="" and="" should="" include="" information="" about="" bad="" addresses.="" stderr="" -="" should="" be="" an="" xml="" representation="" of="" the="" addresses="" read="" from="" the="" infilename="" file.="" if="" errors="" are="" encountered="" during="" the="" parsing="" of="" an="" address,="" you="" should="" output="" the="" best="" xml="" possible="" and="" ignore="" the="" bad="" information.="" in="" parse="" mode,="" all="" work="" should="" be="" performed="" by="" the="" parser.="" your="" c="" program="" should="" only="" call="" yyparse()="" and="" provide="" feedback="" on="" its="" return="" value.="" postal="" address="" here="" is="" a="" backus-naur="" form="" (bnf)="" notation="" of="" a="" u.s.="" postal="" address.="" this="" definition="" is="" a="" modified="" version="" lifted="" from="" the="" backus-naur="" form="" wikipedia="" page:="" http://en.wikipedia.org/wiki/backus-naur_form="">
::= EOLTOKEN | ::= ::= EOLTOKEN | EOLTOKEN | error ::= NAMETOKEN | NAME_INITIAL_TOKEN ::= NAMETOKEN ::= SRTOKEN | JRTOKEN | ROMANTOKEN ::= INTTOKEN EOLTOKEN | HASHTOKEN INTTOKEN EOLTOKEN | EOLTOKEN | error ::= INTTOKEN | IDENTIFIERTOKEN ::= NAMETOKEN ::= COMMATOKEN EOLTOKEN | error ::= NAMETOKEN UT Dallas CS 3377 Dr. Perkins Assignment #4 Page 3 of 6 ::= NAMETOKEN ::= INTTOKEN DASHTOKEN INTTOKEN | INTTOKEN Additional Info: NAMETOKEN Regular Expression An identifier that represents something that only contains 2 or more letters IDENTIFIERTOKEN Regular Expression An identifier that represents something that starts with a letter or number and contains 1 or more letters or numbers. NAME_INITIAL_TOKEN Regular Expression An identifier that represents one letter or one letter followed by a period. ROMANTOKEN Regular Expression An identifier that represents roman numerals SRTOKEN Regular Expression An identifier that represents "Sr." JRTOKEN Regular Expression An identifier that represents "Jr." EOLTOKEN Regular Expression An identifier that represents the end of line INTTOKEN Regular Expression An identifier that represents an integer COMMATOKEN Regular Expression An identifier that represents a comma (,) DASHTOKEN Regular Expression An identifier that represents a dash (-) HASHTOKEN Regular Expression An identifier that represents a hash (#) XML Output The XML notation should match this: (You should assume street names are exactly 1 word long) If an item is empty, you may omit it from the output. Example Input file UT Dallas CS 3377 Dr. Perkins Assignment #4 Page 4 of 6 The input file should be a text file containing sets of address blocks. Each address block should be separated from the next by exactly one blank line. NOTE: the last three addresses have errors. This is so you can test your parser's operation in the presence of errors. The goal is to completely parse the file. You may omit XML output for bad data. You may print error messages and continue parsing the file, but your parser should not stop with syntax error during parsing. yyparse() should return success and not failure. F. Flinstone 5806 PebbleRd #345 Stonecity, TX 75080 W Flinstone IV 5806 PebbleRd 345 Stonecity, TX 75080‐4321 Barney Rubble Jr. 106B RockyRoad Stonecity, TX 75080‐9384 Betty Rubble 106B RockyRoad Stonecity, TX 75080 1234 Bad Name Line 9000 SomeStreet Dallas, TX 75080‐4872 B. Wayne III BadBatStreetNumber #456 Gotham, TX 88234‐3664 B. Wayne III 1000 GothamManor Gotham, TX ABCD Example Output in Scanner Mode /Program4} ./scanner < input.txt ="" operating in scan mode ="" ="" yylex returned name_initial_token token (f.) ="" yylex returned nametoken token (flinstone) ="" yylex returned eoltoken token (267) ="" yylex returned inttoken token (5806) ="" yylex returned nametoken token (pebblerd) ="" yylex returned hashtoken token (265) ="" yylex returned inttoken token (345) ="" yylex returned eoltoken token (267) ="" yylex returned nametoken token (stonecity) ="" yylex returned commatoken token (266) ="" yylex returned nametoken token (tx) ="" yylex returned inttoken token (75080) ="" yylex returned eoltoken token (267)="" yylex returned eoltoken token (267) ="" ut="" dallas="" cs="" 3377="" dr.="" perkins="" assignment="" #4="" page="" 5="" of="" 6="" yylex returned name_initial_token token (w) ="" yylex returned nametoken token (flinstone) ="" yylex returned romantoken token (262) ="" yylex returned eoltoken token (267) ="" yylex returned inttoken token (5806) ="" yylex returned nametoken token (pebblerd) ="" yylex returned inttoken token (345) ="" yylex returned eoltoken token (267) ="" yylex returned nametoken token (stonecity) ="" yylex returned commatoken token (266) ="" yylex returned nametoken token (tx) ="" yylex returned inttoken token (75080) ="" yylex returned dashtoken token (268) ="" yylex returned inttoken token (4321) ="" yylex returned eoltoken token (267) ="" yylex returned eoltoken token (267) ="" …="" example="" of="" stdout="" in="" parser="" mode=""> input.txt >< input.txt 2> output.txt Operating in parse mode Bad name‐part ... skipping to newline Bad address_line ... skipping to newline Bad location_line... skipping to newline Parse Successful! Example of stderr in Parser ModeF.Flinstone5806PebbleRd345StonecityTX75080WFlinstoneIV5806PebbleRd345StonecityTX750804321BarneyRubbleJr.106BRockyRoad UT Dallas CS 3377 Dr. Perkins Assignment #4 Page 6 of 6StonecityTX750809384BettyRubble106BRockyRoadStonecityTX750809000SomeStreetDallasTX750804872B.WayneIIIGothamTX882343664B.WayneIII1000GothamManorGothamTX Deliverables You must submit your homework through ELearning. You must include a tarball that contains your Makefile, .h, .c, .l, .y, and any other important files. All source files and Makefiles need to have the class standard header at the top. You also need to capture and submit the output of your program by redirecting it to appropriate files. Additional Info You may assume that people do not have full names that are one letter long. You may assume that people do not have names that are spelled like roman numerals. You may assume that all streets are exactly one word long. Notes All of your source files / scripts must have the standard header Your code must be compiled using the -Werror compiler flag and must product no errors/warnings. All work must be done within the shell and must be performed on cs1.utdallas.edu No late homework is accepted. input.txt 2>