In this tutorial we're going to build a set of parser combinators.
We'll answer the above question in 2 steps.
- What is a parser?
- and, what is a parser combinator?
So first question: What is parser?
--[[ json.lua | |
A compact pure-Lua JSON library. | |
The main functions are: json.stringify, json.parse. | |
## json.stringify: | |
This expects the following to be true of any tables being encoded: | |
* They only have string or number keys. Number keys must be represented as | |
strings in json; this is part of the json spec. |
# placed in ~/.local/share/nautilus-python/extensions/open-kitty.py | |
# you will need the package nautilus-python on fedora, or python-nautilus on ubuntu... | |
# french version | |
# translate and enjoy | |
import os | |
try: | |
from urllib import unquote | |
except ImportError: | |
from urllib.parse import unquote |
" | |
" | |
" Vim/Nvim configuration | |
" | |
" https://github.com/tpope/vim-fugitive | |
" https://github.com/udalov/kotlin-vim | |
" https://github.com/junegunn/vim-plug | |
" https://github.com/puremourning/vimspector | |
" |
This project is a tiny compiler for a very simple language consisting of boolean expression.
The language has two constants: 1
for true and 0
for false, and 4 logic gates:
!
(not), &
(and), |
(or), and ^
(xor).
It can also use parentheses to manage priorities.
Here is its grammar in BNF format:
expr ::= "0" | "1"
type term = | |
| Lam of (term -> term) | |
| Pi of term * (term -> term) | |
| Appl of term * term | |
| Ann of term * term | |
| FreeVar of int | |
| Star | |
| Box | |
let unfurl lvl f = f (FreeVar lvl) |