Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ラムダ計算に基づいた純粋関数型言語の実装 ~パーサーコンビネータを使ってみる~ #Te...
Search
Livesense Inc.
PRO
April 23, 2014
Technology
0
230
ラムダ計算に基づいた純粋関数型言語の実装 ~パーサーコンビネータを使ってみる~ #TechLunch
2011/05/18(水) @ Livesense TechLunch
発表者:塩足 拓也
Livesense Inc.
PRO
April 23, 2014
Tweet
Share
More Decks by Livesense Inc.
See All by Livesense Inc.
27新卒_総合職採用_会社説明資料
livesense
PRO
0
1.4k
27新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
0
5.1k
株式会社リブセンス・転職会議 採用候補者様向け資料
livesense
PRO
0
130
株式会社リブセンス 会社説明資料(報道関係者様向け)
livesense
PRO
0
1.6k
データ基盤の負債解消のためのリプレイス
livesense
PRO
0
510
26新卒_総合職採用_会社説明資料
livesense
PRO
0
12k
株式会社リブセンス会社紹介資料 / Invent the next common.
livesense
PRO
2
47k
26新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
1
13k
中途セールス職_会社説明資料
livesense
PRO
0
280
Other Decks in Technology
See All in Technology
ブロックテーマとこれからの WordPress サイト制作 / Toyama WordPress Meetup Vol.81
torounit
0
570
寫了幾年 Code,然後呢?軟體工程師必須重新認識的 DevOps
cheng_wei_chen
1
1.4k
regrowth_tokyo_2025_securityagent
hiashisan
0
230
大企業でもできる!ボトムアップで拡大させるプラットフォームの作り方
findy_eventslides
1
760
mairuでつくるクレデンシャルレス開発環境 / Credential-less development environment using Mailru
mirakui
2
280
手動から自動へ、そしてその先へ
moritamasami
0
300
[CMU-DB-2025FALL] Apache Fluss - A Streaming Storage for Real-Time Lakehouse
jark
0
120
Ruby で作る大規模イベントネットワーク構築・運用支援システム TTDB
taketo1113
1
280
re:Invent 2025 ふりかえり 生成AI版
takaakikakei
1
200
Snowflakeでデータ基盤を もう一度作り直すなら / rebuilding-data-platform-with-snowflake
pei0804
4
1.4k
WordPress は終わったのか ~今のWordPress の制作手法ってなにがあんねん?~ / Is WordPress Over? How We Build with WordPress Today
tbshiki
1
730
Karate+Database RiderによるAPI自動テスト導入工数をCline+GitLab MCPを使って2割削減を目指す! / 20251206 Kazuki Takahashi
shift_evolve
PRO
1
730
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.7k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Statistics for Hackers
jakevdp
799
230k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Facilitating Awesome Meetings
lara
57
6.7k
Embracing the Ebb and Flow
colly
88
4.9k
RailsConf 2023
tenderlove
30
1.3k
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
Practical Orchestrator
shlominoach
190
11k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Transcript
ラムダ計算に基づいた純粋関数型 言語の実装 2011/05/18 Takuya Shiotari ~パーサーコンビネータを使ってみる~
AGENDA ¢ Abstrac,on ¢ Design policy ¢ Programming
Language & Compiler ¢ Func,onal Language ¢ What’s Lambda calculus? ¢ Parser Combinator ¢ rparsec
ABSTRACTION 動機 目的 ラムダ計算に基づいたプログラミング言語の設計・実装を行う なんか関数型言語って流行っぽい… んで、その関数型言語でパーサーコンビネータってのがおもろいらしい… おっしゃー!やってみるか!! やるんだったら言語作りたいよね でも、あんまり実用的な言語意識しすぎると設計で終わっちゃいそうだなぁ…
じゃ、超シンプルな言語仕様で実装しよう!!!!
DESIGN POLICY ¢ 実装言語はRuby ¢ インタプリタとして実装 ¢ 実装を単純化するためにIO等は実装しない
¢ パフォーマンスは一切考えない ¢ 文法はLisp-‐Like ¢ Scanner/ParserはParser Combinatorで実装する
PROGRAMMING LANGUAGE & COMPILER 別紙
FUNCTIONAL LANGUAGE 純粋関数型言語 ¢ Haskell、Concurrent Clean、Miranda
非純粋関数型言語 ¢ ML、Lisp、Scheme、OCaml、F# ラムダ計算の概念に基づいたプログラミング言語 特徴 第一級関数(First class func,on) 副作用(side effects)なし カリー化(carrying) 遅延評価(lazy evalua,on) 代表的な言語
関数の定義と実行を抽象化した計算モデル WHAT’S LAMBDA CALCULUS? <expr> ::= <iden,fier>
| (“λ” <iden,fier> “.” <expr>) | (<expr> <expr>) 例 f(x) = x + 1 λ.x x+1 変数 ラムダ抽象 関数適用 ラムダ抽象 f(2) (λ.x x+1) 2 関数適用
PARSER COMBINATOR ¢ 最近流行のトップダウン構文解析 ¢ 基本的なアイデアはパーサを結合子で合成して複雑な パーサを生成 ¢
BNFからコードに落とし込むのが簡単 ¢ 実装と文法定義で言語にギャップレス ¢ ScannerとParserでギャップレス
RPARSEC require 'rubygems' require 'rparsec' include RParsec::Parsers
eol = string ?\n quoted_char = not_char(?") | string('""') >> value(?") quoted_cell = char(?") >> quoted_char.many.bind { |s| value(s.join('')) } << char(?") cell = quoted_cell | regexp(/[^,"\n]*/) line = cell.separated(char(?,)) csv_file = (line << eol).many csvパーサ
RPARSEC require 'rubygems' require 'rparsec' include RParsec::Parsers
include RParsec::Functors ops = RParsec::OperatorTable.new do |tbl| tbl.infixl(string(?+) >> Plus, 10) tbl.infixl(string(?-‐) >> Minus, 10) tbl.infixl(string(?*) >> Mul, 20) tbl.infixl(string(?/) >> Div, 20) tbl.prefix(string(?-‐) >> Neg, 50) end expr = nil term = integer.map(&To_i) | string(?() >> lazy { expr } << string(?)) delim = whitespace.many_ expr = delim >> RParsec::Expressions.build(term, ops, delim) calc
次回予告 ¢ ラムダ計算の実装 ¢ ラムダ式を用いて自然数を定義(チャーチ数) 0 := λf x.
x 1 := λf x. f x 2 := λf x. f (f x) 3 := λf x. f (f (f x))