def string(self, children): (literal, ) = children if literal.type in ( "STRING_LITERAL_QUOTE", "STRING_LITERAL_SINGLE_QUOTE", ): string = decode_literal(literal[1:-1]) if literal.type in ( "STRING_LITERAL_LONG_SINGLE_QUOTE", "STRING_LITERAL_LONG_QUOTE", ): string = decode_literal(literal[3:-3]) return string
def literal(self, children): quoted_literal = children[0] quoted_literal = quoted_literal[1:-1] # Remove ""s literal = decode_literal(quoted_literal) if len(children) == 2 and isinstance(children[1], NamedNode): type_ = children[1] return self.make_datatype_literal(literal, type_) elif len(children) == 2 and children[1].type == 'LANGTAG': lang = children[1][1:] # Remove @ return self.make_language_literal(literal, lang) else: return self.make_language_literal(literal)
def prefixed_name(self, children): (pname, ) = children ns, _, ln = pname.partition(":") return self.make_named_node(self.prefixes[ns] + decode_literal(ln))
def decode_iriref(self, iriref): return validate_iri(decode_literal(iriref[1:-1]))
def iriref(self, children): iri = ''.join(children) iri = decode_literal(iri) return self.make_named_node(iri)