Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ラムダ計算に基づいた純粋関数型言語の実装 ~パーサーコンビネータを使ってみる~ #Te...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Livesense Inc.
PRO
April 23, 2014
Technology
240
0
Share
ラムダ計算に基づいた純粋関数型言語の実装 ~パーサーコンビネータを使ってみる~ #TechLunch
2011/05/18(水) @ Livesense TechLunch
発表者:塩足 拓也
Livesense Inc.
PRO
April 23, 2014
More Decks by Livesense Inc.
See All by Livesense Inc.
28新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
0
55
27新卒_総合職採用_会社説明資料
livesense
PRO
0
4.6k
27新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
0
9k
株式会社リブセンス・転職会議 採用候補者様向け資料
livesense
PRO
0
350
株式会社リブセンス 会社説明資料(報道関係者様向け)
livesense
PRO
1
1.7k
データ基盤の負債解消のためのリプレイス
livesense
PRO
0
600
26新卒_総合職採用_会社説明資料
livesense
PRO
0
13k
株式会社リブセンス会社紹介資料 / Invent the next common.
livesense
PRO
2
63k
26新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
1
13k
Other Decks in Technology
See All in Technology
試作とデモンストレーション / Prototyping and Demonstrations
ks91
PRO
0
190
Oracle Cloud Infrastructure presents managed, serverless MCP Servers for Oracle AI Database
thatjeffsmith
0
110
ServiceによるKubernetes通信制御ーClusterIPを例に
miku01
1
150
生成AIが変える SaaS の競争原理と弁護士ドットコムのプロダクト戦略
bengo4com
1
3.6k
AIが盛んな時代に 技術記事を書き始めて起きた私の中での小さな変化
peintangos
0
360
国内外の生成AIセキュリティの最新動向 & AIガードレール製品「chakoshi」のご紹介 / Latest Trends in Generative AI Security (Domestic & International) & Introduction to AI Guardrail Product "chakoshi"
nttcom
4
2.1k
巨大プラットフォームを進化させる「第3のROI」
recruitengineers
PRO
2
2.5k
新卒エンジニア研修、ハンズオンの設計における課題と実践知/ #tachikawaany
nishiuma
2
130
生成AIはソフトウェア開発の革命か、ソフトウェア工学の宿題再提出なのか -ソフトウェア品質特性の追加提案-
kyonmm
PRO
2
860
AI時代に越境し、 組織を変えるQAスキルの正体 / QA Skills for Transforming an Organization
mii3king
5
4.1k
ファインディの事業拡大を支える 拡張可能なデータ基盤へのリアーキテクチャ
hiracky16
0
930
拝啓、あの夏の僕へ〜あなたも知っているApp Runnerの世界〜
news_it_enj
0
220
Featured
See All Featured
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
Designing for Timeless Needs
cassininazir
0
220
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
110
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.5k
Utilizing Notion as your number one productivity tool
mfonobong
4
300
Odyssey Design
rkendrick25
PRO
2
610
WENDY [Excerpt]
tessaabrams
10
37k
We Have a Design System, Now What?
morganepeng
55
8.1k
Code Reviewing Like a Champion
maltzj
528
40k
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))