Created
March 6, 2017 00:51
-
-
Save TheNorthEestern/caf9d2267dcaeb0d1f9b487ee3d62745 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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