Skip to content

Instantly share code, notes, and snippets.

@TheNorthEestern
Created March 6, 2017 00:51
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 TheNorthEestern/caf9d2267dcaeb0d1f9b487ee3d62745 to your computer and use it in GitHub Desktop.
Save TheNorthEestern/caf9d2267dcaeb0d1f9b487ee3d62745 to your computer and use it in GitHub Desktop.
// UniForm PEG
// @autos #miles 3000
start =
expression
expression = cat:category* prop:property* {return JSON.stringify({"category": cat, properties:prop}, undefined, 2); }
category = whitespace '@'symbol:word whitespace { return symbol; }
property = whitespace
'#'symbol:word
whitespace
phrase:alphanumeric
whitespace
{ return [symbol, phrase]; }
whitespace = [' '\n\r]*
word = wholeWord:[a-zA-Z]* { return wholeWord.join(""); }
digit = wholeDigit:[0-9]* { return wholeDigit.join("") ; }
alphanumeric = wholePhrase:[a-zA-Z0-9]* { return wholePhrase.join("") ; }
price = amount:[$£¥€]digit { return amount; }
// @autos #miles 300000 #model 2002 Honda Accord
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment