Skip to content

Instantly share code, notes, and snippets.

@matschaffer
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matschaffer/789dbb6f1607c4965392 to your computer and use it in GitHub Desktop.
Save matschaffer/789dbb6f1607c4965392 to your computer and use it in GitHub Desktop.
stumped by lpeg
info: type=query, sql=update `Transactions` set `confirmedAt` = ? where `id` = ?
error: unhandled error type name=NetworkError, stack=NetworkError: noNetwork
local l = require 'lpeg'
l.locale(l)
local space = l.space^0
local level = l.Ct(l.Cg(l.C(l.alpha^1), "level"))
local name = l.C(l.alpha^1) * space
local sep = l.S(",") * space
local pair = lpeg.Cg(name * ":" * space * name) * sep^-1
grammar = lpeg.Cf(level * l.Ct(l.Cg(l.C(l.P":"), "colon")) * space, rawset)
[
{"level": "info",
"type": "query",
"sql": "update `Transactions` set `confirmedAt` = ? where `id` = ?"
},
{
"level": "error",
"unhandled error type name": "NetworkError",
"stack": "NetworkError: noNetwork"
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment