1///|
2pub fn 
struct Input {
  chars: @string.StringView
  row: Int
  col: Int
}
Input
::
(chars : @string.StringView) -> Input
new
(
@string.StringView
chars
:
type @string.StringView

A @string.View represents a view of a String that maintains proper Unicode character boundaries. It allows safe access to a substring while handling multi-byte characters correctly.

@string.View
) ->
struct Input {
  chars: @string.StringView
  row: Int
  col: Int
}
Input
{
3
struct Input {
  chars: @string.StringView
  row: Int
  col: Int
}
Input
::{
@string.StringView
chars
,
Int
row
: 0,
Int
col
: 0 }
4} 5 6///| 7pub fn[A]
type Parser[A] (Input) -> (A, Input) raise ParseError
Parser
::
(self : Parser[A], input : Input) -> A raise ParseError
run
(
Parser[A]
self
:
type Parser[A] (Input) -> (A, Input) raise ParseError
Parser
[

type parameter A

A
],
Input
input
:
struct Input {
  chars: @string.StringView
  row: Int
  col: Int
}
Input
) ->

type parameter A

A
raise
type! ParseError {
  ParseError(SourcePos, @list.T[String])
}
ParseError
{
8
Parser[A]
self
(
Input
input
).
A
0
9} 10 11///| 12pub fn[A]
type Parser[A] (Input) -> (A, Input) raise ParseError
Parser
::
(self : Parser[A]) -> Parser[A]
discard_spaces
(
Parser[A]
self
:
type Parser[A] (Input) -> (A, Input) raise ParseError
Parser
[

type parameter A

A
]) ->
type Parser[A] (Input) -> (A, Input) raise ParseError
Parser
[

type parameter A

A
] {
13
Parser[Char]
spaces
.
(x : Parser[Char], y : Parser[A]) -> Parser[A]
discard_left
(
Parser[A]
self
)
14} 15 16///| 17pub fnalias
type Parser[A] (Input) -> (A, Input) raise ParseError
Parser
::(
18
(self : Parser[A], open~ : Parser[B], close~ : Parser[C]) -> Parser[A]
between
,
19
(x : Parser[A], f : (A) -> Parser[B]) -> Parser[B]
bind
,
20
(ch : Char) -> Parser[Char]
char
,
21
(x : Parser[A], y : Parser[B]) -> Parser[B]
discard_left
,
22
(x : Parser[A], y : Parser[B]) -> Parser[A]
discard_right
,
23
(x : A) -> Parser[A]
eof
,
24
(x : Parser[A], msg : String) -> Parser[A]
label
,
25
(self : Parser[A], f : (A) -> B) -> Parser[B]
map
,
26
(xs : String) -> Parser[Char]
none_of
,
27
(xs : String) -> Parser[Char]
one_of
,
28
(self : Parser[A]) -> Parser[A]
round_bracket
,
29
(self : Parser[A]) -> Parser[A]
square_bracket
,
30
(self : Parser[A]) -> Parser[A]
curly_bracket
,
31
(x : A) -> Parser[A]
pure
,
32
(self : Parser[A], input : Input) -> A raise ParseError
run
,
33
(f : (Char) -> Bool, label~ : String) -> Parser[Char]
satisfy
,
34
(str : String) -> Parser[String]
string
,
35
(x : Parser[A], z : Parser[B], f : Parser[(B, A) -> B]) -> Parser[B]
foldl
,
36
(x : Parser[A], z : Parser[B], f : Parser[(B, A) -> B]) -> Parser[B]
foldr
,
37
(x : Parser[A], f : Parser[(A, A) -> A]) -> Parser[A]
foldl1
,
38
(x : Parser[A], f : Parser[(A, A) -> A]) -> Parser[A]
foldr1
,
39
(self : Parser[A]) -> Parser[A]
discard_spaces
,
40
(self : Parser[A]) -> Parser[Array[A]]
many
,
41
(x : Parser[A], f : (A) -> Unit) -> Parser[Unit]
many_each
,
42
(self : Parser[A], f : (SourcePos, A) -> B) -> Parser[B]
map_srcpos
,
43
(x : Parser[A], y : Parser[A]) -> Parser[A]
or
44) 45 46///| 47pub fn[A]
type Parser[A] (Input) -> (A, Input) raise ParseError
Parser
::
(x : Parser[A], y : Parser[A]) -> Parser[A]
or
(
Parser[A]
x
:
type Parser[A] (Input) -> (A, Input) raise ParseError
Parser
[

type parameter A

A
],
Parser[A]
y
:
type Parser[A] (Input) -> (A, Input) raise ParseError
Parser
[

type parameter A

A
]) ->
type Parser[A] (Input) -> (A, Input) raise ParseError
Parser
[

type parameter A

A
] {
48
Parser[A]
x
(x : Parser[A], y : Parser[A]) -> Parser[A]
|
Parser[A]
y
49} 50 51///| 52pub fn
type! ParseError {
  ParseError(SourcePos, @list.T[String])
}
ParseError
::
(row~ : Int, col~ : Int, msg : String) -> ParseError
expect
(
Int
row
~ :
Int
Int
,
Int
col
~ :
Int
Int
,
String
msg
:
String
String
) ->
type! ParseError {
  ParseError(SourcePos, @list.T[String])
}
ParseError
{
53
(SourcePos, @list.T[String]) -> ParseError
ParseError
({
Int
row
,
Int
col
},
(x : String) -> @list.T[String]
@list.singleton
(
String
msg
))
54} 55 56///| 57pub fn
type! ParseError {
  ParseError(SourcePos, @list.T[String])
}
ParseError
::
(self : ParseError) -> SourcePos
source_pos
(
ParseError
self
:
type! ParseError {
  ParseError(SourcePos, @list.T[String])
}
ParseError
) ->
struct SourcePos {
  row: Int
  col: Int
}
SourcePos
{
58 let
(SourcePos, @list.T[String]) -> ParseError
ParseError
(
SourcePos
pos
, _) =
ParseError
self
59 // xs.unsafe_head().0 60
SourcePos
pos
61} 62 63///| 64pub fn
type! ParseError {
  ParseError(SourcePos, @list.T[String])
}
ParseError
::
(self : ParseError, x : String) -> ParseError
cons
(
ParseError
self
:
type! ParseError {
  ParseError(SourcePos, @list.T[String])
}
ParseError
,
String
x
:
String
String
) ->
type! ParseError {
  ParseError(SourcePos, @list.T[String])
}
ParseError
{
65 let
(SourcePos, @list.T[String]) -> ParseError
ParseError
(
SourcePos
pos
,
@list.T[String]
xs
) =
ParseError
self
66
(SourcePos, @list.T[String]) -> ParseError
ParseError
(
SourcePos
pos
,
(head : String, tail : @list.T[String]) -> @list.T[String]

Prepend an element to the list and create a new list.

@list.construct
(
String
x
,
@list.T[String]
xs
))
67} 68 69///| 70pub fnalias
type! ParseError {
  ParseError(SourcePos, @list.T[String])
}
ParseError
::
(row~ : Int, col~ : Int, msg : String) -> ParseError
expect
71