Skip to content

Instantly share code, notes, and snippets.

View Chubek's full-sized avatar

Chubak Bidpaa Chubek

View GitHub Profile
@Chubek
Chubek / README.md
Last active April 26, 2024 23:00
Hummingbot Scripts

generate-volume.py

This script can be used with Hummingbot to:

1- Download latest books from specified exchange,

2- Subtrct/add delta from latest buy/sell,

3- Sell back based on order amount,

@Chubek
Chubek / README.md
Last active April 20, 2024 18:59
Semantics: Denotational vs. Operational

Semantics: Operational vs. Denotational

In this document I wish to explain the difference between operational and denotational semantics. It may sound like a dry subject but you and I both will learn plenty from it.

Semantics of a language defines how the language behaves, where as the syntax of a programming language defines how it is formed.

  • Syntax is the foundation of a language;
  • Semantics give purpose to the syntax;
  • Syntax errors often lead to semantic errors, but they don't have much of a 'causual' relationship;
@Chubek
Chubek / README.md
Last active April 19, 2024 06:13
Xeph Grammar -> Draft 1

Xeph.ebnf contains the first draft of the Xeph non-pure functional language. A prototype of Xeph, compiled targeting GNU C, is at works.

EDIT: It is currently the second revision. I have added meta programming, and a lot of other imporvements.

However, the definition is weak, and it needs your feedback to be refined.

The ADTs in Xeph are taken from Zephyr ASDL (which there are many implementations of, like mine) and the rest are 'original', that is, taken from ML, Haskell, and Scheme.

This is not the final version of the grammar. The implementation at the moment is focusing on the backend and semantics. The grammar of a functional language is its most important aspect, and it can't be taken lightly.

@Chubek
Chubek / allocppx.1
Last active April 16, 2024 15:02
AllocPPx.pl -> A C preprocessor that adds garbage collection
LLOCPPX(1) User Contributed Perl Documentation ALLOCPPX(1)
NAME
allocppx.pl - A Perl script for preprocessing C files with specific
annotations.
SYNOPSIS
perl allocppx.pl [options] [input_file]
@Chubek
Chubek / README.md
Created April 7, 2024 21:30
Introduction to Zephyr ASDL

I wrote an implementation of Zephyr ASDL which you can install from here:

https:///github.com/Chubek/ZephyrASDL

In this document I wanna write a short intro to ASDL and you you can utilize it.

ASDL is in use in CPython's source code. Not my implementation of course, an implementation called 'PyASDL' which parses it, and it's up to you to provide the semantics and code generation. CPython's source code uses ASDL to build the Abstract Syntax Tree for Python in C++. My implementation of ASDL translates the syntax description directly to C. You can specify the types to be also emitted in an extra header file (via the -s flag).

Zephyr ASDL is not an standard, it's just a short paper written in 1997, by Wang, Appel, Korn and Serra, all Princeton alumni.

@Chubek
Chubek / POSIX-Shell.ebnf
Last active April 6, 2024 18:48
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 / README.md
Created March 29, 2024 14:29
This is, hands-down, the best way to convert PDFs to EPUB (or any other format)

This document describes several shell pipelines for converting PDF files to any format.

I'm not sure if it's true for all people, but my e-reader sucks at displaying PDF --- which is, in all reality, a giant executable file (we'll discuss this soon). Also, there's dozens of other reasons one may wish to convert a PDF to a better 'text format'. Let's say, you wanna put it up on your website, feed it to a mathematical optimization model, feed it to an script, etc.

Before you read this document, yes, I know there is a utility, nay, dozens that converty PDFs directly to text (like pdftotext). I ALSO know that. there are millions, if not BILLIONS of crappy web services that serve you a malware on the platter alongisde converting the files. So let's not talk about them! It's about "owning" your software, read this!

What are PDF Files?

This is not meant to be a description or history of PDF files, you can consult Sahih Al-Bukhari f

@Chubek
Chubek / ECMAScript.ebnf
Last active April 2, 2024 00:12
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
Last active March 10, 2024 13:04
EBNF Grammar for AWK

Note: if you wish to understand these notations, please read this: https://gist.github.com/Chubek/52884d1fa766fa16ae8d8f226ba105ad

So, again, why did I write the EBNF grammar for AWK?

Basically, I have two ongoing projects where AWK is involved. Firs is Squawk, and implementation of AWK and second is AWK2c, which obviously translates AWK to C.

Plus, I am thinking of making a Github page called 'The Internet Grammar Database' where I would post EBNF, Yacc, PEG, Lex, definitions of languages. However, I don't have much experience in web development, so if you can help me, let me know (chubakbidpaa [at] riseup [dot] net).

So anyways, awk.ebnf contains the EBNF grammar for AWK. Some considerations:

@Chubek
Chubek / README.md
Last active March 9, 2024 16:04
EBNF Grammar for C

c.ebnf contains grammar ofr C99. Note that this is ANSI C, not ISO C, so there are some omissions. The reason I wrote this is, I am currently writing a C compiler, with my own backend (and hopefully, frontend) in OCaml. And I needed to collect the grammar in one place.

How to Read EBNF Grammars?

Reading EBNF grammars is pretty simple:

  • Enclosed within two ?s is a global capture, it does not mean optional. It means 'I am writing a free-style sentence'.
  • Enclosed within { and } means : repeat at least zero times
  • Enclosed within [ and ] means : this is optional
  • Enclosed within ( and ) means : this is a group