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
def check_classes | |
# Get list of all subclasses of Scanny::Checks::Check. | |
classes = [] | |
ObjectSpace.each_object(Class) do |klass| | |
classes << klass if klass < Scanny::Checks::Check | |
end | |
# Filter out classes that are a superclass of some other class in the list. | |
# This way only "leaf" classes remain. | |
classes.reject do |klass| |
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
[ | |
:REGEXP, | |
/^ | |
\/ | |
( | |
\\ # escape | |
( | |
[\\"ntrfvaebs] # one-character escape | |
| | |
[0-7]{1,3} # octal number escape |
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 makeNode(type, head, tail) { | |
return tail.length > 0 | |
? { | |
type: type, | |
terms: [head].concat(tail.map(function(t) { return t[1]; })) | |
} | |
: head; | |
} | |
} |
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
/* | |
* Task: Parse even numbers in PEG.js (http://pegjs.majda.cz). | |
* | |
* Solution: Let's parse all numbers and reject odd ones using a semantic | |
* predicate -- an arbitrary piece of code that returns true (meaning "continue | |
* parsing") or false (meaning "halt parsing"). | |
* | |
* This solution wouldn't work before commit a2af1fe612 because predicates | |
* didn't have access to labeled expressions in the grammar as variables | |
* (without ugly workarounds). But they have the access now and the solution |
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
# Syntax of Ruby is flexible enough to allow writing Lisp-like code. | |
# We need few helper functions (no Lisp yet): | |
def list(*args) | |
args | |
end | |
def car(list) | |
list.first |
NewerOlder