Documentation
¶
Overview ¶
Package body implements parsing of a rbnf rule body.
Token format:
substitution = bracket-start substitution-descriptor bracket-end part = substitution or literal item = part OR ('[' part* ']') * substitution = a rule set name starting with % OR a DecimalFormat pattern starting with '0' or '#'. OR empty
bracket-start, bracket-end pairs are:
→, → ←, ← =, = $(, )$
Index ¶
Constants ¶
const ( TypeLiteral // literal text data e.g. " million" TypeSubstRightArrow // →...→, simple TypeSubstLeftArrow // ←...←, simple TypeSubstEqualsSign // =...=, simple TypeOptionalStart // "[" in [...], may contain substitutions and literals TypeOptionalEnd // "]" in [...], may contain substitutions and literals TypeSubstPluralCardinal // $(cardinal,plural-syntax)$ TypeSubstPluralOrdinal // $(ordinal,plural-syntax)$ TypeTripleRightArrow // →→→. TypeEOF )
const ( SubstTypeNone = SubstType(iota) SubstTypeEmpty SubstTypeRulesetName SubstTypeDecimalFormat SubstTypeInvalid )
Variables ¶
This section is empty.
Functions ¶
func NewTokenizer ¶
Types ¶
type Token ¶
Token represents one broken-down component of a rule body. Where it includes string data (such as a substitution descriptor or literal text), this is represented by a Slice containing indexes into the original string initially passed to the tokenizer.
Tokens produced by a stream either contain an empty slice, or the slice indexes are non-overlapping and the start index is greater than or equal to any previous token's slice end index.
func (Token) SimpleSubstType ¶
SimpleSubstType returns the type of substitution descriptor appearing between delimiters e.g. "→→" (empty), "=%RulesetName=" "=#DecimalFormat=". The string argument is the rule body string that the token content slice applies to.