<commit_before>package org.jetbrains.plugins.scala.lang.parser.parsing.patterns
/**
* @author <NAME>
*/
import com.intellij.lang.PsiBuilder, org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes
import org.jetbrains.plugins.scala.lang.parser.ScalaElementTypes
import org.jetbrains.plugins.scala.lang.lexer.ScalaElementType
import org.jetbrains.plugins.scala.lang.parser.bnf.BNF
import com.intellij.psi.tree.TokenSet
import com.intellij.psi.tree.IElementType
import org.jetbrains.plugins.scala.lang.parser.util.ParserUtils
import org.jetbrains.plugins.scala.lang.parser.parsing.types._
import org.jetbrains.plugins.scala.lang.parser.parsing.top.template._
import org.jetbrains.plugins.scala.lang.parser.parsing.expressions._
import org.jetbrains.plugins.scala.lang.parser.bnf._

object SimplePattern {
  /*
  SimplePattern ::=   _
                      | varid
                      | Literal
                      | StableId [ ( [Patterns] ) ]
                      | ( [Pattern] )
                      | XmlPattern
  */

  def parse(builder: PsiBuilder): ScalaElementType = {
    var spMarker = builder.mark()

    // Process ")" symbol
    def closeParent: ScalaElementType = {
      ParserUtils.eatElement(builder, ScalaTokenTypes.tRPARENTHIS)
      spMarker.drop()
      ScalaElementTypes.SIMPLE_PATTERN
    }

    // Process "}" symbol
    def closeParent1 = {
      if (ScalaTokenTypes.tRBRACE.equals(builder.getTokenType)){
        ParserUtils.eatElement(builder, ScalaTokenTypes.tRBRACE)
        spMarker.done(ScalaElementTypes.SIMPLE_PATTERN)
        ScalaElementTypes.SIMPLE_PATTERN
      }
      else {
        ParserUtils.rollPanicToBrace(builder, ScalaTokenTypes.tLBRACE, ScalaTokenTypes.tRBRACE)
        spMarker.error("} expected")
        ScalaElementTypes.SIMPLE_PATTERN
      }
    }



    def argsParse: ScalaElementType = {
      var argsMarker = builder.mark()

      // Process ")" symbol
      def closeParent: ScalaElementType = {
        ParserUtils.eatElement(builder, ScalaTokenTypes.tRPARENTHIS)
        argsMarker.done(ScalaElementTypes.PATTERNS)
        ScalaElementTypes.PATTERNS
      }

      if (ScalaTokenTypes.tLPARENTHIS.equals(builder getTokenType)){
        ParserUtils.eatElement(builder, ScalaTokenTypes.tLPARENTHIS)
        if (ScalaTokenTypes.tRPARENTHIS.eq(builder getTokenType)) {
          closeParent
        } else {
          var res = Patterns.parse(builder)
          if (res.equals(ScalaElementTypes.PATTERNS)) {
            // LOOK!!! ParserUtils.rollForward(builder)
            if (ScalaTokenTypes.tRPARENTHIS.eq(builder getTokenType)) {
              closeParent
            } else {
              builder.error(") expected")
              argsMarker.done(ScalaElementTypes.PATTERNS)
              ScalaElementTypes.PATTERNS
            }
          } else {
            builder.error("Wrong patterns")
            argsMarker.done(ScalaElementTypes.PATTERNS)
            ScalaElementTypes.PATTERNS
          }
        }
      } else {
        argsMarker.rollbackTo()
        ScalaElementTypes.WRONGWAY
      }
    }

    def parseStableId: ScalaElementType = {
      var result = StableId.parse(builder)
      if (ScalaElementTypes.STABLE_ID.equals(result) || ScalaElementTypes.STABLE_ID_ID.equals(result)) {
        if (ScalaTokenTypes.tLPARENTHIS.equals(builder.getTokenType)){
          argsParse
          spMarker.drop()
          ScalaElementTypes.SIMPLE_PATTERN
        } else {
          spMarker.drop()
          ScalaElementTypes.SIMPLE_PATTERN
        }
      } else {
        spMarker.drop()
        builder.error("Wrong pattern!")
        ScalaElementTypes.SIMPLE_PATTERN
      }
    }

    //  _
    if (builder.getTokenType == ScalaTokenTypes.tUNDER) {
      ParserUtils.eatElement(builder, ScalaTokenTypes.tUNDER)
      spMarker.drop()<commit_msg>Added node for simple pattern with arguments<commit_after>package org.jetbrains.plugins.scala.lang.parser.parsing.patterns
/**
* @author <NAME>
*/
import com.intellij.lang.PsiBuilder, org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes
import org.jetbrains.plugins.scala.lang.parser.ScalaElementTypes
import org.jetbrains.plugins.scala.lang.lexer.ScalaElementType
import org.jetbrains.plugins.scala.lang.parser.bnf.BNF
import com.intellij.psi.tree.TokenSet
import com.intellij.psi.tree.IElementType
import org.jetbrains.plugins.scala.lang.parser.util.ParserUtils
import org.jetbrains.plugins.scala.lang.parser.parsing.types._
import org.jetbrains.plugins.scala.lang.parser.parsing.top.template._
import org.jetbrains.plugins.scala.lang.parser.parsing.expressions._
import org.jetbrains.plugins.scala.lang.parser.bnf._

object SimplePattern {
  /*
  SimplePattern ::=   _
                      | varid
                      | Literal
                      | StableId [ ( [Patterns] ) ]
                      | ( [Pattern] )
                      | XmlPattern
  */

  def parse(builder: PsiBuilder): ScalaElementType = {
    var spMarker = builder.mark()

    // Process ")" symbol
    def closeParent: ScalaElementType = {
      ParserUtils.eatElement(builder, ScalaTokenTypes.tRPARENTHIS)
      spMarker.drop()
      ScalaElementTypes.SIMPLE_PATTERN
    }

    // Process "}" symbol
    def closeParent1 = {
      if (ScalaTokenTypes.tRBRACE.equals(builder.getTokenType)){
        ParserUtils.eatElement(builder, ScalaTokenTypes.tRBRACE)
        spMarker.done(ScalaElementTypes.SIMPLE_PATTERN)
        ScalaElementTypes.SIMPLE_PATTERN
      }
      else {
        ParserUtils.rollPanicToBrace(builder, ScalaTokenTypes.tLBRACE, ScalaTokenTypes.tRBRACE)
        spMarker.error("} expected")
        ScalaElementTypes.SIMPLE_PATTERN
      }
    }



    def argsParse: ScalaElementType = {
      var argsMarker = builder.mark()

      // Process ")" symbol
      def closeParent: ScalaElementType = {
        ParserUtils.eatElement(builder, ScalaTokenTypes.tRPARENTHIS)
        argsMarker.done(ScalaElementTypes.PATTERNS)
        ScalaElementTypes.PATTERNS
      }

      if (ScalaTokenTypes.tLPARENTHIS.equals(builder getTokenType)){
        ParserUtils.eatElement(builder, ScalaTokenTypes.tLPARENTHIS)
        if (ScalaTokenTypes.tRPARENTHIS.eq(builder getTokenType)) {
          closeParent
        } else {
          var res = Patterns.parse(builder)
          if (res.equals(ScalaElementTypes.PATTERNS)) {
            // LOOK!!! ParserUtils.rollForward(builder)
            if (ScalaTokenTypes.tRPARENTHIS.eq(builder getTokenType)) {
              closeParent
            } else {
              builder.error(") expected")
              argsMarker.done(ScalaElementTypes.PATTERNS)
              ScalaElementTypes.PATTERNS
            }
          } else {
            builder.error("Wrong patterns")
            argsMarker.done(ScalaElementTypes.PATTERNS)
            ScalaElementTypes.PATTERNS
          }
        }
      } else {
        argsMarker.rollbackTo()
        ScalaElementTypes.WRONGWAY
      }
    }

    def parseStableId: ScalaElementType = {
      var result = StableId.parse(builder)
      if (ScalaElementTypes.STABLE_ID.equals(result) || ScalaElementTypes.STABLE_ID_ID.equals(result)) {
        if (ScalaTokenTypes.tLPARENTHIS.equals(builder.getTokenType)){
          argsParse
          spMarker.done(ScalaElementTypes.SIMPLE_PATTERN)
          ScalaElementTypes.SIMPLE_PATTERN
        } else {
          spMarker.drop()
          ScalaElementTypes.SIMPLE_PATTERN
        }
      } else {
        spMarker.drop()
        builder.error("Wrong pattern!")
        ScalaElementTypes.SIMPLE_PATTERN
      }
    }

    //  _
    if (builder.getTokenType == ScalaTokenTypes.tUNDER) {
      ParserUtils.eatElement(builder, ScalaTokenTypes.tUNDER)
      spMarker.drop()
{'fraction_non_alphanumeric': 0.09565217391304348, 'fraction_numerical': 0.00025957170668397143, 'mean_word_length': 2.502727272727273, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '681667', 'n_tokens_mistral': 2460, 'n_tokens_neox': 2323, 'n_words': 297}