Class RegexObject
java.lang.Object
com.oracle.truffle.regex.AbstractRegexObject
com.oracle.truffle.regex.AbstractConstantKeysObject
com.oracle.truffle.regex.RegexObject
- All Implemented Interfaces:
com.oracle.truffle.api.interop.TruffleObject
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 properties:
Stringpattern: the source of the compiled regular expressionTruffleObjectflags: the set of flags passed to the regular expression compiler. The type differs based on the flavor of regular expressions used:RegexFlagsif the flavor wasECMAScriptJavaFlagsif the flavor wasJavaUtilPatternOracleDBFlagsif the flavor wasOracleDBPythonFlagsif the flavor wasPythonRubyFlagsif the flavor wasRuby
int groupCount: number of capture groups present in the regular expression, including group 0.RegexObject.RegexObjectExecMethodexec: an executable method that matches the compiled regular expression against a string. The method has two signatures:exec(TruffleString,int)(exec(TruffleString,int,int,int,int)(
-
Their respective parameters are:
TruffleStringinput: the string to search in. Its encoding must match the encoding selected viaRegexOptions.NumberfromIndex: the position to start searching from, i.e. the minimum starting index of capture group 0. Look-behind assertions are allowed to move past this index up toregionFrom. IffromIndexis greater thanInteger.MAX_VALUE, this method will immediately return NO_MATCH.NumbertoIndex: the position to stop searching at, i.e. the maximum end index of capture group 0. Look-ahead assertions are allowed to move past this index up toregionTo. This parameter is not yet supported, but was added for future API compatibility. For now, this parameter must be equal toregionTo. Defaults to the input string's length.NumberregionFrom: Hard string starting boundary. TRegex will not read any character preceding this index, and treat it as the string's start in respect to position assertions (^and\Awill match this index). Defaults to 0. UsingregionFromandregionTo, the caller can effectively restrict the search to a substring ofinput.NumberregionTo: Hard string end boundary. TRegex will not read any character past this index, and treat it as the string's end in respect to position assertions ($,\Zand\zwill match this index). Defaults to the input string's length. UsingregionFromandregionTo, the caller can effectively restrict the search to a substring ofinput.
int, since aTruffleStringcan not be longer thanInteger.MAX_VALUE.
The return value is aRegexResult. The contents of theexeccan be compiled lazily and so its first invocation might involve a longer delay as the regular expression is compiled on the fly.TruffleObjectgroups: 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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final classNested classes/interfaces inherited from class com.oracle.truffle.regex.AbstractConstantKeysObject
AbstractConstantKeysObject.IsMemberReadable, AbstractConstantKeysObject.ReadMember -
Constructor Summary
ConstructorsConstructorDescriptionRegexObject(RegexExecNode execNode, RegexSource source, AbstractRegexObject flags, int numberOfCaptureGroups, AbstractRegexObject namedCaptureGroups) -
Method Summary
Modifier and TypeMethodDescriptioncom.oracle.truffle.api.CallTargetcom.oracle.truffle.api.CallTargetcom.oracle.truffle.api.interop.TruffleObjectgetFlags()getKeys()getLabel()com.oracle.truffle.api.interop.TruffleObjectintbooleanbooleanisMemberReadableImpl(String symbol) readMemberImpl(String symbol) toString()Methods inherited from class com.oracle.truffle.regex.AbstractConstantKeysObject
getMembers, hasMembersMethods inherited from class com.oracle.truffle.regex.AbstractRegexObject
createNamedCaptureGroupMapInt, createNamedCaptureGroupMapListInt, getLanguage, hasLanguage, toDisplayString
-
Constructor Details
-
RegexObject
public RegexObject(RegexExecNode execNode, RegexSource source, AbstractRegexObject flags, int numberOfCaptureGroups, AbstractRegexObject namedCaptureGroups)
-
-
Method Details
-
getSource
-
getFlags
public com.oracle.truffle.api.interop.TruffleObject getFlags() -
getNumberOfCaptureGroups
public int getNumberOfCaptureGroups() -
getNamedCaptureGroups
public com.oracle.truffle.api.interop.TruffleObject getNamedCaptureGroups() -
getLabel
-
getExecCallTarget
public com.oracle.truffle.api.CallTarget getExecCallTarget() -
getExecBooleanCallTarget
public com.oracle.truffle.api.CallTarget getExecBooleanCallTarget() -
isBacktracking
public boolean isBacktracking() -
getExecMethod
-
getExecBooleanMethod
-
getKeys
- Specified by:
getKeysin classAbstractConstantKeysObject
-
isMemberReadableImpl
- Specified by:
isMemberReadableImplin classAbstractConstantKeysObject
-
readMemberImpl
public Object readMemberImpl(String symbol) throws com.oracle.truffle.api.interop.UnknownIdentifierException - Specified by:
readMemberImplin classAbstractConstantKeysObject- Throws:
com.oracle.truffle.api.interop.UnknownIdentifierException
-
toString
-