A simple JSON parser using Pratt Parsing. This repository is mainly for educational purpose.
Code is based on Writing An Interpreter In Go by Thorsten Ball.
The original JSON string will be parsed and turned into a Go struct, defined in
object/object.go:
type Hash struct {
Pairs map[HashKey]HashPair
}There are three stages:
-
Lexing: breaks down the original string into an array of tokens.
-
Parsing: forms an Abstract Syntax Tree (AST) based on the tokens. Pratt parsing—"top-down operator precedence" category—is used.
-
Evaluation: walks down the AST and checks for syntax error. The hash of the keys are also checked.