January 2013
Intermediate to advanced
328 pages
8h 5m
English
JSON is a text data format that captures a collection of name-value pairs, and since values can themselves be collections, JSON can include nested structures. Designing a parser for JSON gives us an opportunity to derive a grammar from a language reference manual[31] and to work with some more complicated lexical rules. To make things more concrete, here’s a simple JSON data file:
| | { |
| | "antlr.org": { |
| | "owners" : [], |
| | "live" : true, |
| | "speed" : 1e100, |
| | "menus" : ["File", "Help\nMenu"] |
| | } |
| | } |
Our goal is to build an ANTLR grammar by reading the JSON reference manual and looking at its syntax diagram and existing grammar. We’ll pull out key phrases from the manual and figure out how to encode them as ANTLR ...
Read now
Unlock full access