mirror of
https://github.com/kmc7468/cs220.git
synced 2025-12-14 22:18:46 +00:00
assignment 1~5: fixes
- assignment05/pascal.mlw: lowered the difficulty (one more invariant given) - assignment02, 03: minor fixes & divide into sub-problems
This commit is contained in:
28
src/assignments/assignment03/parse_shell.rs
Normal file
28
src/assignments/assignment03/parse_shell.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
//! Parsing a shell command.
|
||||
//!
|
||||
//! Shell commands are text-based instructions that you can enter in a command-line interface (CLI)
|
||||
//! to interact with operating systems (e.g. Linux) and others.
|
||||
//! For example, you can use the `ls` command to list files in a directory.
|
||||
//!
|
||||
//! You will parse a given string consists of a small number of shell commands.
|
||||
|
||||
/// Parse the string as a shell command.
|
||||
///
|
||||
/// Usually, a shell command is whitespace-separated array of strings.
|
||||
/// ```text
|
||||
/// cat file --> ["cat", "file"]
|
||||
/// ```
|
||||
/// But sometimes, you may want to include whitespaces in each argument.
|
||||
/// In that case, you can use quotes.
|
||||
/// ```text
|
||||
/// ls 'VirtualBox VMs' --> ["ls", 'VirtualBox VMs']
|
||||
/// ls VirtualBox' 'VMs --> ["ls", 'VirtualBox VMs']
|
||||
/// ```
|
||||
///
|
||||
/// For simplicity, you may assume that the string only contains alphanumeric characters, spaces
|
||||
/// (" "), and single quotes ("'").
|
||||
///
|
||||
/// See `test_shell` for more examples.
|
||||
pub fn parse_shell_command(command: &str) -> Vec<String> {
|
||||
todo!()
|
||||
}
|
||||
Reference in New Issue
Block a user