| java.lang.Object com.hp.hpl.jena.graph.query.regexptrees.PerlPatternParser
PerlPatternParser | public class PerlPatternParser (Code) | | Parse Perl5 patterns into RegexpTree structures, or throw an exception for
cases that haven't been implemented.
author: hedgehog |
Field Summary | |
final public static String | digits The digits, in order. | protected RegexpTreeGenerator | generator The generator for the RegexpTree nodes to be used in the parse. | final protected int | limit The length of the string to parse, used as a limit. | protected int | matchPointsSeen Count of how many back-references match-points seen so far. | protected int | pointer The index into the string of the next undealt-with character, ie, it starts at 0. | final protected String | toParse The string being parsed, as supplied to the constructor(s). | final public static String | wordChars The characters that are (non-)matchable by \w[W]. |
Method Summary | |
protected RegexpTree | backReferenceOrOctalChar(char ch) Answer the backreference or octal character described by \nnnn sequences. | protected RegexpTree | control(char ch) Answer a RegexpTree representing the single character which is CTRL-ch. | public int | getPointer() Answer the current index into the parse string. | public String | getString() Answer the string that this parser is parsing. | protected RegexpTree | hexEscape() Answer a RegexpTree representing the single character whose value is
given by the next two hexadecimal digits. | protected char | nextChar() Answer the character under the pointer, and advance the pointer. | protected char | numeric(char[] chars, int base, int limit) Answer the numeric value represented by chars[0..limit-1] in the given base. | public static RegexpTree | parse(String string) Answer the result of parsing the given string as a sequence of alternatives. | public static RegexpTree | parse(String string, RegexpTreeGenerator gen) Answer the result of parsing the given string as a sequence of alternatives,
using the supplied generator for the pattern nodes. | public RegexpTree | parseAlts() Parse an alternation of sequences and answer an alternative tree (or the
single component if there is just one alternative). | public RegexpTree | parseAtom() Parse a single atom and return the tree for it, advancing the pointer. | protected RegexpTree | parseClass() Parse a class expression and answer an appropriate tree. | protected boolean | parseClassNegation() | public RegexpTree | parseElement() Parse an element (an atom and any following quantifier) and answer the
possibly-quantified tree. | protected RegexpTree | parseParens() Parse a parenthesised expression. | public RegexpTree | parseQuantifier(RegexpTree d) Parse any quantifier and answer the quantified version of the argument
tree d . | public RegexpTree | parseSeq() Parse a sequence of elements [possibly-quantified atoms] and answer the
sequence (singular sequences may be reduced to its single element). |
digits | final public static String digits(Code) | | The digits, in order.
|
limit | final protected int limit(Code) | | The length of the string to parse, used as a limit.
|
matchPointsSeen | protected int matchPointsSeen(Code) | | Count of how many back-references match-points seen so far.
|
pointer | protected int pointer(Code) | | The index into the string of the next undealt-with character, ie, it starts at 0.
|
toParse | final protected String toParse(Code) | | The string being parsed, as supplied to the constructor(s).
|
wordChars | final public static String wordChars(Code) | | The characters that are (non-)matchable by \w[W].
|
PerlPatternParser | public PerlPatternParser(String toParse)(Code) | | Initialise this parser with the string to parse and with the default
generator (SimpleGenerator).
|
PerlPatternParser | public PerlPatternParser(String toParse, RegexpTreeGenerator gen)(Code) | | Initialise this parser with the string to parse and with the generator to
use for node construction.
|
backReferenceOrOctalChar | protected RegexpTree backReferenceOrOctalChar(char ch)(Code) | | Answer the backreference or octal character described by \nnnn sequences.
|
control | protected RegexpTree control(char ch)(Code) | | Answer a RegexpTree representing the single character which is CTRL-ch.
|
getPointer | public int getPointer()(Code) | | Answer the current index into the parse string.
|
getString | public String getString()(Code) | | Answer the string that this parser is parsing.
|
hexEscape | protected RegexpTree hexEscape()(Code) | | Answer a RegexpTree representing the single character whose value is
given by the next two hexadecimal digits.
|
nextChar | protected char nextChar()(Code) | | Answer the character under the pointer, and advance the pointer.
|
numeric | protected char numeric(char[] chars, int base, int limit)(Code) | | Answer the numeric value represented by chars[0..limit-1] in the given base.
|
parse | public static RegexpTree parse(String string)(Code) | | Answer the result of parsing the given string as a sequence of alternatives.
|
parse | public static RegexpTree parse(String string, RegexpTreeGenerator gen)(Code) | | Answer the result of parsing the given string as a sequence of alternatives,
using the supplied generator for the pattern nodes.
|
parseAlts | public RegexpTree parseAlts()(Code) | | Parse an alternation of sequences and answer an alternative tree (or the
single component if there is just one alternative).
|
parseAtom | public RegexpTree parseAtom()(Code) | | Parse a single atom and return the tree for it, advancing the pointer. This
does not deal with quantifiers, for which see parseQuantifier. Unmatched
right parentheses, unexpected (hence unbound) quantifiers, and those things
that aren't implemented, throw exceptions. An empty atom is permitted
(at the end of a string or before a |).
|
parseClass | protected RegexpTree parseClass()(Code) | | Parse a class expression and answer an appropriate tree.
|
parseClassNegation | protected boolean parseClassNegation()(Code) | | |
parseElement | public RegexpTree parseElement()(Code) | | Parse an element (an atom and any following quantifier) and answer the
possibly-quantified tree.
|
parseParens | protected RegexpTree parseParens()(Code) | | Parse a parenthesised expression. Throw a SyntaxException if the closing
bracket is missing. Answer the wrapped sub-expression. Does not cater
for the (? ...) stuff.
|
parseQuantifier | public RegexpTree parseQuantifier(RegexpTree d)(Code) | | Parse any quantifier and answer the quantified version of the argument
tree d . TODO: handle non-greedy quantifiers. (These will
currently generate syntax errors when their flagging ? is encountered by
parseAtom.)
|
parseSeq | public RegexpTree parseSeq()(Code) | | Parse a sequence of elements [possibly-quantified atoms] and answer the
sequence (singular sequences may be reduced to its single element).
|
|
|