rfc3987_syntax2.syntax_helpers
Attributes
All supported RFC 3987 grammar rule names exposed by this module. |
|
Top-level RFC 3987 parser start terms accepted by |
|
Callable validator for one RFC 3987 grammar rule. |
|
Mapping from syntax term to validator. |
|
Lark grammar text for RFC 3987. |
|
Lazily initialized parser for RFC 3987 syntax. |
Functions
|
Parse text as one of the top-level RFC 3987 syntax terms. |
|
Check whether text is valid for a top-level RFC 3987 syntax term. |
|
Create a validator function for a specific RFC 3987 grammar rule. |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
|
Validate that input text conforms to the RFC 3987 |
Module Contents
- rfc3987_syntax2.syntax_helpers.RFC3987_SYNTAX_PARSER_TYPE: Final[str] = 'earley'
- rfc3987_syntax2.syntax_helpers.RFC3987_SYNTAX_GRAMMAR_PATH: Final[pathlib.Path]
- rfc3987_syntax2.syntax_helpers.RFC3987_SYNTAX_TERMS: Final[Sequence[str]] = ['iri', 'iri_reference', 'absolute_iri', 'scheme', 'ihier_part', 'irelative_ref',...
All supported RFC 3987 grammar rule names exposed by this module.
These term names can be used to select validators from
RFC3987_SYNTAX_TERM_VALIDATORSand correspond to rules defined in the RFC 3987 Lark grammar.
- rfc3987_syntax2.syntax_helpers.T_SYNTAX_PARSER_TERM
Top-level RFC 3987 parser start terms accepted by
parse()andis_valid_syntax().Allowed values are
"iri","iri_reference", and"absolute_iri".
- rfc3987_syntax2.syntax_helpers.parse(term: T_SYNTAX_PARSER_TERM, value: str) lark.ParseTree
Parse text as one of the top-level RFC 3987 syntax terms.
- Parameters:
term – Start rule used for parsing. Must be one of
"iri","iri_reference", or"absolute_iri".value – Input text to parse.
- Returns:
The Lark parse tree for
valueunder the selected start rule.- Raises:
lark.exceptions.LarkError – If parser initialization fails or parsing cannot be completed.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax(term: T_SYNTAX_PARSER_TERM, value: str) bool
Check whether text is valid for a top-level RFC 3987 syntax term.
This is a boolean convenience wrapper around
parse().Warning
Emits a
RuntimeWarning(viawarnings.warn()) when a non-UnexpectedInputlark.exceptions.LarkErroroccurs.- Parameters:
term – Start rule used for validation. Must be one of
"iri","iri_reference", or"absolute_iri".value – Input text to validate.
- Returns:
Trueif parsing succeeds; otherwiseFalse.
- rfc3987_syntax2.syntax_helpers.T_SYNTAX_VALIDATOR
Callable validator for one RFC 3987 grammar rule.
- Parameters:
text – Input text to validate.
- Returns:
Trueiftextmatches the target rule, otherwiseFalse.
- rfc3987_syntax2.syntax_helpers.make_syntax_validator(rule_name: str) T_SYNTAX_VALIDATOR
Create a validator function for a specific RFC 3987 grammar rule.
The returned callable lazily initializes and caches a dedicated
lark.Larkparser configured withstart=rule_nameandparser=RFC3987_SYNTAX_PARSER_TYPE.- Parameters:
rule_name – Grammar rule name to validate against. Must be a value from
RFC3987_SYNTAX_TERMS.- Returns:
A callable
(text: str) -> boolthat returnsTruewhen parsing succeeds andFalseif alark.exceptions.LarkErroris raised.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_iri(text: str) bool
Validate that input text conforms to the RFC 3987
IRIrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_iri_reference(text: str) bool
Validate that input text conforms to the RFC 3987
IRI-referencerule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_absolute_iri(text: str) bool
Validate that input text conforms to the RFC 3987
absolute-IRIrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_scheme(text: str) bool
Validate that input text conforms to the RFC 3987
schemerule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ihier_part(text: str) bool
Validate that input text conforms to the RFC 3987
ihier-partrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_irelative_ref(text: str) bool
Validate that input text conforms to the RFC 3987
irelative-refrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_irelative_part(text: str) bool
Validate that input text conforms to the RFC 3987
irelative-partrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_iauthority(text: str) bool
Validate that input text conforms to the RFC 3987
iauthorityrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_iuserinfo(text: str) bool
Validate that input text conforms to the RFC 3987
iuserinforule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ihost(text: str) bool
Validate that input text conforms to the RFC 3987
ihostrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ireg_name(text: str) bool
Validate that input text conforms to the RFC 3987
ireg-namerule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ipath(text: str) bool
Validate that input text conforms to the RFC 3987
ipathrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ipath_abempty(text: str) bool
Validate that input text conforms to the RFC 3987
ipath-abemptyrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ipath_absolute(text: str) bool
Validate that input text conforms to the RFC 3987
ipath-absoluterule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ipath_noscheme(text: str) bool
Validate that input text conforms to the RFC 3987
ipath-noschemerule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ipath_rootless(text: str) bool
Validate that input text conforms to the RFC 3987
ipath-rootlessrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ipath_empty(text: str) bool
Validate that input text conforms to the RFC 3987
ipath-emptyrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_isegment(text: str) bool
Validate that input text conforms to the RFC 3987
isegmentrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_isegment_nz(text: str) bool
Validate that input text conforms to the RFC 3987
isegment-nzrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_isegment_nz_nc(text: str) bool
Validate that input text conforms to the RFC 3987
isegment-nz-ncrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ipchar(text: str) bool
Validate that input text conforms to the RFC 3987
ipcharrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_iquery(text: str) bool
Validate that input text conforms to the RFC 3987
iqueryrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ifragment(text: str) bool
Validate that input text conforms to the RFC 3987
ifragmentrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_iunreserved(text: str) bool
Validate that input text conforms to the RFC 3987
iunreservedrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ucschar(text: str) bool
Validate that input text conforms to the RFC 3987
ucscharrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_iprivate(text: str) bool
Validate that input text conforms to the RFC 3987
iprivaterule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_sub_delims(text: str) bool
Validate that input text conforms to the RFC 3987
sub-delimsrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ip_literal(text: str) bool
Validate that input text conforms to the RFC 3987
IP-literalrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ipvfuture(text: str) bool
Validate that input text conforms to the RFC 3987
IPvFuturerule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ipv6address(text: str) bool
Validate that input text conforms to the RFC 3987
IPv6addressrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_h16(text: str) bool
Validate that input text conforms to the RFC 3987
h16rule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ls32(text: str) bool
Validate that input text conforms to the RFC 3987
ls32rule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_ipv4address(text: str) bool
Validate that input text conforms to the RFC 3987
IPv4addressrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_dec_octet(text: str) bool
Validate that input text conforms to the RFC 3987
dec-octetrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_digit(text: str) bool
Validate that input text conforms to the RFC 3987
DIGITrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_unreserved(text: str) bool
Validate that input text conforms to the RFC 3987
unreservedrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_alpha(text: str) bool
Validate that input text conforms to the RFC 3987
ALPHArule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_hexdig(text: str) bool
Validate that input text conforms to the RFC 3987
HEXDIGrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_port(text: str) bool
Validate that input text conforms to the RFC 3987
portrule.
- rfc3987_syntax2.syntax_helpers.is_valid_syntax_pct_encoded(text: str) bool
Validate that input text conforms to the RFC 3987
pct-encodedrule.
- rfc3987_syntax2.syntax_helpers.RFC3987_SYNTAX_TERM_VALIDATORS: Final[Mapping[str, T_SYNTAX_VALIDATOR]]
Mapping from syntax term to validator.
Allowed keys are the RFC3987 term literals (see
RFC3987_SYNTAX_TERMS).
- rfc3987_syntax2.syntax_helpers.grammar: Final[str]
Lark grammar text for RFC 3987.
- rfc3987_syntax2.syntax_helpers.syntax_parser: Final[lark.Lark]
Lazily initialized parser for RFC 3987 syntax.