Giter VIP home page Giter VIP logo

pegex's Introduction

PEGEX: A PEG-based pattern matching library EXtended by back reference with regex-like notation in Scala Build Status

Join the chat at https://gitter.im/kmizu/pegex Build Status Maven Central Scaladoc Reference Status

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.

For sbt user

Include the following in your build.sbt to add pegex to your project libraryDependencies:

libraryDependency += "com.github.kmizu" %% "pegex" % "0.3"

Runtime Requirement

  • Scala 2.11.X or Scala 2.12.X
  • JDK 1.8.0 or later

Build Requirement

  • Sbt 0.13.X

Example

See tests.

Syntax of PEGEX

(name=e;)*, where name is name of this rule and e is an expression

Kind of Expressions (e)

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 of E
    • is identical to #{E}
  • \k<name>: back reference of the named capture of name
#{E}$; E=<(?<tag>#{I})>#{E}*</\k<tag>>; I=[a-z]+;
  • .: any character.
    • "(?!a)." matches one character except a
  • _: success certainly.
  • x: one character.
  • [f-t...xyz...]: character class. e.g. [a-zA-Z_]

pegex's People

Contributors

gitter-badger avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.