Skip to main content

xgrammar/parser/
rule_attributes.rs

1//! The attribute block of a rule definition, e.g. `name[max_tokens=10, capture] ::= ...`.
2
3use crate::grammar::SuffixStopInfo;
4
5/// Rule attributes attached to a rule-definition identifier by the lexer.
6#[derive(Debug, Clone, PartialEq)]
7pub struct RuleAttributes {
8    /// The token budget, or `-1`.
9    pub max_tokens: i32,
10    /// The character budget, or `-1`.
11    pub max_chars: i32,
12    /// The capture name, or empty.
13    pub capture_name: String,
14    /// The capture-hidden suffix/stop metadata (the `rule_id` field is unused).
15    pub suffix_stop_info: SuffixStopInfo,
16    /// Whether the rule is lazy (committed-shortest).
17    pub is_lazy: bool,
18    /// The sampling temperature.
19    pub temperature: Option<f32>,
20}