Unable to use Regex in rules for Parboiled2

72 views
Skip to first unread message

sanjyot bandal

unread,
Oct 19, 2016, 3:26:01 AM10/19/16
to parboiled2.org User List
Hi,

I want to convert my current code written using Scala Parser Combinator(Packrat Parser) to Parboiled2 Parser.
But Parboiled2 Parser is not allowing me to use any kind of Regex while writing Rules.

For example:
Consider following sample code snippet written using Scala Parser Combinator:
 def sampleGrammarRule(): PackratParser[String] = "(?i)hello".r ~ "(?i)world".r ^^ {
  case str1 ~ str2 => {
   //...
  } 
 }

In short, it is grammar rule to match 'hello world' case insensitive.
 
But using Parboiled2 Parser, I am unable to use Regex (ex: "(?i)hello".r).
Please help me to use Regex while writing grammar rules with Parboiled2.
A small code snippet would be of great help.

Thanks in advance.
Sanjyot

Mathias Doenitz

unread,
Oct 19, 2016, 3:28:37 AM10/19/16
to parboil...@googlegroups.com
Sanjyot,

if you already have a parser written in Scala Parser Combinators
I'd recommend you turn to fastparse (http://www.lihaoyi.com/fastparse/) rather than parboiled.

The syntax and logic will be more familiar, the project is better maintained with a larger user base,
and the performance is almost on par with what pb2 offers.

Cheers,
Mathias

---
mat...@parboiled.org
http://www.parboiled.org
> --
> You received this message because you are subscribed to the Google Groups "parboiled2.org User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to parboiled-use...@googlegroups.com.
> Visit this group at https://groups.google.com/group/parboiled-user.
> To view this discussion on the web visit https://groups.google.com/d/msgid/parboiled-user/82b26db8-acc2-4765-93be-a3a215a6be97%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

sanjyot bandal

unread,
Oct 19, 2016, 4:17:22 AM10/19/16
to parboiled2.org User List
Thanks Mathias for prompt reply.
Will check and try to use FastParse.

Regards,
Sanjyot.
Reply all
Reply to author
Forward
0 new messages