Package hydra.parse
Interface Regex
-
public interface RegexParser for Hydra's translingual regular-expression syntax (docs/specification/regex.md): text -> hydra.regex AST. Built on the hydra.parsers combinators. Rejects ill-formed patterns (empty alternation branches, empty classes, out-of-range code points) via the ParseResult failure channel, so 'well-formed' is portable across hosts. See issue #567. A structured textual-syntax parser (precedent for the general parser in #497), not a scalar parse<T> convention function (see docs/specification/index.md, Conventions).
-
-
Method Summary
Static Methods Modifier and Type Method Description static Parser<java.util.List<java.util.List<Quantified>>>alternation()Parse an alternation of sequences separated by |.static Parser<Atom>atom()Parse a single atom: a group ( ...static Parser<Atom>characterClass()Parse a character class [ ...static Parser<ClassItem>classItem()Parse one member of a character class: a range like a-z, or a single character (escapes allowed).static Parser<java.lang.Integer>escapedChar()Parse a backslash followed by any character; yields that character's codepoint (the escape is consumed).static java.lang.BooleanisMetachar(java.lang.Integer c)True if the codepoint is a top-level regex metacharacter that must be escaped to match literally.static Parser<Atom>literalAtom()Parse a literal character (an escaped metacharacter, or any ordinary non-metacharacter) into an Atom.static Optional<java.util.List<java.util.List<Quantified>>>parseRegex(java.lang.String input)Parse a full regex pattern string into a hydra.regex AST.static Parser<Quantified>quantified()Parse an atom followed by an optional quantifier.static Parser<Quantifier>quantifier()Parse an optional quantifier following an atom; yields 'one' when no quantifier is present.static Parser<java.util.List<java.util.List<Quantified>>>regex()Parse a complete regex (an alternation).static Parser<java.util.List<Quantified>>regexSequence()Parse a sequence of quantified atoms (a single alternation branch).static Parser<java.lang.Integer>unsignedInt()Parse a non-negative decimal integer (one or more digits).
-
-
-
Method Detail
-
alternation
static Parser<java.util.List<java.util.List<Quantified>>> alternation()
Parse an alternation of sequences separated by |. When there is more than one branch, each branch must be non-empty; empty branches (a|, |b, a||b, and the nested (a|)) are rejected at every level. A single empty branch is the legal empty case (empty whole pattern / empty group).
-
atom
static Parser<Atom> atom()
Parse a single atom: a group ( ... ), a class [ ... ], ., an anchor ^ or $, or a literal.
-
characterClass
static Parser<Atom> characterClass()
Parse a character class [ ... ] or [^ ... ]; the class must be non-empty.
-
classItem
static Parser<ClassItem> classItem()
Parse one member of a character class: a range like a-z, or a single character (escapes allowed).
-
escapedChar
static Parser<java.lang.Integer> escapedChar()
Parse a backslash followed by any character; yields that character's codepoint (the escape is consumed).
-
isMetachar
static java.lang.Boolean isMetachar(java.lang.Integer c)
True if the codepoint is a top-level regex metacharacter that must be escaped to match literally.
-
literalAtom
static Parser<Atom> literalAtom()
Parse a literal character (an escaped metacharacter, or any ordinary non-metacharacter) into an Atom.
-
parseRegex
static Optional<java.util.List<java.util.List<Quantified>>> parseRegex(java.lang.String input)
Parse a full regex pattern string into a hydra.regex AST. Returns nothing if the pattern is ill-formed or does not consume all input; a well-formed pattern is exactly one that parses here, so 'well-formed' is portable across all hosts.
-
quantified
static Parser<Quantified> quantified()
Parse an atom followed by an optional quantifier.
-
quantifier
static Parser<Quantifier> quantifier()
Parse an optional quantifier following an atom; yields 'one' when no quantifier is present.
-
regex
static Parser<java.util.List<java.util.List<Quantified>>> regex()
Parse a complete regex (an alternation). The empty pattern parses to a single empty sequence.
-
regexSequence
static Parser<java.util.List<Quantified>> regexSequence()
Parse a sequence of quantified atoms (a single alternation branch). May be empty only as the whole pattern; as an alternation branch it is constrained to be non-empty by the alternation parser's use of sepBy1 plus a non-empty check.
-
unsignedInt
static Parser<java.lang.Integer> unsignedInt()
Parse a non-negative decimal integer (one or more digits).
-
-