Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable expansion and subshells, add Vec<Arg> for commands #6

Merged
merged 3 commits into from
Feb 9, 2025

Conversation

samp5
Copy link
Contributor

@samp5 samp5 commented Feb 5, 2025

Add Support for Subshells + Variable Expansion

  • Subshell expansion for cmd1 (cmd2) and cmd1 $(cmd2)
  • Variable expansion for $name but not `${name}
  • Instead of an Option<Token>, Lexer::lex_subshell returns a Result<Token> so that unmatched parentheses can be collected as errors to emit
  • We could implement this for single and double quotes as well.
  • Because subshell results should get placed directly into the containing command, I changed Command::argv from a Vec<String> to a Vec<Arg> where Arg is an enum with variants for basic "words", subshells, and variables.

Remove redundant CommandGroup

  • Because additional commands are being stored in the and_then field of the Command struct, the commands in CommandGroup was redundant.
  • Because of this, AndThen now has to have a Box<Command>

Update Tests

  • To test all the new functionality, I basically dropped all the previous tests and (per precedent) had a LLM write a bunch of tests that use the new Vec<Arg> format for Command.

@samp5 samp5 changed the title Variable expansion and subshells, add Vec<Args> for commands Variable expansion and subshells, add Vec<Arg> for commands Feb 5, 2025
@samp5
Copy link
Contributor Author

samp5 commented Feb 5, 2025

Results for lexing and parsing

  • All lexing targets that can produce errors return results.
  • The Item for the Lexer iterator implementation is now Result<Token, ParseError>
  • If there are any errors during parsing inCommand::parse, a ParseErrors is returned which contains a Vec<ParseErrors>.
    • Each ParseError could be extended to include additional information about the error (as inner values)

Testing

  • Instead of rewriting all the tests Ok is mapped to Some and Err to None

@CJacob314 CJacob314 merged commit cb838fb into acm-uic:main Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants