Expand description
AST provides a set of Syntax Tree Nodes used to store
the output of parse method that is used in test_condition method
to evaluate whether a given PluralCategory should be used.
🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
including in SemVer minor releases. In particular, the `DataProvider` implementations are only
guaranteed to match with this version's `*_unstable` providers. Use with caution.
§Examples
use icu::plurals::provider::rules::reference::ast::*;
use icu::plurals::provider::rules::reference::parse_condition;
let input = "i = 1";
let ast = parse_condition(input.as_bytes()).expect("Parsing failed.");
assert_eq!(
ast,
Condition(vec![AndCondition(vec![Relation {
expression: Expression {
operand: Operand::I,
modulus: None,
},
operator: Operator::Eq,
range_list: RangeList(vec![RangeListItem::Value(Value(1))])
}])])
);Structs§
- AndCondition
- An incomplete AST representation of a plural rule. Comprises a vector of
Relations. - Condition
- A complete AST representation of a plural rule’s condition. Comprises a vector of
AndConditions. - Decimal
Value - A decimal value used in samples.
- Expression
- An incomplete AST representation of a plural rule. Comprises an
Operandand an optional modulo. - Range
List - An incomplete AST representation of a plural rule. Comprises a vector of
RangeListItems. - Relation
- An incomplete AST representation of a plural rule. Comprises an
Expression, anOperator, and aRangeList. - Rule
- A complete AST representation of a plural rule.
Comprises a vector of
AndConditionsand optionally a set ofSamples. - Sample
List - A list of values used in samples.
- Sample
Range - A value range used in samples.
- Samples
- A sample of example values that match the given rule.
- Value
- An incomplete AST representation of a plural rule, representing one integer.