Class RegexParser
- java.lang.Object
-
- org.sonarsource.analyzer.commons.regex.RegexParser
-
public class RegexParser extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classRegexParser.EscapedSequenceDataHolderprotected static interfaceRegexParser.GroupConstructorprotected static interfaceRegexParser.TreeConstructor<T>
-
Field Summary
Fields Modifier and Type Field Description protected FlagSetactiveFlagsprotected List<BackReferenceTree>backReferencesprotected Map<String,CapturingGroupTree>capturingGroupsprotected RegexLexercharactersprotected List<SyntaxError>errorsprotected intgroupNumberprotected RegexSourcesource
-
Constructor Summary
Constructors Constructor Description RegexParser(RegexSource source, FlagSet initialFlags)
-
Method Summary
-
-
-
Field Detail
-
source
protected final RegexSource source
-
characters
protected final RegexLexer characters
-
activeFlags
protected FlagSet activeFlags
-
backReferences
protected final List<BackReferenceTree> backReferences
-
capturingGroups
protected final Map<String,CapturingGroupTree> capturingGroups
-
errors
protected final List<SyntaxError> errors
-
groupNumber
protected int groupNumber
-
-
Constructor Detail
-
RegexParser
public RegexParser(RegexSource source, FlagSet initialFlags)
-
-
Method Detail
-
parse
public RegexParseResult parse()
-
parseDisjunction
protected RegexTree parseDisjunction()
-
parseSequence
protected RegexTree parseSequence()
-
parseRepetition
@CheckForNull protected RegexTree parseRepetition()
-
parseQuantifier
@CheckForNull protected Quantifier parseQuantifier()
-
parseInteger
@CheckForNull protected RegexToken parseInteger()
-
parsePrimaryExpression
@CheckForNull protected RegexTree parsePrimaryExpression()
-
readCharacter
protected CharacterTree readCharacter()
-
parseGroup
protected GroupTree parseGroup()
-
newNamedCapturingGroup
protected RegexParser.GroupConstructor newNamedCapturingGroup(int namePrefixLength, char nameDelimiter)
-
newCapturingGroup
protected RegexParser.GroupConstructor newCapturingGroup(@Nullable String name)
-
parseGroupName
protected String parseGroupName(char nameDelimiter)
-
parseNonCapturingGroup
protected GroupTree parseNonCapturingGroup(SourceCharacter openingParen)
-
conditionGroupReference
public ReferenceConditionTree conditionGroupReference(RegexSource source, IndexRange range, @Nullable CharacterTree plus, RegexTree inner, FlagSet activeFlags)
-
parseFlags
protected FlagSet parseFlags()
-
parseFlag
@CheckForNull protected static Integer parseFlag(char ch)
-
finishGroup
protected GroupTree finishGroup(SourceCharacter openingParen, RegexParser.GroupConstructor groupConstructor)
-
finishGroup
protected GroupTree finishGroup(boolean previousFreeSpacingMode, SourceCharacter openingParen, RegexParser.GroupConstructor groupConstructor)
-
parseEscapeSequence
protected RegexTree parseEscapeSequence()
-
parseNamedUnicodeCharacter
protected RegexTree parseNamedUnicodeCharacter(SourceCharacter backslash)
-
parseControlSequence
protected RegexTree parseControlSequence(SourceCharacter backslash)
-
simpleEscapeToCharacter
protected static char simpleEscapeToCharacter(char escapeCharacter)
-
parseUnicodeEscape
protected RegexTree parseUnicodeEscape(SourceCharacter backslash)
-
parseHexEscape
protected RegexTree parseHexEscape(SourceCharacter backslash)
-
parseFixedAmountOfHexDigits
protected int parseFixedAmountOfHexDigits(int amount)
-
parseHexDigit
protected int parseHexDigit()
-
parseEscapedCharacterClass
protected RegexTree parseEscapedCharacterClass(SourceCharacter backslash)
-
parseEscapedProperty
protected RegexTree parseEscapedProperty(SourceCharacter backslash)
-
parseNamedBackReference
protected RegexTree parseNamedBackReference(SourceCharacter backslash)
-
parseNamedBackReference
protected RegexTree parseNamedBackReference(SourceCharacter backslash, char opener, char closer)
-
collect
protected BackReferenceTree collect(BackReferenceTree backReference)
-
index
protected CapturingGroupTree index(CapturingGroupTree capturingGroup)
-
parseEscapedSequence
protected RegexTree parseEscapedSequence(char opener, char closer, String expected, Function<RegexParser.EscapedSequenceDataHolder,RegexTree> builder)
-
parseNumericalBackReference
protected RegexTree parseNumericalBackReference(SourceCharacter backslash)
Parses a numerical back reference greedily, taking as many numbers as it can. The first digit is always treated as a back reference, but multi digit numbers are only treated as a back reference if at least that many back references exist at this point in the regex. SeePattern.ref(int refNum)
-
parseOctalEscape
protected RegexTree parseOctalEscape(SourceCharacter backslash)
-
parseBoundary
protected RegexTree parseBoundary(SourceCharacter backslash)
-
parseCharacterClass
protected CharacterClassTree parseCharacterClass()
-
parseCharacterClassIntersection
protected CharacterClassElementTree parseCharacterClassIntersection()
-
parseCharacterClassUnion
protected CharacterClassElementTree parseCharacterClassUnion(boolean isAtBeginning)
-
parseCharacterClassElement
@CheckForNull protected CharacterClassElementTree parseCharacterClassElement(boolean isAtBeginning)
-
parsePosixCharacterClass
@CheckForNull protected PosixCharacterClassElementTree parsePosixCharacterClass()
-
parseCharacterRange
protected CharacterClassElementTree parseCharacterRange(CharacterTree startCharacter)
-
characterTree
protected CharacterTree characterTree(SourceCharacter character)
-
characterRange
protected CharacterRangeTree characterRange(CharacterTree startCharacter, CharacterTree endCharacter)
-
expected
protected void expected(String expectedToken, RegexSyntaxElement actual)
-
expected
protected void expected(String expectedToken)
-
error
protected void error(String message)
-
supportsAnyOfFeatures
protected boolean supportsAnyOfFeatures(RegexFeature... features)
-
combineTrees
protected static <T extends RegexSyntaxElement> T combineTrees(List<T> elements, RegexParser.TreeConstructor<T> treeConstructor)
-
isAsciiDigit
protected static boolean isAsciiDigit(int c)
-
isOctalDigit
protected static boolean isOctalDigit(int c)
-
isHexDigit
protected static boolean isHexDigit(int c)
-
isPlainTextCharacter
protected boolean isPlainTextCharacter(int c)
-
-