Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
ANTLR
ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
Now we are ready to create a new project. For project building i'll use sbt, but it is also possible to use maven or gradle. After project creation we need to add antlr4 compiler plugin – sbt-antlr4. Also, we will need a shapeless for codec derivation, so let's add this library too. After all, plugins.sbt and build.sbt will look like this:
First of all, we need a grammar. I think, that the best place for exploring grammars and take some ideas is grammars-v4. There are a lot of grammar examples, but we need a special one – json.
We will change it a little bit soon, but for now let's look on what's going on there. In general, grammar consists of parser and lexer rules.
The source code of a whole project could be found here: https://github.com/nryanov/json-serde
Related posts
- How should I prepare for AI-driven changes in the industry as a Software Engineering Manager
- ELI5- Why can’t regex parse HTML?
- Error "ImportError: No Module named antlr4
- MASSIVE help needed on this, using ANTLR4 on Ubuntu and it keeps giving this error when trying to make a parse tree… (it should show up in another window but it gives this instead) I don’t know what to do 😭
- SQLite Internals: How the Most Used Database Works