public final class RegexObject extends AbstractConstantKeysObject
RegexObject represents a compiled regular expression that can be used to match against
input strings. It is the result of a call to
RegexLanguage.parse(TruffleLanguage.ParsingRequest). It exposes the following three
properties:
String pattern: the source of the compiled regular expressionTruffleObject flags: the set of flags passed to the regular expression
compiler. The type differs based on the flavor of regular expressions used:
RegexFlags if the flavor was ECMAScriptPythonFlags if the flavor was PythonRubyFlags if the flavor was Rubyint groupCount: number of capture groups present in the regular expression, including
group 0.RegexObject.RegexObjectExecMethod exec: an executable method that matches the compiled
regular expression against a string. The method accepts two parameters:
Object input: the character sequence to search in. This may either be a
String or a TruffleObject that responds to
InteropLibrary.hasArrayElements(Object) and returns Characters on indexed
InteropLibrary.readArrayElement(Object, long) requests.Number fromIndex: the position to start searching from. This argument will be
cast to int, since a String can not be longer than Integer.MAX_VALUE. If
fromIndex is greater than Integer.MAX_VALUE, this method will immediately return
NO_MATCH.RegexResult. The contents of the exec can be compiled
lazily and so its first invocation might involve a longer delay as the regular expression is
compiled on the fly.
TruffleObject groups: a Truffle object that has a member for every named
capture group. The value of the member depends on the flavor of regular expressions. In flavors
where all capture groups must have a unique name, the value of the member is a single integer,
the index of the group that bears the member's name. In flavors where it is possible to have
multiple groups of the same name (as in Ruby), the value of the member has array elements that
give the indices of the groups with the member's name.boolean isBacktracking: whether or not matching with this regular expression will use
backtracking when matching, which could result in an exponential runtime in the worst case
scenario| Modifier and Type | Class and Description |
|---|---|
static class |
RegexObject.RegexObjectExecBooleanMethod |
static class |
RegexObject.RegexObjectExecMethod |
AbstractConstantKeysObject.IsMemberReadable, AbstractConstantKeysObject.ReadMember| Constructor and Description |
|---|
RegexObject(RegexExecNode execNode,
RegexSource source,
AbstractRegexObject flags,
int numberOfCaptureGroups,
AbstractRegexObject namedCaptureGroups) |
| Modifier and Type | Method and Description |
|---|---|
com.oracle.truffle.api.CallTarget |
getExecBooleanCallTarget() |
RegexObject.RegexObjectExecBooleanMethod |
getExecBooleanMethod() |
com.oracle.truffle.api.CallTarget |
getExecCallTarget() |
RegexObject.RegexObjectExecMethod |
getExecMethod() |
com.oracle.truffle.api.interop.TruffleObject |
getFlags() |
TruffleReadOnlyKeysArray |
getKeys() |
String |
getLabel() |
com.oracle.truffle.api.interop.TruffleObject |
getNamedCaptureGroups() |
int |
getNumberOfCaptureGroups() |
RegexSource |
getSource() |
boolean |
isBacktracking() |
boolean |
isMemberReadableImpl(String symbol) |
Object |
readMemberImpl(String symbol) |
String |
toString() |
getMembers, hasMemberscreateNamedCaptureGroupMapInt, createNamedCaptureGroupMapListInt, getLanguage, hasLanguage, toDisplayStringpublic RegexObject(RegexExecNode execNode, RegexSource source, AbstractRegexObject flags, int numberOfCaptureGroups, AbstractRegexObject namedCaptureGroups)
public RegexSource getSource()
public com.oracle.truffle.api.interop.TruffleObject getFlags()
public int getNumberOfCaptureGroups()
public com.oracle.truffle.api.interop.TruffleObject getNamedCaptureGroups()
public String getLabel()
public com.oracle.truffle.api.CallTarget getExecCallTarget()
public com.oracle.truffle.api.CallTarget getExecBooleanCallTarget()
public boolean isBacktracking()
public RegexObject.RegexObjectExecMethod getExecMethod()
public RegexObject.RegexObjectExecBooleanMethod getExecBooleanMethod()
public TruffleReadOnlyKeysArray getKeys()
getKeys in class AbstractConstantKeysObjectpublic boolean isMemberReadableImpl(String symbol)
isMemberReadableImpl in class AbstractConstantKeysObjectpublic Object readMemberImpl(String symbol) throws com.oracle.truffle.api.interop.UnknownIdentifierException
readMemberImpl in class AbstractConstantKeysObjectcom.oracle.truffle.api.interop.UnknownIdentifierException