Rollback to scala parser combinators?

It seems that scala parser combinators are not returning. I have a grammar (see below) that cannot parse the following "stmt" correctly:

copy in to out .

This should be easy to analyze using backtracking:

stmt: (to out(copy in))

or am i missing something?

Parser:

type ExprP = Parser[Expr]
type ValueP = Parser[ValExpr]
type CallP = Parser[Call]
type ArgsP = Parser[Seq[Expr]]

val ident     = "[a-zA-Z\\+\\-\\*/%><\\\\\\=]+".r
val sqstart   = "\\["                          .r
val sqend     = "\\]"                          .r
val del       = ","                            .r
val end       = "\\."                          .r

def stmt: ExprP      = expr <~ end
def expr: ExprP      = ucall | call | value
def value: ValueP    = ident ^^ {str => IdentExpr(str)}
def call: CallP      = (args ~ ident ~ expr) ^^ {case args ~ method ~ upon => Call(args, method, upon)}
def ucall: CallP     = (ident ~ expr) ^^ {case method ~ upon => Call(Seq(), method, upon)}
def args: ArgsP      = advargs | smplargs
def smplargs: ArgsP  = expr ^^ {e => Seq(e)}
def advargs: ArgsP   = (sqstart ~> repsep(expr, del) <~ sqend) ^^ {seq => seq}
+5
source share
2 answers

You want to use PackratParsersin 2.8. I think the parrat parser is the only reverse tracking parser.

: 2015 fastparse. , ( ).

+4

. | scala.util.parsing.combinator . - (exprcallargssmplargsexpr). Packrat .

+3

All Articles