mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03:00
Shell: Parse comments
This commit is contained in:
parent
a862c230b1
commit
1d0d0e9d00
Notes:
sideshowbarker
2024-07-19 06:46:42 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/1d0d0e9d001 Pull-request: https://github.com/SerenityOS/serenity/pull/2170
@ -86,6 +86,19 @@ Vector<Command> Parser::parse()
|
||||
char ch = m_input.characters()[i];
|
||||
switch (state()) {
|
||||
case State::Free:
|
||||
if (ch == '#') {
|
||||
commit_token(Token::Bare);
|
||||
|
||||
while (i < m_input.length()) {
|
||||
ch = m_input.characters()[++i];
|
||||
++m_position;
|
||||
if (ch == '\n')
|
||||
break;
|
||||
m_token.append(ch);
|
||||
}
|
||||
commit_token(Token::Comment);
|
||||
break;
|
||||
}
|
||||
if (ch == ' ') {
|
||||
commit_token(Token::Bare);
|
||||
break;
|
||||
|
@ -36,6 +36,7 @@ struct Token {
|
||||
DoubleQuoted,
|
||||
UnterminatedSingleQuoted,
|
||||
UnterminatedDoubleQuoted,
|
||||
Comment,
|
||||
Special,
|
||||
};
|
||||
String text;
|
||||
|
@ -782,6 +782,9 @@ static Vector<String> process_arguments(const Vector<Token>& args)
|
||||
{
|
||||
Vector<String> argv_string;
|
||||
for (auto& arg : args) {
|
||||
if (arg.type == Token::Comment)
|
||||
continue;
|
||||
|
||||
// This will return the text passed in if it wasn't a variable
|
||||
// This lets us just loop over its values
|
||||
auto expanded_parameters = expand_parameters(arg.text);
|
||||
@ -863,6 +866,9 @@ static ExitCodeOrContinuationRequest run_command(const StringView& cmd)
|
||||
case Token::Special:
|
||||
dbgprintf("<%s> ", arg.text.characters());
|
||||
break;
|
||||
case Token::Comment:
|
||||
dbgprintf("<%s> ", arg.text.characters());
|
||||
break;
|
||||
}
|
||||
}
|
||||
dbgprintf("\n");
|
||||
|
Loading…
Reference in New Issue
Block a user