Skip to content

Instantly share code, notes, and snippets.

@Varriount
Last active August 29, 2015 13:56
Show Gist options
  • Save Varriount/9175147 to your computer and use it in GitHub Desktop.
Save Varriount/9175147 to your computer and use it in GitHub Desktop.
PEGS Test
import pegs
var testPattern = peg"""
packageEntry <- \n {name} {slot}+
slot <- \n ws {name} ws ':' ws {data}
name <- \ident
ws <- \white*
data <- (!\n .)* \n
"""
var testOutput = """
babel:
url: git://github.com/nimrod-code/babel (git)
tags: app, binary, package, manager
description: Babel package manager
license: BSD
website: https://github.com/nimrod-code/babel
"""
when isMainModule:
var captures: seq[string] = testOutput.findAll(testPattern)
echo("Match Captures: ", repr(captures))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment