LanguageExt.Parsec

LanguageExt.Parsec

Contents

Sub modules

ParserIOs
Parsers

class Common Source #

Methods

method Parser<T> setDefPos <T> (Pos defpos, Parser<T> p) Source #

method bool onside (Pos pos, Pos delta) Source #

method ParserError mergeError (ParserError? err1, ParserError? err2) Source #

method Reply<T> mergeErrorReply <T> (ParserError err, Reply<T> reply) Source #

class ParserException Source #

Constructors

constructor ParserException () Source #

constructor ParserException (string message) Source #

constructor ParserException (string message, Exception innerException) Source #

class GenLanguageDef Source #

The GenLanguageDef type is a record that contains all parameteridable features of the "Parsec.Text.Token" module. The module "Parsec.Text.Language" contains some default definitions.

Fields

field string CommentStart Source #

Describes the start of a block comment. Use the empty string if the language doesn't support block comments. For example "/*".

field string CommentEnd Source #

Describes the end of a block comment. Use the empty string if the language doesn't support block comments. For example "*".

field string CommentLine Source #

Describes the start of a line comment. Use the empty string if the language doesn't support line comments. For example "//".

field bool NestedComments Source #

Set to 'True' if the language supports nested block comments.

field Parser<char> IdentStart Source #

This parser should accept any start characters of identifiers. For example either(letter,char('_')).

field Parser<char> IdentLetter Source #

This parser should accept any legal tail characters of identifiers. For example either(alphaNum, char('_')).

field Parser<char> OpStart Source #

This parser should accept any start characters of operators. For example oneOf(":!#$%&*+./\〈=〉?@\\^|-~")

field Parser<char> OpLetter Source #

This parser should accept any legal tail characters of operators. Note that this parser should even be defined if the language doesn't support user-defined operators, or otherwise the 'reservedOp' parser won't work correctly.

field Lst<string> ReservedNames Source #

The list of reserved identifiers.

field Lst<string> ReservedOpNames Source #

The list of reserved operators.

field bool CaseSensitive Source #

Set to 'True' if the language is case sensitive.

Methods

method GenLanguageDef With ( string? CommentStart = null, string? CommentEnd = null, string? CommentLine = null, bool? NestedComments = null, Parser<char>? IdentStart = null, Parser<char>? IdentLetter = null, Parser<char>? OpStart = null, Parser<char>? OpLetter = null, Lst<string>? ReservedNames = null, Lst<string>? ReservedOpNames = null, bool? CaseSensitive = null ) Source #

class GenTokenParser Source #

Fields

field Parser<string> Identifier Source #

This lexeme parser parses a legal identifier. Returns the identifier string. This parser will fail on identifiers that are reserved words. Legal identifier (start) characters and reserved words are defined in the 'LanguageDef' that is passed to 'makeTokenParser'. An identifier is treated as a single token using 'try'.

field Func<string, Parser<string>> Reserved Source #

The lexeme parser reserved(name) parses a symbol name, but it also checks that the name is not a prefix of a valid identifier. A reserved word is treated as a single token using 'try'.

field Parser<string> Operator Source #

This lexeme parser parses a legal operator. Returns the name of the operator. This parser will fail on any operators that are reserved operators. Legal operator (start) characters and reserved operators are defined in the 'LanguageDef' that is passed to 'makeTokenParser'. An operator is treated as a single token using 'try'.

field Func<string, Parser<Unit>> ReservedOp Source #

The lexeme parser reservedOp name parses symbol name, but it also checks that the name is not a prefix of a valid operator. A reservedOp is treated as a single token using 'try'.

field Parser<char> CharLiteral Source #

This lexeme parser parses a single literal character. Returns the literal character value. This parsers deals correctly with escape sequences. The literal character is parsed according to the grammar rules defined in the Haskell report (which matches most programming languages quite closely).

field Parser<string> StringLiteral Source #

This lexeme parser parses a literal string. Returns the literal string value. This parsers deals correctly with escape sequences and gaps. The literal string is parsed according to the grammar rules defined in the Haskell report (which matches most programming languages quite closely).

field Parser<int> Natural Source #

This lexeme parser parses a natural number (a positive whole number). Returns the value of the number. The number can be specified in 'decimal', 'hexadecimal' or 'octal'. The number is parsed according to the grammar rules in the Haskell report.

field Parser<int> Integer Source #

This lexeme parser parses an integer (a whole number). This parser is like 'natural' except that it can be prefixed with sign (i.e. '-' or '+'). Returns the value of the number. The number can be specified in 'decimal', 'hexadecimal' or 'octal'. The number is parsed according to the grammar rules in the Haskell report.

field Parser<double> Float Source #

This lexeme parser parses a floating point value. Returns the value of the number. The number is parsed according to the grammar rules defined in the Haskell report.

field Parser<Either<int,double>> NaturalOrFloat Source #

This lexeme parser parses either 'natural' or a 'float'. Returns the value of the number. This parsers deals with any overlap in the grammar rules for naturals and floats. The number is parsed according to the grammar rules defined in the Haskell report.

field Parser<int> Decimal Source #

Parses a positive whole number in the decimal system. Returns the value of the number.

field Parser<int> Hexadecimal Source #

Parses a positive whole number in the hexadecimal system. The number should be prefixed with "0x" or "0X". Returns the value of the number.

field Parser<int> Octal Source #

Parses a positive whole number in the octal system. The number should be prefixed with "0o" or "0O". Returns the value of the number.

field Func<string, Parser<string>> Symbol Source #

Lexeme parser symbol(s) parses 'string' s and skips trailing white space.

field Parser<Unit> WhiteSpace Source #

Parses any white space. White space consists of /zero/ or more occurrences of a 'space', a line comment or a block (multi line) comment. Block comments may be nested. How comments are started and ended is defined in the 'LanguageDef' that is passed to 'makeTokenParser'.

field Parser<string> Semi Source #

Lexeme parser semi parses the character ; and skips any trailing white space. Returns the string ";".

field Parser<string> Comma Source #

Lexeme parser comma parses the character , and skips any trailing white space. Returns the string ",".

field Parser<string> Colon Source #

Lexeme parser colon parses the character : and skips any trailing white space. Returns the string ":".

field Parser<string> Dot Source #

Lexeme parser dot parses the character . and skips any trailing white space. Returns the string ".".

Methods

method Parser<T> Lexeme <T> (Parser<T> p) Source #

lexeme(p) first applies parser p and than the 'whiteSpace' parser, returning the value of p. Every lexical token (lexeme) is defined using lexeme, this way every parse starts at a point without white space. Parsers that use lexeme are called lexeme parsers in this document.

The only point where the 'whiteSpace' parser should be called explicitly is the start of the main parser in order to skip any leading white space.

method Parser<T> Parens <T> (Parser<T> p) Source #

Lexeme parser parens(p) parses p enclosed in parenthesis, returning the value of p.

method Parser<T> Braces <T> (Parser<T> p) Source #

Lexeme parser braces(p) parses p enclosed in braces { and }, returning the value of p.

method Parser<T> Angles <T> (Parser<T> p) Source #

Lexeme parser angles(p) parses p enclosed in angle brackets 〈 and 〉, returning the value of p.

method Parser<T> Brackets <T> (Parser<T> p) Source #

Lexeme parser brackets(p) parses p enclosed in brackets [ and ], returning the value of p.

method Parser<Seq<T>> SemiSep <T> (Parser<T> p) Source #

Lexeme parser semiSep(p) parses /zero/ or more occurrences of p separated by semi. Returns a list of values returned by p.

method Parser<Seq<T>> SemiSep1 <T> (Parser<T> p) Source #

Lexeme parser semiSep1(p) parses /one/ or more occurrences of p separated by 'semi'. Returns a list of values returned by p.

method Parser<Seq<T>> CommaSep <T> (Parser<T> p) Source #

Lexeme parser commaSep(p) parses /zero/ or more occurrences of p separated by 'comma'. Returns a list of values returned by p.

method Parser<Seq<T>> CommaSep1 <T> (Parser<T> p) Source #

Lexeme parser commaSep1(p) parses /one/ or more occurrences of p separated by 'comma'. Returns a list of values returned by p.

method Parser<Seq<T>> BracketsCommaSep1 <T> (Parser<T> p) Source #

method Parser<Seq<T>> BracketsCommaSep <T> (Parser<T> p) Source #

method Parser<Seq<T>> ParensCommaSep1 <T> (Parser<T> p) Source #

method Parser<Seq<T>> ParensCommaSep <T> (Parser<T> p) Source #

method Parser<Seq<T>> AnglesCommaSep1 <T> (Parser<T> p) Source #

method Parser<Seq<T>> AnglesCommaSep <T> (Parser<T> p) Source #

method Parser<Seq<T>> BracesCommaSep1 <T> (Parser<T> p) Source #

method Parser<Seq<T>> BracesCommaSep <T> (Parser<T> p) Source #

method Parser<Seq<T>> BracketsSemiSep1 <T> (Parser<T> p) Source #

method Parser<Seq<T>> BracketsSemiSep <T> (Parser<T> p) Source #

method Parser<Seq<T>> ParensSemiSep1 <T> (Parser<T> p) Source #

method Parser<Seq<T>> ParensSemiSep <T> (Parser<T> p) Source #

method Parser<Seq<T>> AnglesSemiSep1 <T> (Parser<T> p) Source #

method Parser<Seq<T>> AnglesSemiSep <T> (Parser<T> p) Source #

method Parser<Seq<T>> BracesSemiSep1 <T> (Parser<T> p) Source #

method Parser<Seq<T>> BracesSemiSep <T> (Parser<T> p) Source #

class GenTokenParser2 Source #

Fields

field Parser<(string Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Identifier Source #

This lexeme parser parses a legal identifier. Returns the identifier string. This parser will fail on identifiers that are reserved words. Legal identifier (start) characters and reserved words are defined in the 'LanguageDef' that is passed to 'makeTokenParser'. An identifier is treated as a single token using 'try'.

field Func<string, Parser<(string Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)>> Reserved Source #

The lexeme parser reserved(name) parses a symbol name, but it also checks that the name is not a prefix of a valid identifier. A reserved word is treated as a single token using 'try'.

field Parser<(string Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Operator Source #

This lexeme parser parses a legal operator. Returns the name of the operator. This parser will fail on any operators that are reserved operators. Legal operator (start) characters and reserved operators are defined in the 'LanguageDef' that is passed to 'makeTokenParser'. An operator is treated as a single token using 'try'.

field Func<string, Parser<(Unit Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)>> ReservedOp Source #

The lexeme parser reservedOp name parses symbol name, but it also checks that the name is not a prefix of a valid operator. A reservedOp is treated as a single token using 'try'.

field Parser<(char Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> CharLiteral Source #

This lexeme parser parses a single literal character. Returns the literal character value. This parsers deals correctly with escape sequences. The literal character is parsed according to the grammar rules defined in the Haskell report (which matches most programming languages quite closely).

field Parser<(string Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> StringLiteral Source #

This lexeme parser parses a literal string. Returns the literal string value. This parsers deals correctly with escape sequences and gaps. The literal string is parsed according to the grammar rules defined in the Haskell report (which matches most programming languages quite closely).

field Parser<(int Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Natural Source #

This lexeme parser parses a natural number (a positive whole number). Returns the value of the number. The number can be specified in 'decimal', 'hexadecimal' or 'octal'. The number is parsed according to the grammar rules in the Haskell report.

field Parser<(int Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Integer Source #

This lexeme parser parses an integer (a whole number). This parser is like 'natural' except that it can be prefixed with sign (i.e. '-' or '+'). Returns the value of the number. The number can be specified in 'decimal', 'hexadecimal' or 'octal'. The number is parsed according to the grammar rules in the Haskell report.

field Parser<(double Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Float Source #

This lexeme parser parses a floating point value. Returns the value of the number. The number is parsed according to the grammar rules defined in the Haskell report.

field Parser<(Either<int, double> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> NaturalOrFloat Source #

This lexeme parser parses either 'natural' or a 'float'. Returns the value of the number. This parsers deals with any overlap in the grammar rules for naturals and floats. The number is parsed according to the grammar rules defined in the Haskell report.

field Parser<(int Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Decimal Source #

Parses a positive whole number in the decimal system. Returns the value of the number.

field Parser<(int Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Hexadecimal Source #

Parses a positive whole number in the hexadecimal system. The number should be prefixed with "0x" or "0X". Returns the value of the number.

field Parser<(int Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Octal Source #

Parses a positive whole number in the octal system. The number should be prefixed with "0o" or "0O". Returns the value of the number.

field Func<string, Parser<(string Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)>> Symbol Source #

Lexeme parser symbol(s) parses 'string' s and skips trailing white space.

field Parser<Unit> WhiteSpace Source #

Parses any white space. White space consists of /zero/ or more occurrences of a 'space', a line comment or a block (multi line) comment. Block comments may be nested. How comments are started and ended is defined in the 'LanguageDef' that is passed to 'makeTokenParser'.

field Parser<(string Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Semi Source #

Lexeme parser semi parses the character ; and skips any trailing white space. Returns the string ";".

field Parser<(string Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Comma Source #

Lexeme parser comma parses the character , and skips any trailing white space. Returns the string ",".

field Parser<(string Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Colon Source #

Lexeme parser colon parses the character : and skips any trailing white space. Returns the string ":".

field Parser<(string Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Dot Source #

Lexeme parser dot parses the character . and skips any trailing white space. Returns the string ".".

Methods

method Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Lexeme <A> (Parser<A> p) Source #

lexeme(p) first applies parser p and than the 'whiteSpace' parser, returning the value of p. Every lexical token (lexeme) is defined using lexeme, this way every parse starts at a point without white space. Parsers that use lexeme are called lexeme parsers in this document.

The only point where the 'whiteSpace' parser should be called explicitly is the start of the main parser in order to skip any leading white space.

method Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Parens <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

Lexeme parser parens(p) parses p enclosed in parenthesis, returning the value of p.

method Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Braces <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

Lexeme parser braces(p) parses p enclosed in braces { and }, returning the value of p.

method Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Angles <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

Lexeme parser angles(p) parses p enclosed in angle brackets〈 and 〉, returning the value of p.

method Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> Brackets <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

Lexeme parser brackets(p) parses p enclosed in brackets [ and ], returning the value of p.

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> SepBy <A, S> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p, Parser<S> sep) Source #

Lexeme parser semiSep(p) parses /zero/ or more occurrences of p separated by semi. Returns a list of values returned by p.

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> SepBy1 <A, S> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p, Parser<S> sep) Source #

Lexeme parser semiSep1(p) parses /one/ or more occurrences of p separated by 'semi'. Returns a list of values returned by p.

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> SemiSep <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

Lexeme parser semiSep(p) parses /zero/ or more occurrences of p separated by semi. Returns a list of values returned by p.

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> SemiSep1 <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

Lexeme parser semiSep1(p) parses /one/ or more occurrences of p separated by 'semi'. Returns a list of values returned by p.

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> CommaSep <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

Lexeme parser commaSep(p) parses /zero/ or more occurrences of p separated by 'comma'. Returns a list of values returned by p.

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> CommaSep1 <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

Lexeme parser commaSep1(p) parses /one/ or more occurrences of p separated by 'comma'. Returns a list of values returned by p.

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> BracketsCommaSep1 <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> BracketsCommaSep <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> ParensCommaSep1 <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> ParensCommaSep <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> AnglesCommaSep1 <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> AnglesCommaSep <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> BracesCommaSep1 <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> BracesCommaSep <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> BracketsSemiSep1 <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> BracketsSemiSep <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> ParensSemiSep1 <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> ParensSemiSep <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> AnglesSemiSep1 <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> AnglesSemiSep <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> BracesSemiSep1 <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

method Parser<(Seq<A> Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> BracesSemiSep <A> (Parser<(A Value, Pos BeginPos, Pos EndPos, int BeginIndex, int EndIndex)> p) Source #

class Language Source #

Fields

class Operator Source #

Methods

method Operator<I, O> Infix <I, O> (Assoc assoc, Parser<I, Func<O, O, O>> p) Source #

method Operator<I, O> Prefix <I, O> (Parser<I, Func<O, O>> p) Source #

method Operator<I, O> Postfix <I, O> (Parser<I, Func<O, O>> p) Source #

class Operator <I, O> Source #

Fields

field OperatorTag Tag Source #

Constructors

constructor Operator (OperatorTag tag) Source #

Methods

method (Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O>>>, Seq<Parser<I, Func<O, O>>>) SplitOp ( (Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O>>>, Seq<Parser<I, Func<O, O>>>) state) Source #

class InfixOp <I, O> Source #

Fields

field Assoc Assoc Source #

field Parser<I, Func<O, O, O>> Op Source #

Methods

method (Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O>>>, Seq<Parser<I, Func<O, O>>>) SplitOp ( (Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O>>>, Seq<Parser<I, Func<O, O>>>) state) Source #

class PrefixOp <I, O> Source #

Fields

field Parser<I, Func<O, O>> Op Source #

Methods

method (Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O>>>, Seq<Parser<I, Func<O, O>>>) SplitOp ( (Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O>>>, Seq<Parser<I, Func<O, O>>>) state) Source #

class PostfixOp <I, O> Source #

Fields

field Parser<I, Func<O, O>> Op Source #

Methods

method (Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O>>>, Seq<Parser<I, Func<O, O>>>) SplitOp ( (Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O, O>>>, Seq<Parser<I, Func<O, O>>>, Seq<Parser<I, Func<O, O>>>) state) Source #

enum Assoc Source #

class Operator Source #

Methods

method Operator<A> Infix <A> (Assoc assoc, Parser<Func<A, A, A>> p) Source #

method Operator<A> Prefix <A> (Parser<Func<A, A>> p) Source #

method Operator<A> Postfix <A> (Parser<Func<A, A>> p) Source #

class Operator <A> Source #

Fields

field OperatorTag Tag Source #

Constructors

constructor Operator (OperatorTag tag) Source #

Methods

method (Seq<Parser<Func<A,A,A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A>>>, Seq<Parser<Func<A, A>>>) SplitOp ( (Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A>>>, Seq<Parser<Func<A, A>>>) state) Source #

class InfixOp <A> Source #

Fields

field Assoc Assoc Source #

field Parser<Func<A, A, A>> Op Source #

Methods

method (Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A>>>, Seq<Parser<Func<A, A>>>) SplitOp ( (Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A>>>, Seq<Parser<Func<A, A>>>) state) Source #

class PrefixOp <A> Source #

Fields

field Parser<Func<A, A>> Op Source #

Methods

method (Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A>>>, Seq<Parser<Func<A, A>>>) SplitOp ( (Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A>>>, Seq<Parser<Func<A, A>>>) state) Source #

class PostfixOp <A> Source #

Fields

field Parser<Func<A, A>> Op Source #

Methods

method (Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A>>>, Seq<Parser<Func<A, A>>>) SplitOp ( (Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A, A>>>, Seq<Parser<Func<A, A>>>, Seq<Parser<Func<A, A>>>) state) Source #

delegate Parser <T> Source #

Parser delegate type - Parses an input PString and returns a ParserResult

Parameters

type T

Parsed value result type

param input

Input string

returns

Parsed value or error report

class ParserExtensions Source #

Methods

method Parser<T> label <T> (this Parser<T> p, string expected) Source #

A label for the parser

Parameters

param expected

What was expected

method ParserResult<T> Parse <T> (this Parser<T> self, PString input) Source #

method ParserResult<T> Parse <T> (this Parser<T> self, string input) Source #

method Parser<T> Filter <T> (this Parser<T> self, Func<T, bool> pred) Source #

method Parser<T> Where <T> (this Parser<T> self, Func<T, bool> pred) Source #

method Parser<U> Map <T, U> (this Parser<T> self, Func<T, U> map) Source #

method Parser<U> Select <T, U> (this Parser<T> self, Func<T, U> map) Source #

method Parser<B> Bind <A, B> (this Parser<A> self, Func<A, Parser<B>> f) Source #

method Parser<B> SelectMany <A, B> ( this Parser<A> self, Func<A, Parser<B>> f) Source #

method Parser<V> SelectMany <T, U, V> ( this Parser<T> self, Func<T, Parser<U>> bind, Func<T, U, V> project) Source #

method Parser<A> Flatten <A> (this Parser<Parser<A>> mma) Source #

method Parser<T> Flatten <T> (this Parser<Option<T>> p, Func<string> failureText) Source #

method Parser<R> Flatten <L, R> (this Parser<Either<L, R>> p, Func<L, string> failureText) Source #

method Parser<R> Flatten <R> (this Parser<Either<string,R>> p) Source #

class ParserError Source #

Fields

field ParserErrorTag Tag Source #

field Pos Pos Source #

field string Msg Source #

field Lst<string> Expected Source #

field ParserError? Inner Source #

Constructors

constructor ParserError (ParserErrorTag tag, Pos pos, string message, Lst<string> expected, ParserError? inner = null) Source #

Methods

method ParserError Unknown (Pos pos) Source #

method ParserError SysUnexpect (Pos pos, string message) Source #

method ParserError Unexpect (Pos pos, string message) Source #

method ParserError Expect (Pos pos, string message, string expected) Source #

method ParserError Message (Pos pos, string message) Source #

method string ToString () Source #

method string ToStringNoPosition () Source #

method bool Equals (ParserError? other) Source #

method bool Equals (object? obj) Source #

method int GetHashCode () Source #

method int CompareTo (ParserError? other) Source #

method R Compare <R> ( ParserError lhs, ParserError rhs, Func<R> EQ, Func<R> GT, Func<R> LT ) Source #

Operators

operator == (ParserError lhs, ParserError rhs) Source #

operator != (ParserError lhs, ParserError rhs) Source #

operator < (ParserError lhs, ParserError rhs) Source #

operator > (ParserError lhs, ParserError rhs) Source #

operator <= (ParserError lhs, ParserError rhs) Source #

operator >= (ParserError lhs, ParserError rhs) Source #

delegate Parser <I, O> Source #

Parser delegate type - Parses an input PString and returns a ParserResult

Parameters

type I

Input stream element type

type O

Parsed value result type

param input

Input string

returns

Parsed value or error report

class ParserIOExtensions Source #

Methods

method Parser<I, O> label <I, O> (this Parser<I, O> p, string expected) Source #

A label for the parser

Parameters

param expected

What was expected

method ParserResult<I, O> Parse <I, O> (this Parser<I, O> self, PString<I> input) Source #

method ParserResult<I, O> Parse <I, O> (this Parser<I, O> self, Seq<I> input, Func<I, Pos> tokenPos) Source #

method ParserResult<I, O> Parse <I, O> (this Parser<I, O> self, IEnumerable<I> input, Func<I, Pos> tokenPos) Source #

method Parser<I, O> Filter <I, O> (this Parser<I, O> self, Func<O, bool> pred) Source #

method Parser<I, O> Where <I, O> (this Parser<I, O> self, Func<O, bool> pred) Source #

method Parser<I, U> Map <I, O, U> (this Parser<I, O> self, Func<O, U> map) Source #

method Parser<I, U> Select <I, O, U> (this Parser<I, O> self, Func<O, U> map) Source #

method Parser<I, B> Bind <I, A, B> (this Parser<I, A> self, Func<A, Parser<I, B>> f) Source #

method Parser<I, B> SelectMany <I, A, B> ( this Parser<I, A> self, Func<A, Parser<I, B>> f) Source #

method Parser<I, V> SelectMany <I, O, U, V> ( this Parser<I, O> self, Func<O, Parser<I, U>> bind, Func<O, U, V> project) Source #

method Parser<I, A> Flatten <I, A> (this Parser<I, Parser<I, A>> mma) Source #

class ParserResult Source #

Methods

method ParserResult<T> Consumed <T> (Reply<T> reply) Source #

method ParserResult<T> Empty <T> (Reply<T> reply) Source #

method ParserResult<T> EmptyOK <T> (T value, PString input, ParserError? error = null) Source #

method ParserResult<T> EmptyError <T> (ParserError error) Source #

method ParserResult<T> ConsumedOK <T> (T value, PString input) Source #

method ParserResult<T> ConsumedOK <T> (T value, PString input, ParserError error) Source #

method ParserResult<T> ConsumedError <T> (ParserError error) Source #

class ParserResult <T> Source #

Fields

field ResultTag Tag Source #

field Reply<T> Reply Source #

Properties

property bool IsFaulted Source #

Methods

method ParserResult<T> SetEndIndex (int endIndex) Source #

method ParserResult<U> Project <S, U> (S s, Func<S, T, U> project) Source #

method string ToString () Source #

method R Match <R> ( Func<ParserError, R> EmptyError, Func<ParserError, R> ConsumedError, Func<ParserResult<T>, R> Otherwise ) Source #

method R Match <R> ( Func<ParserError, R> EmptyError, Func<ParserResult<T>, R> Otherwise ) Source #

method R Match <R> ( Func<Reply<T>, R> Empty, Func<ParserResult<T>, R> Otherwise ) Source #

method R Match <R> ( Func<Reply<T>, R> Empty, Func<Reply<T>, R> Consumed ) Source #

method R Match <R> ( Func<T, PString, ParserError, R> ConsumedOK, Func<ParserError, R> ConsumedError, Func<T, PString, ParserError, R> EmptyOK, Func<ParserError, R> EmptyError ) Source #

method ParserResult<U> Select <U> (Func<T,U> map) Source #

method Either<string, T> ToEither () Source #

method Either<ERROR, T> ToEither <ERROR> (Func<string, ERROR> f) Source #

method Option<T> ToOption () Source #

class ParserResultIO Source #

Methods

method ParserResult<I, O> Consumed <I, O> (Reply<I, O> reply) Source #

method ParserResult<I, O> Empty <I, O> (Reply<I, O> reply) Source #

method ParserResult<I, O> EmptyOK <I, O> (O value, PString<I> input, ParserError? error = null) Source #

method ParserResult<I, O> EmptyError <I, O> (ParserError error, Func<I, Pos> tokenPos) Source #

method ParserResult<I, O> ConsumedOK <I, O> (O value, PString<I> input) Source #

method ParserResult<I, O> ConsumedOK <I, O> (O value, PString<I> input, ParserError error) Source #

method ParserResult<I, O> ConsumedError <I, O> (ParserError error, Func<I, Pos> tokenPos) Source #

class ParserResult <I, O> Source #

Fields

field ResultTag Tag Source #

field Reply<I, O> Reply Source #

Properties

property bool IsFaulted Source #

Methods

method ParserResult<I, O> SetEndIndex (int endIndex) Source #

method ParserResult<I, U> Project <S, U> (S s, Func<S, O, U> project) Source #

method string ToString () Source #

method R Match <R> ( Func<ParserError, R> EmptyError, Func<ParserError, R> ConsumedError, Func<ParserResult<I, O>, R> Otherwise ) Source #

method R Match <R> ( Func<ParserError, R> EmptyError, Func<ParserResult<I, O>, R> Otherwise ) Source #

method R Match <R> ( Func<Reply<I, O>, R> Empty, Func<ParserResult<I, O>, R> Otherwise ) Source #

method R Match <R> ( Func<Reply<I, O>, R> Empty, Func<Reply<I, O>, R> Consumed ) Source #

method R Match <R> ( Func<O, PString<I>, ParserError, R> ConsumedOK, Func<ParserError, R> ConsumedError, Func<O, PString<I>, ParserError, R> EmptyOK, Func<ParserError, R> EmptyError ) Source #

method ParserResult<I, U> Select <U> (Func<O, U> map) Source #

method Either<string, O> ToEither () Source #

method Either<ERROR, O> ToEither <ERROR> (Func<string, ERROR> f) Source #

method Option<O> ToOption () Source #

class ParsecPipes Source #

Properties

property Pipe<string, PString, Unit> toParserString Source #

Pipe a string to a PString

Methods

method Pipe<A[], PString<A>, Unit> toTokenString <A> (Func<A, Pos>? tokenPos) Source #

Pipe tokens to a PString

method Pipe<PString, OUT, M, Unit> ToPipe <M, OUT> (this Parser<OUT> ma) Source #

where M : Monad<M>

Convert a parser to a pipe that awaits a PString and yields the result of the parse operation If the parser fails then the pipe fails

method Pipe<PString, OUT, Unit> ToPipe <OUT> (this Parser<OUT> ma) Source #

Convert a parser to a pipe that awaits a string and yields the result of the parse operation The value is only forwarded if the parsing succeeds

method Pipe<PString<IN>, OUT, Unit> ToPipe <IN, OUT> (this Parser<IN, OUT> ma) Source #

Convert a parser to a pipe that awaits a string and yields the result of the parse operation The value is only forwarded if the parsing succeeds

method Pipe<PString<IN>, OUT, M, Unit> ToPipe <M, IN, OUT> (this Parser<IN, OUT> ma) Source #

where M : Monad<M>

Convert a parser to a pipe that awaits a PString and yields the result of the parse operation If the parser fails then the pipe fails

class Pos Source #

Represents a parser source position

Fields

field int Line Source #

field int Column Source #

Constructors

constructor Pos (int line, int column) Source #

Methods

method bool Equals (Pos? other) Source #

method bool Equals (object? obj) Source #

method int GetHashCode () Source #

method string ToString () Source #

method int CompareTo (Pos? other) Source #

method R Compare <R> ( Pos lhs, Pos rhs, Func<R> EQ, Func<R> GT, Func<R> LT ) Source #

Operators

operator == (Pos lhs, Pos rhs) Source #

operator != (Pos lhs, Pos rhs) Source #

operator < (Pos lhs, Pos rhs) Source #

operator > (Pos lhs, Pos rhs) Source #

operator <= (Pos lhs, Pos rhs) Source #

operator >= (Pos lhs, Pos rhs) Source #

class PString Source #

Represents the parser source text and the parser's positional state.

Fields

field string Value Source #

field int Index Source #

field int EndIndex Source #

field Pos Pos Source #

field Pos DefPos Source #

field Sidedness Side Source #

field Option<object> UserState Source #

Constructors

constructor PString (string value, int index, int endIndex, Pos pos, Pos defPos, Sidedness side, Option<object> userState) Source #

Methods

method PString SetDefPos (Pos defpos) Source #

method PString SetPos (Pos pos) Source #

method PString SetSide (Sidedness side) Source #

method PString SetValue (string value) Source #

method PString SetIndex (int index) Source #

method PString SetUserState (object? state) Source #

method PString SetEndIndex (int endIndex) Source #

method string ToString () Source #

class PString <T> Source #

Represents the parser source string and the parser's positional state.

Fields

field T[] Value Source #

field int Index Source #

field int EndIndex Source #

field Option<object> UserState Source #

field Func<T, Pos> TokenPos Source #

Properties

property Pos Pos Source #

Constructors

constructor PString (T[] value, int index, int endIndex, Option<object> userState, Func<T, Pos> tokenPos) Source #

Methods

method PString<T> SetValue (T[] value) Source #

method PString<T> SetIndex (int index) Source #

method PString<T> SetUserState (object? state) Source #

method PString<T> SetEndIndex (int endIndex) Source #

method string ToString () Source #

method PString<T> Zero (Func<T, Pos> tokenPos) Source #

method PString<U> Cast <U> () Source #

where U : T

class Reply Source #

Methods

method Reply<T> OK <T> (T result, PString remaining, ParserError? error = null) Source #

method Reply<T> Error <T> (ParserErrorTag tag, Pos pos, string message, Lst<string> expected) Source #

method Reply<T> Error <T> (ParserError error) Source #

class Reply <T> Source #

Fields

field ReplyTag Tag Source #

field T? Result Source #

field PString? State Source #

field ParserError? Error Source #

Methods

method Reply<U> Project <S, U> (S s, Func<S, T, U> project) Source #

method Reply<U> Select <U> (Func<T, U> map) Source #

class Reply Source #

Methods

method Reply<I, O> OK <I, O> (O result, PString<I> remaining, ParserError? error = null) Source #

method Reply<I, O> Error <I, O> (ParserErrorTag tag, Pos pos, string message, Lst<string> expected, Func<I, Pos> tokenPos) Source #

method Reply<I, O> Error <I, O> (ParserError error, Func<I, Pos> tokenPos) Source #

class Reply <I, O> Source #

Fields

field ReplyTag Tag Source #

field O? Result Source #

field PString<I> State Source #

field ParserError? Error Source #

Methods

method Reply<I, U> Project <S, U> (S s, Func<S, O, U> project) Source #

method Reply<I, U> Select <U> (Func<O, U> map) Source #

class StringAndCollectionExtensions Source #

Methods

method PString ToPString (this string value) Source #

method PString<T> ToPString <T> (this IEnumerable<T> value, Func<T, Pos> tokenPos) Source #

method PString<T> ToPString <T> (this Seq<T> value, Func<T, Pos> tokenPos) Source #