fastparse
Members list
Packages
Type members
Classlikes
Attributes
- Supertypes
- Known subtypes
-
class IteratorParserInputclass ReaderParserInput
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
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
CharPredicates.type
Container for all the type-level logic around appending things to tuples or flattening Seq[Unit]s into Units.
Container for all the type-level logic around appending things to tuples or flattening Seq[Unit]s into Units.
Some of these implicits make liberal use of mutable state, so as to minimize allocations while parsing.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Implicits.type
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass ParserInputtrait IsReachableclass Objecttrait Matchableclass AnyShow all
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
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class ParserInputtrait BufferedParserInputclass IteratorParserInputclass ReaderParserInputclass IndexedParserInput
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.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait BufferedParserInputclass ParserInputtrait IsReachableclass Objecttrait Matchableclass AnyShow all
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 // line-comments and /* / multiline-comments, without nesting of / */ comments, as is the case in the Java programming language
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
JavaWhitespace.type
Whitespace syntax that supports // and # line comments, and /* / multiline-comments, but without nesting of / */ comments. This is the case in the Jsonnet programming language
Whitespace syntax that supports // and # line comments, and /* / multiline-comments, but without nesting of / */ comments. This is the case in the Jsonnet programming language
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
JsonnetWhitespace.type
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
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
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Whitespace syntax that consumes both single-line " " and "\t" and multiline "\r" and "\n" whitespace characters.
Whitespace syntax that consumes both single-line " " and "\t" and multiline "\r" and "\n" whitespace characters.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
MultiLineWhitespace.type
No-op whitespace syntax that doesn't consume anything
No-op whitespace syntax that doesn't consume anything
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
NoWhitespace.type
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.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ParserInput.type
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.
Attributes
- Companion
- object
- Supertypes
- Known subtypes
-
trait BufferedParserInputclass IteratorParserInputclass ReaderParserInputclass IndexedParserInput
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class FromReadableclass fromParserInput[T]
Attributes
- Companion
- trait
- Supertypes
- Self type
-
ParserInputSource.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object ParserInputSource
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
Value parameters
- cut
-
Has the current parse been prevented from backtracking? This field starts as
trueat top-level, since there is nowhere to backtrack to. Upon entering a parser that can backtrack, such as|or.?or.rep, it is set tofalse, and re-set totrueupon encountering a./or~/cut operator that prevents backtracking. - failureStack
-
The stack of named
P(...)parsers in effect when the failure occurred; only constructed when tracing is enabled viatraceIndex != -1 - index
-
The current index of the parse
- input
-
The input to the parsing run, as a ParserInput.
- instrument
-
Callbacks that can be injected before/after every
P(...)parser. - isSuccess
-
Whether or not the parse is currently successful
- logDepth
-
How many nested
.logcalls are currently surrounding us. Used to nicely indent the log output so you can see which parsers are nested within which other parsers; -1 means logging is disabled - misc
-
Additional key-value metadata that a user can attach to a parsing run, and manage however they like. Not as high performance as the built-in fields of ParsingRun, but perhaps sufficient to satisfy ad-hoc needs e.g. keeping track of indentation or other contextual information
- noDropBuffer
-
Flag that prevents the parser from dropping earlier input. Used for the
.!capture operator that needs the input around to return as a string, theNoCutoperator that forces backtracking (regardless of internal cuts), or whitespace consumption which implicitly backtracks if the parser on the RHS of the whitespace fails or consumes 0 characters. The value for this field is lexically scoped, but it is up to the individual parser method implementations to set the values and remember to un-set it to the previous value after they finish. Forgetting to re-set it to the previous value can cause strange behavior or crashes. - originalParser
-
The original parsing function we used to start this run, so as to allow
.result.tracedto re-create it with tracing enabled. - shortMsg
-
When tracing is enabled, this contains string representation of the last parser to run. Since parsers aren't really objects, we piece together the string in the parser body and return store it here, and an enclosing parser may fetch it back out to help build its own string representation. If the last parser started before the
traceIndex, we only aggregate the portion of the parser msg that takes place aftertraceIndex - startIndex
-
Where the parse initially started, so as to allow
.result.tracedto re-create it with tracing enabled. - successValue
-
The currently returned success value
- terminalMsgs
-
When tracing is enabled, this collects up all the upper-most failures that happen at traceIndex (in fastparse.internal.Lazy wrappers) so they can be shown to the user at end-of-parse as suggestions for what could make the parse succeed. For terminal parsers like LiteralStr, it just aggregate's the string representation. For composite parsers like
a ~ bor!awhich may fail at traceIndex even without any of their wrapped terminal parsers failing there, it makes use of the shortMsg as the string representation of the composite parser. - traceIndex
-
The index we wish to trace if tracing is enabled, else -1. Used to find failure messages to aggregate into
terminalMsgs - verboseFailures
-
Whether or not we are currently collecting lastFailureMsgs; defaults to false, unless traceIndex is set OR we are inside a LogByNameOps.log call which necessitates tracing in order to print out failure traces during logging
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ParsingRun.type
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
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
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait BufferedParserInputclass ParserInputtrait IsReachableclass Objecttrait Matchableclass AnyShow all
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 and /* / multiline-comments, including nesting of / */ comments, as is the case in the Scala programming language
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ScalaWhitespace.type
Whitespace syntax that supports # line-comments, as in the case in programming languages such as Bash, Ruby, or Python
Whitespace syntax that supports # line-comments, as in the case in programming languages such as Bash, Ruby, or Python
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ScriptWhitespace.type
Attributes
- Supertypes
- Known subtypes
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
SharedPackageDefs.type
Whitespace syntax that consumes only single-line " " and "\t" whitespace characters.
Whitespace syntax that consumes only single-line " " and "\t" whitespace characters.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
SingleLineWhitespace.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object whitespaceobject whitespaceobject whitespaceobject noWhitespaceImplicitobject whitespaceobject whitespaceobject whitespaceShow all
Types
Shorthand alias for ParsingRun; this is both the parameter-to and the return type for all Fastparse's parsing methods.
Shorthand alias for ParsingRun; this is both the parameter-to and the return type for all Fastparse's parsing methods.
Type parameters
- T
-
is the type of the value returned by the parser method on success
Attributes
Inherited types
Shorthand for P[Unit]
Value members
Concrete methods
Positive lookahead operator: succeeds if the wrapped parser succeeds and fails if the wrapped parser fails, but in all cases consumes zero characters.
Positive lookahead operator: succeeds if the wrapped parser succeeds and fails if the wrapped parser fails, but in all cases consumes zero characters.
Attributes
Parses a single character in one of the input strings representing character classes
Parses a single character in one of the input strings representing character classes
Attributes
Parses a single character satisfying the given predicate
Parses a single character satisfying the given predicate
Attributes
Parses min or more characters as long as they satisfy the given predicate
Parses min or more characters as long as they satisfy the given predicate
Attributes
Parses min or more characters as long as they are contained in one of the input strings representing character classes
Parses min or more characters as long as they are contained in one of the input strings representing character classes
Attributes
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.
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.
Attributes
Efficiently parses any one of the given Strings; more efficient than chaining EagerOps.| together
Efficiently parses any one of the given Strings; more efficient than chaining EagerOps.| together
Attributes
Efficiently parses any one of the given Strings, case-insensitively; more efficient than chaining EagerOps.| together with IgnoreCase
Efficiently parses any one of the given Strings, case-insensitively; more efficient than chaining EagerOps.| together with IgnoreCase
Attributes
Inherited methods
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)
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)
Attributes
- Inherited from:
- SharedPackageDefs
Parser that is only successful at the end of the input. Useful to ensure your parser parses the whole file.
Parser that is only successful at the end of the input. Useful to ensure your parser parses the whole file.
Attributes
- Inherited from:
- SharedPackageDefs
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
Attributes
- Inherited from:
- SharedPackageDefs
No-op parser that always fails, consuming zero characters
No-op parser that always fails, consuming zero characters
Attributes
- Inherited from:
- SharedPackageDefs
Parses a string value case-insensitively
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
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
Attributes
- Inherited from:
- SharedPackageDefs
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.
Attributes
- Inherited from:
- SharedPackageDefs
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.
Attributes
- Inherited from:
- SharedPackageDefs
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
Attributes
- Inherited from:
- SharedPackageDefs
No-op parser that always succeeds, consuming zero characters
No-op parser that always succeeds, consuming zero characters
Attributes
- Inherited from:
- SharedPackageDefs
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
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
Attributes
- Inherited from:
- SharedPackageDefs
Parser that is only successful at the start of the input.
Parser that is only successful at the start of the input.
Attributes
- Inherited from:
- SharedPackageDefs
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
Value parameters
- input
-
the input to parse
- instrument
-
Callbacks that get run before and after every named
P(...)parser - parser
-
the parser method to use to parse the input
- startIndex
-
where in the input to start parsing
- verboseFailures
-
enable this to show a more detailed error message if a parser fails, without needing to run
.traced.trace. Defaults tofalseas it slows down parsing considerably
Attributes
- Inherited from:
- SharedPackageDefs
Attributes
- Inherited from:
- SharedPackageDefs
Concrete fields
Extensions
Extensions
Plain cut operator. Runs the parser, and if it succeeds, backtracking past that point is now prohibited
Plain cut operator. Runs the parser, and if it succeeds, backtracking past that point is now prohibited
Attributes
Optional operator. Parses the given input to wrap it in a Some, but if parsing fails backtracks and returns None
Optional operator. Parses the given input to wrap it in a Some, but if parsing fails backtracks and returns None
Attributes
Transforms the result of this parser using the given partial function, failing the parse if the partial function is not defined on the result of the current parser. This is eqivalent to .filter(f.isDefinedAt).map(f.apply)
Transforms the result of this parser using the given partial function, failing the parse if the partial function is not defined on the result of the current parser. This is eqivalent to .filter(f.isDefinedAt).map(f.apply)
Attributes
Tests the output of the parser with a given predicate, failing the parse if the predicate returns false. Useful for doing local validation on bits and pieces of your parsed output
Tests the output of the parser with a given predicate, failing the parse if the predicate returns false. Useful for doing local validation on bits and pieces of your parsed output
Attributes
Transforms the result of this parser using the given function into a new parser which is applied (after whitespace). Useful for doing dependent parsing, e.g. when parsing JSON you may first parse a character to see if it's a [, {, or ", and then deciding whether you next want to parse an array, dictionary or string.
Transforms the result of this parser using the given function into a new parser which is applied (after whitespace). Useful for doing dependent parsing, e.g. when parsing JSON you may first parse a character to see if it's a [, {, or ", and then deciding whether you next want to parse an array, dictionary or string.
Attributes
Transforms the result of this parser using the given function into a new parser which is applied (without consuming whitespace). Useful for doing dependent parsing, e.g. when parsing JSON you may first parse a character to see if it's a [, {, or ", and then deciding whether you next want to parse an array, dictionary or string.
Transforms the result of this parser using the given function into a new parser which is applied (without consuming whitespace). Useful for doing dependent parsing, e.g. when parsing JSON you may first parse a character to see if it's a [, {, or ", and then deciding whether you next want to parse an array, dictionary or string.
Attributes
Transforms the result of this parser using the given function. Useful for turning the Strings captured by ! and the tuples built by ~ into your own case classes or data structure
Transforms the result of this parser using the given function. Useful for turning the Strings captured by ! and the tuples built by ~ into your own case classes or data structure
Attributes
Repeat operator; runs the LHS parser 0 or more times separated by the given whitespace (in implicit scope), and returns a Seq[T] of the parsed values. On failure, backtracks to the starting index of the last run.
Repeat operator; runs the LHS parser 0 or more times separated by the given whitespace (in implicit scope), and returns a Seq[T] of the parsed values. On failure, backtracks to the starting index of the last run.
Attributes
Raw repeat operator; runs the LHS parser 0 or more times without any whitespace in between, and returns a Seq[T] of the parsed values. On failure, backtracks to the starting index of the last run.
Raw repeat operator; runs the LHS parser 0 or more times without any whitespace in between, and returns a Seq[T] of the parsed values. On failure, backtracks to the starting index of the last run.
Attributes
Either-or operator: tries to parse the left-hand-side, and if that fails it backtracks and tries to pass the right-hand-side. Can be chained more than once to parse larger numbers of alternatives.
Either-or operator: tries to parse the left-hand-side, and if that fails it backtracks and tries to pass the right-hand-side. Can be chained more than once to parse larger numbers of alternatives.
Attributes
Sequence operator. Runs two parsers one after the other, with optional whitespace in between.If both parsers return a value, this returns a tuple.
Sequence operator. Runs two parsers one after the other, with optional whitespace in between.If both parsers return a value, this returns a tuple.
Attributes
Sequence-with-cut operator. Runs two parsers one after the other, with optional whitespace in between. If the first parser completes successfully, backtracking is now prohibited. If both parsers return a value, this returns a tuple.
Sequence-with-cut operator. Runs two parsers one after the other, with optional whitespace in between. If the first parser completes successfully, backtracking is now prohibited. If both parsers return a value, this returns a tuple.
Attributes
Raw sequence operator. Runs two parsers one after the other, without whitespace in between. If both parsers return a value, this returns a tuple.
Raw sequence operator. Runs two parsers one after the other, without whitespace in between. If both parsers return a value, this returns a tuple.
Attributes
Raw sequence-with-cut operator. Runs two parsers one after the other, without whitespace in between. If the first parser completes successfully, backtracking is no longer prohibited. If both parsers return a value, this returns a tuple.
Raw sequence-with-cut operator. Runs two parsers one after the other, without whitespace in between. If the first parser completes successfully, backtracking is no longer prohibited. If both parsers return a value, this returns a tuple.
Attributes
Hides the internals of the given parser when it fails, such that it only succeeds completely or fails completely, and none of it's internal parsers end up in the failure traces or failure stack to be displayed to the user.
Hides the internals of the given parser when it fails, such that it only succeeds completely or fails completely, and none of it's internal parsers end up in the failure traces or failure stack to be displayed to the user.
Attributes
Repeat operator; runs the LHS parser at least min to at most max times separated by the given whitespace (in implicit scope) and separator sep, and returns a Seq[T] of the parsed values. On failure, backtracks to the starting index of the last run.
Repeat operator; runs the LHS parser at least min to at most max times separated by the given whitespace (in implicit scope) and separator sep, and returns a Seq[T] of the parsed values. On failure, backtracks to the starting index of the last run.
The convenience parameter exactly is provided to set both min and max to the same value.
Attributes
Raw repeat operator; runs the LHS parser at least min to at most max times separated by the separator sep without any whitespace in between, and returns a Seq[T] of the parsed values. On failure, backtracks to the starting index of the last run.
Raw repeat operator; runs the LHS parser at least min to at most max times separated by the separator sep without any whitespace in between, and returns a Seq[T] of the parsed values. On failure, backtracks to the starting index of the last run.
The convenience parameter exactly is provided to set both min and max to the same value.
Attributes
Negative lookahead operator: succeeds if the wrapped parser fails and fails if the wrapped parser succeeds. In all cases, it ends up consuming zero characters.
Negative lookahead operator: succeeds if the wrapped parser fails and fails if the wrapped parser succeeds. In all cases, it ends up consuming zero characters.
Attributes
Implicits
Implicits
Parses an exact string value.
Parses an exact string value.
Attributes
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
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
Attributes
Provides logging-related LogByNameOps implicits on String.