BashSpark
Loading...
Searching...
No Matches
shell_node_visitor_json.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <nlohmann/json.hpp>
35
37
38namespace bs {
48 class shell_node_visitor_json final : public shell_node_visitor<nlohmann::ordered_json> {
49 public:
61 nlohmann::basic_json<nlohmann::ordered_map>
62 visit_node(shell_session &oSession, const shell_node *pRawNode) override;
63
64 private:
68
75 visit_type visit(shell_session &oSession, const shell_node_word *pNode) override;
76
83 visit_type visit(shell_session &oSession, const shell_node_unicode *pNode) override;
84
91 visit_type visit(shell_session &oSession, const shell_node_str_simple *pNode) override;
92
99 visit_type visit(shell_session &oSession, const shell_node_str_double *pNode) override;
100
107 visit_type visit(shell_session &oSession, const shell_node_str_back *pNode) override;
108
115 visit_type visit(shell_session &oSession, const shell_node_null_command *pNode) override;
116
123 visit_type visit(shell_session &oSession, const shell_node_command *pNode) override;
124
131 visit_type visit(shell_session &oSession, const shell_node_command_expression *pNode) override;
132
139 visit_type visit(shell_session &oSession, const shell_node_command_block *pNode) override;
140
147 visit_type visit(shell_session &oSession, const shell_node_command_block_subshell *pNode) override;
148
155 visit_type visit(shell_session &oSession, const shell_node_arg *pNode) override;
156
163 visit_type visit(shell_session &oSession, const shell_node_variable *pNode) override;
164
171 visit_type visit(shell_session &oSession, const shell_node_dollar_arg *pNode) override;
172
179 visit_type visit(shell_session &oSession, const shell_node_dollar_variable *pNode) override;
180
187 visit_type visit(shell_session &oSession, const shell_node_dollar_arg_dhop *pNode) override;
188
195 visit_type visit(shell_session &oSession, const shell_node_dollar_variable_dhop *pNode) override;
196
203 visit_type visit(shell_session &oSession, const shell_node_dollar_command *pNode) override;
204
211 visit_type visit(shell_session &oSession, const shell_node_dollar_special *pNode) override;
212
219 visit_type visit(shell_session &oSession, const shell_node_background *pNode) override;
220
227 visit_type visit(shell_session &oSession, const shell_node_pipe *pNode) override;
228
235 visit_type visit(shell_session &oSession, const shell_node_or *pNode) override;
236
243 visit_type visit(shell_session &oSession, const shell_node_and *pNode) override;
244
251 visit_type visit(shell_session &oSession, const shell_node_test *pNode) override;
252
259 visit_type visit(shell_session &oSession, const shell_node_if *pNode) override;
260
267 visit_type visit(shell_session &oSession, const shell_node_break *pNode) override;
268
275 visit_type visit(shell_session &oSession, const shell_node_continue *pNode) override;
276
283 visit_type visit(shell_session &oSession, const shell_node_for *pNode) override;
284
291 visit_type visit(shell_session &oSession, const shell_node_while *pNode) override;
292
299 visit_type visit(shell_session &oSession, const shell_node_until *pNode) override;
300
307 visit_type visit(shell_session &oSession, const shell_node_function *pNode) override;
308
310 };
311}
Logical AND operator node (executes right only if left succeeded).
Definition shell_node.h:1159
Extract positional argument from the session (e.g. $1, $2).
Definition shell_node.h:536
Evaluates a subcommand in background semantics (implementation-specific).
Definition shell_node.h:1002
Represents a break statement inside a loop.
Definition shell_node.h:1466
Command block executed in a subshell (may isolate environment changes).
Definition shell_node.h:960
A sequence of evaluable nodes executed in order (a block).
Definition shell_node.h:920
Represents a command expression composed of expandable children.
Definition shell_node.h:229
Wraps a command expression and executes it as a command.
Definition shell_node.h:885
Represents a continue statement inside a loop.
Definition shell_node.h:1418
Dollar-argument with "double-hop" semantics (implementation-specific).
Definition shell_node.h:696
Extract an argument referenced with a leading $ (e.g. $@, $* or $1).
Definition shell_node.h:657
Command-substitution node used in $() or backticks when appearing inside other contexts.
Definition shell_node.h:776
Special dollar items such as $?, $#, $$, etc. (implementation-specific).
Definition shell_node.h:816
Dollar-variable with double-hop lookup semantics.
Definition shell_node.h:735
Dollar-prefixed variable node (may have different semantics).
Definition shell_node.h:618
Iterative 'for' loop node that iterates over an expandable sequence.
Definition shell_node.h:1513
Create function and adds to the shell session.
Definition shell_node.h:1702
Conditional execution node (if-then-else).
Definition shell_node.h:1345
Represents a no-op command node (useful as placeholder).
Definition shell_node.h:856
Logical OR operator node (executes right only if left failed).
Definition shell_node.h:1247
Pipe operator node (connects stdout of left to stdin of right).
Definition shell_node.h:1203
Command-substitution string node (backticks or $(...)).
Definition shell_node.h:362
Double-quoted string node.
Definition shell_node.h:339
Simple (unquoted) string node.
Definition shell_node.h:317
Node that evaluates an expandable expression as a test/condition.
Definition shell_node.h:1296
A single Unicode codepoint node.
Definition shell_node.h:450
'Until' loop node that executes the iterative block until the condition succeeds.
Definition shell_node.h:1646
Extract a named shell variable from the session environment.
Definition shell_node.h:577
Visitor that converts shell nodes into JSON.
Definition shell_node_visitor_json.h:48
nlohmann::basic_json< nlohmann::ordered_map > visit_node(shell_session &oSession, const shell_node *pRawNode) override
Visit a generic shell node and return its JSON representation.
Definition shell_node_visitor_json.cpp:42
Generic visitor for shell AST nodes.
Definition shell_node_visitor.h:46
nlohmann::ordered_json visit_type
Type of data resulting of visit.
Definition shell_node_visitor.h:52
While-loop node executing the iterative block while the condition succeeds.
Definition shell_node.h:1586
A plain word token node.
Definition shell_node.h:404
Base class for all parser nodes.
Definition shell_node.h:116
Represents an execution environment for a shell instance.
Definition shell_session.h:57
BashSpark main namespace.
Definition command.h:39
Defines template bs::shell_node_visitor