<commit_before>package org.parboiled.scala.rules

import org.parboiled.matchers._
import org.parboiled.Action
import org.parboiled.Context
import java.lang.String
import org.parboiled.scala._
import Rule._
import org.parboiled.support.{IndexRange, ValueStack}

/**
 * The base class of all scala parser rules.
 */
abstract class Rule {
  val matcher: Matcher

  /**
   * Creates a "NOT" syntactic predicate according to the PEG formalism.
   */
  def unary_!(): Rule0 = new TestNotMatcher(matcher)

  def ~(other: Rule0): this.type = withMatcher(append(other))

  /**
   * Creates a semantic predicate on the first char of the input text matched by the immediately preceding rule.
   */
  def ~:?[R](f: Char => Boolean): this.type = withMatcher(append(exec(GetMatchedChar, f)))

  /**
   * Creates a semantic predicate on the input text matched by the immediately preceding rule.
   */
  def ~?[R](f: String => Boolean): this.type = withMatcher(append(exec(GetMatch, f)))

  /**
   * Creates a simple parser action with the input text matched by the immediately preceding rule as parameter.
   */
  def ~%(f: String => Unit): this.type = ~?(ok(f))

  def label(label: String): this.type = withMatcher(matcher.label(label).asInstanceOf[Matcher])

  def suppressNode(): this.type = withMatcher(matcher.suppressNode().asInstanceOf[Matcher])

  def suppressSubnodes(): this.type = withMatcher(matcher.suppressSubnodes().asInstanceOf[Matcher])

  def skipNode(): this.type = withMatcher(matcher.skipNode().asInstanceOf[Matcher])

  def memoMismatches(): this.type = withMatcher(matcher.memoMismatches().asInstanceOf[Matcher])

  override def toString = getClass.getSimpleName + ": " + matcher.toString

  protected def withMatcher(matcher: Matcher): this.type

  protected def append(action: Action[_]): Matcher = append(new ActionMatcher(action).label(nameAction("")))

  protected def append(f: Context[Any] => Boolean): Matcher = append(action(f))

  protected def append(other: Rule): Matcher = append(other.matcher)

  protected def append(other: Matcher): Matcher = matcher match {
    case m: SequenceMatcher if (m.getLabel == "Sequence") => new SequenceMatcher(addSub(m.getChildren, other))
    case _ => new SequenceMatcher(Array(matcher, other))
  }

  protected def appendChoice(other: Rule): Matcher = appendChoice(other.matcher)

  protected def appendChoice(other: Matcher): Matcher = matcher match {
    case m: StringMatcher => other match {
      case o: StringMatcher => new FirstOfStringsMatcher(Array(m, o), Array(m.characters, o.characters))<commit_msg>scala: removed empty parens on a number of rule marker methods<commit_after>package org.parboiled.scala.rules

import org.parboiled.matchers._
import org.parboiled.Action
import org.parboiled.Context
import java.lang.String
import org.parboiled.scala._
import Rule._
import org.parboiled.support.{IndexRange, ValueStack}

/**
 * The base class of all scala parser rules.
 */
abstract class Rule {
  val matcher: Matcher

  /**
   * Creates a "NOT" syntactic predicate according to the PEG formalism.
   */
  def unary_! : Rule0 = new TestNotMatcher(matcher)

  def ~(other: Rule0): this.type = withMatcher(append(other))

  /**
   * Creates a semantic predicate on the first char of the input text matched by the immediately preceding rule.
   */
  def ~:?[R](f: Char => Boolean): this.type = withMatcher(append(exec(GetMatchedChar, f)))

  /**
   * Creates a semantic predicate on the input text matched by the immediately preceding rule.
   */
  def ~?[R](f: String => Boolean): this.type = withMatcher(append(exec(GetMatch, f)))

  /**
   * Creates a simple parser action with the input text matched by the immediately preceding rule as parameter.
   */
  def ~%(f: String => Unit): this.type = ~?(ok(f))

  def label(label: String): this.type = withMatcher(matcher.label(label).asInstanceOf[Matcher])

  def suppressNode: this.type = withMatcher(matcher.suppressNode().asInstanceOf[Matcher])

  def suppressSubnodes: this.type = withMatcher(matcher.suppressSubnodes().asInstanceOf[Matcher])

  def skipNode: this.type = withMatcher(matcher.skipNode().asInstanceOf[Matcher])

  def memoMismatches: this.type = withMatcher(matcher.memoMismatches().asInstanceOf[Matcher])

  override def toString = getClass.getSimpleName + ": " + matcher.toString

  protected def withMatcher(matcher: Matcher): this.type

  protected def append(action: Action[_]): Matcher = append(new ActionMatcher(action).label(nameAction("")))

  protected def append(f: Context[Any] => Boolean): Matcher = append(action(f))

  protected def append(other: Rule): Matcher = append(other.matcher)

  protected def append(other: Matcher): Matcher = matcher match {
    case m: SequenceMatcher if (m.getLabel == "Sequence") => new SequenceMatcher(addSub(m.getChildren, other))
    case _ => new SequenceMatcher(Array(matcher, other))
  }

  protected def appendChoice(other: Rule): Matcher = appendChoice(other.matcher)

  protected def appendChoice(other: Matcher): Matcher = matcher match {
    case m: StringMatcher => other match {
      case o: StringMatcher => new FirstOfStringsMatcher(Array(m, o), Array(m.characters, o.characters))
{'fraction_non_alphanumeric': 0.12070297412128235, 'fraction_numerical': 0.000772499034376207, 'mean_word_length': 4.780133928571429, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7586963', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1500, 'n_words': 443}