public class TokenPattern extends java.lang.Object
skipNested(Object, Object, boolean)
 | Constructor and Description | 
|---|
TokenPattern()  | 
| Modifier and Type | Method and Description | 
|---|---|
TokenPattern | 
alternative(java.lang.Object... matchTerms)
Adds a new alternative pattern part that tries the given match terms one
 after the other and stops as soon as one of them matches. 
 | 
TokenPattern | 
beginningOfStream()
Adds a new pattern part that matches the beginning of the token stream (i.e. 
 | 
TokenPattern | 
endOfStream()
Adds a new pattern part that matches the end of the token stream (i.e. 
 | 
java.util.List<TokenPatternMatch> | 
findAll(java.util.List<IToken> tokens)
Matches the pattern at all positions in the given token stream and returns
 the found matches. 
 | 
TokenPatternMatch | 
findFirstMatch(java.util.List<IToken> tokens)
Matches the pattern at all positions in the given token stream and returns
 the first found match or  
null if no match happened. | 
java.util.List<TokenPatternMatch> | 
findNonOverlappingMatches(java.util.List<IToken> tokens)
Finds and returns non-overlapping matches in the tokens. 
 | 
TokenPattern | 
group(int groupIndex)
Specifies that the last added subpattern should be appended to the group with
 the given index. 
 | 
TokenPatternMatch | 
matchAtCurrentPosition(TokenStream stream)
Matches the pattern at the start position of the token stream. 
 | 
TokenPatternMatch | 
matchAtStartOf(java.util.List<IToken> tokens)
Matches the pattern at the start position of the given tokens. 
 | 
boolean | 
matchesAnywhere(java.util.List<IToken> tokens)
Returns  
true if the pattern matches at least once in the given
 token stream. | 
TokenPattern | 
notAtBeginningOfStream()
Adds a new pattern part that matches anything but the beginning of the token
 stream (i.e. 
 | 
TokenPattern | 
notFollowedBy(java.lang.Object matchTerm)
Adds a new pattern part that matches if the last matched token is not
 followed by a token that matches the given term. 
 | 
TokenPattern | 
notPrecededBy(java.lang.Object matchTerm)
Adds a new pattern part that matches if the last matched token is not
 preceded by a token that matches the given term. 
 | 
TokenPattern | 
optional(java.lang.Object... matchTerms)
Adds a new optional pattern part that matches the given terms zero times or
 once in the given order. 
 | 
TokenPattern | 
regex(java.lang.String regex)
Adds a new pattern part that matches token text with specified regex. 
 | 
TokenPattern | 
repeated(java.lang.Object... matchTerms)
Adds a new "repeated" pattern part that matches the given terms zero or more
 times in the given order. 
 | 
TokenPattern | 
repeatedAtLeastOnce(java.lang.Object... matchTerms)
Matches the given terms one or more times. 
 | 
TokenPattern | 
sequence(java.lang.Object... matchTerms)
Adds a new pattern part that matches the given sequence of terms exactly once
 in the given order. 
 | 
TokenPattern | 
skipNested(java.lang.Object openTerm,
          java.lang.Object closeTerm,
          boolean optional)
Adds a new pattern part that consumes nested structures. 
 | 
TokenPattern | 
skipTo(java.lang.Object... matchTerms)
Adds a new pattern part that consumes anything until it encounters one of the
 given match terms. 
 | 
static TokenPatternBase | 
text(java.lang.String tokenText)
Returns a new Token pattern that matches on tokens that have exactly the
 given text. 
 | 
java.lang.String | 
toString() | 
public TokenPattern()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.util.List<TokenPatternMatch> findAll(java.util.List<IToken> tokens)
const int a and pattern
 (KEYWORD)* IDENTIFIFER, this method will return 3 matches
 const int a, int a & a.public TokenPatternMatch findFirstMatch(java.util.List<IToken> tokens)
null if no match happened.public java.util.List<TokenPatternMatch> findNonOverlappingMatches(java.util.List<IToken> tokens)
const int a and pattern
 (KEYWORD)* IDENTIFIFER, this method will return only one match
 contrary to findAll(java.util.List<eu.cqse.check.framework.scanner.IToken>) that will return 3 matches. The search starts at
 beginning of token stream say point x. If a match is found say at position x
 + 5, the next search starts just after the position of the previous
 successful search (x + 6). If no match is found, the search continues from
 position x + 1. This ensures no overlapping matches.public TokenPatternMatch matchAtStartOf(java.util.List<IToken> tokens)
null if no match happened.public TokenPatternMatch matchAtCurrentPosition(TokenStream stream)
null if no match happened. The stream's position
 is preserved.public boolean matchesAnywhere(java.util.List<IToken> tokens)
true if the pattern matches at least once in the given
 token stream.public TokenPattern group(int groupIndex)
public TokenPattern skipTo(java.lang.Object... matchTerms)
matchTerms - a list of match terms which must match in order. These may be
            instances of ETokenType, ETokenType.ETokenClass, or sets of
            them, as well as TokenPatterns.public TokenPattern skipNested(java.lang.Object openTerm, java.lang.Object closeTerm, boolean optional)
openTerm - a match term that identifies the opening braces. May be an
            instance of ETokenType, ETokenType.ETokenClass, or a set of
            them, as well as an TokenPattern.closeTerm - a match term that identifies the closing braces. May be an
            instance of ETokenType, ETokenType.ETokenClass, or a set of
            them, as well as an TokenPattern.optional - if this is false, the nested structure must be
            present or the pattern will not match. If this is
            true, this pattern may return an empty match.public TokenPattern repeated(java.lang.Object... matchTerms)
matchTerms - a list of match terms which must match in order. These may be
            instances of ETokenType, ETokenType.ETokenClass, or sets of
            them, as well as TokenPatterns.public TokenPattern sequence(java.lang.Object... matchTerms)
matchTerms - a list of match terms which must match in order. These may be
            instances of ETokenType, ETokenType.ETokenClass, or sets of
            them, as well as TokenPatterns.public TokenPattern endOfStream()
public TokenPattern beginningOfStream()
public TokenPattern notAtBeginningOfStream()
public TokenPattern notFollowedBy(java.lang.Object matchTerm)
matchTerm - May be an instance of ETokenType, ETokenType.ETokenClass, or
            a set of them, as well as a TokenPattern.public TokenPattern notPrecededBy(java.lang.Object matchTerm)
TokenPattern to this function will not result in an
 exception, but it will not yield the intuitive result. The given pattern will
 be matched against the token stream, starting with the token preceding the
 current token. It is therefore discouraged to pass a TokenPattern to
 this function as it makes understanding the pattern difficult.matchTerm - May be an instance of ETokenType, ETokenType.ETokenClass, or
            a set of them, but usually not a TokenPattern.public TokenPattern alternative(java.lang.Object... matchTerms)
matchTerms - a list of match terms which must match in order. These may be
            instances of ETokenType, ETokenType.ETokenClass, or sets of
            them, as well as TokenPatterns.public TokenPattern optional(java.lang.Object... matchTerms)
matchTerms - a list of match terms which must match in order. These may be
            instances of ETokenType, ETokenType.ETokenClass, or sets of
            them, as well as TokenPatterns.public TokenPattern regex(java.lang.String regex)
regex - string to contain in token text.public TokenPattern repeatedAtLeastOnce(java.lang.Object... matchTerms)
.sequence(matchTerms).repeated(matchTerms)public static TokenPatternBase text(java.lang.String tokenText)