tiger_lib::datatype

Function validate_datatypes

Source
pub fn validate_datatypes(
    chain: &CodeChain,
    data: &Everything,
    sc: &mut ScopeContext,
    expect_type: Datatype,
    lang: Option<Language>,
    format: Option<&Token>,
    expect_promote: bool,
)
Expand description

Validate a datafunction chain, which is the stuff between [ ] in localization.

  • chain is the parsed datafunction structure.
  • sc is a ScopeContext used to evaluate scope references in the datafunctions. If nothing is known about the scope, just pass an empty ScopeContext with set_strict_types(false).
  • expect_type is the datatype that should be returned by this chain, can be Datatype::Unknown in many cases.
  • lang is set to a specific language if Custom references in this chain only need to be defined for one language. It can just be None otherwise.
  • format is the formatting code given after | in the datatype expression. It’s used for checking that game concepts in ck3 have |E formats.
  • expect_promote is true iff the chain is expected to end on a promote rather than on a function. Promotes and functions are very similar but they are defined separately in the datafunction tables and usually only a function can end a chain.