Skip to content

Instantly share code, notes, and snippets.

Avatar
🐪

Vladimir Keleshev keleshev

🐪
View GitHub Profile
View Lexer.l
%{
#include <stdio.h>
#include "parser.h"
%}
%%
[ \r\n\t]* { continue; /* Skip blanks. */ }
[0-9]+ { sscanf(yytext, "%d", &yylval->value); return TOKEN_NUMBER; }
"*" { return TOKEN_STAR; }
View verboseRegExp.js
function verboseRegExp(input) {
if (input.raw.length !== 1) {
throw Error('verboseRegExp: interpolation is not supported');
}
let source = input.raw[0];
let regexp = /(?<!\\)\s|[/][/].*|[/][*][\s\S]*[*][/]/g;
let result = source.replace(regexp, '');
View Makefile
.PHONY: build install
ifeq ($(PREFIX),)
INSTALL_FLAGS=
else
INSTALL_FLAGS=--prefix=$(PREFIX)
endif
build:
dune build
View Makefile
.PHONY: always_run
%.exe: %.s always_run
@arm-linux-gnueabihf-gcc -static -o $@ $<
@-qemu-arm-static $@; echo $$?
@rm -f $@
@keleshev
keleshev / ctrl.reg
Created Oct 22, 2019
Windows Registry script for mapping Caps Lock to Ctrl
View ctrl.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
View length.ml
let rec compare_lengths l1 l2 =
match l1, l2 with
| [], [] -> 0
| [], _ -> -1
| _, [] -> 1
| _ :: l1, _ :: l2 -> compare_lengths l1 l2
let rec compare_length_with l n =
match l with
View base_vs_stdlib.md

Comparision of JaneStreet Base and OCaml Stdlib

How to use Base

Either use Base selectively:

# #show List.hd;;
View environment_monad.ml
module Environment = struct
type t = (string * int) list
let set id number env = (id, number) :: env
let rec get id = function
| [] -> 0
| (key, value) :: tail ->
View precedence_1.ml
open Printf
module Token = struct
type t =
| Number of int
| Addition
| Exponent
| Left_paren
| Right_paren
end
View free.ml
let (=>) left right = print_char (if left = right then '.' else 'F')
module Env = struct
include Set.Make (String)
let to_list t = fold List.cons t []
end
You can’t perform that action at this time.