• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Developing a Language
 

Developing a Language

on

  • 1,914 views

A talk by Evan Phoenix at LARubyConf all about creating a new language from scratch to run on top of the Rubinius VM.

A talk by Evan Phoenix at LARubyConf all about creating a new language from scratch to run on top of the Rubinius VM.

Statistics

Views

Total Views
1,914
Views on SlideShare
1,910
Embed Views
4

Actions

Likes
0
Downloads
14
Comments
0

4 Embeds 4

http://summify.com 1
http://twitter.com 1
https://twitter.com 1
http://paper.li 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Developing a Language Developing a Language Presentation Transcript

    • Developing a Language @evanphx ♘ github.com/evanphx Evan Phoenix Feb 5th, 2011Tuesday, February 8, 2011
    • #11Tuesday, February 8, 2011
    • LA.RB Los Angeles Ruby Brigade Tuesday Night. Every Week. http://rb.laTuesday, February 8, 2011
    • DINNERTuesday, February 8, 2011
    • DINNERTuesday, February 8, 2011
    • DINNERTuesday, February 8, 2011
    • DINNERTuesday, February 8, 2011
    • Which came first?Tuesday, February 8, 2011
    • Language > IdeaTuesday, February 8, 2011
    • Language < IdeaTuesday, February 8, 2011
    • Language = IdeaTuesday, February 8, 2011
    • The programmer, like the poet, works only slightly removed from pure thought-stuff. - Fred BrooksTuesday, February 8, 2011
    • If ideas are a manifestation of languageTuesday, February 8, 2011
    • Can better language lead to better ideas?Tuesday, February 8, 2011
    • better != newerTuesday, February 8, 2011
    • Tuesday, February 8, 2011
    • To craft a language from scratch is to take 95% from the past and call it groundbreaking. - Evan PhoenixTuesday, February 8, 2011
    • Peek backTuesday, February 8, 2011
    • Tuesday, February 8, 2011
    • RLKTuesday, February 8, 2011
    • RLK Implement with easeTuesday, February 8, 2011
    • RLK KPegTuesday, February 8, 2011
    • RLK KPeg A new parsing libraryTuesday, February 8, 2011
    • Prattle < RLKTuesday, February 8, 2011
    • URLs In the Building git://192.168.2.88/prattle In the Cloud github.com/evanphx/prattle.git github.com/evanphx/kpeg.gitTuesday, February 8, 2011
    • Tuesday, February 8, 2011
    • Dude. Really?Tuesday, February 8, 2011
    • PrattleTuesday, February 8, 2011
    • self true false nilTuesday, February 8, 2011
    • +module Prattle + module AST + class Self < AST::Node + Prattle::Parser.register self + + def self.rule_name + "self" + end + + def initialize + # Nothing. + end + + def self.grammar(g) + g.self = g.str("self") { Self.new } + end + end + end +endTuesday, February 8, 2011
    • +module Prattle + module AST + class Self < AST::Node + Prattle::Parser.register self + + def self.rule_name + "self" + end + + def initialize + # Nothing. + end + + def self.grammar(g) + g.self = g.str("self") { Self.new } + end + end + end +endTuesday, February 8, 2011
    • Self def self.grammar(g) g.self = g.str("self") { Self.new } end 047b522Tuesday, February 8, 2011
    • True def self.grammar(g) g.true = g.str("true") { True.new } end 04ad51bTuesday, February 8, 2011
    • False def self.grammar(g) g.false = g.str("false") { False.new } end 04ad51bTuesday, February 8, 2011
    • Nil def self.grammar(g) g.nil = g.str("nil") { Nil.new } end 7609e64Tuesday, February 8, 2011
    • Number 0 10 42 10323Tuesday, February 8, 2011
    • Number def self.grammar(g) g.number = g.reg(/0|([1-9][0-9]*)/) { |i| Number.new(i.to_i) } end a06d98cTuesday, February 8, 2011
    • Root def self.grammar(g) g.root = g.any(:true, :false, :self, :nil, :number) end dfd78cbTuesday, February 8, 2011
    • root = self | true | false | nil | numberTuesday, February 8, 2011
    • REPLTuesday, February 8, 2011
    • REPL Instant GratificationTuesday, February 8, 2011
    • $ rbx bin/repl.rb > 42 #<Prattle::AST::Number:0x9c @value=42> > true #<Prattle::AST::True:0x9d>Tuesday, February 8, 2011
    • Self def bytecode(g) g.push :self end 4e4c1c9Tuesday, February 8, 2011
    • True def bytecode(g) g.push :true end 4e4c1c9Tuesday, February 8, 2011
    • False def bytecode(g) g.push :false end 4e4c1c9Tuesday, February 8, 2011
    • Nil def bytecode(g) g.push :nil end 4e4c1c9Tuesday, February 8, 2011
    • Number def bytecode(g) g.push @value end 4e4c1c9Tuesday, February 8, 2011
    • String def self.grammar(g) not_quote = g.many( g.any(escapes, /[^]/)) { |*a| a.join } g.string = g.seq("", g.t(not_quote), "") { |str| String.new(str) } endTuesday, February 8, 2011
    • String char = escapes | [^’] not_quote = char* string = “‘“ not_quote “‘“Tuesday, February 8, 2011
    • $ rbx bin/repl.rb > 42 => 42 > true => 42 > ‘hello’ => “hello”Tuesday, February 8, 2011
    • BORINGTuesday, February 8, 2011
    • Unary Send 3 classTuesday, February 8, 2011
    • Unary Send 3.class RubyTuesday, February 8, 2011
    • Unary Send 3 classTuesday, February 8, 2011
    • Unary Send 3 classTuesday, February 8, 2011
    • Unary Send g.seq(:number, “ “, :method_name) { |v,_,n| UnarySend.new(v,n) }Tuesday, February 8, 2011
    • Unary Send us = number “ “ method_nameTuesday, February 8, 2011
    • Unary Send true classTuesday, February 8, 2011
    • Unary Send g.seq(:atom, “ “, :method_name) { |v,_,n| UnarySend.new(v,n) }Tuesday, February 8, 2011
    • atom = true | false | self | nil | number | stringTuesday, February 8, 2011
    • Unary Send us = atom “ “ method_nameTuesday, February 8, 2011
    • Unary Send 3 class classTuesday, February 8, 2011
    • Unary Send g.any( g.seq(:unary_send, “ “, :method_name) { |v,_,n| UnarySend.new(v,n) }, g.seq(:atom, “ “, :method_name) { |v,_,n| UnarySend.new(v,n) } )Tuesday, February 8, 2011
    • Unary Send us = us “ “ method_name | atom “ “ method_nameTuesday, February 8, 2011
    • Unary Send def bytecode(g) @receiver.bytecode(g) g.send @method_name.to_sym, 0 endTuesday, February 8, 2011
    • $ rbx bin/repl.rb > 3 class => Fixnum > 3 class class => Class > ‘hello’ class => StringTuesday, February 8, 2011
    • Keyword Send‘hello’ index: ‘o’Tuesday, February 8, 2011
    • Keyword Send“hello”.index(“o”) RubyTuesday, February 8, 2011
    • Keyword Sendg.keyword_send = g.seq(:atom, ‘ ‘, :method_name, “:”, “ “, :atom)Tuesday, February 8, 2011
    • Keyword Send ks = atom “ “ method_name “: ” :atomTuesday, February 8, 2011
    • Keyword Send‘hello’ at: 0 put: ‘j’Tuesday, February 8, 2011
    • Keyword Send“hello”[0] = “j” RubyTuesday, February 8, 2011
    • Keyword Sendg.pairs = g.seq(:method_name, “:”, “ “, :atom)Tuesday, February 8, 2011
    • Keyword Sendg.keyword_send = g.seq( :atom, ‘ ‘, g.many([:pair, ‘ ‘]), :pair )Tuesday, February 8, 2011
    • Keyword Send ks = atom (pair ‘ ‘)+ pairTuesday, February 8, 2011
    • Keyword Send def bytecode(g) @receiver.bytecode(g) @arguments.each do |a| a.bytecode(a) end g.send @method_name.to_sym, @arguments.size endTuesday, February 8, 2011
    • Keyword Send def bytecode(g) @receiver.bytecode(g) @arguments.each do |a| a.bytecode(a) end g.send @method_name.to_sym, @arguments.size endTuesday, February 8, 2011
    • $ rbx bin/repl.rb > ‘hello’ index: ‘o’ NoMethodError: Unknown method ‘index:’Tuesday, February 8, 2011
    • $ rbx bin/repl.rb > ‘hello’ index: ‘o’ NoMethodError: Unknown method ‘index:’Tuesday, February 8, 2011
    • Keyword Send‘hello’ index: ‘o’Tuesday, February 8, 2011
    • Keyword Send “hello”.send( “index:”, “o” ) RubyTuesday, February 8, 2011
    • Keyword Send‘hello’ ~index: ‘o’Tuesday, February 8, 2011
    • Keyword Send def bytecode(g) if @method_name[0] == ?~ ruby_style else smalltalk_style end endTuesday, February 8, 2011
    • Keyword Send “hello”.send( “index”, “o” ) RubyTuesday, February 8, 2011
    • $ rbx bin/repl.rb > ‘hello’ ~index: ‘o’ => 4 NoMethodError: Unknown method ‘index:’Tuesday, February 8, 2011
    • Keyword Send obj string at: 0 put: ‘j’Tuesday, February 8, 2011
    • Keyword Send obj string at: 0 put: ‘j’Tuesday, February 8, 2011
    • Keyword Send obj string at: 0 put: ‘j’Tuesday, February 8, 2011
    • Keyword Sendg.keyword_send = g.seq( :atom, ‘ ‘, g.many([:pair, ‘ ‘]), :pair )Tuesday, February 8, 2011
    • Keyword Sendg.keyword_send = g.seq( :atom, ‘ ‘, g.many([:pair, ‘ ‘]), :pair )Tuesday, February 8, 2011
    • Keyword Send ks = atom (pair ‘ ‘)+ pairTuesday, February 8, 2011
    • Keyword Send g.any(:atom, :unary_send)Tuesday, February 8, 2011
    • Keyword Send recv = us | atom ks = recv (pair ‘ ‘)+ pairTuesday, February 8, 2011
    • Block [ 1 ]Tuesday, February 8, 2011
    • Keyword Send g.block = g.seq(‘[‘, :expr, ‘]’)Tuesday, February 8, 2011
    • Keyword Send expr = ks | us | atomTuesday, February 8, 2011
    • Keyword Send block = “[“ expr “]Tuesday, February 8, 2011
    • Block [ 1. 2 ]Tuesday, February 8, 2011
    • Keyword Send g.exprs = g.seq(:expr, g.kleene(‘.’, :expr))Tuesday, February 8, 2011
    • Keyword Send exprs = (‘.’ expr)*Tuesday, February 8, 2011
    • Keyword Send block = “[“ exprs “]Tuesday, February 8, 2011
    • $ rbx bin/repl.rb > 10 ~times: [ Kernel ~puts: ‘hello’ ]Tuesday, February 8, 2011
    • $ rbx bin/repl.rb > 10 ~times: [ Kernel ~puts: ‘rb.la’ ] “rb.la” “rb.la” “rb.la” ... => 10Tuesday, February 8, 2011
    • $ rbx bin/repl.rb > 10 ~times: [ :x | Kernel ~p: x ]Tuesday, February 8, 2011
    • $ rbx bin/repl.rb > 10 ~times: [ :x | Kernel ~p: x ] 0 1 2 ... => 10Tuesday, February 8, 2011
    • Cascade Send ary concat: a; concat: b; concat: cTuesday, February 8, 2011
    • Operators 3 + 4 * 5Tuesday, February 8, 2011
    • $ rbx bin/repl.rb > 3 + 4 * 5Tuesday, February 8, 2011
    • $ rbx bin/repl.rb > 3 + 4 * 5 => 35Tuesday, February 8, 2011
    • Parens parens = “(“ expr “)Tuesday, February 8, 2011
    • $ rbx bin/repl.rb > 3 + (4 * 5) => 23Tuesday, February 8, 2011
    • zero to usableTuesday, February 8, 2011
    • BIG IDEATuesday, February 8, 2011
    • little ideaTuesday, February 8, 2011
    • Complex LanguageTuesday, February 8, 2011
    • simple languageTuesday, February 8, 2011
    • Thanks! See ya out there.Tuesday, February 8, 2011
    • MIA: ReturnTuesday, February 8, 2011
    • MIA: =Tuesday, February 8, 2011