See: Description
Interface | Description |
---|---|
ExpressionConstants |
Constants used by subclasses of AbstractRegularExpression.
|
Class | Description |
---|---|
AbstractRegularExpression |
This is the abstract superclass for all regular expressions that may help building a RegExp-based parser.
|
AlternateExpression |
A regular expression that mimics the "x|y" RegExp syntax.
|
CommentExpression |
Parse comment strings.
|
Context |
A class that stores context information about the parsing process, like : current line
number, current parsed substring, block markers, stack for markers...
|
EnclosingExpression |
An expression that can encompass a sub-expression it encloses with markers, e.g.
|
InstanciationExpression |
An expression that can instanciate a new Element by cloning the given graphic element when it finds a given
litteral tag, then add it to the current PicGroup in the pool.
|
LiteralExpression |
An expression specified by a String to be exactly matched at the current cursor position.
|
NotParsableExpression |
Any string (but w/o line-feeds !)
|
NumericalExpression |
An expression containing only digits, possibly preceded by whitespaces ;
a post-delimiters can be specified, as well as the number's type (int or double) and its sign
|
OptionalExpression |
an expression that represents a pattern repeating at most once
|
ParserEvent |
An event that gets sent as an argument of the "action" method during an interpret operation
|
PicPointExpression |
An expression for 2D-Point parsing e.g.
|
Pool |
Offers a means for expressions belonging to the parser-tree to share variables across the tree.
|
Pool.Key |
Enforces use of strong typing for keys being pushed in the map .
|
RegExExpression |
An expression specified by a java.util.regex.Pattern regular expression.
|
RepeatExpression |
an expression that represents a pattern repeating a given number of times
|
RootExpression |
This is the super-class for head-expressions that contain grammar rule for a given format.
|
SequenceExpression |
An expression that represents a sequence of expressions to be matched exactly in
the same order they're being added to the sequence.
|
StatementExpression |
An expression for "statement"-parsing, i.e.
|
WhiteSpaces |
Multiple white spaces (w/o line-feeds)
|
WhiteSpacesOrEOL |
multiple white spaces and/or '\n'
|
WildCharExpression |
a RegExp that represents a single occurence of a wild-char, i.e.
|
WordExpression |
A RegExp that parses a word, that is, a string :
either composed of letters only, or letters and digits only (see java.lang.Character.isLetter() for details),
or terminated by the specified end-delimiter (in which case it may contain chars not restricted to letters)
|
Exception | Description |
---|---|
REParserException |
An Exception manager to be used by RE-parsers (i.e.
|
REParserException.BeginGroupMismatch |
a "begin group" has no matching "end group"
|
REParserException.BlockMismatch |
a closing delimiter has no matching opening delimiter (see EnclosingExpression)
|
REParserException.EndGroupMismatch |
a "end group" has no matching "begin group"
|
REParserException.EndOfPicture |
the end of the picture environment was encoutered.
|
REParserException.EndOfPictureNotFound |
the end of the picture environment wasn't found in the current Reader.
|
REParserException.EOF |
the end of the file (or the underlying Reader) was reached abnormally, e.g.
|
REParserException.IncompleteSequence |
signals an incomplete SequenceExpression
|
REParserException.NotFoundInFile |
a mandatory expression wasn't found
|
REParserException.NumberFormat |
aka NumberFormatException
|
REParserException.NumberSign |
signals an error concerning the sign of a number (see NumericalExpression)
|
REParserException.SyntaxError |
a syntax error has occured ; should be used as a last resort, when
no specific exception message applies.
|
This package contains helper classes for building a parser based on the well-known RegExp scheme, yet with a strong object-oriented approach in mind. Keyword human-readibility !
The base superclass of this package is the AbstractRegularExpression
class. Two
daughter classes then help building a grammar tree, namely
AlternateExpression
and SequenceExpression
,
which perform RegExp-like OR and AND operations respectively.
Regular expressions work hand-in-hand with two important classes :
an instance of the Context
class,
which is used to feed successive pieces of text to the set of reg-exp's that build up
the grammar tree, and an instance of the Pool
class,
which allows regular expression to share data across the whole grammar tree.
A RootExpression
might then help building a stand-alone parser, by serving as a communication hub
between the context, the pool and the various regular expressions that build up the tree.
We make use of the classical callback mechanism to process parsing events, yet
instead of using a unique, separate content-handler (e.g. as in most XML/HTML parsers),
each AbstractRegularExpression
has its own content-handler, which is part of the same class, and is implemented
in the core of the action(ParserEvent e)
method. This allows subclasses to
easily specialize content-handling behaviour only, by simply overiding the latter method.
(see e.g. InstanciationExpression
for an example).
As a rule of thumb, developpers should as much as possible avoid dealing directly
with the Context instance in their own implementations, and rather rely on existing
helper classes, since the latters already encapsulate much of the tricky communication scheme.
To set the stage, classes LiteralExpression
, NumericalExpression
,
StatementExpression
and WordExpression
comprise a minimal set
of helpers from which it might be easy to build a rather complicated grammar rule.
Besides, classes OptionalExpression
and RepeatExpression
allow
to handle RegExp-like *
, +
and ?
operations quite easily.
Submit a bug : syd@jpicedt.org