使用 LIBLR 解析带注释的 JSON

Skywind Inside at 
使用 LIBLR 解析带注释的 JSON的配图
前文《基于 LR(1) 和 LALR 的 Parser Generator》里介绍了春节期间开发的小玩具 LIBLR ,今天春节最后一天,用它跑一个小例子,解析带注释的 json 文件。由于 python 自带 json 库不支持带注释的 json 解析,而 vscode 里大量带注释的 json 没法解析,所以我们先写个文法,保存为 json.txt: # 定义两个终结符 %token NUMBER %token STRING start: value {get1} ; value: object {get1} | array {get1} | STRING {get_string} | N……