Module

Perspectives.Parsing.Arc.IndentParser

#IP

type IP a = IndentParser Identity String a

This is the type that is produced by Perspectives.Parsing.TransferFile.

#runIndentParser

runIndentParser :: forall a. String -> IP a -> Identity (Either ParseError a)

Apply a parser, keeping only the parsed result.

#onSameLine

onSameLine :: forall m s a. Monad m => IndentParser m s a -> IndentParser m s a

#getPosition

getPosition :: IP ArcPosition

Returns the position as recorded in ParseState

#get'

get' :: IP ArcPosition

Returns the position as recorded by the IndentParser.

#put'

put' :: ArcPosition -> IP Unit

Records the position with the IndentParser.

#ArcPosition

newtype ArcPosition

Position represents the position of the parser in the input.

  • line is the current line in the input
  • column is the column of the next character in the current line that will be parsed

Constructors

Instances

#arcPosition2Position

#position2ArcPosition

#withEntireBlock

withEntireBlock :: forall a b c. (a -> List b -> c) -> IP a -> IP b -> IP c

withBlock f a p parses a followed by an indented block of p, where the entire block must have been consumed, combining them with f.

#entireBlock

entireBlock :: forall x. IP x -> IP (List x)

Parses a block of lines at the same indentation level. If not every line has been parsed, fails by applying p to the next line

#unlessOutdented

unlessOutdented :: forall a. IP a -> a -> IP a

Applies parser p iff the current location of the parser is not outdented with respect to the reference position stored previously by the IndentParser (and the end of the input has not been reached). Otherwise returns a.

#isIndented

isIndented :: IP Boolean

True iff the Parser Position is further to the right than the reference position. Sets the reference position to the current Parser Position.

#sourceColumn

#sourceLine

#setSourceLine

#nextLine

nextLine :: IP Unit

Parses only on lines that are lower than the reference (unless the end of the input stream has been reached).

Modules