Skip to content

Instantly share code, notes, and snippets.

View stepancheg's full-sized avatar

Stepan Koltsov stepancheg

View GitHub Profile
diff --git a/lib-clay/parsing/combinators/generic/generic.clay b/lib-clay/parsing/combinators/generic/generic.clay
index 24cac60..84a7c6d 100644
--- a/lib-clay/parsing/combinators/generic/generic.clay
+++ b/lib-clay/parsing/combinators/generic/generic.clay
@@ -414,6 +414,6 @@ optSeparatedListStrict(#TokenInput, forward _separator:Separator, forward _eleme
alias T = ParseResult(TokenInput, Element);
return modify(
x => maybe(move(x), y => move(y), () => Vector[T]()),
- optional(separatedListStrict(_separator, _element)),
+ optional(TokenInput, separatedListStrict(TokenInput, _separator, _element)),
// "library" function to declare a record
[Base]
recordExtend(static Base, ..fields) = ..RecordFields(Base), ..fields;
// "library" function to declare hierarchy
// should be overloaded for each subtype, type pair
[A, B]
Extends?(static A, static B) = false;
# tested in zsh
# Don't try this at home.
command_not_found_handler() {
replaced=false
set -A args "$@"
# aliases like gcc-O2='gcc -O2'
@stepancheg
stepancheg / gist:3388855
Created August 18, 2012 18:22
Full error
###############################
overload GenericOSError?(#GenericOSError) = true;
[E, I, S when GenericOSError?(E) and Integer?(I) and StringLiteral?(S)]
-----------------------------^
overload E(code:I, #S) --> returned:E {
returned.code = Int(code);
###############################
/Users/yozh/devel/left/clay/lib-clay/os/errors/errors.clay(13,29): error: unholy recursion detected
import printer.*;
private external backtrace(array:Pointer[RawPointer], size:Int) : Int;
record Backtrace (
callstack: Array[RawPointer, 128],
);
showBacktraceMine() {
var bt = Backtrace();
#include <stdio.h>
#include <unistd.h>
struct large_struct {
void* a[1024];
};
static void foo() {
struct large_struct r;
// call any function that is guaranteed to be not inlined
import printer.*;
import unix;
record LargeRecord (
a: Array[RawPointer, 1024],
);
foo() {
var a = LargeRecord();
// call any function that is guaranteed to be not inlined
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
" from http://vim.wikia.com/wiki/Highlight_unwanted_spaces
highlight ExtraWhitespace ctermbg=lightgray guibg=lightgray
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=lightgray guibg=lightgray
match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
#include <execinfo.h>
#include <sys/time.h>
#include <stdio.h>
void foo(int i) {
if (i == 0) {
void* array[128];
backtrace(array, 128);
} else {
foo(i - 1);