NeoMutt  2025-12-11-58-g09398d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
parse.h File Reference

Expando Parsing. More...

#include <stdbool.h>
#include "node_text.h"
+ Include dependency graph for parse.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ExpandoParseError
 Buffer for parsing errors. More...
 

Functions

struct ExpandoNodenode_parse_one (const char *str, NodeTextTermFlags term_chars, const struct ExpandoDefinition *defs, const char **parsed_until, struct ExpandoParseError *err)
 Parse a single Expando from a format string.
 
bool node_parse_many (struct ExpandoNode *node_cont, const char *str, NodeTextTermFlags term_chars, const struct ExpandoDefinition *defs, const char **parsed_until, struct ExpandoParseError *err)
 Parse a format string.
 

Detailed Description

Expando Parsing.

Authors
  • Tóth János
  • Richard Russon

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 http://www.gnu.org/licenses/.

Definition in file parse.h.

Function Documentation

◆ node_parse_one()

struct ExpandoNode * node_parse_one ( const char * str,
NodeTextTermFlags term_chars,
const struct ExpandoDefinition * defs,
const char ** parsed_until,
struct ExpandoParseError * err )

Parse a single Expando from a format string.

Parameters
[in]strString to parse
[in]term_charsTerminator characters, e.g. NTE_GREATER
[in]defsExpando definitions
[out]parsed_untilFirst character after parsed string
[out]errBuffer for errors
Return values
ptrExpando Node

Definition at line 49 of file parse.c.

52{
53 if (!str || (*str == '\0') || !defs || !parsed_until || !err)
54 return NULL;
55
56 struct ExpandoNode *node = NULL;
57
58 node = node_text_parse(str, term_chars, parsed_until);
59 if (node)
60 return node;
61
62 node = node_condition_parse(str, term_chars, defs, parsed_until, err);
63 if (node)
64 return node;
65
66 node = node_expando_parse_name(str, defs, EP_NO_FLAGS, parsed_until, err);
67 if (node)
68 return node;
69
70 return node_expando_parse(str, defs, EP_NO_FLAGS, parsed_until, err);
71}
#define EP_NO_FLAGS
No flags are set.
Definition definition.h:34
struct ExpandoNode * node_condition_parse(const char *str, NodeTextTermFlags term_chars, const struct ExpandoDefinition *defs, const char **parsed_until, struct ExpandoParseError *err)
Parse a conditional Expando.
struct ExpandoNode * node_expando_parse(const char *str, const struct ExpandoDefinition *defs, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse an Expando format string.
struct ExpandoNode * node_expando_parse_name(const char *str, const struct ExpandoDefinition *defs, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse an Expando format string.
struct ExpandoNode * node_text_parse(const char *str, NodeTextTermFlags term_chars, const char **parsed_until)
Extract a block of text.
Definition node_text.c:86
Basic Expando Node.
Definition node.h:67
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ node_parse_many()

bool node_parse_many ( struct ExpandoNode * node_cont,
const char * str,
NodeTextTermFlags term_chars,
const struct ExpandoDefinition * defs,
const char ** parsed_until,
struct ExpandoParseError * err )

Parse a format string.

Parameters
[in]node_contContainer for the results
[in]strString to parse
[in]term_charsTerminator characters, e.g. NTE_GREATER
[in]defsExpando definitions
[out]parsed_untilFirst character after parsed string
[out]errBuffer for errors
Return values
trueSuccess

Definition at line 83 of file parse.c.

86{
87 if (!node_cont || !str || !parsed_until || !err)
88 return false;
89
90 while (*str)
91 {
92 if ((str[0] == '&') && (term_chars & NTE_AMPERSAND))
93 break;
94
95 if ((str[0] == '>') && (term_chars & NTE_GREATER))
96 break;
97
98 if ((str[0] == '?') && (term_chars & NTE_QUESTION))
99 break;
100
101 struct ExpandoNode *node = node_parse_one(str, term_chars, defs, parsed_until, err);
102 if (!node)
103 return false;
104
105 node_add_child(node_cont, node);
106 str = *parsed_until;
107 }
108
109 *parsed_until = str;
110 return true;
111}
struct ExpandoNode * node_parse_one(const char *str, NodeTextTermFlags term_chars, const struct ExpandoDefinition *defs, const char **parsed_until, struct ExpandoParseError *err)
Parse a single Expando from a format string.
Definition parse.c:49
void node_add_child(struct ExpandoNode *node, struct ExpandoNode *child)
Add a child to an ExpandoNode.
Definition node.c:76
#define NTE_QUESTION
'?' Question mark
Definition node_text.h:36
#define NTE_GREATER
'>' Greater than
Definition node_text.h:35
#define NTE_AMPERSAND
'&' Ampersand
Definition node_text.h:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function: