Trait that represents classes with isReachable method
Trait that represents classes with isReachable method
Currently the only use of it is to avoid the cyclic dependencies between Utils and ParserInput
Contains buffer - queue of elements that extends from given iterator when particular elements are requested;
and shrinks by calling dropBuffer
method.
Contains buffer - queue of elements that extends from given iterator when particular elements are requested;
and shrinks by calling dropBuffer
method.
Generally, at any specific time this buffer contains "suffix" of given iterator,
e.g. some piece of data from past calls of next
, which extends by requesting new batches from iterator.
Therefore we can denote the same notation of indices as for regular Array
or more abstract IndexedSeq
.
The only difference is when index doesn't fit into the bounds of current buffer
either the new batches are requested to extend the buffer, either it's inaccessible at all,
so calling of dropBuffer
should guarantee that there won't be any attempts to access to the elements in dropped part of input.
Separated out from ByNameOps because .log
isn't easy to make an
AnyVal extension method, but it doesn't matter since .log
calls
are only for use in development while the other ByNameOps operators
are more performance-sensitive
Shorthand alias for ParsingRun; this is both the parameter-to and the return type for all Fastparse's parsing methods.
Shorthand for P[Unit]
Shorthand for P[Unit]
The outcome of a ParsingRun run, either a success (with value and index) or failure (with associated debugging metadata to help figure out what went wrong).
The outcome of a ParsingRun run, either a success (with value and index) or failure (with associated debugging metadata to help figure out what went wrong).
Doesn't contain any information not already present in ParsingRun, but packages it up nicely in an immutable case class that's easy for external code to make use of.
ParserInput class represents data that is needed to parse.
ParserInput class represents data that is needed to parse.
It can be regular IndexedSeq
that behaves as simple array or
Iterator
of IndexedSeq
batches which is optimized by dropBuffer
method.
Models an in-progress parsing run; contains all the mutable state that may be necessary during the parse, in order to avoid the individual parsers needing to perform their own allocations and instantiations, and greatly improving performance
Models an in-progress parsing run; contains all the mutable state that may be necessary during the parse, in order to avoid the individual parsers needing to perform their own allocations and instantiations, and greatly improving performance
There are a few patterns that let us program with these mutable variables in a sort-of-pure-functional way:
- If a parser that wishes to ignore changes to a field within their child parsers, a common pattern is to save the value of the field before the wrapped parser runs, and then re-set the field. e.g. this can be used to backtrack index after a lookahead parser finishes
- If a parser wants to read the value of the field "returned" by multiple child parsers, make sure to read the field into a local variable after each child parser is complete to make sure the value you want from an earlier child isn't stomped over by a later child
In general, for a parser to "return" a value in a mutable field, it is sufficient to simply set the value of that field before returning. It is the parent-parser's responsibility to make sure it reads out the value of the field to a local variable before running another child parser that will over-write the mutable field
A ParserInput that pulls data from a given java.io.Reader
.
A ParserInput that pulls data from a given java.io.Reader
. Typically
not used alone, and instead is used as part of a ParserInputSource.FromReadable
Positive lookahead operator: succeeds if the wrapped parser succeeds and fails if the wrapped parser fails, but in all cases consumes zero characters.
Parses a single character, any character, as long as there is at least one character for it to parse (i.e.
Parses a single character, any character, as long as there is at least one character for it to parse (i.e. the input isn't at its end)
Provides ByNameOps extension methods on Strings
Parses a single character in one of the input strings representing character classes
Parses a single character satisfying the given predicate
Fast, pre-computed character predicates for charactes from 0 to 65535
Fast, pre-computed character predicates for charactes from 0 to 65535
Useful because FastParse does it's parsing character by character, so
although this doesn't have the full range of the java
Character.getType(c: Int)
functions, it still is good enough for
a wide range of use cases
Parses min
or more characters as long as they satisfy the given
predicate
Parses one or more characters as long as they satisfy the given predicate
Parses min
or more characters as long as they are contained
in one of the input strings representing character classes
Parses one or more characters as long as they are contained in one of the input strings representing character classes
Provides EagerOps extension methods on String
Parser that is only successful at the end of the input.
Parser that is only successful at the end of the input. Useful to ensure your parser parses the whole file.
No-op parser with a custom error message that always fails, consuming zero characters
No-op parser with a custom error message that always fails, consuming zero characters
No-op parser that always fails, consuming zero characters
No-op parser that always fails, consuming zero characters
Parses a string value case-insensitively
Parses a string value case-insensitively
Container for all the type-level logic around appending things
to tuples or flattening Seq[Unit]
s into Unit
s.
Container for all the type-level logic around appending things
to tuples or flattening Seq[Unit]
s into Unit
s.
Some of these implicits make liberal use of mutable state, so as to minimize allocations while parsing.
Parser that always succeeds and returns the current index into the parsed input.
Parser that always succeeds and returns the current index into the parsed input. Useful for e.g. capturing source locations so when downstream valiation raises errors you can tell the user where in the input the error originated from
Whitespace syntax that supports // line-comments and /* */ multiline-comments, *without nesting* of /* */ comments, as is the case in the Java programming language
Whitespace syntax that supports // and # line comments, and /* */ multiline-comments, but *without* nesting of /* */ comments.
Whitespace syntax that supports // and # line comments, and /* */ multiline-comments, but *without* nesting of /* */ comments. This is the case in the Jsonnet programming language
Parses an exact string value.
Provides logging-related LogByNameOps implicits on String.
Whitespace syntax that consumes both single-line " " and "\t" and multiline "\r" and "\n" whitespace characters.
Allows backtracking regardless of whether cuts happen within the wrapped parser; this is useful for re-using an existing parser with cuts within it, in other parts of your grammar where backtracking is necessary and unavoidable.
Allows backtracking regardless of whether cuts happen within the wrapped parser; this is useful for re-using an existing parser with cuts within it, in other parts of your grammar where backtracking is necessary and unavoidable.
Wraps a parser and ensures that none of the parsers within it leave failure traces in terminalMsgs, though unlike ByNameOps.opaque if there is a failure *within* the wrapped parser the failure's location and error message will still be shown
Wraps a parser and ensures that none of the parsers within it leave failure traces in terminalMsgs, though unlike ByNameOps.opaque if there is a failure *within* the wrapped parser the failure's location and error message will still be shown
Useful for wrapping things like whitespace, code-comment, etc. parsers which can be applied everywhere and are not useful to display to the user as part of the error message.
No-op whitespace syntax that doesn't consume anything
Delimits a named parser.
Delimits a named parser. This name will appear in the parser failure messages and stack traces, and by default is taken from the name of the enclosing method.
No-op parser that always succeeds with the given value, consuming zero characters
No-op parser that always succeeds with the given value, consuming zero characters
No-op parser that always succeeds, consuming zero characters
No-op parser that always succeeds, consuming zero characters
Whitespace syntax that supports // line-comments and /* */ multiline-comments, *including nesting* of /* */ comments, as is the case in the Scala programming language
Whitespace syntax that supports # line-comments, as in the case in programming languages such as Bash, Ruby, or Python
Like AnyChar, but returns the single character it parses.
Like AnyChar, but returns the single character it parses. Useful
together with EagerOps.flatMapX to provide one-character-lookahead
style parsing: SingleChar consumes the single character, and then
EagerOps.flatMapX can match
on that single character and decide
which downstream parser you wish to invoke
Whitespace syntax that consumes only single-line " " and "\t" whitespace characters.
Parser that is only successful at the start of the input.
Parser that is only successful at the start of the input.
Efficiently parses any one of the given Strings; more efficient than chaining EagerOps.| together
Efficiently parses any one of the given Strings, case-insensitively; more efficient than chaining EagerOps.| together with IgnoreCase
Parses the given input ParserInput using the given parser and returns a Parsed result containing the success value or failure metadata.
Parses the given input ParserInput using the given parser and returns a Parsed result containing the success value or failure metadata.
Can take either a String, an Iterator or strings or a fastparse.ParserInput object
the input to parse
the parser method to use to parse the input
enable this to show a more detailed error message
if a parser fails, without needing to run
.traced.trace
. Defaults to false
as it slows
down parsing considerably
where in the input to start parsing
Callbacks that get run before and after every named
P(...)
parser