Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Dynamic Grammars
Search
Lukas Renggli
October 04, 2011
Technology
62
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Dynamic Grammars
Lukas Renggli
October 04, 2011
More Decks by Lukas Renggli
See All by Lukas Renggli
Domain-Specific Program Checking
renggli
1
41
Natural Language Checking with Program Checking Tools
renggli
1
58
The Dynamic Language is not Enough
renggli
1
60
Dynamic Language Embedding With Homogeneous Tool Support
renggli
1
120
Other Decks in Technology
See All in Technology
Webの常識が通じないHTMLメールのダークモード
teamlab
PRO
0
120
PagerDuty Tech Hub-鳴らすけれど、人は動かない
ezaki
0
170
フロントエンドカンファレンス関西2026 - 速すぎるUIに、待ち時間を
teamlab
PRO
0
130
AI時代のPRレビューにどう向き合うか?
kairim0
1
240
「Docker Desktop不要の時代」は 来たのか?
ueponx
0
770
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
330
事業成長とデータ活用を止めないためのマネジメントへ挑戦
hiracky16
0
390
Temporal 最高!でも改めて「日付」について調べたら人類の負債すぎる件
riyaamemiya
0
150
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
180
Code for Security プロジェクト紹介 2026年10月
yu23ki14
0
110
M5Stackで作る BLEマウス GPSログの世界
tomokusaba
0
420
Metadata - Section 1: HTML Basics
mohab1
0
120
Featured
See All Featured
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
480
Being A Developer After 40
akosma
92
590k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
730
Skip the Path - Find Your Career Trail
mkilby
1
260
Code Review Best Practice
trishagee
74
20k
The Curious Case for Waylosing
cassininazir
1
570
Claude Code のすすめ
schroneko
67
230k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
460
Fireside Chat
paigeccino
43
4.1k
KATA
mclloyd
PRO
35
16k
Transcript
Dynamic Grammars Lukas Renggli, Stéphane Ducasse, Tudor Gîrba, Oscar Nierstrasz
[Adapted from The New Oxford American Dictionary on Grammar] grammar
a set of rules governing what strings are valid or allowable in a [formal] language.
dynamic grammar a high-level grammar that executes at runtime behaviors
that other grammars perform during compilation, see dynamic languages. [Adapted from Wikipedia on Dynamic Programming Languages]
Dynamic Grammars Dynamic Languages ‣ Late-bound behavior ‣ First-class representation
‣ On-the-fly transformation ‣ Introspection and reflection
Why would we want that?
Language Boxes Host Environment Language and Tool Extensions
Language Boxes Host Environment Dynamic Grammars Language and Tool Extensions
Language Change Language Concern Language Scope Language Box * *
* *
Language Change = Host Language Grammar δ
Language Change = Grammar Transformation
scanIdentifier self step. ((currentCharacter between: $A and: $Z) or: [
currentCharacter between: $a and: $z ]) ifTrue: [ [ self recordMatch: #IDENTIFIER. self step. (currentCharacter between: $0 and: $9) or: [ (currentCharacter between: $A and: $Z) or: [ currentCharacter between: $a and: $z ] ] ] whileTrue. ^ self reportLastMatch ]
scanIdentifier self step. ((currentCharacter between: $A and: $Z) or: [
currentCharacter between: $a and: $z ]) ifTrue: [ [ self recordMatch: #IDENTIFIER. self step. (currentCharacter between: $0 and: $9) or: [ (currentCharacter between: $A and: $Z) or: [ currentCharacter between: $a and: $z ] ] ] whileTrue. ^ self reportLastMatch ] ✖
#( #[1 0 9 0 25 0 13 0 34
0 17 0 40 0 21 0 41] #[1 0 9 0 25 0 13 0 34 0 93 0 76 0 157 0 112] #[1 2 38 0 21 2 38 0 25 2 38 0 26 0 13 0 34] #[0 1 154 0 16 0 21 0 25 0 26 0 34 0 40 0 41] #[0 1 210 0 76 0 81] #[0 1 214 0 76 0 81] #[1 0 173 0 76 0 177 0 81] #[0 1 134 0 16 0 21 0 25 0 26 0 34 0 40 0 41] #[1 1 46 0 21 1 46 0 25 1 46 0 26 1 69] #[1 1 54 0 21 1 54 0 25 1 54 0 26 1 54 0 34] #[0 2 102 0 21 0 25 0 26 0 34 0 40 0 41 0 76] #[0 2 50 0 21 0 25 0 26 0 76 0 79] #[1 1 13 0 76 2 85 0 124 1 21 0 125] #[1 2 89 0 17 2 30 0 21 2 30 0 82] #[1 2 93 0 21 2 97 0 82] )
#( #[1 0 9 0 25 0 13 0 34
0 17 0 40 0 21 0 41] #[1 0 9 0 25 0 13 0 34 0 93 0 76 0 157 0 112] #[1 2 38 0 21 2 38 0 25 2 38 0 26 0 13 0 34] #[0 1 154 0 16 0 21 0 25 0 26 0 34 0 40 0 41] #[0 1 210 0 76 0 81] #[0 1 214 0 76 0 81] #[1 0 173 0 76 0 177 0 81] #[0 1 134 0 16 0 21 0 25 0 26 0 34 0 40 0 41] #[1 1 46 0 21 1 46 0 25 1 46 0 26 1 69] #[1 1 54 0 21 1 54 0 25 1 54 0 26 1 54 0 34] #[0 2 102 0 21 0 25 0 26 0 34 0 40 0 41 0 76] #[0 2 50 0 21 0 25 0 26 0 76 0 79] #[1 1 13 0 76 2 85 0 124 1 21 0 125] #[1 2 89 0 17 2 30 0 21 2 30 0 82] #[1 2 93 0 21 2 97 0 82] ) ✖
None
a..z a..z 0..9 ID ::= letter { letter | digit
} ;
letter letter digit sequence choice star id := #letter ,
(#letter / #digit) star
letter letter digit sequence choice star id := #letter asParser
, (#letter asParser / #digit asParser) star
Scannerless Parser
Parsing Expression Grammar
Packrat Parser
Parser Combinator
None
Grammar Transformation
Graph Rewriting
letter letter digit sequence choice star #letter → #letter /
$_
letter digit sequence choice star choice _ letter choice _
#letter → #letter / $_
Optimizations
letter digit sequence choice star choice _ letter choice _
(`a / `b) / `c → `a / `b / `c
letter digit sequence choice star choice _ letter _ (`a
/ `b) / `c → `a / `b / `c
letter digit sequence choice star choice _ letter _ in
general a graph (`a / `b) / `c → `a / `b / `c
Conflicts?
SELECT * FROM users
SELECT * FROM users | r | r := ^
User fromRow: r .
expr sql |
SELECT * FROM users <SQL: >
expr sql / ordered
No Conflicts
No Ambiguities
expr sql / surprise
/ expr sql surprise
expr sql | !expr sql / !sql expr
expr sql $ !expr sql / !sql expr / ui