Class RubyRegexParser
java.lang.Object
com.oracle.truffle.regex.tregex.parser.flavors.RubyRegexParser
- All Implemented Interfaces:
RegexParser,RegexValidator
Implements the parsing and validation of Ruby regular expressions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic RegexParsercreateParser(RegexLanguage language, RegexSource source, CompilationBuffer compilationBuffer) static RegexValidatorcreateValidator(RegexSource source) getFlags()Returns aTruffleObjectrepresenting the compilation flags which were set for the regular expression.Returns a map from the names of capture groups to their indices.booleanIndicates whether the following is a proper escape sequence, which cannot be a part of a string.booleanIndicates whether a quantifier is coming up next.parse()Runs the parser and produces an AST.voidvalidate()Checks the regular expression for syntax errors without building an AST.
-
Method Details
-
createValidator
- Throws:
RegexSyntaxException
-
createParser
public static RegexParser createParser(RegexLanguage language, RegexSource source, CompilationBuffer compilationBuffer) throws RegexSyntaxException - Throws:
RegexSyntaxException
-
getNamedCaptureGroups
Description copied from interface:RegexParserReturns a map from the names of capture groups to their indices. If the regular expression had no named capture groups, returns null. This method has to be called after callingRegexParser.parse().- Specified by:
getNamedCaptureGroupsin interfaceRegexParser
-
getFlags
Description copied from interface:RegexParserReturns aTruffleObjectrepresenting 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. This method has to be called after callingRegexParser.parse().- Specified by:
getFlagsin interfaceRegexParser
-
validate
Description copied from interface:RegexValidatorChecks the regular expression for syntax errors without building an AST.- Specified by:
validatein interfaceRegexValidator- Throws:
RegexSyntaxException- when the pattern or the flags are not well-formed
-
parse
Description copied from interface:RegexParserRuns the parser and produces an AST.- Specified by:
parsein interfaceRegexParser- Throws:
RegexSyntaxException- when the pattern or the flags are not well-formedUnsupportedRegexException- when the pattern cannot be translated to an equivalent ECMAScript pattern
-
isProperEscapeNext
public boolean isProperEscapeNext()Indicates whether the following is a proper escape sequence, which cannot be a part of a string. Those are all escape sequences with the difference of those handled byfetchEscapedChar(). -
isQuantifierNext
public boolean isQuantifierNext()Indicates whether a quantifier is coming up next.
-