Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 Assignment Description Your program will print a Rust Vector that you create by continually pushing tokens onto it. This assignment is intended to give
1 Assignment Description Your program will print a Rust Vector that you create by continually pushing "tokens" onto it. This assignment is intended to give you practice with the following concepts: enums Vectors . pallern matching and match expressions For this program, you will: Create an enum called Quantity with the following variants: One (doesn't store any data) - ACouple (doesn't store any data) AFew (doesn't store any data) Several (doesn't store any data) - Other (stores a u32) Create an enum called Token with the following variants: Amount (stores a Quantity, the previous enum that you create) Character (stores a char) Whitespace (doesn't store any data) Write a program function that does the following: Accepls one program argument that is the name of a file Reads the contents of the given file into a string - Creates a Vec called tokens - Loops through the string character by character Creates a Token object each iterations based on the current character - Pushes the Token onto tokens . Prints tokens You will be randomly assigned a partner for this assignment (see the Partners section). The assignment is worth 16 points total: 10 points for program correctness (as determined by gradescope) 2 points for a program that is clear and easy to read, including the names of all partners in comments at the top of the file 4 points for following the instructions above 2 Development Environment If you need a refresher on how to develop Rust programs using Visual Studio Code and Ubuntu (WSL) please watch the video from the first programming assignment. 3 Example Execution --/OneDrive - Missouri State University/courses/C%C333/assignments/assignmentoz_print-tokens/code > ls print_tokens.rs testi.txt /OneDrive - Missouri State University/courses/csc333/assignments/assignmente2_print-tokens/code > rustc print_tokers.rs --/OneDrive - Missouri State University/courses/C%C333/assignments/assignmento2_print-tokens/code > -/print_tokens testi.txt Character("'). Character('e'), Character('1'), Character('1'), Character('0'), Whitespace, Amount (On (','), Whitespace, Amount (AFC), Character(','), Whitespace, Amount (Several), Character(','), whitespa veral), Character(','), Whitespace, Amount (Several), Character','), whitespace, Amount (other(8)), cha Whitespace, Character('a'), Character('n'), Character('d'), whitespace, Character('t), Character('e' --/OneDrive - Missouri State University/courses/CC333/assignments/assignmentez_print-tokens/code 1 Assignment Description Your program will print a Rust Vector that you create by continually pushing "tokens" onto it. This assignment is intended to give you practice with the following concepts: enums Vectors . pallern matching and match expressions For this program, you will: Create an enum called Quantity with the following variants: One (doesn't store any data) - ACouple (doesn't store any data) AFew (doesn't store any data) Several (doesn't store any data) - Other (stores a u32) Create an enum called Token with the following variants: Amount (stores a Quantity, the previous enum that you create) Character (stores a char) Whitespace (doesn't store any data) Write a program function that does the following: Accepls one program argument that is the name of a file Reads the contents of the given file into a string - Creates a Vec called tokens - Loops through the string character by character Creates a Token object each iterations based on the current character - Pushes the Token onto tokens . Prints tokens You will be randomly assigned a partner for this assignment (see the Partners section). The assignment is worth 16 points total: 10 points for program correctness (as determined by gradescope) 2 points for a program that is clear and easy to read, including the names of all partners in comments at the top of the file 4 points for following the instructions above 2 Development Environment If you need a refresher on how to develop Rust programs using Visual Studio Code and Ubuntu (WSL) please watch the video from the first programming assignment. 3 Example Execution --/OneDrive - Missouri State University/courses/C%C333/assignments/assignmentoz_print-tokens/code > ls print_tokens.rs testi.txt /OneDrive - Missouri State University/courses/csc333/assignments/assignmente2_print-tokens/code > rustc print_tokers.rs --/OneDrive - Missouri State University/courses/C%C333/assignments/assignmento2_print-tokens/code > -/print_tokens testi.txt Character("'). Character('e'), Character('1'), Character('1'), Character('0'), Whitespace, Amount (On (','), Whitespace, Amount (AFC), Character(','), Whitespace, Amount (Several), Character(','), whitespa veral), Character(','), Whitespace, Amount (Several), Character','), whitespace, Amount (other(8)), cha Whitespace, Character('a'), Character('n'), Character('d'), whitespace, Character('t), Character('e' --/OneDrive - Missouri State University/courses/CC333/assignments/assignmentez_print-tokens/code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started