Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 68bb0b411c
Fetching contributors…

Cannot retrieve contributors at this time

60 lines (43 sloc) 2.041 kB
/*
A Grammar for JSON.
*/
@start = Empty | array | object;
object = openCurly (Empty | objectContent) closeCurly;
objectContent = property commaProperty*;
property = propertyName colon value;
commaProperty = comma property;
propertyName = QuotedString; // NOTE: property names are quoted in JSON
array = openBracket (Empty | arrayContent) closeBracket;
arrayContent = value commaValue*;
commaValue = comma value;
value = null | boolean | array | object | number | string;
string = QuotedString;
number = Number;
null = 'null';
boolean = 'true' | 'false';
openCurly = '{';
closeCurly = '}';
openBracket = '[';
closeBracket = ']';
comma = ',';
colon = ':';
/*
The built-in terminal production types are (note titlecase) : Empty, Number, QuotedString, Word, UppercaseWord, LowercaseWord
You define collections (alternations, repetitions or sequences) and literal terminals (in quotes). These should be lowercase.
The special '@start' production is the outermost production.
you can discard tokens by following them with a bang ('!') like:
closeCurly = '}'!;
Feed this grammar to -[PKParserFactory parserFromGrammar:assembler:] along with a reference
to an assembler (a call back delegate), and it will return a PKParser object which can
parse strings conforming to this language/grammar.
The when the returned parser is used, the provided assembler will receive method callbacks for each production matched, like:
-parser:didMatchObject:
-parser:didMatchObjectContent:
-parser:didMatchProperty:
-parser:didMatchArray:
-parser:didMatchOpenCurly:
etc.
Each callback method must accept a single PKAssembly argument. This assembly argument
will contain information about the progress made on the the string currently being parsed.
Also the assembly's stack will contain the tokens parsed so far in the current statement.
*/
Jump to Line
Something went wrong with that request. Please try again.