Skip to content

Instantly share code, notes, and snippets.

View mark-and-sweep-gc.js
/**
* Mark and Sweep Garbage Collection technique.
* MIT Style License
* by Dmitry Soshnikov
*/
// This diff describes the simplest version of mark and sweep
// GC in order to understand the basic idea. In real practice the
// implementation can be much tricker and optimized.
View LL-parser.js
/**
* = LL parser =
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT Style license
*
* Often one can see manually written LL parsers implemented as
* recursive descent. Approach in this diff is a classical parse table
* state machine.
*
@DmitrySoshnikov
DmitrySoshnikov / LL1-parsing-table.js
Last active Nov 26, 2021
LL(1) Parser. Parsing table, part 2: building the table from First and Follow sets.
View LL1-parsing-table.js
/**
* Building LL(1) parsing table from First and Follow sets.
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT Style License
*
* This diff is a continuation of what we started in the previous two diffs:
*
* Dependencies:
*
View event-loop.js
/**
* Event loop.
*
* Read details here:
* http://dmitrysoshnikov.com/ecmascript/javascript-the-core-2nd-edition/#job
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
*/
/**
View shunting-yard-algorithm.js
/**
* Shunting yard algorithm
* See: http://en.wikipedia.org/wiki/Shunting_yard_algorithm
*
* Converts infix notation to postfix notation
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT Style License
*
* (C) 2011, updated on 2020
@DmitrySoshnikov
DmitrySoshnikov / syntax.s
Created Jan 27, 2018 — forked from mishurov/syntax.s
AT&T assembly syntax and IA-32 instructions
View syntax.s
# --------
# Hardware
# --------
# Opcode - operational code
# Assebly mnemonic - abbreviation for an operation
# Instruction Code Format (IA-32)
# - Optional instruction prefix
# - Operational code
@DmitrySoshnikov
DmitrySoshnikov / python-closures.py
Created Nov 15, 2010
Understanding Python's closures
View python-closures.py
# "Understanding Python's closures".
#
# Tested in Python 3.1.2
#
# General points:
#
# 1. Closured lexical environments are stored
# in the property __closure__ of a function
#
# 2. If a function does not use free variables
@DmitrySoshnikov
DmitrySoshnikov / math-expr-lexer.cpp
Created Oct 13, 2014
Simple math expression lexer.
View math-expr-lexer.cpp
// by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
// MIT Style License.
// Short URL for this example to run online is: http://cpp.sh/333
#include <iostream>
#include <vector>
#include <ctype.h>
#include <cstring>
View JNI-Example-Mac.md

JNI Example (Mac OS)

JNI (Java Native Interface) allows implementing methods in C/C++, and use them in Java.

1. Create JNIExample.java file

class JNIExample {

  // Native method, no body.
@DmitrySoshnikov
DmitrySoshnikov / LL1-parser-first-follow-sets.js
Last active Oct 8, 2021
LL(1) Parser. Parsing table, part 1: First and Follow sets.
View LL1-parser-first-follow-sets.js
/**
* LL(1) parser. Building parsing table, part 1: First and Follow sets.
*
* NOTICE: see full implementation in the Syntax tool, here:
* https://github.com/DmitrySoshnikov/syntax/blob/master/src/sets-generator.js
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT Style License
*
* An LL(1)-parser is a top-down, fast predictive non-recursive parser,