Quick Reference

This isn't intended to be a full, detailed reference; nor is it intended to be of any use to readers who aren't already familiar with Spirit. It's just a brief reminder of the syntax and behaviour of each component, with links to the full documentation.

Null parsers
end_p Matches EOF iter,iter
eps_p
eps_p(P)
Matches without consuming text iter,iter
epsilon_p
epsilon_p(P)
Synonym for eps_p iter,iter
nothing_p Always fails iter,iter
Character parsers
alnum_p Matches any alphanumeric character char
alpha_p Matches any letter char
anychar_p Matches any character char
blank_p Matches a space or tab char
ch_p(char) Matches a character char
chset_p(charset) Matches a character in the set char
cntrl_p Matches any control character char
digit_p Matches any digit char
f_ch_p(func) Matches a character char
f_range_p(func1, func2) Matches any character in the inclusive range char
graph_p Matches any non-space printable character char
lower_p Matches any lower-case letter char
print_p Matches any printable character char
punct_p Matches any punctuation mark char
range_p(char1, char2) Matches any character in the inclusive range char
sign_p Matches a plus or minus sign bool
space_p Matches any whitespace character char
upper_p Matches any upper-case letter char
xdigit_p Matches any hexadecimal digit char
Number parsers
bin_p Matches an unsigned binary integer numeric
hex_p Matches an unsigned hexadecimal integer numeric
int_p Matches a signed decimal integer numeric
int_parser<type, base, min, max> Matches a signed integer with min to max digits numeric
oct_p Matches an unsigned octal integer numeric
real_p Matches a floating point number numeric
real_parser<type, policy> Matches a floating point number numeric
strict_real_p Matches a floating point number (requires decimal point) numeric
strict_ureal_p Matches an unsigned FP number (requires decimal point) numeric
uint_p Matches an unsigned decimal integer numeric
uint_parser<type, base, min, max> Matches an unsigned integer with min to max digits numeric
ureal_p Matches an unsigned FP number numeric
Other lexeme parsers
c_escape_ch_p Matches a C escape code char
comment_p(string)
comment_p (string1, string2)
Matches C++ or C-style comments iter,iter
eol_p Matches CR, LF, or any combination iter,iter
f_str_p(func1, func2) Matches a string iter,iter
lex_escape_ch_p Matches a C escape code or any backslash escape char
regex_p(regex) Matches a regular expression iter,iter
str_p(string)
str_p(iter1, iter2)
Matches a string iter,iter
Text parsers
chseq_p(string)
chseq_p(iter1, iter2)
Matches a string, possibly with embedded whitespace iter,iter
f_chseq_p(func1, func2) Matches a string, possibly with embedded whitespace iter,iter
 
Compound parsers
confix_p(open, exp, close) Matches open >> (exp - close) >> close
do_p[P].while_p(cond) Matches while a condition is true (at least once)
for_p(init, cond, step)[P] Matches in a loop
functor_parser<func> Wraps an external parser
if_p(cond)[P]
if_p(cond)[P].else_p[P]
Matches depending on a condition
lazy_p(P) Evaluates a parser at run time
list_p
list_p(del)
list_p(item, del)
list_p(item, del, end)
Matches a delimited list
repeat_p(num)[P]
repeat_p(min, max)[P]
repeat_p(min, more)[P]
Matches multiple times
while_p (cond) [P] Matches while a condition is true
General directives
as_lower_d[P] Converts text to lower case before matching
attach_action_d[(P1 op P2)[act]] Transforms to P1 [act] op P2 [act]
lexeme_d[P] Turns off whitespace skipping
limit_d[P](min, max) Matches only if the value is within the range
longest_d[P] Matches the longest of alternatives
max_limit_d[P](max) Matches only if value <= max
min_limit_d[P](min) Matches only if value >= min
refactor_action_d[P1 [act] op P2] Transforms to (P1 op P2) [act]
refactor_unary_d[op1 P1 op2 P2] Transforms to op1 (P1 op2 P2)
scoped_lock_d[P](mutex) Locks a mutex while matching
shortest_d[P] Matches the shortest of alternatives
Tree-specific directives
access_node_d[P] Passes node value to action
discard_first_node_d[P] Discards first node
discard_last_node_d[P] Discards last node
discard_node_d[P] Discards the generated node
infix_node_d[P] Discards even-position nodes
inner_node_d[P] Discards first and last nodes
leaf_node_d[P] Generates a single node with no children
no_node_d[P] Does not generate a node
root_node_d[P] Identifies root nodes for an AST
token_node_d[P] Synonym for leaf_node_d
Unary operators
!P Matches P or an empty string
*P Matches P zero or more times
+P Matches P one or more times
~P Matches anything that does not match P
Binary operators
P1 % P2 Matches one or more P1 separated by P2
P1 - P2 Matches P1 but not P2
P1 >> P2 Matches P1 followed by P2
P1 & P2 Matches both P1 and P2
P1 ^ P2 Matches P1 or P2, but not both
P1 | P2 Matches P1 or P2
P1 && P2 Synonym for P1 >> P2
P1 || P2 Matches P1 | P2 | P1 >> P2