Idris2Doc : Text.ILex.Interfaces

Text.ILex.Interfaces

(source)

Definitions

interfaceHasPosition : (Type->Type) ->Type
  An interface for mutable parser stacks `s` that allows us to keep
track of the current position (line and column) in the currently
parsed string.

Parameters: s
Constructor: 
MkHP

Methods:
line : sq->RefqNat
col : sq->RefqNat
positions : sq->Refq (SnocListPosition)

Implementation: 
HasPosition (DStackse)
line : HasPositions=>sq->RefqNat
Totality: total
Visibility: public export
col : HasPositions=>sq->RefqNat
Totality: total
Visibility: public export
positions : HasPositions=>sq->Refq (SnocListPosition)
Totality: total
Visibility: public export
interfaceHasError : (Type->Type) ->Type->Type
  An interface for mutable parser stacks `s` that allow us to
register custom errors, which will then be raised during parsing.

Parameters: s, e
Constructor: 
MkHE

Methods:
error : sq->Refq (Maybe (BoundedErre))

Implementation: 
HasError (DStackse) e
error : HasErrorse=>sq->Refq (Maybe (BoundedErre))
Totality: total
Visibility: public export
interfaceHasStringLits : (Type->Type) ->Type
  An interface for mutable parser stacks `s` that facilitates
parsing string tokens containing escape sequences.

Parameters: s
Constructor: 
MkHSL

Methods:
strings : sq->Refq (SnocListString)

Implementation: 
HasStringLits (DStackse)
strings : HasStringLitss=>sq->Refq (SnocListString)
Totality: total
Visibility: public export
interfaceHasStack : (Type->Type) ->Type->Type
  An interface for mutable parser stacks `s` that facilitates
parsing string tokens containing escape sequences.

Parameters: s, a
Constructor: 
MkHS

Methods:
stack : sq->Refqa

Implementation: 
HasStack (DStackse) (StackTrues [])
stack : HasStacksa=>sq->Refqa
Totality: total
Visibility: public export
go : a-> (sq=>F1q (Indexr)) -> (a, Stepqrs)
Totality: total
Visibility: export
goBS : HasBytess=>a-> (sq=>ByteString->F1q (Indexr)) -> (a, Stepqrs)
Totality: total
Visibility: export
goStr : HasBytess=>a-> (sq=>String->F1q (Indexr)) -> (a, Stepqrs)
Totality: total
Visibility: export
writeAs : Refqa->a->r->F1qr
  Writes a mutable reference and returns the given result.

Totality: total
Visibility: export
push1 : Refq (SnocLista) ->a->F1'q
  Appends a value to mutable reference of a snoclist.

Totality: total
Visibility: export
pop1 : Refq (SnocLista) ->F1'q
  Drops and discards a the last entry from a snoclist
stored in a mutable reference.

Totality: total
Visibility: export
replace1 : Refqa->a->F1qa
  Returns the value stored in a mutable reference and
overwrites it with the given replacement.

Totality: total
Visibility: export
getList : Refq (SnocLista) ->F1q (Lista)
  Empties a mutable reference holding a snoclist and returns
the corresponding list.

Totality: total
Visibility: export
getStack : HasStacksa=>sq=>F1qa
  Returns the content of some mutable state implementing
`HasStack`.

Totality: total
Visibility: export
putStack : HasStacksa=>sq=>a->F1'q
  Overwrites the content of some mutable state implementing
`HasStack`.

Totality: total
Visibility: export
putStackAs : HasStacksa=>sq=>a->v->F1qv
  Like `putStack` but returns the given result.

Totality: total
Visibility: export
putStackAsC : Castbv=>HasStacksa=>sq=>a->b->F1qv
  Like `putStack` but returns the given result.

Totality: total
Visibility: export
modStackAs : (0s : (Type->Type)) ->HasStacksa=>sq=> (a->a) ->v->F1qv
  Reads and updates the stack.

Totality: total
Visibility: export
pushStack : HasStacks (SnocLista) =>sq=>a->F1'q
  Appends a value to some mutable state implementing `HasStack`.

Totality: total
Visibility: export
pushStackAs : HasStacks (SnocLista) =>sq=>a->v->F1qv
  Like `pushStack` but returns the given result.

Totality: total
Visibility: export
countdown : RefqNat->a->a->F1qa
  A small utility for counting down a parser and returning one
of two possible outcomes.

Totality: total
Visibility: export
countdownAct : RefqNat->F1qa->F1qa->F1qa
  A small utility for counting down a parser and returning one
of two possible actions.

Totality: total
Visibility: export
getStr : sq=>HasStringLitss=>F1qString
  Empties the `strings` field of some mutable state implementing
`HasStringLits` and returns the concatenated string literal.

Totality: total
Visibility: export
pushStr' : sq=>HasStringLitss=>String->F1'q
  Appends the given string to the `strings` field of some mutable
state implementing `HasStringLits`.

Totality: total
Visibility: export
pushStr : sq=>HasStringLitss=>Castt (Indexr) =>t->String->F1q (Indexr)
  Appends the given string to the `strings` field of some mutable
state implementing `HasStringLits` and returns the given result.

Totality: total
Visibility: export
pushChar : sq=>HasStringLitss=>Castt (Indexr) =>t->Char->F1q (Indexr)
  Appends the given character to the `strings` field of some mutable
state implementing `HasStringLits` and returns the given result.

Totality: total
Visibility: export
pushBits32 : sq=>HasStringLitss=>Castt (Indexr) =>t->Bits32->F1q (Indexr)
  Appends the given unicode code point to the `strings` field of some mutable
state implementing `HasStringLits` and returns the given result.

Totality: total
Visibility: export
getPosition : sq=>HasPositions=>F1qPosition
  Gets the current text position (line and column) from some
mutable state implementing `HasPosition`.

Totality: total
Visibility: export
inccol : sq=>HasPositions=>Nat->F1q ()
  Increases the text column of some mutable state implementing
`HasPosition` by the given amount.

Totality: total
Visibility: export
setcol : sq=>HasPositions=>Nat->F1q ()
  Increases the text column of some mutable state implementing
`HasPosition` by the given amount.

Totality: total
Visibility: export
incline : sq=>HasPositions=>Nat->F1q ()
  Increases the line of some mutable state implementing
`HasPosition` by the given amount. The column field is
reset to zero.

Totality: total
Visibility: export
incML : sq=>HasPositions=>ByteString->F1q ()
  Increases the current text position according to the characters
encountered in the given byte string.

See also `Text.ILex.Bounds.inBytes`.

Totality: total
Visibility: export
tokenBounds : sq=>HasPositions=>Nat->F1qBounds
  Gets the current token bounds from some
mutable state implementing `HasPosition` after
increasing the column by `n` characters.

Totality: total
Visibility: export
pushPosition : sq=>HasPositions=>F1'q
  Pushes the current text position onto the position stack.

This is often used when ecountering some "opening token"
(such as an opening quote or parenthesis) for which we later
expect a suitable closing token. If no closing token is encountered,
we typically want to fail with an error that lists the position
of the unclosed token.

Totality: total
Visibility: export
popPosition : sq=>HasPositions=>F1'q
  Discards the latest entry from the positions stack.

Totality: total
Visibility: export
closeBounds : sq=>HasPositions=>F1qBounds
  Returns the bounds from start to end of some "enclosed" or
quoted region of text such as an expression in parantheses
or some text in quotes.

Totality: total
Visibility: export
newline : HasPositions=>RExpOfTrueb-> (sq=>F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Recognizes the given expression and invokes `incline` before
returning the given result.

Totality: total
Visibility: export
newline' : HasPositions=>Castt (Indexr) =>RExpOfTrueb->t-> (RExpOfTrueb, Stepqrs)
  Convenience alias for `newline x (pure v)`.

Totality: total
Visibility: export
newlines : HasPositions=>Nat->RExpOfTrueb-> (sq=>F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Recognizes the given expression and invokes `incline n` before
returning the given result.

Totality: total
Visibility: export
newlines' : HasPositions=>Nat->RExpOfTrueb->Indexr-> (RExpOfTrueb, Stepqrs)
  Convenience alias for `newlines n x (pure v)`.

Totality: total
Visibility: export
linecol : HasPositions=>Nat->Nat->RExpOfTrueb-> (sq=>F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Recognizes the given expression, increasing the line count by the given
number and setting the current column to the given value *after* invoming
the given action.

Totality: total
Visibility: export
linecol' : HasPositions=>Nat->Nat->RExpOfTrueb->Indexr-> (RExpOfTrueb, Stepqrs)
  Convenience alias for `linecol line col x (pure v)`.

Totality: total
Visibility: export
failWith : HasErrorse=>sq=>BoundedErre->v->F1qv
  Writes the given exception to the `error` field of some
mutable state and returns the given result.

Totality: total
Visibility: export
failHere : HasErrorse=>HasBytess=>HasPositions=>sq=>InnerErrore->v->F1qv
  Like `failWith`, but generates the bounds of the error from the
current position and the bytes read until the error occurred.

Totality: total
Visibility: export
cexpr : (x : RExpOfTrueb) -> {auto0_ : ConstSizenx} ->HasPositions=> (sq=>F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Recognizes the given character and uses it to update the parser state
as specified by `f`.

The current column is increased by `n` *before* invoking `f`.

Totality: total
Visibility: export
cexpr' : (x : RExpOfTrueb) -> {auto0_ : ConstSizenx} ->HasPositions=>Castt (Indexr) =>t-> (RExpOfTrueb, Stepqrs)
  Convenience alias for `cexpr . pure`.

Totality: total
Visibility: export
copen : (x : RExpOfTrueb) -> {auto0_ : ConstSizenx} ->HasPositions=> (sq=>F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Recognizes the given character(s)
and uses it to update the parser state
as specified by `f`.

The current column is increased by one, and a new entry is pushed onto
the stack of bounds.

Totality: total
Visibility: export
copen' : (x : RExpOfTrueb) -> {auto0_ : ConstSizenx} ->HasPositions=>Castt (Indexr) =>t-> (RExpOfTrueb, Stepqrs)
  Convenience alias for `copen . pure`.

Totality: total
Visibility: export
cclose : (x : RExpOfTrueb) -> {auto0_ : ConstSizenx} ->HasPositions=> (sq=>F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Recognizes the given character(s) and uses it to update the parser state
as specified by `f`.

The current column is increased by `n`, and one `Position` entry
is popped from the stack.

Totality: total
Visibility: export
ccloseStr : (x : RExpOfTrueb) -> {auto0_ : ConstSizenx} ->HasPositions=>HasStringLitss=> (sq=>String->F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Recognizes the given character(s) and uses it to
finalize and assemble a string literal.

The current column is increased by `n`, and one `Position` entry
is popped from the stack.

Totality: total
Visibility: export
ccloseWithBounds : (x : RExpOfTrueb) -> {auto0_ : ConstSizenx} ->HasPositions=> (sq=>Bounds->F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Recognizes the given character(s) and uses it to update the parser state
as specified by `f`.

The current column is increased by one, and on `Bounds` entry
is popped from the stack.

Totality: total
Visibility: export
ccloseBoundedStr : (x : RExpOfTrueb) -> {auto0_ : ConstSizenx} ->HasPositions=>HasStringLitss=> (sq=>BoundedString->F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Recognizes the given character(s) and uses it to
finalize and assemble a string literal.

The current column is increased by `n`, and one `Position` entry
is popped from the stack.

Totality: total
Visibility: export
val : HasPositions=> (a->String) -> (a->Step1qrs) ->a->Maybe (RExpTrue, Stepqrs)
  Lexes a single value based on its printed form. Returns
`Nothing` in case `display` returns the empty string.

For instance, `val show soSomething True` would recognice
the token `"True"` and invoke act with `True`.

Totality: total
Visibility: export
valN : HasPositions=> (a->ListString) -> (a->Step1qrs) ->a->List (RExpTrue, Stepqrs)
  Like `val` but for a value that can be displayed in
different ways.

Totality: total
Visibility: export
writeVal : HasPositions=> (a->String) -> (sq->Refqa) ->Indexr->a->Maybe (RExpTrue, Stepqrs)
  Specialized version of `val` that writes the lexed value
to a predefined mutable field of the parser stack.

Totality: total
Visibility: export
writeValN : HasPositions=> (a->ListString) -> (sq->Refqa) ->Indexr->a->List (RExpTrue, Stepqrs)
  Specialized version of `valN` that writes the lexed value
to a predefined mutable field of the parser stack.

Totality: total
Visibility: export
vals : HasPositions=> (a->String) -> (a->Step1qrs) ->Lista->List (RExpTrue, Stepqrs)
  Applies `val` to a list of values.

Highly useful in combination with the `Finite` interface from
the idris2-finite library.

Totality: total
Visibility: export
valsN : HasPositions=> (a->ListString) -> (a->Step1qrs) ->Lista->List (RExpTrue, Stepqrs)
  Like `vals` but for values that can be displayed in
several ways.

Highly useful in combination with the `Finite` interface from
the idris2-finite library.

Totality: total
Visibility: export
writeVals : HasPositions=> (a->String) -> (sq->Refqa) ->Indexr->Lista->List (RExpTrue, Stepqrs)
  Specialized version of `vals` that writes the lexed value
to a predefined mutable field of the parser stack.

Totality: total
Visibility: export
writeValsN : HasPositions=> (a->ListString) -> (sq->Refqa) ->Indexr->Lista->List (RExpTrue, Stepqrs)
  Specialized version of `valsN` that writes the lexed value
to a predefined mutable field of the parser stack.

Totality: total
Visibility: export
read : RExpOfTrueb->HasPositions=>HasBytess=> (sq=>String->F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Converts the recognized token to a `String`, increases the
current column by its length and invokes the given state transformer.

Totality: total
Visibility: export
readline : RExpOfTrueb->HasPositions=>HasBytess=> (sq=>String->F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Increases the current line by one after invoking the given
state transformer.

Totality: total
Visibility: export
read' : RExpOfTrueb->HasPositions=>HasBytess=>Castt (Indexr) =>t-> (RExpOfTrueb, Stepqrs)
  Convenience alias for `read . pure`
current column by its length after invoking the given state transformer.

Totality: total
Visibility: export
conv : RExpOfTrueb->HasPositions=>HasBytess=> (sq=>ByteString->F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Increases the current column by the length of the byte string
and invokes the given state transformer.

Totality: total
Visibility: export
convline : RExpOfTrueb->HasPositions=>HasBytess=> (sq=>ByteString->F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Increases the current line by one after invoking the given
state transformer.

Totality: total
Visibility: export
multiline : RExpOfTrueb->HasPositions=>HasBytess=> (sq=>ByteString->F1q (Indexr)) -> (RExpOfTrueb, Stepqrs)
  Like `conv` but can handle byte sequence with an unknown number
of line feed characters.

Note: In performance critical parsers, this should be avoided whenever
possible. Advancing token bounds by inspecting every byte a second
time *can* have an impact. Whenever possible, try to separate your
lexems into those which consist of no line breaks and those which
consist of a predefine (typically only one) number of line breaks.

Totality: total
Visibility: export
conv' : RExpOfTrueb->HasPositions=>HasBytess=>Castt (Indexr) =>t-> (RExpOfTrueb, Stepqrs)
  Convenience alias for `conv . pure`.

Totality: total
Visibility: export
multiline' : RExpOfTrueb->HasPositions=>HasBytess=>Indexr-> (RExpOfTrueb, Stepqrs)
  Convenience alias for `convML . pure`.

Please not, that the same performance considerations as for `convML`
apply.

Totality: total
Visibility: export
jsonSpaced : HasPositions=>HasBytess=>Castb (Indexr) =>b->Stepsqrs->Stepsqrs
Totality: total
Visibility: export
raise : HasErrorse=>HasPositions=>HasBytess=>InnerErrore->Nat->sq=>v->F1qv
Totality: total
Visibility: export
unexpected : HasErrorse=>HasPositions=>HasBytess=>ListString->sq->F1q (BoundedErre)
Totality: total
Visibility: export
unclosed : HasErrorse=>HasPositions=>HasBytess=>String->sq->F1q (BoundedErre)
Totality: total
Visibility: export
unclosedIfEOI : HasErrorse=>HasPositions=>HasBytess=>String->ListString->sq->F1q (BoundedErre)
  Fails with `unclosed` if this is the end of input, otherwise
invokes `unexpected`.

Totality: total
Visibility: export
unclosedIfNLorEOI : HasErrorse=>HasPositions=>HasBytess=>String->ListString->sq->F1q (BoundedErre)
  Fails with `unclosed` if this is the end of input or
a linefeed character (`\n`, byte `0x0a`) was encountered,
otherwise, invokes `unexpected`.

Totality: total
Visibility: export
errs : HasErrorse=>HasPositions=>HasBytess=>List (Entryn (sq->F1q (BoundedErre))) ->Arr32n (sq->F1q (BoundedErre))
Totality: total
Visibility: export
noChunk : s->F1q (Maybea)
  Never emits a chunk of values during streaming.

This is for parsers that produce a single value after consuming the
whole input. Such a parser can still be used with the facilities
from ilex-streams but will only emit a single value at the end of input.
In general, such a parser consumes a linear amount of memory and can
typically not be used to process very large amounts of data.

Totality: total
Visibility: export
snocChunk : HasStacks (SnocLista) =>sq->F1q (Maybe (Lista))
  Extracts the values parsed so far from the parser stack
and emits them during streaming.

Totality: total
Visibility: export