BashSpark
Loading...
Searching...
No Matches
bs::shell_parser Class Reference

Parses tokens into an evaluable shell AST. More...

#include <shell_parser.h>

Public Types

using expandable_ptr = std::unique_ptr< shell_node_expandable >
 Unique pointer to an expandable shell node (sugar syntax).
 
using evaluable_ptr = std::unique_ptr< shell_node_evaluable >
 Unique pointer to an evaluable shell node (sugar syntax).
 

Public Member Functions

void increase_depth (std::size_t nPos)
 Increase the nesting depth and check limits.
 
void decrease_depth ()
 Decrease the current nesting depth.
 

Static Public Member Functions

static evaluable_ptr parse (ifakestream &oIstream)
 Parse input into an evaluable AST.
 

Static Public Attributes

static constexpr std::size_t MAX_DEPTH = shell::MAX_DEPTH
 Maximum recursion depth allowed for nested constructs.
 

Detailed Description

Parses tokens into an evaluable shell AST.

Exceptions
shell_parser_exceptionIf a syntax error is found.

The parser consumes tokens produced by shell_tokenizer and constructs a hierarchy of shell_node objects representing shell expressions, commands, conditionals, loops, and expansions.

It is an internal helper for bs::shell and not intended for direct interaction by users.

Member Function Documentation

◆ increase_depth()

void bs::shell_parser::increase_depth ( std::size_t  nPos)

Increase the nesting depth and check limits.

Parameters
nPosPosition of the construct causing the depth increase.

◆ parse()

evaluable_ptr bs::shell_parser::parse ( ifakestream oIstream)
static

Parse input into an evaluable AST.

Reads tokens from the given input stream and produces the root node of the parsed command or expression.

Parameters
oIstreamThe input token stream.
Returns
The root evaluable AST node.

The documentation for this class was generated from the following files: