Class RegexChannel<O>

java.lang.Object
org.sonar.sslr.channel.Channel<O>
org.sonar.sslr.channel.RegexChannel<O>

public abstract class RegexChannel<O> extends Channel<O>
The RegexChannel can be used to be called each time the next characters in the character stream match a regular expression
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a RegexChannel object with the required regular expression
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    consume(CharSequence token, O output)
    The consume method is called each time the regular expression used to create the RegexChannel object matches the next characters in the character streams.
    final boolean
    consume(CodeReader code, O output)
    Tries to consume the character stream at the current reading cursor position (provided by the CodeReader).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RegexChannel

      public RegexChannel(String regex)
      Create a RegexChannel object with the required regular expression
      Parameters:
      regex - regular expression to be used to try matching the next characters in the stream
  • Method Details

    • consume

      public final boolean consume(CodeReader code, O output)
      Description copied from class: Channel
      Tries to consume the character stream at the current reading cursor position (provided by the CodeReader). If the character stream is consumed the method must return true and the OUTPUT object can be fed.
      Specified by:
      consume in class Channel<O>
      Parameters:
      code - the handle on the input character stream
      output - the OUTPUT that can be optionally fed by the Channel
      Returns:
      false if the Channel doesn't want to consume the character stream, true otherwise.
    • consume

      protected abstract void consume(CharSequence token, O output)
      The consume method is called each time the regular expression used to create the RegexChannel object matches the next characters in the character streams.
      Parameters:
      token - the token consumed in the character stream and matching the regular expression
      output - the OUTPUT object which can be optionally fed