Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 26 lines (21 sloc) 0.958 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/**
    A Grammar for JSON
    
    NOTE: This grammar has a fatal flaw. it does not allow for the heirarchical nature of
            JSON. Objects and arrays may only be one level deep according to this grammar.
            This is a limitation of my grammar parser: it does not allow circular references.
            That wll be fixed soon
            
 */
null = 'null';
true = 'true';
false = 'false';
value = null | true | false | Num | QuotedString; // here's the flaw. should include: "array | object"

commaValue = ',' value;
actualArray = value commaValue*;
arrayContent = Empty | actualArray;
array = '[' arrayContent ']';

property = QuotedString ':' value; // NOTE: property names are quoted in JSON
commaProperty = ',' property;
actualObject = property commaProperty*;
objectContent = Empty | actualObject;
object = '{' objectContent '}';

start = (array | object);
Something went wrong with that request. Please try again.