Skip to content

Instantly share code, notes, and snippets.

@lukashavrlant
Last active August 29, 2015 14:16
Show Gist options
  • Save lukashavrlant/44ecfd2c0aa054262762 to your computer and use it in GitHub Desktop.
Save lukashavrlant/44ecfd2c0aa054262762 to your computer and use it in GitHub Desktop.
expr
= m:metric separator e:expr { if (e.length > 1) {return e.concat(m[0]); } else { return e.concat(m); } }
/ metric
metric=n:number w:word { return [{unit:w, amount: n}]; }
number=num:([0-9]+) { return parseInt(num.join("")); }
word=str:([a-zA-Z]+) { return str.join(""); }
separator=","
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment