Your SlideShare is downloading. ×
0
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Dynamic grammars
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Dynamic grammars

637

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
637
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  1. Dynamic Grammars Lukas Renggli, Stéphane Ducasse, Tudor Gîrba, Oscar Nierstrasz
  2. grammar a set of rules governing what strings are valid or allowable in a [formal] language. [Adapted from The New Oxford American Dictionary on Grammar]
  3. 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]
  4. Dynamic Grammars Dynamic Languages ‣ Late-bound behavior ‣ First-class representation ‣ On-the-fly transformation ‣ Introspection and reflection
  5. Why would we want that?
  6. Language and Tool Extensions Language Boxes Host Environment
  7. Language and Tool Extensions Language Boxes Grammars Dynamic Host Environment
  8. Language * Change Language * Language Box Concern * * Language Scope
  9. Language Change = δ Host Language Grammar
  10. Language Grammar = Change Transformation
  11. 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 ]
  12. ✖ 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 ]
  13. #( #[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] )
  14. ✖ #( #[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] )
  15. ID ::= letter { letter | digit } ; a..z a..z 0..9
  16. id := #letter , (#letter / #digit) star sequence letter star choice letter digit
  17. id := #letter asParser , (#letter asParser / #digit asParser) star sequence letter star choice letter digit
  18. Scannerless Parser
  19. Parsing Expression Grammar
  20. Packrat Parser
  21. Parser Combinator
  22. Grammar Transformation
  23. Graph Rewriting
  24. #letter → #letter / $_ sequence letter star choice letter digit
  25. #letter → #letter / $_ sequence choice star letter _ choice choice digit letter _
  26. Optimizations
  27. (`a / `b) / `c → `a / `b / `c sequence choice star letter _ choice choice digit letter _
  28. (`a / `b) / `c → `a / `b / `c sequence choice star letter _ choice letter _ digit
  29. (`a / `b) / `c → `a / `b / `c in general sequence a graph choice star letter _ choice letter _ digit
  30. Conflicts?
  31. SELECT * FROM users
  32. |r| r := SELECT * FROM users . ^ User fromRow: r
  33. expr | sql
  34. <SQL: SELECT * FROM users>
  35. ordered expr / sql
  36. No Conflicts
  37. No Ambiguities
  38. surprise expr / sql
  39. surprise sql / expr
  40. !expr sql / !sql expr expr | sql
  41. !expr sql / !sql expr / ui expr $ sql

×