<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Json on Lloyd Rochester's Geek Blog</title><link>https://lloydroc.github.io/tags/json/</link><description>Recent content in Json on Lloyd Rochester's Geek Blog</description><generator>Hugo</generator><language>en</language><copyright>Copyright © 2025, Lloyd Rochester.</copyright><lastBuildDate>Tue, 27 Oct 2020 00:00:00 +0000</lastBuildDate><atom:link href="https://lloydroc.github.io/tags/json/index.xml" rel="self" type="application/rss+xml"/><item><title>Improved Scanning of JSON with Flex/Bison</title><link>https://lloydroc.github.io/post/flex-bison/json-parse-better-scanner/</link><pubDate>Tue, 27 Oct 2020 00:00:00 +0000</pubDate><guid>https://lloydroc.github.io/post/flex-bison/json-parse-better-scanner/</guid><description>&lt;h1 id="hahahugoshortcode53s0hbhb">Improved Scanning of JSON with Flex/Bison&lt;/h1>
&lt;p>Using Flex/Bison in the last post we &lt;a href="https://lloydroc.github.io/post/flex-bison/json-parse-ast/">Parsed JSON into an AST&lt;/a>. In the first post we setup a &lt;a href="https://lloydroc.github.io/post/flex-bison/json-parse/">Simple Example to Parse JSON&lt;/a>. In this post we will improve our Flex Scanner to tokenize and validate more JSON cases. We will continue to align with the grammar at &lt;a href="https://www.json.org/">json.org&lt;/a>. We will add rules and tokens for &lt;code>DQUOTE&lt;/code> (double-quote), &lt;code>string&lt;/code>, &lt;code>HEX&lt;/code>, and &lt;code>CHARACTERS&lt;/code> not in our previous implementation.&lt;/p></description></item><item><title>Parse JSON into an Abstract Syntax Tree using Flex/Bison</title><link>https://lloydroc.github.io/post/flex-bison/json-parse-ast/</link><pubDate>Sun, 25 Oct 2020 00:00:00 +0000</pubDate><guid>https://lloydroc.github.io/post/flex-bison/json-parse-ast/</guid><description>&lt;h1 id="hahahugoshortcode52s0hbhb">Parse JSON into an Abstract Syntax Tree using Flex/Bison&lt;/h1>
&lt;p>In a previous post we &lt;a href="https://lloydroc.github.io/post/flex-bison/json-parse/">Parsed JSON using Flex/Bison&lt;/a>. This example was very basic. We used a FLEX scanner to tokenize our JSON and created grammar rules in BISON to parse this token stream. This post will take it further and create an Abstract Syntax Tree (AST). The AST is a power data structure typically used in compilers that will store the structure of our JSON. Effectively we will read in the JSON structure a tree-like data structure in C.&lt;/p></description></item><item><title>Parse JSON with Flex and Bison</title><link>https://lloydroc.github.io/post/flex-bison/json-parse/</link><pubDate>Sat, 22 Feb 2020 00:00:00 +0000</pubDate><guid>https://lloydroc.github.io/post/flex-bison/json-parse/</guid><description>&lt;h1 id="hahahugoshortcode51s0hbhb">Parse JSON with Flex and Bison&lt;/h1>
&lt;p>A simple example that will parse JSON in C using Flex and Bison. Forewarning, while this example works well it&amp;rsquo;s not going to handle every JSON case. I&amp;rsquo;ll highlight the limitations of what cannot be parsed towards the end of the post. It&amp;rsquo;s a perfect example to build upon and extend though.&lt;/p>
&lt;h1 id="flex-scanner-to-parse-json">FLEX Scanner to Parse JSON&lt;/h1>
&lt;p>The scanner will create a token stream. Tokens are just regex matches made by flex that can also have values. For example a &lt;code>DECIMAL&lt;/code> token we return a float by calling &lt;code>atof(yytext)&lt;/code>. Whereas, we also tokenize &lt;code>{&lt;/code> to &lt;code>LCURLY&lt;/code>, but there is no value. The &lt;code>ECHO&lt;/code> macro is turned off, and can be turned on for further debug info.&lt;/p></description></item></channel></rss>