Finch
Copyright(c) Leon Vatthauer 2026
LicenseGPL-3
MaintainerLeon Vatthauer <leon.vatthauer@fau.de>
Stabilityexperimental
Portabilitynon-portable (ghc-wasm-meta)
Safe HaskellNone
LanguageGHC2024

Parser.Util

Description

This module provides shared utility parsers used across all other Parser.* modules.

Synopsis

Types

type Parser = MonadParsec Void Text Source #

Constraint alias for a Megaparsec parser over a Text stream with no custom error type.

Lexer

sc :: MonadParsec Void Text m => m () Source #

Space consumer that only skips whitespace

lexeme :: Parser m => m a -> m a Source #

Wraps a parser so that it consumes trailing whitespace via sc.

symbol :: Parser m => Text -> m Text Source #

Parses the exact given Text token and consumes any trailing whitespace.

matchNoSpaces :: Parser m => m a -> m (Text, a) Source #

Runs a Parser via match but strips whitespace from the resulting Text.

Name parsers

pUpperName :: Parser m => m Text Source #

Parses a name that starts with one or more uppercase letters, followed by zero or more letters. Used for predicate symbols.

pLowerName :: Parser m => m Text Source #

Parses a name that starts with one or more lowercase letters, followed by zero or more letters. Used for function symbols and variables.

pSymbolicName :: Parser m => m Text Source #

Parses a symbolic name, i.e. any non-empty sequence of characters that are neither ( nor ). Used for parsing rule applications.

pText :: Parser m => m Text Source #

Parses arbitrary characters, excluding the control characters \28, \29, \30, and \31 that are used as separators in tIncompleteProof.

Symbol parsers

comma :: Parser m => m Text Source #

Parses a comma ,.

minus :: Parser m => m Text Source #

Parses a minus sign -.

parens :: Parser m => m a -> m a Source #

Wraps a parser between ( and ).

brackets :: Parser m => m a -> m a Source #

Wraps a parser between [ and ].

Operator combinators

binary :: forall (m :: Type -> Type) a. Parser m => Text -> (a -> a -> a) -> Operator m a Source #

Creates a left-associative infix operator for use with makeExprParser.

prefix :: forall (m :: Type -> Type) a. Parser m => Text -> (a -> a) -> Operator m a Source #

Creates a prefix operator for use with makeExprParser. Defined specifically so that multiple prefix symbols can get parsed without parentheses.