CSc 354 – Assignment #1 solution

$29.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 (non-class based: create, destroy) Write a complete main/driver program that uses the symbol table module to process two text files: • symtable.dat is used to populate the symbol table. o file format (each line): SYMBOL RFLAG VALUE ▪ zero or more leading spaces in front of the SYMBOL attribute. ▪ one or more leading spaces in front of the RFLAG and VALUE attributes. • search file used to search for symbols stored in 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 symtable.dat. o invalid symbols and/or invalid symbol attributes are not inserted into the symbol table. ▪ display the symbol/attribute along with a detailed error message. o valid symbols with valid attributes are inserted into 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) and digits (0..9). • maximum of 16 characters in length in the source program o only the first 6 characters are significant. o only the first 6 characters are stored in the symbol table. • case sensitive (CSc354, CSc354S1 – same symbol – stored as CSc354). • case sensitive (CSc354, CSC354 – not same symbol – stored as CSc354 & CSC354 respectively).
RFLAG (Boolean) // not case sensitive • 0, false • 1, true
VALUE • signed integer value (–, 0..9).
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 – symtable.dat // File names are case sensitive in Linux as well as some languages ABCDEF True 50 // Valid – insert ABCDEF and all attributes into symbol table (*) b123456 false -3 // Valid – insert b12345 and all attributes into symbol table (*) a1B2c3D4e5F6g7H8 1 -45 // Valid – insert a1B2c3 and all attributes into symbol table (*) abcdef 0 83 // Valid – insert abcdef and all attributes into symbol table (*) 1234567890 0 0 // ERROR – symbol must start with a letter: 1234567890 ABCDEFgh tRuE 100 // ERROR – symbol previously defined: ABCDEF (+) a1B2c3D4e5F6g7H8i TRUE 0 // ERROR – symbol maximum length 16: a1B2c3D4e5F6g7H8i a1234 FALSE 3.5 // ERROR – symbol a1234 invalid value: 3.5 XYZ F 100 // ERROR – symbol XYZ invalid rflag: F
(*) no message displayed for valid symbols with valid attributes – set IFLAG to true – set MFLAG to false (+) set MFLAG attribute to true for symbol ABCDEF
Step #2 – search file ABCDEF // Found – display symbol ABCDEF and all attributes b12345XYZ // Found – display symbol b12345 and all attributes CDEF // ERROR – CDEF not found in symbol table abc_def // ERROR – symbols contain only letters and digits: abc_def
Step #3 – view the symbol table (required output order and format)
Symbol Value RFlag IFlag MFlag // Do not allow the data to scroll off screen // Hold the output every 20 lines – Tera Term screen size ABCDEF 50 1 1 1 // Continue when user indicates to do so a1B2c3 -45 1 1 0 abcdef 83 0 1 0 b12345 -3 0 1 0 // Perform an inorder 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 RFLAG VALUE o Step #2 SYMBOL o Only access the symbol table after verifying that the current symbol and all attributes are valid. • All flag values were converted to 0 or 1 for ease of processing in the examples above.
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 Community 2017 Edition solution/project. • All Java programs must compile and run as a NetBeans 8.2 project: Java SE 8 Update 144 • Zip all files together and send them to the account listed on the course syllabus before class on the due date. o Visual Studio zip entire solution folder or project folder (if no solution folder was created). o NetBeans zip entire project folder. • All duplicate or near duplicate assignments will earn a grade of 0