CSc 354 – Assignment #1 – Werpy solution

$24.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

Write a complete module used to maintain the symbol table for the SIC/XE assembler: • use a binary search tree implementation to store each symbol along with its associated attributes o exportable binary search tree operations: insert, search, view (create, destroy – non-class based) Write a complete main/driver program that uses the symbol table module to process two text files: • SYMBOLS.DAT used to populate the symbol table. o file format (each line): SYMBOL VALUE RFLAG ▪ zero or more leading spaces in front of the SYMBOL attribute. ▪ one or more leading spaces in front of the VALUE and RFLAG attributes. • search file used to search the symbol table. o search file name obtained from the command line. o file format (each line): SYMBOL ▪ zero or more leading spaces in front of the SYMBOL attribute. Basic Algorithm 1. read symbols and their attributes one line at a time from the file named SYMBOLS.DAT. o invalid symbols and/or invalid symbol attributes are not inserted in the symbol table. ▪ display the symbol along with a detailed error message. o valid symbols with valid attributes are inserted in the symbol table. 2. read symbols one at a time from the search file. o if no file name was specified on the command line then prompt the user for the file name. o invalid symbol: display the symbol along with a detailed error message. o valid symbol: search for the symbol in the symbol table (significant portion only). ▪ found: display the symbol and its associated attributes. ▪ not found: display the symbol along with a detailed error message. 3. perform an inorder traversal of the symbol table. o display all symbols and associated attributes in a tabular format using output formatting techniques. SYMBOL (also referred to as a label in assembly language programing) • starts with a letter (A..Z, a..z). • followed by letters (A..Z, a..z), digits (0..9), and the dash (-). • maximum of 10 characters in length in the source program o only the first 5 characters are significant. o only the first 5 characters are stored in the symbol table. • not case sensitive (CSC-354, CSc-354, csc-354 – all the same symbol – stored as CSC-3).
VALUE • signed integer value (+, –, 0..9).
RFLAG (Boolean) • 0, f, false • 1, t, true • not case sensitive.
IFLAG (Boolean) • indicates whether or not a symbol has been defined within the current control section – (true for now).
MFLAG (Boolean) • indicates whether or not a symbol has been defined more than one time in the same control section. • each valid symbol is inserted into the symbol table exactly one time (invalid symbols are never inserted). Sample Program Run
Step #1 – SYMBOLS.DAT // File names are case sensitive in Linux as well as some languages ABCDE 50 True // Valid – insert ABCDE and all attributes into symbol table (*) B12-34 -3 false // Valid – insert B12-3 and all attributes into symbol table (*) a1B2-c3-D4 +45 1 // Valid – insert A1B2- and all attributes into symbol table (*) ABCD! 33 t // ERROR – symbols contain letters, digits and dashes: ABCD! 1234567890 0 0 // ERROR – symbols start with a letter: 1234567890 ABCDEF +100 1 // ERROR – symbol previously defined: ABCDE (+) a1234 3.5 F // ERROR – symbol a1234 invalid value: 3.5 XYZ 100 5 // ERROR – symbol XYZ invalid rflag: 5
(*) no message displayed for valid symbols with valid attributes – set IFLAG to true – set MFLAG to false (+) set MFLAG attribute to true for symbol ABCDE
Step #2 – search file ABCDE // Found – display symbol ABCDE and all attributes A1b2-C3xYz // Found – display symbol A1B2- and all attributes CDEF // ERROR – CDEF not found in symbol table abc_def // ERROR – symbols contain letters, digits and dashes: abc~def a1b2c3d4e5f6 // ERROR – symbols contain 10 characters maximum: a1b2c3d4e5f6
Step #3 – view the symbol table – required output order and format
Symbol Value RFlag IFlag MFlag // Do not allow the data to scroll off of the screen // Hold the output every 20 lines – Tera Term screen size A1B2- 45 1 1 0 // Continue when user indicates to do so ABCDE 50 1 1 1 B12-3 -3 0 1 0 // Perform an in-order traversal of symbol table
Notes and Suggestions • Do NOT stop on error!!! Process all data in both files completely!!! Display detailed error messages!!! • Check for errors in all symbols and all symbol attributes read from both files o Step #1 SYMBOL VALUE RFLAG o Step #2 SYMBOL • Convert all values to one common format: o All symbols were converted to uppercase: csc, CSC, CSc = CSC o All flag values were converted to Boolean values: 0, f, false = 0 1, t, true = 1 Other Requirements • The module/program must use proper data abstraction techniques. o See the Assignment Requirements document on the course web site. • All module/program files must be fully documented. o See the Documentation Requirements document on the course web site. • All C/C++ programs must compile and run using the Computer Science Linux server: cscssh.sdstate.edu
• All C# programs must compile and run as a Visual Studio 2017 Community Edition solution/project. • All Java programs must compile and run from the command line. Include Instructions for building/running with your program submission. • Zip all files together and send them to the account listed one the course syllabus before class on the due date. o Visual Studio zip entire solution folder (containing project folder) o Java zip entire project folder o C/C++ zip all necessary program and header files. • All duplicate or near duplicate assignments will earn a grade of 0.