Overrides FileLogger to remove the time stamp.
Compile-time switch trie from Brian Schott
CT Switch for testing 'keywords' implementations
Match any character. As long as there is at least a character left in the input, it succeeds. Conversely, it fails only if called at the end of the input.
Matches the end of input. Fails if there is any character left.
eps matches the empty string (usually denoted by the Greek letter 'epsilon') and always succeeds. It's equivalent to literal!"" (for example, it creates a match of [""]: one match, the empty string).
Basic rule, that always fail without consuming.
Generic ParseTree modifier: predicate must be callable with a ParseTree and return a boolean. modifier must be callable with a ParseTree and return a ParseTree.
Given an input string, returns the position corresponding to the end of the string.
Same as previous overload, but from the begin of P.input to p.end
Supply a function to dynamically switch tracing on and off based on the rule name.
Discard one-child nodes and replace them with their children. Most grammar tend to produce long one-child/one-child branches, simplifyTree compacts these.
To compare two trees for content (not bothering with node names) That's useful to compare the results from two different grammars.
Trace all rules.
Do not trace any rules.
Predefined parser: matches word boundaries, as \b for regexes.
CT Switch for testing 'keywords' implementations
Mixin to simplify a parse tree inside a grammar
The basic parse tree, as used throughout the project. You can define your own parse tree node, but respect the basic layout.
To record a position in a text
Low-level representation for the expression 'r {act}'. That is, it applies rule 'r' on the input and then calls 'act' on the resulting ParseTree.
Basic operator: it matches if all its subrules (stored in the rules template parameter tuple) match the input successively. Its subrules parse trees are stored as its children and its matches field will contain all its subrules matches, in order.
Represents a case insensitive literal in a PEG, like "abc"i or 'abc'i (or even ''i). It succeeds if a case insensitive comparison of a prefix of the input and its template parameter yields no difference and fails otherwise.
Represents a range of chars, from begin to end, included. So charRange!('a','z') matches all English lowercase letters. If fails if the input is empty or does not begin with a character between begin and end.
Internal helper template, to get a parse tree node with a name, while keeping the original node (see also named). For example, given:
Calls 'r' on the input and then discard everything 'r' returned: no children, no match and index put at the end of the match. It's the low-level engine behind ':r'.
Calls 'r' on the input and then discards its children nodes.
Calls 'r' on the input and then discards its matches.
Calls 'r' on the input and then discards everything 'r' did, except its matches (so that they propagate upwards). Equivalent to ';r'.
Concatenates a ParseTree's matches as one match and discards its children. Equivalent to the expression '~r'.
Makes 'r's result be kept when it would be discarded by the tree-decimation done by a grammar. Equivalent to '^r'.
or special case for literal list ("abstract"/"alias"/...)
A list of elem's separated by sep's. One element minimum.
A list of elem's separated by sep's. The empty list (no elem, no sep) is OK.
Represents a literal in a PEG, like "abc" or 'abc' (or even ''). It succeeds if a prefix of the input is equal to its template parameter and fails otherwise.
Basic operator: it matches if one of its subrules (stored in the rules template parameter tuple) match the input. All subrules are tested and the one producing the longest match is taken.
Internal helper template, to get a parse tree node with a name. For example, given:
Tries 'r' on the input. If it fails, the rule succeeds, without consuming any input. If 'r' succeeds, then negLookahead!r fails. Low-level implementation of '!r'.
Tries to match subrule 'r' one or more times. If 'r' fails from the very beginning, it fails and else succeeds.
Given a subrule 'r', represents the expression 'r?'. It tries to match 'r' and if this matches successfully, it returns this match. If 'r' failed, 'r?' is still a success, but without any child nor match.
Basic operator: it matches if one of its subrules (stored in the rules template parameter tuple) match the input. The subrules are tested in order, from rules[0] to rules[$-1].
Tries 'r' on the input. If it succeeds, the rule also succeeds, without consuming any input. If 'r' fails, then posLookahead!r also fails. Low-level implementation of '&r'.
Makes r disappear in a sequence, letting its children take its place. It's equivalent to the '%' operator. Given A <- B %C D and C <- E F, a successful parse for A will generate a three with four children: B, E, F and D parse trees.
The engine formerly behind the '< ' Pegged rule: all sequence subelements of a rule are interspersed with a space-consuming rule, given as the first template parameter. It's not used by Pegged anymore but can be useful for low-level code. It might become deprecated, but it's not there yet.
Tries to match subrule 'r' zero or more times. It always succeeds, since if 'r' fails from the very beginning, it matched 'r' zero times...
This module contains the engine behind Pegged, the expression templates building blocks to create a top-down recursive-descent parser.
The terminals and non-terminals described here are meant to be used inside a Pegged grammar. As such, they are a bit less user-friendly than what's output by pegged.grammar. For example they take a ParseTree as input, not a string.
See the /docs directory for the full documentation as markdown files.