added support for loading dictionary structure
This commit is contained in:
parent
49db07b9ee
commit
4b33ab4a56
@ -2,8 +2,9 @@
|
||||
/// This function returns a dictionary of structures
|
||||
///
|
||||
/// Supported formats: #schema.valid-extensions.map(e => raw("." + e)).join(", ")
|
||||
/// - path-or-schema (str, raw): If it is a string, defines the path to load. \
|
||||
/// If it is a raw block, its content is directly parsed (the block's language will define the format to use)
|
||||
/// - path-or-schema (str, raw, dictionary): If it is a string, defines the path to load. \
|
||||
/// If it is a raw block, its content is directly parsed (the block's language will define the format to use) \
|
||||
/// If it is a dictionary, it directly defines the schema structure
|
||||
/// -> dictionary
|
||||
#let load(path-or-schema) = {}
|
||||
|
||||
|
BIN
gallery/test.pdf
BIN
gallery/test.pdf
Binary file not shown.
102
gallery/test.typ
102
gallery/test.typ
@ -26,3 +26,105 @@ structures:
|
||||
#schema.render(test-raw, config: config.config(
|
||||
full-page: true
|
||||
))
|
||||
|
||||
#let test-typ = schema.load((
|
||||
structures: (
|
||||
main: (
|
||||
bits: 32,
|
||||
ranges: (
|
||||
"31-28": (name: "cond"),
|
||||
"27": (name: "0"),
|
||||
"26": (name: "1"),
|
||||
"25": (name: "I"),
|
||||
"24": (
|
||||
name: "P",
|
||||
description: "pre / post indexing bit",
|
||||
values: (
|
||||
"0": "post, add offset after transfer",
|
||||
"1": "pre, add offset before transfer"
|
||||
)
|
||||
),
|
||||
"23": (
|
||||
name: "U",
|
||||
description: "up / down bit",
|
||||
values: (
|
||||
"0": "down, subtract offset from base",
|
||||
"1": "up, addition offset to base"
|
||||
)
|
||||
),
|
||||
"22": (
|
||||
name: "B",
|
||||
description: "byte / word bit",
|
||||
values: (
|
||||
"0": "transfer word quantity",
|
||||
"1": "transfer byte quantity"
|
||||
)
|
||||
),
|
||||
"21": (
|
||||
name: "W",
|
||||
description: "write-back bit",
|
||||
values: (
|
||||
"0": "no write-back",
|
||||
"1": "write address into base"
|
||||
)
|
||||
),
|
||||
"20": (
|
||||
name: "L",
|
||||
description: "load / store bit",
|
||||
values: (
|
||||
"0": "store to memory",
|
||||
"1": "load from memory"
|
||||
)
|
||||
),
|
||||
"19-16": (
|
||||
name: "Rn",
|
||||
description: "base register"
|
||||
),
|
||||
"15-12": (
|
||||
name: "Rd",
|
||||
description: "source / destination register"
|
||||
),
|
||||
"11-0": (
|
||||
name: "offset",
|
||||
depends-on: "25",
|
||||
values: (
|
||||
"0": (
|
||||
description: "offset is an immediate value",
|
||||
structure: "immediateOffset"
|
||||
),
|
||||
"1": (
|
||||
description: "offset is a register",
|
||||
structure: "registerOffset"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
immediateOffset: (
|
||||
bits: 12,
|
||||
ranges: (
|
||||
"11-0": (
|
||||
name: "12-bit immediate offset",
|
||||
description: "unsigned number"
|
||||
)
|
||||
)
|
||||
),
|
||||
registerOffset: (
|
||||
bits: 12,
|
||||
ranges: (
|
||||
"11-4": (
|
||||
name: "shift",
|
||||
description: "shift applied to Rm"
|
||||
),
|
||||
"3-0": (
|
||||
name: "Rm",
|
||||
description: "offset register"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
))
|
||||
|
||||
#schema.render(test-typ, config: config.config(
|
||||
full-page: true
|
||||
))
|
BIN
manual.pdf
BIN
manual.pdf
Binary file not shown.
@ -44,6 +44,8 @@
|
||||
#let load(path-or-schema) = {
|
||||
let schema = if type(path-or-schema) == str {
|
||||
parse-file(path-or-schema)
|
||||
} else if type(path-or-schema) == dictionary {
|
||||
path-or-schema
|
||||
} else {
|
||||
parse-raw(path-or-schema)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user