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
分析AIエージェントを育てる、動く環境を育てる
codatum
1
1.1k
Rust で関数型ドメインモデリング
takonda
0
140
Getting Started with Google Antigravity
glaforge
0
310
DevelopersIO 2026 知識の地図を描く ─ オントロジーとは何か?
ishikawa_satoru
1
1.7k
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
4
1.1k
TinyGoでオブザーバビリティ?OpenTelemetryはTinyGoで使えるのか / Is OpenTelemetry available in TinyGo environment?
ymotongpoo
2
140
hackers_champloo_2026_tidb
makocchi
0
160
AI × アーキテクト 第1・2章|生成AIの課題とアーキテクトの素養
daidaidai
0
170
USB PDを使ってスマホを労わりたい
raspython3
0
180
Rustuna: Rustによる高速なOptuna実装
pfn
PRO
0
190
S3 Filesで挑む! 八戸せんべい汁の食べ頃問題
usanchuu
0
100
アウトプット初心者、半年間のふりかえり
4o1sobblue
0
430
Featured
See All Featured
Practical Orchestrator
shlominoach
192
12k
Faster Mobile Websites
deanohume
310
32k
Technical Leadership for Architectural Decision Making
baasie
3
600
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.7k
Writing Fast Ruby
sferik
630
63k
Typedesign – Prime Four
hannesfritz
42
3.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.3k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
The Invisible Side of Design
smashingmag
301
52k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
570
How to Ace a Technical Interview
jacobian
280
24k
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