C -> D o D
D -> C
D -> t
D -> D o D
D -> t
This file contains hidden or 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
// Parse a document using "offside rule" indentation (as in Python) into lines | |
// grouped by indentation level, using PEG.js. | |
// Attempts to segregate the "stateful" rules from the other production/parsing | |
// rules by "disallowing" indentation-level-sensitive rules from consuming any | |
// text. | |
{ var margin_stack = [""]; } | |
Document | |
= content: Element+ |
This file contains hidden or 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
sequence: (A B C ...) => A B C ... | |
ordered choice: (/ A B C ...) => A / B / C / ... | |
optional branch: (? ...) => (...)? | |
zero or more: (* ...) => (...)* | |
one or more: (+ ...) => (...)+ | |
not: (! ...) => !(...) | |
and (lookahead): (& ...) => &(...) | |
drop node: (: ...) - Drops a node from the parse tree. | |
concat captures: (~ ...) - Concatenates captures. |
This file contains hidden or 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
/* | |
* For something like A == 2 AND (B > 3 OR C >= 4 ) | |
*/ | |
start | |
= additive | |
additive | |
= left:multiplicative _ "OR" _ right:additive { return left + " OR " + right; } | |
/ multiplicative |
This file contains hidden or 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
const reduce = (reducer, initial, [head, ...tail]) => | |
head // condition to go or stop | |
? reduce(reducer, reducer(initial, head), tail) // recursion | |
: initial // stop | |
const map = (mapper, [head, ...tail]) => | |
head // condition to go or stop | |
? [ mapper(head), ...map(mapper, tail) ] //recursion | |
: [] // stop |
This file contains hidden or 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
# PROBLEM: Small brewery produces ale and beer | |
# Production is limited by scarce resources: corn, hops, barley malt. | |
# Recipes for ale and beer require differenty proportions of resources | |
# | |
# Ale (barrel) | |
# - 5lb corn | |
# - 4oz hops | |
# - 35lb malt | |
# - $13 profit | |
# |
By: @BTroncone
Also check out my lesson @ngrx/store in 10 minutes on egghead.io!
Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!
This file contains hidden or 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
Syntax = | |
AssignmentExpression: 'AssignmentExpression' | |
ArrayExpression: 'ArrayExpression' | |
BlockStatement: 'BlockStatement' | |
BinaryExpression: 'BinaryExpression' | |
BreakStatement: 'BreakStatement' | |
CallExpression: 'CallExpression' | |
CatchClause: 'CatchClause' | |
ConditionalExpression: 'ConditionalExpression' | |
ContinueStatement: 'ContinueStatement' |
This file contains hidden or 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(n,t,i,r){"use strict";function h(n,t){return typeof t!="object"&&(t=t()),Object.keys(t).forEach(function(i){n[i]=t[i]}),n}function y(n){return{from:function(t){return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,{extend:function(i){h(n.prototype,typeof i!="object"?i(t.prototype):i)}}}}}function p(n,t){return t(n)}function f(t){function or(){if(i)w.on("versionchange",function(t){w.close();t.newVersion&&n.location.reload(!0)})}function ki(n){this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null};this.stores({})}function sr(n,t,i,r){var e,f,o,h,l,c;if(n==0)Object.keys(pt).forEach(function(n){di(t,n,pt[n].primKey,pt[n].indexes)}),e=w._createTransaction(kt,ri,pt),e.idbtrans=t,e.idbtrans.onerror=s(i,["populating database"]),e.on("error").subscribe(i),u.newPSD(function(){u.PSD.trans=e;try{w.on("populate").fire(e)}catch(n){r.onerror=t.onerror=function(n){n.preventDefault()};try{t.abort()}catch(f){}t.db.close();i(n)}});else{if(f=[],o=ii.filter(function(t){return |
This file contains hidden or 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
/** | |
* MIT License | |
* | |
* Copyright (c) 2016 Richard Adams (https://github.com/enriched) | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is |