Class RegExp
java.lang.Object
jflex.core.RegExp
Stores a regular expression of rules section in a JFlex-specification.
This base class has no content other than its type.
- Version:
- JFlex 1.9.1
- Author:
- Gerwin Klein
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RegExpanyChar()Returns a regexp that matches any character:[^]static RegExp1Confirms that the parameter is a RegExp1 of type sym.PRIMCLASS.expandPreClasses(Map<Integer, IntCharSet> cache, CharClasses cl, boolean caseless) Expand pre-defined character classes into primitive IntCharSet classes.booleanFind out if this regexp is a char class or equivalent to one.final voidmakeCCLs(CharClasses c, boolean caseless) Make character class partitions based on the classes mentioned in this regexp.final RegExpnormaliseCCLs(File f, int line) Normalise the regular expression to eliminate compound character class expression (compute their content).final RegExpNormalise the regular expression to eliminate macro use (expand them).static IntCharSetperformClassOp(int op, IntCharSet l, IntCharSet r, RegExp ctxt) Performs the given set operation on the twoIntCharSetparameters.Returns a String-representation of this regular expression with the specified indentation.final RegExpRecursively convert tilde (upto) expressions into negation and star.final RegExprev()Creates a new regexp that matches the reverse text of this one.intThe approximate number of NFA states this expression will need (only works correctly after macro expansion and without negation)toString()typeName()String representation of the type of this regular expression.
-
Constructor Details
-
RegExp
public RegExp(int type) Create a new regular expression of the specified type.- Parameters:
type- a value from the cup generated class sym.
-
-
Method Details
-
print
-
toString
-
typeName
String representation of the type of this regular expression. -
isCharClass
public boolean isCharClass()Find out if this regexp is a char class or equivalent to one.- Returns:
- true if the regexp is equivalent to a char class.
-
size
The approximate number of NFA states this expression will need (only works correctly after macro expansion and without negation)- Parameters:
macros- macro table for expansion- Returns:
- a int.
-
resolveTilde
Recursively convert tilde (upto) expressions into negation and star.- Returns:
- new RegExp equivalent to the current one, but without upto expressions.
-
anyChar
Returns a regexp that matches any character:[^]- Returns:
- the regexp for
[^]
-
checkPrimClass
Confirms that the parameter is a RegExp1 of type sym.PRIMCLASS.- Parameters:
r- the RegExp to check- Returns:
- r cast to RegExp1
- Throws:
CharClassException- if r is not a RegExp1 or of type sym.PRIMCLASS.
-
performClassOp
Performs the given set operation on the twoIntCharSetparameters.- Parameters:
op- the operation to perform (as @{link sym} constant)l- the left operator of the expressionr- the right operator of the expressionctxt- the regular expression containing the provided operator- Returns:
- a new
IntCharSet - Throws:
RegExpException- forctxtif the operator is not supported
-
normaliseMacros
Normalise the regular expression to eliminate macro use (expand them).- Returns:
- a regexp that contains no
sym.MACROUSE.
-
normaliseCCLs
Normalise the regular expression to eliminate compound character class expression (compute their content).- Parameters:
f- the spec file containing the regular expression (for error reporting)line- the line number of the regular expression (for error reporting)- Returns:
- a regexp where all char classes are primitive
IntCharSetclasses.
-
expandPreClasses
Expand pre-defined character classes into primitive IntCharSet classes.- Parameters:
cache- memoized pre-defined character class expansionscl- character class partitions- Returns:
- the expanded regular expression
-
makeCCLs
Make character class partitions based on the classes mentioned in this regexp.Assumption: regexp is normalised.
-
rev
Creates a new regexp that matches the reverse text of this one.- Returns:
- the reverse regexp
-