title: Backtracking in scala parser combinators?
body: <p>It seems like scala's parser combinators don't backtrack. I have a grammar (see bottom) which can't parse the following "stmt" correctly:</p>
  
  <pre><code>copy in to out .
  </code></pre>
  
  <p>That should be easy to parse with backtracking:</p>
  
  <pre><code>stmt: (to out(copy in))
  </code></pre>
  
  <p>or am I missing something?</p>
  
  <p>Parser:</p>
  
  <pre><code>type ExprP = Parser[Expr]
  type ValueP = Parser[ValExpr]
  type CallP = Parser[Call]
  type ArgsP = Parser[Seq[Expr]]
  
  val ident     = "[a-zA-Z\\+\\-\\*/%&gt;&lt;\\\\\\=]+".r
  val sqstart   = "\\["                          .r
  val sqend     = "\\]"                          .r
  val del       = ","                            .r
  val end       = "\\."                          .r
  
  def stmt: ExprP      = expr &lt;~ end
  def expr: ExprP      = ucall | call | value
  def value: ValueP    = ident ^^ {str =&gt; IdentExpr(str)}
  def call: CallP      = (args ~ ident ~ expr) ^^ {case args ~ method ~ upon =&gt; Call(args, method, upon)}
  def ucall: CallP     = (ident ~ expr) ^^ {case method ~ upon =&gt; Call(Seq(), method, upon)}
  def args: ArgsP      = advargs | smplargs
  def smplargs: ArgsP  = expr ^^ {e =&gt; Seq(e)}
  def advargs: ArgsP   = (sqstart ~&gt; repsep(expr, del) &lt;~ sqend) ^^ {seq =&gt; seq}
  </code></pre>