1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

Shell: Start implementing a POSIX-compliant parser

The parser is still very much a work-in-progress, but it can currently
parse most of the basic bits, the only *completely* unimplemented things
in the parser are:
- heredocs (io_here)
- alias expansion
- arithmetic expansion

There are a whole suite of bugs, and syntax highlighting is unreliable
at best.
For now, this is not attached anywhere, a future commit will enable it
for /bin/sh or a `Shell --posix` invocation.
This commit is contained in:
Ali Mohammad Pur 2023-02-11 17:59:15 +03:30 committed by Ali Mohammad Pur
parent 2dc1682274
commit 2a276c86d4
14 changed files with 3444 additions and 28 deletions

View file

@ -19,10 +19,11 @@ namespace Shell {
class Formatter final : public AST::NodeVisitor {
public:
Formatter(StringView source, ssize_t cursor = -1)
Formatter(StringView source, ssize_t cursor = -1, bool parse_as_posix = false)
: m_builders({ StringBuilder { round_up_to_power_of_two(source.length(), 16) } })
, m_source(source)
, m_cursor(cursor)
, m_parse_as_posix(parse_as_posix)
{
if (m_source.is_empty())
return;
@ -124,6 +125,8 @@ private:
StringView m_trivia;
Vector<DeprecatedString> m_heredocs_to_append_after_sequence;
bool m_parse_as_posix { false };
};
}