BashSpark
Loading...
Searching...
No Matches
shell_node.h File Reference

Defines the shell node hierarchy used by the parser. More...

#include <memory>
#include <stdexcept>
#include <string>
#include <vector>
#include "BashSpark/shell/shell_status.h"
Include dependency graph for shell_node.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  bs::shell_node_invalid_argument
 Exception thrown when a node is constructed with invalid args. More...
 
class  bs::shell_node
 Base class for all parser nodes. More...
 
class  bs::shell_node_evaluable
 Base interface for nodes that can be evaluated (executed). More...
 
class  bs::shell_node_expandable
 Base interface for nodes that expand to tokens (strings). More...
 
class  bs::shell_node_command_expression
 Represents a command expression composed of expandable children. More...
 
class  bs::shell_node_str
 Base for string-like nodes composed of expandable fragments. More...
 
class  bs::shell_node_str_simple
 Simple (unquoted) string node. More...
 
class  bs::shell_node_str_double
 Double-quoted string node. More...
 
class  bs::shell_node_str_back
 Command-substitution string node (backticks or $(...)). More...
 
class  bs::shell_node_word
 A plain word token node. More...
 
class  bs::shell_node_unicode
 A single Unicode codepoint node. More...
 
class  bs::shell_node_session_extractor
 Base for nodes that extract values from the session (args/vars/etc.). More...
 
class  bs::shell_node_arg
 Extract positional argument from the session (e.g. $1, $2). More...
 
class  bs::shell_node_variable
 Extract a named shell variable from the session environment. More...
 
class  bs::shell_node_dollar_variable
 Dollar-prefixed variable node (may have different semantics). More...
 
class  bs::shell_node_dollar_arg
 Extract an argument referenced with a leading $ (e.g. $@, $* or $1). More...
 
class  bs::shell_node_dollar_arg_dhop
 Dollar-argument with "double-hop" semantics (implementation-specific). More...
 
class  bs::shell_node_dollar_variable_dhop
 Dollar-variable with double-hop lookup semantics. More...
 
class  bs::shell_node_dollar_command
 Command-substitution node used in $() or backticks when appearing inside other contexts. More...
 
class  bs::shell_node_dollar_special
 Special dollar items such as $?, $#, $$, etc. (implementation-specific). More...
 
class  bs::shell_node_null_command
 Represents a no-op command node (useful as placeholder). More...
 
class  bs::shell_node_command
 Wraps a command expression and executes it as a command. More...
 
class  bs::shell_node_command_block
 A sequence of evaluable nodes executed in order (a block). More...
 
class  bs::shell_node_command_block_subshell
 Command block executed in a subshell (may isolate environment changes). More...
 
class  bs::shell_node_background
 Evaluates a subcommand in background semantics (implementation-specific). More...
 
class  bs::shell_node_operator
 Base class for binary operator nodes (pipe, and, or) with priority handling. More...
 
class  bs::shell_node_and
 Logical AND operator node (executes right only if left succeeded). More...
 
class  bs::shell_node_pipe
 Pipe operator node (connects stdout of left to stdin of right). More...
 
class  bs::shell_node_or
 Logical OR operator node (executes right only if left failed). More...
 
class  bs::shell_node_test
 Node that evaluates an expandable expression as a test/condition. More...
 
class  bs::shell_node_if
 Conditional execution node (if-then-else). More...
 
class  bs::shell_node_continue
 Represents a continue statement inside a loop. More...
 
class  bs::shell_node_continue::continue_signal
 Exception used internally to signal a loop "continue". More...
 
class  bs::shell_node_break
 Represents a break statement inside a loop. More...
 
class  bs::shell_node_break::break_signal
 Exception used internally to signal a loop "break". More...
 
class  bs::shell_node_for
 Iterative 'for' loop node that iterates over an expandable sequence. More...
 
class  bs::shell_node_while
 While-loop node executing the iterative block while the condition succeeds. More...
 
class  bs::shell_node_until
 'Until' loop node that executes the iterative block until the condition succeeds. More...
 
class  bs::shell_node_function
 Create function and adds to the shell session. More...
 

Namespaces

namespace  bs
 BashSpark main namespace.
 

Enumerations

enum class  bs::shell_node_type {
  SNT_COMMAND_EXPRESSION , SNT_STR_SIMPLE , SNT_STR_DOUBLE , SNT_STR_BACK ,
  SNT_WORD , SNT_UNICODE , SNT_ARG , SNT_VARIABLE ,
  SNT_DOLLAR_SPECIAL , SNT_DOLLAR_VARIABLE , SNT_DOLLAR_VARIABLE_DHOP , SNT_DOLLAR_ARG ,
  SNT_DOLLAR_ARG_DHOP , SNT_DOLLAR_COMMAND , SNT_BACKGROUND , SNT_AND ,
  SNT_PIPE , SNT_OR , SNT_IF , SNT_TEST ,
  SNT_FOR , SNT_WHILE , SNT_UNTIL , SNT_BREAK ,
  SNT_CONTINUE , SNT_FUNCTION , SNT_NULL_COMMAND , SNT_COMMAND ,
  SNT_COMMAND_BLOCK , SNT_COMMAND_BLOCK_SUBSHELL
}
 Types of nodes recognized by the shell parser. More...
 

Detailed Description

Defines the shell node hierarchy used by the parser.

This file provides the node types and helper node classes used by the shell parser. Nodes are categorized as expandable (produce string tokens) or evaluable (execute behavior and return a shell_status).

Medium verbosity Doxygen comments: class/constructor/method brief, parameters, return values and exceptions where appropriate.

Date
Created on 2/11/25
Author
Dante Doménech Martínez

This file is part of BashSpark. Copyright (C) 2025 Dante Doménech Martínez

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.