public final class PythonFlavorProcessor extends Object implements RegexFlavorProcessor
The implementation strives to be as close as possible to the behavior of the regex parser that ships with Python 3.7, down to the wording of the error messages.
RegexFlavorProcessor| Constructor and Description |
|---|
PythonFlavorProcessor(RegexSource source,
PythonREMode mode) |
| Modifier and Type | Method and Description |
|---|---|
com.oracle.truffle.api.interop.TruffleObject |
getFlags()
Returns a
TruffleObject representing the compilation flags which were set for the
regular expression. |
Map<String,Integer> |
getNamedCaptureGroups()
Returns a map from the names of capture groups to their indices.
|
int |
getNumberOfCaptureGroups()
Returns the number of capture groups contained in the expression, including capture group 0.
|
boolean |
isUnicodePattern()
Returns
true if the generated ECMAScript pattern is a Unicode pattern (matches
Unicode code points instead of UTF-16 code units). |
RegexSource |
toECMAScriptRegex()
Runs the parser and emits an equivalent ECMAScript regex.
|
void |
validate()
Runs the parser without trying to find an equivalent ECMAScript regex.
|
public PythonFlavorProcessor(RegexSource source, PythonREMode mode)
public int getNumberOfCaptureGroups()
RegexFlavorProcessorgetNumberOfCaptureGroups in interface RegexFlavorProcessorpublic Map<String,Integer> getNamedCaptureGroups()
RegexFlavorProcessorgetNamedCaptureGroups in interface RegexFlavorProcessorpublic com.oracle.truffle.api.interop.TruffleObject getFlags()
RegexFlavorProcessorTruffleObject representing the compilation flags which were set for the
regular expression. The returned object responds to 'READ' messages on names which correspond
to the names of the flags as used in the language from which the flavor originates.getFlags in interface RegexFlavorProcessorpublic boolean isUnicodePattern()
RegexFlavorProcessortrue if the generated ECMAScript pattern is a Unicode pattern (matches
Unicode code points instead of UTF-16 code units).isUnicodePattern in interface RegexFlavorProcessorpublic void validate()
throws RegexSyntaxException
RegexFlavorProcessorvalidate in interface RegexFlavorProcessorRegexSyntaxException - when the pattern or the flags are not well-formedpublic RegexSource toECMAScriptRegex() throws RegexSyntaxException, UnsupportedRegexException
RegexFlavorProcessortoECMAScriptRegex in interface RegexFlavorProcessorRegexSource compatible to the input oneRegexSyntaxException - when the pattern or the flags are not well-formedUnsupportedRegexException - when the pattern cannot be translated to an equivalent
ECMAScript pattern