This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo(stream) { | |
if (stream.lookahead("if")) { | |
var ifNode = stream.consume("if"); | |
var elseIfNode = stream.maybe("else if") || stream.maybe("poop") | |
} | |
} | |
var dot = (str) => str.consume("."); | |
var minus = (str) => str.consume("-"); | |
var parseIf = (str) => str.consume("if"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use <filter> as only | |
use <func> as F | |
use [Input] of <io> | |
fn fib(n) { | |
ret F.decide({ | |
n <= 1 : () => n | |
}).else(() => F.sum([ | |
fib(n - 1), | |
fib(n - 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar Grammar; | |
WS: [ \n\r\t] -> skip; | |
ID: [A-Za-z_] [A-Za-z0-9_]*; | |
compilationUnit: block*; | |
block: name=ID '{' (stmt ';'*)* '}'; | |
stmt: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mode release { | |
# Define executables | |
assembler "i686-elf-as" | |
compiler "i686-elf-gcc" | |
bootstrap "boot.s" | |
link "linker.ld" | |
sources "src/**/*.c", "path.c" | |
entry "kernel.c" | |
grub "menu.grub" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@component() | |
export default class Layout { | |
render() { | |
return div { | |
this.title(), | |
this.content() | |
}; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add2(num) { | |
return num + 2; | |
} | |
function add2_array(num[]) { | |
return num.map(function(num) { | |
return add2(num); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:angel_framework/angel_framework.dart'; | |
import 'package:angular2/angular2.dart'; | |
import 'playing_card.dart'; | |
import 'lib/models/user.dart'; | |
@Component( | |
selector: 'home', | |
templateUrl: 'home.html', | |
directives: const [PlayingCardComponent]) | |
class HomeComponent { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
options { | |
prefix: 'MyAmazingCalculatorGrammar', | |
mixins: { | |
ExampleMixin: 'example_mixin.dart' | |
} | |
} | |
lexer { | |
// Tags for grouping tokens separately, i.e. comments | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:convert'; | |
import 'dart:io'; | |
main() async { | |
var client = new HttpClient(); | |
List<Cookies> sessionCookies = []; // Store our cookies here | |
// Let's login | |
var rq = await client.openUrl('POST', 'http://foo.com/login'); | |
rq.write('username=foo&password=bar'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/43519368/promise-practical-self-implement/43519600?noredirect=1#comment74092616_43519600 | |
function Promises(cb) { | |
if (cb) { | |
cb(Promises.prototype.resolve.bind(this), Promises.prototype.reject.bind(this)); | |
} | |
} | |
Promises.prototype.resolve = function(value) { | |
if (this.callback) this.callback(value); |