Question
[Compiler] JSON is a popular language-independent data interchange format. JSON is built on two basic structures, an object and an array. An object is an
[Compiler]
JSON is a popular language-independent data interchange format. JSON is built on two basic structures, an object and an array.
An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is a string followed by : (colon) and the name/value pairs are separated by , (comma).
An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma).
A value can be a string in double quotes, or a number, or true or false or null, or an object or an array.
A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string.
A number is very much like a C or Java number, except that the octal and hexadecimal formats are not used.
List of escape characters and sequences
" quotation mark \ reverse solidus / solidus b backspace f formfeed n newline r carriage return t horizontal tab u following 4 hexadecimal digits for a Unicode character
(1) Write a finite state machine or a regular expression that recognizes JSONs string.
For (2)-(4) Let a string and a number are represented using terminal symbol string and number, respectively.
(2) Write a context-free grammar for a JSONs value (3) Write a context-free grammar for a JSONs object (4) Write a context-free grammar for a JSONs array
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started