hydra-kernel-0.18.1: src/main/haskell/Hydra/Core/Parsing.hs
-- Note: this is an automatically generated file. Do not edit.
-- | Parser combinator types for text parsing
module Hydra.Core.Parsing where
import qualified Hydra.Core.Model as Model
import Prelude hiding (Enum, Ordering, decodeFloat, encodeFloat, fail, lines, map, pure, sum, unlines)
import qualified Data.Scientific as Sci
import Data.Void
-- | An error which occurred while parsing
data ParseError =
ParseError {
-- | An error message
parseErrorMessage :: String,
-- | The remaining input at the point of failure
parseErrorRemainder :: ParseInput}
deriving (Eq, Ord, Read, Show)
_ParseError = Model.Name "hydra.core.parsing.ParseError"
_ParseError_message = Model.Name "message"
_ParseError_remainder = Model.Name "remainder"
-- | The input state threaded through a parser: the unconsumed codepoints, together with the number of codepoints already consumed, and where the last token ended. The offset makes the absolute source position of any parse step available in constant time, without rescanning the input.
data ParseInput =
ParseInput {
-- | The number of codepoints consumed so far, i.e. the absolute offset of the first remaining codepoint
parseInputOffset :: Int,
-- | The offset just past the most recently completed token, excluding any whitespace or comments that followed it. Used to give source spans a tight end
parseInputTokenEnd :: Int,
-- | The remaining unparsed input, as codepoints. Represented as a list rather than a string, so that consuming one character is a constant-time operation
parseInputCodepoints :: [Int]}
deriving (Eq, Ord, Read, Show)
_ParseInput = Model.Name "hydra.core.parsing.ParseInput"
_ParseInput_offset = Model.Name "offset"
_ParseInput_tokenEnd = Model.Name "tokenEnd"
_ParseInput_codepoints = Model.Name "codepoints"
-- | The result of a parse operation
data ParseResult a =
-- | A successful parse, with a value and the remaining unparsed input
ParseResultSuccess (ParseSuccess a) |
-- | A failed parse, with an error message and the remaining input
ParseResultFailure ParseError
deriving (Eq, Ord, Read, Show)
_ParseResult = Model.Name "hydra.core.parsing.ParseResult"
_ParseResult_success = Model.Name "success"
_ParseResult_failure = Model.Name "failure"
-- | A successful parse result
data ParseSuccess a =
ParseSuccess {
-- | The parsed value
parseSuccessValue :: a,
-- | The remaining unparsed input
parseSuccessRemainder :: ParseInput}
deriving (Eq, Ord, Read, Show)
_ParseSuccess = Model.Name "hydra.core.parsing.ParseSuccess"
_ParseSuccess_value = Model.Name "value"
_ParseSuccess_remainder = Model.Name "remainder"
-- | A parser which consumes characters from a codepoint list and produces a value. The input is a list, rather than a string, so that consuming one character is a constant-time operation rather than a linear-time string copy.
newtype Parser a =
Parser {
unParser :: (ParseInput -> ParseResult a)}
_Parser = Model.Name "hydra.core.parsing.Parser"
-- | A position in source text, as an editor reports it: zero-based line and zero-based column. The column counts UTF-16 code units, matching the Language Server Protocol's Position.
data SourcePosition =
SourcePosition {
-- | The zero-based line number. Lines are terminated by LF, CR, or CR LF
sourcePositionLine :: Int,
-- | The zero-based column, in UTF-16 code units from the start of the line
sourcePositionColumn :: Int}
deriving (Eq, Ord, Read, Show)
_SourcePosition = Model.Name "hydra.core.parsing.SourcePosition"
_SourcePosition_line = Model.Name "line"
_SourcePosition_column = Model.Name "column"
-- | A half-open range [start, end) of source text, measured in codepoints from the start of the input. Attached to parsed terms and types as a reserved, round-trip-exempt annotation (see hydra.core.positions).
data SourceSpan =
SourceSpan {
-- | The offset of the first codepoint of the span
sourceSpanStart :: Int,
-- | The offset one past the last codepoint of the span
sourceSpanEnd :: Int}
deriving (Eq, Ord, Read, Show)
_SourceSpan = Model.Name "hydra.core.parsing.SourceSpan"
_SourceSpan_start = Model.Name "start"
_SourceSpan_end = Model.Name "end"