Skip to content

Instantly share code, notes, and snippets.

View simonask's full-sized avatar

Simon Ask Ulsnes simonask

View GitHub Profile
#include <stdio.h>
class Mixin1 {
protected:
Mixin1() {}
public:
int a, b, c;
};
class Mixin2 {
class Base {
private:
int m_Lol;
public:
Base(int lol) : m_Lol(lol) {}
};
class Foo : public Base {
public:
Foo() : Base(123) {}
#include <iostream>
using namespace std;
template <int N> int fib() {
return fib<N-1>() + fib<N-2>();
}
template <>
int fib<0>() {
foo: [a, b] { return a + b }
puts(foo.disassemble())
void render() {
// Tiles
for (int i = 0; i < columns; ++i)
{
for (int j = 0; j < rows; ++j)
{
glBegin(GL_QUADS);
glColor3f(0.0, 1.0, 0.0);
glVertex2f(i*tile_width, j*tile_height);
glVertex2f(i*tile_width+tile_width, j*tile_height);
void whatever(Object* raw_ptr) {
Handle<Object> ptr = raw_ptr; // bookkeeping pointer
ptr->lals();
return;
// ptr destroyed, book kept
}
window: Window("Test") {
.button1: Button("Lol") { print "HELLO WORLD" }
}
window.show
window.button1.click
window.on_close << { print ":(" }
Mutexed: class {
.initialize: [closure] {
.closure: closure
.mutex: Mutex
}
.(): [*args] {
.mutex.lock
.closure(*args)
.mutex.unlock
SomeClass: class() {
.initialize: { ... }
}
foo: SomeClass()
bar: SomeClass()
foo.lol: { print "HELLO" }
bar.lol() // => ERROR
foo.lol() // => "HELLO"
tIDENTIFIER = tNORMAL_IDENTIFIER | tOPERATOR_IDENTIFIER
tNORMAL_IDENTIFIER = [\w][\w\d*]*
tOPERATOR_IDENTIFIER = [\+\-\*\/\\]*
tOPERATOR_CALL = tIDENTIFIER tIDENTIFIER tIDENTIFIER
tNORMAL_CALL = tIDENTIFIER tDOT tSTART_PAREN tARG_LIST tEND_PAREN
tEXPR = ... | ... | tOPERATOR_CALL | tNORMAL_CALL | ... | ...