UniForm

UniForm is a proof-of-concept micro-language built using PEG.js. The goal of UniForm is to provide a friction-free alternative to web forms.

The example below demonstrates how a UniForm interface might work on a classified advertising website.

Sample input and output

// 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