Parlot
The flags for the compiler
The default flags: Invocation lambda is inlined, no debug info
Prevents the inlining of the lambda in the Invocation expression to optimize for the multiple same lambda compiled once
Adds the Expression, ExpressionString, and CSharpString to the delegate closure for the debugging inspection
When the flag is set then instead of the returning `null` the specific exception is thrown*346
FEC Not Supported exception
The reason
Constructor
Constructor
The interface is implemented by the compiled delegate Target if `CompilerFlags.EnableDelegateDebugInfo` is set.
The lambda expression object that was compiled to the delegate
The lambda expression construction syntax C# code
The equivalent C# code of the lambda expression
Compiles expression to delegate ~20 times faster than Expression.Compile.
Partial to extend with your things when used as source file.
Compiles lambda expression to TDelegate type. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles a static method to the passed IL Generator.
Could be used as alternative for `CompileToMethod` like this .
Check `IssueTests.Issue179_Add_something_like_LambdaExpression_CompileToMethod.cs` for example.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Unifies Compile for System.Linq.Expressions and FEC.LightExpression
Unifies Compile for System.Linq.Expressions and FEC.LightExpression
Compiles lambda expression to TDelegate type. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to TDelegate type. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to TDelegate type. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.
Tries to compile lambda expression to
Tries to compile lambda expression to
with the provided closure object and constant expressions (or lack there of) -
Constant expression should be the in order of Fields in closure object!
Note 1: Use it on your own risk - FEC won't verify the expression is compile-able with passed closure, it is up to you!
Note 2: The expression with NESTED LAMBDA IS NOT SUPPORTED!
Note 3: `Label` and `GoTo` are not supported in this case, because they need first round to collect out-of-order labels
Tries to compile lambda expression to
with the provided closure object and constant expressions (or lack there of)
Tries to compile expression to "static" delegate, skipping the step of collecting the closure object.
Collects the lambda info for the compilation
Compiled lambda
The nested lambdas and their info
The lambda expression
Parameters not passed through lambda parameter list But used inside lambda body.
The top expression should Not contain not passed parameters.
Index of the compiled lambda in the parent lambda closure array
Index of the variable which store the non-passed variables array before passing it to the closure constructor.
It used to assign the closed variables from the outside of the nested lambda
Returns the type of lambda
Compares 2 lambda expressions for equality
Track the info required to build a closure object + some context information not directly related to closure.
Tracks that the last emit was an address
Tracks the use of the variables in the blocks stack per variable,
(uint) contains (ushort) BlockIndex in the upper bits and (ushort) VarIndex in the lower bits.
to determine if variable is the local variable and in what block it's defined
The map of inlined invocations collected in TryCollect and then used in TryEmit
New or Call expressions containing the complex expression, e.g. inlined Lambda Invoke or Try with Finally
The stack for the lambda invocation and the labels bound to them
This is required because we have the return from the nested lambda expression,
and when inlined in the parent lambda it is no longer the return but just a jump to the label.
Constant expressions to find an index (by reference) of constant expression from compiled expression.
Constant usage count and variable index.
It is a separate collection from the Constants because we directly convert later into the closure array
Parameters not passed through lambda parameter list But used inside lambda body.
The top expression should Not contain not passed parameters.
The nested lambdas and their info
Populates the info
Populates info directly with provided closure object and constants.
Local variable index is not known in the collecting phase when we only need to decide if ParameterExpression is an actual parameter or variable
Helps to identify constants as the one to be put into the Closure
Multi-dimensional array initializer is not supported
Quote is not supported
Dynamic is not supported
RuntimeVariables is not supported
MemberInit MemberBinding is not supported
MemberInit ListBinding is not supported
Goto of the Return kind from the TryCatch is not supported
Not supported assignment target
TypeEqual is not supported
`when` in catch is not supported yet
Wraps the call to `TryCollectInfo` for the compatibility and provide the root place to check the returned error code.
Imprtant: The method collects the info from the nested lambdas up-front and de-duplicates the lambdas as well.
Collects the information about closure constants, nested lambdas, non-passed parameters, goto labels and variables in blocks.
Returns `OK` result if everything is fine and other result for error.
Return IDelegateDebugInfo if the delegate is fast compiled with `CompilerFlags.EnableDelegateDebugInfo` flag
The minimal context-aware flags set by parent
Default is no flags
The result of expression is ignored and maybe popped out
Some parent is the call expression
Any Parent Expression is a MemberExpression
Some arithmetic operation
Subject
Expression with instance object (method call or member access or array access)
Subject
Subject
Combination`of InstanceAccess and Call
Constructor
Constructor call
Indexer
Invoking the inlined lambda (the default System.Expression behavior)
Indicate if the part AT LEAST participates in the assignment on the left side,
it may also participate in the right side, e.g. ++x.Bar
Indicates the ONLY right value of assignment, e.g. `p` in `foo.Bar += p`
Assigning the ref of the right value to the left, e.g. in `var a = ref b[1]` we are passing this flag for the `ref b[1]`
Supports emitting of selected expressions, e.g. lambdaExpr are not supported yet.
When emitter find not supported expression it will return false from , so I could fallback
to normal and slow Expression.Compile.
Get the advantage of the optimized specialized EmitCall method
Same as EmitMethodCall which checks the method for null first, and returns false if it is null.
Same as EmitMethodCallOrVirtualCall which checks the method for null first, and returns false if it is null.
Efficiently emit the int constant
Reflecting the internal methods to access the more performant for defining the local variable
Efficiently returns the next variable index, hopefully without unnecessary allocations.
Prints the expression in its constructing syntax -
helpful to get the expression from the debug session and put into it the code for the test.
Prints the expression in its constructing syntax -
helpful to get the expression from the debug session and put into it the code for the test.
In addition, returns the gathered expressions, parameters ad labels.
Converts the expression into the valid C# code representation
Tries hard to convert the expression into the valid C# code
Tries hard to convert the expression into the valid C# code
Tries hard to convert the expression into the valid C# code
Indicates the expression container
Prefers the parens by default
The test part of the If expression
The `if (test)` part
The lambda
Return expression
Instructs the client code to avoid parenthesis for the generated C# code, e.g. if we have as single argument in a method
The instance when calling the instance method or accessing the instance member
Converts the into the proper C# representation.
Prints valid C# Boolean
Prints valid C# String escaping the things
Prints valid C# Enum literal
Custom handler for output the object in valid C#. Note, the `printGenericTypeArgs` is excluded because it cannot be a open-generic object.
This handler is also used to allow user to fully control a Constant expression output
Outputs the `default(Type)` for the unknown constant with the comment message
Prints many code items as the array initializer.
Prints many code items as array initializer.
Prints a valid C# for known ,
otherwise uses passed or falls back to `ToString()`.
Helper method to find the number of lambdas in the C# `code` string
Wrapper for the array and count
Array of items
The count of used items
Creating this stuff
Creates the wrapper out of the items
Popping candy
SmallList module he-he
Appends the new default item at the end of the items. Assumes that `index lte items.Length`!
`items` should be not null
Appends the new default item at the end of the items. Assumes that `index lte items.Length`, `items` may be null
Returns surely present item ref by its index
Appends the new default item to the list and returns ref to it for write or read
Appends the new item to the list
Looks for the item in the list and return its index if found or -1 for the absent item
Returns the ref of the found item or appends the item to the end of the list, and returns ref to it
Returns surely present item ref by its index
Returns last present item ref, assumes that the list is not empty!
Returns the ref to tombstone indicating the missing item.
Appends the default item to the end of the list and returns the reference to it.
Looks for the item in the list and return its index if found or -1 for the absent item
Returns the ref of the found item or appends the item to the end of the list, and returns ref to it
Returns surely present item ref by its index
Returns last present item ref, assumes that the list is not empty!
Returns the ref to tombstone indicating the missing item.
Appends the default item to the end of the list and returns the reference to it.
Looks for the item in the list and return its index if found or -1 for the absent item
Returns the ref of the found item or appends the item to the end of the list, and returns ref to it
List with the number of first items (4) stored inside its struct and the rest in the growable array.
Supports addition and removal (removel is without resize) only at the end of the list, aka Stack behavior
The number of entries stored inside the map itself without moving them to array on heap
Gets the number of items in the list
Returns surely present item by its index
Adds the item to the end of the list aka the Stack.Push
Bridge to go from the List.Add
Adds the default item to the end of the list aka the Stack.Push default
Removes the last item from the list aka the Stack Pop. Assumes that the list is not empty!
Copy items to new the array
Exposing as list
List with the number of first items (2) stored inside its struct and the rest in the growable array.
Supports addition and removal (removel is without resize) only at the end of the list, aka Stack behavior
The number of entries stored inside the map itself without moving them to array on heap
Good stuff
Good stiff
Good steff
Good staff
Good styff
Good staff
Gets the number of items in the list
Returns surely present item by its index
Adds the item to the end of the list aka the Stack.Push
Sugar bridge from the List.Add
Adds the default item to the end of the list aka the Stack.Push default
Removes the last item from the list aka the Stack Pop. Assumes that the list is not empty!
Copy items to new the array
Exposing as list
Configiration and the tools for the FHashMap map data structure
Upper hash bits spent on storing the probes, e.g. 5 bits mean 31 probes max.
The number of entries stored inside the map itself without moving them to array on heap
Creates the map with the storage
Holds a single entry consisting of key and value.
Value may be set or changed but the key is set in stone (by construction).
The readonly key
The mutable value
Construct with the key and default value
Construct with the key and value
binary reprsentation of the `int`
Configures removed key tombstone, equality and hash function for the FHashMap
Defines the value of the key indicating the removed entry
Equals keys
Calculates and returns the hash of the key
Default comparer using the `object.GetHashCode` and `object.Equals` oveloads
Uses the `object.GetHashCode` and `object.ReferenceEquals`
Compares via `ReferenceEquals` and gets the hash faster via `RuntimeHelpers.GetHashCode`
Compares via `ReferenceEquals` and gets the hash faster via `RuntimeHelpers.GetHashCode`
Combines the hashes of 2 keys
Combines the hashes of 2 keys
Abstraction to configure your own entries data structure. Check the derivitives for the examples
Initializes the entries storage to the specified capacity via the number of bits in the capacity
Returns the reference to entry by its index, index should map to the present/non-removed entry
Adds the key at the "end" of entriesc- so the order of addition is preserved.
For now to use in the Set as a value
Stores the entries in a single dynamically reallocated array
Finds the stored value by key. If found returns ref to the value it can be modified in place.
Finds the stored value by key. If found returns ref to the value it can be modified in place.
Gets the reference to the existing value of the provided key, or the default value to set for the newly added key.
Adds the sure absent key entry.
Provides the performance in scenarios where you look for present key, and using it, and if ABSENT then add the new one.
So this method optimized NOT to look for the present item for the second time in SEQUENCE
Get the value ref by the entry index. Also the index corresponds to entry adding order.
Improtant: it does not checks the index bounds, so you need to check that the index is from 0 to map.Count-1
Fast and less-allocating hash map without thread safety nets. Please measure it in your own use case before use.
It is configurable in regard of hash calculation/equality via `TEq` type paremeter and
in regard of key-value storage via `TEntries` type parameter.
Details:
- Implemented as a struct so that the empty/default map does not allocate on heap
- Hashes and key-values are the separate collections enabling better cash locality and faster performance (data-oriented design)
- No SIMD for now to avoid complexity and costs for the smaller maps, so the map is more fit for the smaller sizes.
- Provides the "stable" enumeration of the entries in the added order
- The TryRemove method removes the hash but replaces the key-value entry with the tombstone key and the default value.
For instance, for the `RefEq` the tombstone is . You may redefine it in the `IEq{K}.GetTombstone()` implementation.
Capacity bits
Access to the hashes and indexes
Number of entries in the map
Access to the key-value entries
Capacity calculates as `1 leftShift capacityBitShift`
Specifies that null is allowed as an input even if the corresponding type disallows it.
Specifies that null is disallowed as an input even if the corresponding type allows it.
Applied to a method that will never return under any circumstance.
Specifies that the method will not return if the associated Boolean parameter is passed the specified value.
Initializes the attribute with the specified parameter value.
The condition parameter value. Code after the method will be considered unreachable
by diagnostics if the argument to the associated parameter matches this value.
Gets the condition parameter value.
Indicates that an API is experimental and it may change in the future.
This attribute allows call sites to be flagged with a diagnostic that indicates that an experimental
feature is used. Authors can use this attribute to ship preview features in their assemblies.
Initializes a new instance of the class,
specifying the ID that the compiler will use when reporting a use of the API the attribute applies to.
The ID that the compiler will use when reporting a use of the API the attribute applies to.
Gets the ID that the compiler will use when reporting a use of the API the attribute applies to.
The unique diagnostic ID.
The diagnostic ID is shown in build output for warnings and errors.
This property represents the unique ID that can be used to suppress the warnings or errors, if needed.
Gets or sets the URL for corresponding documentation.
The API accepts a format string instead of an actual URL, creating a generic URL that includes the diagnostic ID.
The format string that represents a URL to corresponding documentation.
An example format string is https://contoso.com/obsoletion-warnings/{0}.
Specifies that an output may be null even if the corresponding type disallows it.
Specifies that when a method returns , the parameter may be null even if the corresponding type disallows it.
Initializes the attribute with the specified return value condition.
The return value condition. If the method returns this value, the associated parameter may be null.
Gets the return value condition.
Specifies that the method or property will ensure that the listed field and property members have not-null values.
Initializes the attribute with a field or property member.
The field or property member that is promised to be not-null.
Initializes the attribute with the list of field and property members.
The list of field and property members that are promised to be not-null.
Gets field or property member names.
Specifies that the method or property will ensure that the listed field and property
members have not-null values when returning with the specified return value condition.
Initializes the attribute with the specified return value condition and a field or property member.
The return value condition. If the method returns this value, the associated parameter will not be null.
The field or property member that is promised to be not-null.
Initializes the attribute with the specified return value condition and list of field and property members.
The return value condition. If the method returns this value, the associated parameter will not be null.
The list of field and property members that are promised to be not-null.
Gets the return value condition.
Gets field or property member names.
Specifies that an output will not be null even if the corresponding type allows it.
Specifies that an input argument was not null when the call returns.
Specifies that the output will be non-null if the named parameter is non-null.
Initializes the attribute with the associated parameter name.
The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null.
Gets the associated parameter name.
Specifies that when a method returns , the parameter will not be null even if the corresponding type allows it.
Initializes the attribute with the specified return value condition.
The return value condition. If the method returns this value, the associated parameter will not be null.
Gets the return value condition.
Specifies that this constructor sets all required members for the current type,
and callers do not need to set any required members themselves.
Specifies the syntax used in a string.
Initializes the with the identifier of the syntax used.
The syntax identifier.
Initializes the with the identifier of the syntax used.
The syntax identifier.
Optional arguments associated with the specific syntax employed.
Gets the identifier of the syntax used.
Optional arguments associated with the specific syntax employed.
The syntax identifier for strings containing composite formats for string formatting.
The syntax identifier for strings containing date format specifiers.
The syntax identifier for strings containing date and time format specifiers.
The syntax identifier for strings containing format specifiers.
The syntax identifier for strings containing format specifiers.
The syntax identifier for strings containing JavaScript Object Notation (JSON).
The syntax identifier for strings containing numeric format specifiers.
The syntax identifier for strings containing regular expressions.
The syntax identifier for strings containing time format specifiers.
The syntax identifier for strings containing format specifiers.
The syntax identifier for strings containing URIs.
The syntax identifier for strings containing XML.
Used to indicate a byref escapes and is not scoped.
There are several cases where the C# compiler treats a as implicitly
- where the compiler does not allow the to escape the method.
For example:
- for instance methods.
- parameters that refer to types.
- parameters.
This attribute is used in those instances where the should be allowed to escape.
Applying this attribute, in any form, has impact on consumers of the applicable API. It is necessary for
API authors to understand the lifetime implications of applying this attribute and how it may impact their users.
Represent a type can be used to index a collection either from the start or the end.
Index is used by the C# compiler to support the new index syntax
int[] someArray = new int[5] { 1, 2, 3, 4, 5 } ;
int lastElement = someArray[^1]; // lastElement = 5
Construct an Index using a value and indicating if the index is from the start or from the end.
The index value. it has to be zero or positive number.
Indicating if the index is from the start or from the end.
If the Index constructed from the end, index value 1 means pointing at the last element and index value 0 means pointing at beyond last element.
Create an Index pointing at first element.
Create an Index pointing at beyond last element.
Create an Index from the start at the position indicated by the value.
The index value from the start.
Create an Index from the end at the position indicated by the value.
The index value from the end.
Returns the index value.
Indicates whether the index is from the start or the end.
Calculate the offset from the start using the giving collection length.
The length of the collection that the Index will be used with. length has to be a positive value
For performance reason, we don't validate the input length parameter and the returned offset value against negative values.
we don't validate either the returned offset is greater than the input length.
It is expected Index will be used with collections which always have non negative length/count. If the returned offset is negative and
then used to index a collection will get out of range exception which will be same affect as the validation.
Indicates whether the current Index object is equal to another object of the same type.
An object to compare with this object
Indicates whether the current Index object is equal to another Index object.
An object to compare with this object
Returns the hash code for this instance.
Converts integer number to an Index.
Converts the value of the current Index object to its equivalent string representation.
Represent a range has start and end indexes.
Range is used by the C# compiler to support the range syntax.
int[] someArray = new int[5] { 1, 2, 3, 4, 5 };
int[] subArray1 = someArray[0..2]; // { 1, 2 }
int[] subArray2 = someArray[1..^0]; // { 2, 3, 4, 5 }
Represent the inclusive start index of the Range.
Represent the exclusive end index of the Range.
Construct a Range object using the start and end indexes.
Represent the inclusive start index of the range.
Represent the exclusive end index of the range.
Indicates whether the current Range object is equal to another object of the same type.
An object to compare with this object
Indicates whether the current Range object is equal to another Range object.
An object to compare with this object
Returns the hash code for this instance.
Converts the value of the current Range object to its equivalent string representation.
Create a Range object starting from start index to the end of the collection.
Create a Range object starting from first element in the collection to the end Index.
Create a Range object starting from first element to the end.
Calculate the start offset and length of range object using a collection length.
The length of the collection that the range will be used with. length has to be a positive value.
For performance reason, we don't validate the input length parameter against negative values.
It is expected Range will be used with collections which always have non negative length/count.
We validate the range is inside the length scope though.
Indicates the type of the async method builder that should be used by a language compiler to
build the attributed async method or to build the attributed type when used as the return type
of an async method.
Initializes the .
The of the associated builder.
Gets the of the associated builder.
An attribute that allows parameters to receive the expression of other parameters.
Initializes a new instance of the class.
The condition parameter value.
Gets the parameter name the expression is retrieved from.
Initialize the attribute to refer to the method on the type.
The type of the builder to use to construct the collection.
The name of the method on the builder to use to construct the collection.
must refer to a static method that accepts a single parameter of
type and returns an instance of the collection being built containing
a copy of the data from that span. In future releases of .NET, additional patterns may be supported.
Gets the type of the builder to use to construct the collection.
Gets the name of the method on the builder to use to construct the collection.
This should match the metadata name of the target method.
For example, this might be ".ctor" if targeting the type's constructor.
Indicates that compiler support for a particular feature is required for the location where this attribute is applied.
Creates a new instance of the type.
The name of the feature to indicate.
The name of the compiler feature.
If true, the compiler can choose to allow access to the location where this attribute is applied if it does not understand .
The used for the ref structs C# feature.
The used for the required members C# feature.
Indicates which arguments to a method involving an interpolated string handler should be passed to that handler.
Initializes a new instance of the class.
The name of the argument that should be passed to the handler.
may be used as the name of the receiver in an instance method.
Initializes a new instance of the class.
The names of the arguments that should be passed to the handler.
may be used as the name of the receiver in an instance method.
Gets the names of the arguments that should be passed to the handler.
may be used as the name of the receiver in an instance method.
Indicates the attributed type is to be used as an interpolated string handler.
Reserved to be used by the compiler for tracking metadata.
This class should not be used by developers in source code.
Used to indicate to the compiler that a method should be called
in its containing module's initializer.
When one or more valid methods
with this attribute are found in a compilation, the compiler will
emit a module initializer which calls each of the attributed methods.
Certain requirements are imposed on any method targeted with this attribute:
- The method must be `static`.
- The method must be an ordinary member method, as opposed to a property accessor, constructor, local function, etc.
- The method must be parameterless.
- The method must return `void`.
- The method must not be generic or be contained in a generic type.
- The method's effective accessibility must be `internal` or `public`.
The specification for module initializers in the .NET runtime can be found here:
https://github.com/dotnet/runtime/blob/main/docs/design/specs/Ecma-335-Augments.md#module-initializer
Specifies that a type has required members or that a member is required.
Reserved for use by a compiler for tracking metadata.
This attribute should not be used by developers in source code.
Used to indicate to the compiler that the .locals init flag should not be set in method headers.
Initializes a new instance of the class.
Initializes a new instance of the class with the specified message.
An optional message associated with this attribute instance.
Returns the optional message associated with this attribute instance.
Returns the optional URL associated with this attribute instance.
Cache of char to string mapping to reduce allocations
when doing chars comparisons.
Reprensents the context of a compilation phase, coordinating all the parsers involved.
Gets the expression containing the the instance for the parser.
Gets or sets a counter used to generate unique variable names.
Gets the list of global variables to add the the final list of statements.
Gets the list of global expressions to add the the final list of statements.
Gets the list of shared lambda expressions representing intermediate parsers.
This is used for debug only, in order to inspect the source generated for these intermediate parsers.
Gets or sets whether the current compilation phase should ignore the results of the parsers.
When set to false, the compiled statements don't need to record and define the property.
This is done to optimize compiled parser that are usually used for pattern matching only.
Every parser that is compiled returns an instance of which encapsulates the statements to execute in order
to parse the expected input.
The convention is that these statements are returned in the property, and any variable that needs to be declared in the block
that the is used in are set in the list.
The property reprsents the variable that contains the success of the statements once executed, and if true then
the property contains the result.
Gets the list of representing the variables used by the compiled result.
Gets the list of representing the body of the compiled results.
Gets or sets the of the variable representing the success of the parsing statements.
Gets or sets the of the variable representing the value of the parsing statements.
Marker interface to detect a Parser has already been compiled.
An instance of this class encapsulates the result of a compiled parser
in order to expose is as as standard parser contract.
This class is used in .
Creates a compiled representation of a parser.
The current compilation context.
Advances the cursor by one character.
Advances the cursor.
Advances the cursor with the knowledge there are no new lines.
Moves the cursor to the specific position
Evaluates the char at the current position.
Returns the cursor's position in the _buffer.
Evaluates a char forward in the _buffer.
Whether a char is at the current position.
Whether a string is at the current position.
Whether a string is at the current position.
Doesn't parse anything and return the default value.
Doesn't parse anything and return the default value.
Returns a default value if the previous parser failed.
Successful when the cursor is at the end of the string.
OneOf the inner choices when all parsers return the same type.
We then return the actual result of each parser.
The number of usages of the parser before it is compiled automatically. 0 to disable automatic compilation. Default is 0.
Whether new lines are treated as normal chars or white spaces. Default is false.
When false, new lines will be skipped like any other white space.
Otherwise new lines need to be read explicitely by a rule.
The scanner used for the parsing session.
Delegate that is executed whenever a parser is invoked.
The parser that is used to parse whitespaces and comments.
Called whenever a parser is invoked. Will be used to detect invalid states and infinite loops.
Compiles the current parser.
A compiled parser.
Invokes the method of the if it's available or
creates a generic one.
The instance.
Forces the instruction to compute the resulting value whatever the state of is.
Builds a parser that converts the previous result when it succeeds.
Builds a parser that converts the previous result, and can alter the current .
Builds a parser that converts the previous result.
Builds a parser that converts the previous result when it succeeds or returns a default value if it fails.
Builds a parser that converts the previous result or returns a default value if it fails, and can alter the current .
Builds a parser that converts the previous result or returns a default value if it fails.
Builds a parser that emits an error when the previous parser failed.
Builds a parser that emits an error.
Builds a parser that emits an error.
Builds a parser that verifies the previous parser result matches a predicate.
Builds a parser what returns another one based on the previous result.
Builds a parser that ensures the cursor is at the end of the input.
Builds a parser that discards the previous result and replaces it by the specified type or value.
Builds a parser that discards the previous result and replaces it by the specified type or value.
Builds a parser that returns a default value if the previous parser fails.
Builds a parser that ensure the specified parsers match consecutively.
Builds a parser that ensure the specified parsers match consecutively.
Builds a parser that ensure the specified parsers match consecutively.
Builds a parser that ensure the specified parsers match consecutively.
Builds a parser that ensure the specified parsers match consecutively.
Builds a parser that ensure the specified parsers match consecutively.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Provides parsers for literals. Literals do not skip spaces before being parsed and can be combined to
parse composite terms.
Provides parsers for terms. Terms skip spaces before being parsed.
Builds a parser that looks for zero or many times a parser separated by another one.
Builds a parser that skips white spaces before another one.
Builds a parser that looks for zero or one time the specified parser.
Builds a parser that looks for zero or many times the specified parser.
Builds a parser that looks for one or many times the specified parser.
Builds a parser that succeeds when the specified parser fails to match.
Builds a parser that can be defined later one. Use it when a parser need to be declared before its rule can be set.
Builds a parser than needs a reference to itself to be declared.
Builds a parser that matches the specified parser between two other ones.
Builds a parser that matches any chars before a specific parser.
Builds a parser that captures the output of another parser.
This is used to provide pattern matching capabilities, and optimized compiled parsers that then don't need to materialize each parser result.
Builds a parser that always succeeds.
Builds a parser that always succeeds.
Builds a parser that always succeeds.
Builds a parser that return either of the first successful of the specified parsers.
Builds a parser that return either of the first successful of the specified parsers.
Builds a parser that return either of the first successful of the specified parsers.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that ensure the specified parsers match consecutively. The last parser's result is then ignored.
Builds a parser that creates a left-associative structure.
c.f. https://en.wikipedia.org/wiki/Operator_associativity
The type of the returned parser.
The type of the symbol parsers.
The higher-priority parser the symbols are separating.
The list of operators that can be parsed and their associated result factory methods.
// additive => multiplicative(("-" | "+") multiplicative) * ;
var additive = multiplicative.LeftAssociative(
(plus, static (a, b) => new Addition(a, b)),
(minus, static (a, b) => new Subtraction(a, b))
);
Builds a parser that creates a left-associative structure.
c.f. https://en.wikipedia.org/wiki/Operator_associativity
The type of the returned parser.
The type of the symbol parsers.
The higher-priority parser the symbols are separating.
The list of operators that can be parsed and their associated result factory methods.
// additive => multiplicative(("-" | "+") multiplicative) * ;
var additive = multiplicative.LeftAssociative(
(plus, static (a, b) => new Addition(a, b)),
(minus, static (a, b) => new Subtraction(a, b))
);
Builds a parser that creates a right-associative structure.
c.f. https://en.wikipedia.org/wiki/Operator_associativity
The type of the returned parser.
The type of the symbol parsers.
The higher-priority parser the symbols are separating.
The list of operators that can be parsed and their associated result factory methods.
// exponentiation => primary( ("^") primary) * ;
var exponentiation = primary.RightAssociative(
(equal, static (a, b) => new Exponent(a, b))
);
Builds a parser that creates a right-associative structure.
c.f. https://en.wikipedia.org/wiki/Operator_associativity
The type of the returned parser.
The type of the symbol parsers.
The higher-priority parser the symbols are separating.
The list of operators that can be parsed and their associated result factory methods.
// exponentiation => primary( ("^") primary) * ;
var exponentiation = primary.RightAssociative(
(equal, static (a, b) => new Exponent(a, b))
);
Builds a parser that creates a unary operation.
The type of the returned parser.
The type of the symbol parsers.
The higher-priority parser the symbols are separating.
The list of operators that can be parsed and their associated result factory methods.
Builds a parser that creates a unary operation.
The type of the returned parser.
The type of the symbol parsers.
The higher-priority parser the symbols are separating.
The list of operators that can be parsed and their associated result factory methods.
Builds a parser that matches whitespaces.
Builds a parser that matches anything until whitespaces.
Builds a parser that matches the specified text.
Builds a parser that matches the specified char.
Builds a parser that matches an integer.
Builds a parser that matches a floating point number represented as a value.
Builds a parser that matches a floating point number represented as a value.
Builds a parser that matches a floating point number represented as a value.
Builds a parser that matches an quoted string that can be escaped.
Builds a parser that matches an identifier.
Builds a parser that matches a char against a predicate.
The predicate to match against each char.
The minimum number of matches required. Defaults to 1.
When the parser reaches the maximum number of matches it returns . Defaults to 0, i.e. no maximum size.
Builds a parser that matches anything until whitespaces.
Builds a parser that matches the specified text.
Builds a parser that matches the specified char.
Builds a parser that matches an integer.
Builds a parser that matches a floating point number represented as a value.
Builds a parser that matches a floating point number represented as a value.
Builds a parser that matches a floating point number represented as a value.
Builds a parser that matches an quoted string that can be escaped.
Builds a parser that matches an identifier.
Builds a parser that matches a char against a predicate.
The predicate to match against each char.
The minimum number of matches required. Defaults to 1.
When the parser reaches the maximum number of matches it returns . Defaults to 0, i.e. no maximum size.
Routes the parsing based on a custom delegate.
Returns a new converting the input value of
type T to the output value of type U using a custom function.
The input parser type.
The output parser type.
Ensure the given parser is valid based on a condition, and backtracks if not.
The output parser type.
A Parser implementing this interface can be rewritten in a more optimized way.
The result will replace the instance.
Returns the parser to substitute.
A Parser implementing this interface can only be triggered if the next char matches the one provided.
It is used to create char lookups to optimize which Parsers need to be invoked next.
Gets whether the current parser can be selected from a single char.
This could vary based on the subsequent parsers.
Gets the chars that can be matched next to evaluate this Parser.
Gets whether the current parser needs to skip whitespaces before being invoked.
This class is used to return tokens extracted from the input buffer.
Scans some text.
The string containing the text to scan.
Reads any whitespace without generating a token.
Whether some white space was read.
Reads a token while the specific predicate is valid.
Reads a token while the specific predicate is valid.
Reads the specified text.
Reads the specified text.
Reads the specific expected text.
Reads the specific expected text.
Reads the specific expected text.
Reads the specific expected text.
Reads a string token enclosed in single or double quotes.
This method doesn't escape the string, but only validates its content is syntactically correct.
The resulting Span contains the original quotes.
Represents a position in a text buffer.
Map from an ASCII char to its hex value, e.g. arr['b'] == 11. 0xFF means it's not a hex digit.