Skip to content

Instantly share code, notes, and snippets.

View Chubek's full-sized avatar

Behrang Nevii Chubek

View GitHub Profile
@Chubek
Chubek / CurryZoo.lua
Created September 8, 2024 22:53
The Lua Combinatory Logic Zoo!
#!/usr/bin/env lua
function I(x)
return x
end
function K(x, y)
return x
end
@Chubek
Chubek / ECMAScript.ebnf
Last active September 8, 2024 15:11
EBNF Grammar for JavaScript (aka ECMAScript)
# Syntactic Grammar for ECMAScript
ecma-script-module ::= { top-level | ignorable }
top-level ::= statement
| function-declaration
| class-declaration
function-declaration ::= [ "async" ] "function" identifier function-params-postfix compound-statement
@Chubek
Chubek / README.md
Created August 21, 2024 13:50
Ramkal, a parser for ISO Pascal (in D)

ramkal.d contains a so-and-so ready parser for the ISO variant of the Pascal language. It was mainly an experiment. I am done with it.

You can look at the source for influence, and ideas.

Note: Several additional constructs have been defined.

@Chubek
Chubek / POSIX-Shell.ebnf
Last active August 7, 2024 09:06
The POSIX Shell Grammar
# Lexical and Syntactic EBNF Grammar for POSIX Shell (Non-Attributed)
# Authored by Chubak Bidpaa (chubakbidpaa@riseup.net)
# Written For the Marsh Shell (https://github.com/Chubek/Marsh)
# This grammar is based on POSIX specs (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html)
# This document is released under `Unlicense` Public Domain License Agreement | (C) 2024 Chubak Bidpaa | No Warranty
# A: Lexical Grammar for POSIX Shell
@Chubek
Chubek / Pacal-Syntax.ml
Last active July 26, 2024 23:14
Pascal-Syntax.ml: ISO Pascal's syntax formalized in OCaml type system
(* Formalism for ISO-7185:1990 "Pascal" Syntax *)
(* These will be extended into an AST *)
(* ISO Pascal is different from Delphi *)
(* Please submit your comments to chubakbidpaa [at] riseup [dot] net *)
type pas_kw = And | Array | Begin | Case | Const
| Div | Do | Downto | Else | End
| File | For | Function | Goto
| If | In | Label | Mod | Nil
| Not | Of | Or | Packed | Procedure
@Chubek
Chubek / README.md
Created July 15, 2024 12:22
The 'map' function is the same as Kleene star (regex *)!

The map function and Kleene Star (regex *) are the same! (homomorphic)

In functional languages, and most modern imperative languages which implement functional features, we often have a map function. In λ-> (simply-typed λ-calc) we could describe the type of this function as:

Γ ⊢ λfλmα.m(α) : (A -> B) -> [A] -> Unit

Let me explain what this notation means.

@Chubek
Chubek / README.md
Last active June 28, 2024 16:43
Schemeroni: Useful Scheme Macaronis

I will use this Gist to post useful Scheme macros.

These macros will be compliant with R7Rs and down.

All macros are partially tested (warning!). Don't use them in serious work before thorough test.

@Chubek
Chubek / Inter.h
Last active June 24, 2024 23:38
Imperative representation of Peyton Jones' "enriched" λ-Calc language
#ifndef INTER_H
#define INTER_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@Chubek
Chubek / README.md
Created May 27, 2024 22:16
SML's "implode" and "explode" in OCaml

In Standard ML, we have two built-in functions called 'explode' and 'implode':

fun explode: string -> char list
fun implode: char list -> string

So, you get it, 'explode' makes a list of characters from a string and 'implode' does the inverse.

However, OCaml does not have these functions. Regardless; you may derive them like so:

@Chubek
Chubek / README.md
Last active May 30, 2024 16:01
TSV datasets of ROFF (Requests, Escapes, NRs, SRs, Characters)

This Gist contains a total of 5 tab-separated values files (TSV), and they list:

  • ROFF-Requests.tsv -> ROFF requests, this file is the only one where the structure is taken from the manual downloaded from TROFF's website authored by the late Joe Ossanna and the legendary BWK, refer to the listing in the manual to get a sense of what each column means (name;args;default;default arg values;flags;description).
  • ROFF-Escapes.tsv -> The escape sequences --- those accepting arguments and those variable have been marked;
  • ROFF-NRs.tsv -> The built-in numeric registers (which GROFF just calls registers);
  • ROFF-SRs.tsv -> The built-in string registers (which GROFF just calls strings);
  • ROFF-Chars.tsv -> The pre-defined character list;

Important thing to note is, these are the listings as defined by Ossanna and Kernighan. GNU additions have not been accounted for. Whatever Heirloom DocTools adds neither. This is pure ROFF!