Skip to main content

Module validation

Module validation 

Source
Expand description

Validate the Parsed dialogue based on the RepliqueSchema.

The schema is what a project says about itself, and what a dialogue cannot know on its own: who can speak, which tags mean something, and which functions and commands the game answers to. It is written in a replique.toml:

speakers = ["Robin", "Fanny", "Bertille"]

[tags]
happy = { scope = ["Robin", "Fanny"] }
delay = {}

[functions]
get_flower = "1-2"

[commands]
add_scene = "1+"
change_mood = "2"

Every part is optional, and a part left out is not checked: without speakers, anyone can speak. A tag without a scope is one any line can carry; with one, only the lines of those speakers can. A function or a command is given the number of arguments it takes: "2" for exactly two, "1+" for one or more, "1-2" for one or two.

use replique::parser::validation::{Arity, RepliqueSchema};

let schema: RepliqueSchema = r#"
    speakers = ["Robin"]

    [commands]
    add_scene = "1+"
"#
.parse()
.unwrap();

assert_eq!(schema.speakers, ["Robin"]);
assert_eq!(schema.commands[0].arity, Arity::AtLeast(1));

Re-exports§

pub use crate::builtins::Arity;

Structs§

CallSchema
InvalidArity
An arity that reads as none of "2", "1+" and "1-2".
RepliqueSchema
What a replique.toml contains.
TagSchema

Enums§

SchemaError
Why a replique.toml could not be read.
TagScope
Which lines can carry a tag.