Skip to content

Instantly share code, notes, and snippets.

View aarongough's full-sized avatar

Aaron Gough (He/Him) aarongough

View GitHub Profile
framework 'cocoa'
class Application
def applicationDidFinishLaunching(notification)
frame = NSRect.new(NSPoint.new(100, 100), NSSize.new(300, 300))
@main_window = NSWindow.alloc.initWithContentRect(
frame,
:styleMask => (NSTitledWindowMask | NSClosableWindowMask),
:backing => NSBackingStoreBuffered,
unknown: warning: instance variable @inheritable_attributes not initialized
unknown: warning: instance variable @inheritable_attributes not initialized
unknown: warning: instance variable @inheritable_attributes not initialized
unknown: warning: instance variable @__instance__ not initialized
unknown: warning: instance variable @inheritable_attributes not initialized
unknown: warning: instance variable @inheritable_attributes not initialized
unknown: warning: instance variable @inheritable_attributes not initialized
unknown: warning: instance variable __attached__ not initialized
unknown: warning: instance variable __attached__ not initialized
unknown: warning: instance variable __attached__ not initialized
require 'benchmark'
require 'sexpistol'
require 'sxp'
class Lexer
def initialize(str)
@str = str
@p = 0
end
require 'benchmark'
require 'sexpistol'
require 'sxp'
class Lexer
def initialize(str)
@str = str
@p = 0
end
require 'benchmark'
require 'sexpistol'
require 'sxp'
example_sexp = <<-EOD
((display "This is a test string!")
(define test (lambda () (begin
(display (== 1 1))
def extract_string_literals( string )
string_literal_pattern = /"([^"\\]|\\.)*"/
string_replacement_token = "___+++STRING_LITERAL+++___"
# Find and extract all the string literals
string_literals = []
string.gsub(string_literal_pattern) {|x| string_literals << x}
# Replace all the string literals with our special placeholder token
string = string.gsub(string_literal_pattern, string_replacement_token)
# Return the modified string and the array of string literals
return [string, string_literals]
# Benchmark this system's performance from a developer's perspective.
#
# * Configure and compile Ruby
# * Run the test suite of several medium sized Ruby applications
# * Run the database-heavy test-suite of a Rails application
# * Test the launch times of several common applications
class DeveloperBenchmark
require 'fileutils'
run_lexer("test = -100")
#=> [{:value=>"test", :name=>:identifier}, {:value=>"=", :name=>:assignment_operator}, {:value=>"-100", :name=>:integer_literal}]
=begin
%%{
machine simple_lexer;
integer = ('+'|'-')?[0-9]+;
float = ('+'|'-')?[0-9]+'.'[0-9]+;
assignment = '=';
identifier = [a-zA-Z][a-zA-Z_]+;
%%{
machine simple_lexer;
integer = ('+'|'-')?[0-9]+;
float = ('+'|'-')?[0-9]+'.'[0-9]+;
assignment = '=';
identifier = [a-zA-Z][a-zA-Z_]+;
main := |*