PEGEX: A PEG-based pattern matching library EXtended by back reference with regex-like notation in Scala
PEGEX (Parsing Expression Grammar EXtended by back reference with regex-like notations) is a PEG-like pattern matching library for Scala.
PEGEX provides both power of PEG and light-weight syntax of regular expressions. It accepts a PEG-variant with regex-like notations.
Currently, PEGEXes seem stronger than CFGs and alike Boolean Grammars.
Add the following line to your build.sbt
libraryDependency += "com.github.kmizu" %% "pegex" % "1.0.0"
- Scala 2.11.X, Scala 2.12.X, and Scala 2.13.X
- JDK 1.8.0 or later
- sbt 1.2.8 or later
See tests.
(name=e;)*, where name is name of this rule and e is an expression
Note that in PEGEX, space characters have meanings.
Thus, A=;
is different from A= ;
e1e2
: sequence of expressions"ab"
"ac"
e1|e2
: unordered choice of expressions"a|b"
"(ab|bc)"
e*
: zero or more repetition"a*"
e+
: one or more repetition."a+"
e?
: zero-or-one repetition."(a|b)?"
(?=e)
: positive lookahead."(?=a)"
(?!e)
: negative lookahead"(?!a)"
(?<name>e)
: named capture\g'E'
: (recursive) rule invocation ofE
- is identical to
#{E}
- is identical to
\k<name>
: back reference of the named capture ofname
#{E}$; E=<(?<tag>#{I})>#{E}*</\k<tag>>; I=[a-z]+;
- .: any character.
"(?!a)."
matches one character excepta
- _: success certainly.
- x: one character.
[f-t...xyz...]
: character class. e.g.[a-zA-Z_]
- Support Scala 2.11.X, 2.12.X, and 2.13.X
- From this version, follow Semantic Versioning