use crate::parser::_common::State;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum TriGState {
DefaultGraph,
NamedGraph(bool),
Block(bool),
LabelNotSubject,
AtDirective,
BaseIri,
PrefixDeclaration,
PrefixIri,
VersionSpecifier,
Triples(bool),
PredicateObjectList,
ObjectList,
Verb,
Object,
BlankNodePropertyListOrAnon,
Collection,
RdfLiteral(bool),
Reifier,
ReifiedTriple(bool),
RtSubject,
RtObject,
TripleTerm,
TtSubject,
TtObject,
AnnotationBlock,
StringLiteralLong(u8),
Anon(bool),
}
impl State for TriGState {
fn new_annotation_block() -> Self {
Self::AnnotationBlock
}
fn new_anon(reifier: bool) -> Self {
Self::Anon(reifier)
}
fn new_at_directive() -> Self {
Self::AtDirective
}
fn new_base_iri() -> Self {
Self::BaseIri
}
fn new_collection() -> Self {
Self::Collection
}
fn new_blank_node_property_list_or_anon() -> Self {
Self::BlankNodePropertyListOrAnon
}
fn new_object_list() -> Self {
Self::ObjectList
}
fn new_object() -> Self {
Self::Object
}
fn new_predicate_object_list() -> Self {
Self::PredicateObjectList
}
fn new_prefix_declaration() -> Self {
Self::PrefixDeclaration
}
fn new_prefix_iri() -> Self {
Self::PrefixIri
}
fn new_rdf_literal(after_dt: bool) -> Self {
Self::RdfLiteral(after_dt)
}
fn new_reified_triple(inside: bool) -> Self {
Self::ReifiedTriple(inside)
}
fn new_reifier() -> Self {
Self::Reifier
}
fn new_rt_object() -> Self {
Self::RtObject
}
fn new_rt_subject() -> Self {
Self::RtSubject
}
fn new_string_literal_long(quote: u8) -> Self {
debug_assert!(matches!(quote, b'"' | b'\''));
Self::StringLiteralLong(quote)
}
fn new_triple_term() -> Self {
Self::TripleTerm
}
fn new_tt_object() -> Self {
Self::TtObject
}
fn new_tt_subject() -> Self {
Self::TtSubject
}
fn new_verb() -> Self {
Self::Verb
}
fn new_version_specifier() -> Self {
Self::VersionSpecifier
}
fn in_annotation_block(&self) -> bool {
matches!(self, Self::AnnotationBlock)
}
fn in_anon(&self) -> bool {
matches!(self, Self::Anon(_))
}
fn in_at_directive(&self) -> bool {
matches!(self, Self::AtDirective)
}
fn in_base_iri(&self) -> bool {
matches!(self, Self::BaseIri)
}
fn in_blank_node_property_list_or_anon(&self) -> bool {
matches!(self, Self::BlankNodePropertyListOrAnon)
}
fn in_collection(&self) -> bool {
matches!(self, Self::Collection)
}
fn in_lang_dir(&self) -> bool {
matches!(self, Self::RdfLiteral(_))
}
fn in_object_list(&self) -> bool {
matches!(self, Self::ObjectList)
}
fn in_predicate_object_list(&self) -> bool {
matches!(self, Self::PredicateObjectList)
}
fn in_prefix_declaration(&self) -> bool {
matches!(self, Self::PrefixDeclaration)
}
fn in_prefix_iri(&self) -> bool {
matches!(self, Self::PrefixIri)
}
fn in_rdf_literal(&self) -> bool {
matches!(self, Self::RdfLiteral(_))
}
fn in_reified_triple(&self, inside: bool) -> bool {
if let Self::ReifiedTriple(i) = self {
*i == inside
} else {
false
}
}
fn in_reifier(&self) -> bool {
matches!(self, Self::Reifier)
}
fn in_rt_object(&self) -> bool {
matches!(self, Self::RtObject)
}
fn in_rt_subject(&self) -> bool {
matches!(self, Self::RtSubject)
}
fn in_string_literal_long(&self) -> bool {
matches!(self, Self::StringLiteralLong(_))
}
fn in_triple_term(&self) -> bool {
matches!(self, Self::TripleTerm)
}
fn in_triples(&self) -> bool {
matches!(self, Self::Triples(_))
}
fn in_tt_object(&self) -> bool {
matches!(self, Self::TtObject)
}
fn in_tt_subject(&self) -> bool {
matches!(self, Self::TtSubject)
}
fn in_verb(&self) -> bool {
matches!(self, Self::Verb)
}
fn in_version_specifier(&self) -> bool {
matches!(self, Self::VersionSpecifier)
}
fn in_boolean_literal_context(&self) -> bool {
matches!(
self,
Self::ObjectList | Self::Collection | Self::RtObject | Self::TtObject
)
}
fn in_numeric_literal_context(&self) -> bool {
matches!(
self,
Self::ObjectList | Self::Collection | Self::RtObject | Self::TtObject
)
}
fn in_object_context(&self) -> bool {
matches!(self, Self::ObjectList | Self::Collection)
}
fn in_predicate_object_list_context(&self) -> bool {
matches!(
self,
TriGState::AnnotationBlock
| TriGState::BlankNodePropertyListOrAnon
| TriGState::Triples(_)
)
}
fn in_rdf_literal_context(&self) -> bool {
matches!(self, Self::Object | Self::RtObject | Self::TtObject)
}
fn in_verb_context(&self) -> bool {
matches!(
self,
TriGState::PredicateObjectList | TriGState::ReifiedTriple(true) | TriGState::TripleTerm
)
}
fn as_triples_require_pol_mut(&mut self) -> Option<&mut bool> {
if let Self::Triples(ret) = self {
Some(ret)
} else {
None
}
}
}