Struct GrammarWithLexer
pub struct GrammarWithLexer {
pub name: Option<String>,
pub nodes: Vec<Node>,
pub json_schema: Option<Value>,
pub lark_grammar: Option<String>,
pub greedy_lexer: bool,
pub greedy_skip_rx: Option<RegexSpec>,
pub contextual: Option<bool>,
pub rx_nodes: Vec<RegexNode>,
pub allow_initial_skip: bool,
pub no_forcing: bool,
pub allow_invalid_utf8: bool,
}
Fields§
§name: Option<String>
The name of this grammar, can be used in GenGrammar nodes.
nodes: Vec<Node>
The start symbol is at nodes[0] When nodes is empty, then one of json_schema or lark_grammar must be set.
json_schema: Option<Value>
The JSON schema that the grammar should generate. When this is set, nodes and rx_nodes must be empty.
lark_grammar: Option<String>
The Lark grammar that the grammar should generate. When this is set, nodes and rx_nodes must be empty.
greedy_lexer: bool
This is no longer used.
When enabled, the grammar can use Lexeme
but not Gen
.
When disabled, the grammar can use Gen
but not Lexeme
.
String
is allowed in either case as a shorthand for either Lexeme
or Gen
.
greedy_skip_rx: Option<RegexSpec>
Only applies to greedy_lexer grammars. This adds a new lexeme that will be ignored when parsing.
contextual: Option<bool>
The default value for ‘contextual’ in Lexeme nodes.
rx_nodes: Vec<RegexNode>
When set, the regexps can be referenced by their id (position in this list).
allow_initial_skip: bool
If set, the grammar will allow skip_rx as the first lexeme.
no_forcing: bool
Normally, when a sequence of bytes is forced by grammar, it is tokenized
canonically and forced as tokens.
With no_forcing
, we let the model decide on tokenization.
This generally reduces both quality and speed, so should not be used
outside of testing.
allow_invalid_utf8: bool
If set, the grammar will allow invalid utf8 byte sequences. Any Unicode regex will cause an error.
Implementations§
§impl GrammarWithLexer
impl GrammarWithLexer
pub fn from_lark(lark_grammar: String) -> GrammarWithLexer
pub fn from_regex(rx: RegexNode) -> GrammarWithLexer
Trait Implementations§
§impl Clone for GrammarWithLexer
impl Clone for GrammarWithLexer
§fn clone(&self) -> GrammarWithLexer
fn clone(&self) -> GrammarWithLexer
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for GrammarWithLexer
impl Debug for GrammarWithLexer
§impl Default for GrammarWithLexer
impl Default for GrammarWithLexer
§fn default() -> GrammarWithLexer
fn default() -> GrammarWithLexer
§impl<'de> Deserialize<'de> for GrammarWithLexer
impl<'de> Deserialize<'de> for GrammarWithLexer
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<GrammarWithLexer, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<GrammarWithLexer, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for GrammarWithLexer
impl Serialize for GrammarWithLexer
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for GrammarWithLexer
impl RefUnwindSafe for GrammarWithLexer
impl Send for GrammarWithLexer
impl Sync for GrammarWithLexer
impl Unpin for GrammarWithLexer
impl UnwindSafe for GrammarWithLexer
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any
.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.