<commit_before>package cli.controllers

import cli.models._
import cli.views._

import scala.util.parsing.combinator.JavaTokenParsers

class GrammarParser extends JavaTokenParsers {

  val cl = new CommandLauncher
  val view = new ResultView
  cl.attach(view)

  // base arguments types
  def types : Parser[String] = """Integer|Double|String|Binary""".r
  def value : Parser[String] = """".*"""".r
  def string : Parser[String] = """.*""".r
  def list : Parser[String] = """\S+,\s*\S+""".r
  def key : Parser[String] = """\S*""".r

  // chained commands
  def insertCommand : Parser[String] = "insert" ~ key ~ types ~ value ~ "to" ~ string ^^ {
    case cmd_part_1 ~ args_1 ~ args_2 ~ args_3 ~ cmd_part_2 ~ args_4 => cl.storeAndExecute(new InsertCommand(new Operations(
      Map[Any, Any]("key" -> args_1, "type" -> args_2, "value" -> args_3, cmd_part_2 -> args_4))))
  }

  def exportCommand : Parser[String] = "export" ~ (list | key) ~ "to" ~ string ^^ {
    case cmd_part_1 ~ args_1 ~ cmd_part_2 ~ args_2 => {
      val exp = new ExportCommand(new Operations(Map[Any, Any]("p_list" -> args_1, "f_path" -> args_2)))
      cl.storeAndExecute(exp)
    }
  }

  def loginCommand : Parser[String] = "login" ~ key ~ string ^^ {
    case cmd_part_1 ~ args_1 ~ args_2 => {
      val exp = new LoginCommand(new Operations(Map[Any, Any]("username" -> args_1, "password" -> args_2)))
      cl.storeAndExecute(exp)
    }
  }

  def commandList = rep(insertCommand | exportCommand | loginCommand)
}<commit_msg>fix insertItemCommand<commit_after>package cli.controllers

import cli.models._
import cli.views._

import scala.util.parsing.combinator.JavaTokenParsers

class GrammarParser extends JavaTokenParsers {

  val cl = new CommandLauncher
  val view = new ResultView
  cl.attach(view)

  // base arguments types
  def types : Parser[String] = """Integer|Double|String|Binary""".r
  def value : Parser[String] = """".*"""".r
  def string : Parser[String] = """.*""".r
  def list : Parser[String] = """\S+,\s*\S+""".r
  def key : Parser[String] = """\S*""".r

  // chained commands
  def insertItemCommand : Parser[String] = "insert" ~ key ~ types ~ value ~ "to" ~ string ^^ {
    case cmd_part_1 ~ args_1 ~ args_2 ~ args_3 ~ cmd_part_2 ~ args_4 => cl.storeAndExecute(new InsertItemCommand(new Operations(
      Map[Any, Any]("key" -> args_1, "type" -> args_2, "value" -> args_3, cmd_part_2 -> args_4))))
  }

  def exportCommand : Parser[String] = "export" ~ (list | key) ~ "to" ~ string ^^ {
    case cmd_part_1 ~ args_1 ~ cmd_part_2 ~ args_2 => {
      val exp = new ExportCommand(new Operations(Map[Any, Any]("p_list" -> args_1, "f_path" -> args_2)))
      cl.storeAndExecute(exp)
    }
  }

  def loginCommand : Parser[String] = "login" ~ key ~ string ^^ {
    case cmd_part_1 ~ args_1 ~ args_2 => {
      val exp = new LoginCommand(new Operations(Map[Any, Any]("username" -> args_1, "password" -> args_2)))
      cl.storeAndExecute(exp)
    }
  }

  def commandList = rep(insertItemCommand | exportCommand | loginCommand)
}
{'fraction_non_alphanumeric': 0.1593915343915344, 'fraction_numerical': 0.01455026455026455, 'mean_word_length': 3.6826625386996903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '2489318', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1063, 'n_words': 245}