kicad_sexpr/decode
Types
pub type DecodeError {
UnexpectedEndOfAttributes(expected: ExprType)
UnexpectedTrailingAttributes(got: List(parse.SExpr))
IncorrectExprType(got: parse.SExpr, expected: ExprType)
IncorrectTokenName(got: String, expected: String)
IncorrectName(got: String, expected: String)
UnmatchedEnum(got: String, expected: List(String))
UnmatchedIntEnum(got: Int, expected: List(Int))
UnmatchedOneOf(got: parse.SExpr)
TokenAttributeError(name: String, error: DecodeError)
}
Constructors
-
UnexpectedEndOfAttributes(expected: ExprType)
-
UnexpectedTrailingAttributes(got: List(parse.SExpr))
-
IncorrectExprType(got: parse.SExpr, expected: ExprType)
-
IncorrectTokenName(got: String, expected: String)
-
IncorrectName(got: String, expected: String)
-
UnmatchedEnum(got: String, expected: List(String))
-
UnmatchedIntEnum(got: Int, expected: List(Int))
-
UnmatchedOneOf(got: parse.SExpr)
-
TokenAttributeError(name: String, error: DecodeError)
pub type Decoded(a) =
Result(#(a, List(parse.SExpr)), DecodeError)
pub type Decoder(a) =
fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
)
pub type ExprType {
Token(name: String)
String
Int
Float
Name
Unknown
}
Constructors
-
Token(name: String)
-
String
-
Int
-
Float
-
Name
-
Unknown
pub type NextFn(a, b) =
fn(a) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
)
Values
pub fn enum(
with variants: List(#(String, a)),
then next: fn(a) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
)
pub fn failure(
error: DecodeError,
) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
)
pub fn flag(
named name: String,
then next: fn(Bool) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
)
pub fn float(
then next: fn(Float) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
)
pub fn int(
then next: fn(Int) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
)
pub fn int_enum(
with variants: List(a),
then next: fn(a) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
)
pub fn list(
attr: fn(
fn(a) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
),
then next: fn(List(b)) -> fn(List(parse.SExpr)) -> Result(
#(c, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(c, List(parse.SExpr)),
DecodeError,
)
pub fn map(
with attr: fn(
fn(a) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(c, List(parse.SExpr)),
DecodeError,
),
to map_fn: fn(a) -> b,
) -> fn(
fn(c) -> fn(List(parse.SExpr)) -> Result(
#(d, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(d, List(parse.SExpr)),
DecodeError,
)
pub fn name(
then next: fn(String) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
)
pub fn name_number(
then next: fn(String) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
)
pub fn name_number_string(
then next: fn(String) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
)
pub fn name_string(
then next: fn(String) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
)
pub fn of(
with decoder: fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
then next: fn(a) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
)
pub fn one_of(
attr: fn(
fn(a) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
),
or attrs: List(
fn(
fn(a) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
),
),
then next: fn(b) -> fn(List(parse.SExpr)) -> Result(
#(c, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(c, List(parse.SExpr)),
DecodeError,
)
pub fn optional(
attr: fn(
fn(a) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
),
then next: fn(option.Option(b)) -> fn(List(parse.SExpr)) -> Result(
#(c, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(c, List(parse.SExpr)),
DecodeError,
)
pub fn run(
decoder: fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
on source: parse.SExpr,
) -> Result(a, DecodeError)
pub fn string(
then next: fn(String) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
)
pub fn success(
value: a,
) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
)
pub fn token(
named name: String,
with decoder: fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
then next: fn(a) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
)
pub fn token_wrapper(
named name: String,
with attr: fn(
fn(a) -> fn(List(parse.SExpr)) -> Result(
#(a, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(b, List(parse.SExpr)),
DecodeError,
),
then next: fn(b) -> fn(List(parse.SExpr)) -> Result(
#(c, List(parse.SExpr)),
DecodeError,
),
) -> fn(List(parse.SExpr)) -> Result(
#(c, List(parse.SExpr)),
DecodeError,
)