Rockit Jason Morrison Language Processors and Compiler Construction Winter 2006-3
Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>I...
It used to be GLR <ul><ul><li>First home I found: </li></ul></ul><ul><ul><ul><li>http://rockit.sourceforge.net/ </li></ul>...
Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>I...
Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><ul><li>What’s that? </li></ul></ul><ul><li>Maybe in the fu...
What’s GLR? <ul><ul><li>Generalized LR </li></ul></ul><ul><ul><li>Parse tables have multiple transitions </li></ul></ul><u...
How well does it work? <ul><ul><li>Run time scales with degree of nondeterminism. </li></ul></ul><ul><ul><li>O(n) on deter...
Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>I...
Maybe in the future it will be PEG. <ul><ul><li>Rockit 0.8.0 </li></ul></ul><ul><ul><li>C-based parser, Ruby production ru...
Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><ul><...
What’s PEG? <ul><li>“Parsing Expression Grammar” </li></ul><ul><li>No separate tokenizing phase </li></ul><ul><li>Unambigu...
What’s PEG? <ul><li>Fixes “dangling else” via prioritization </li></ul><ul><li>Infinite lookahead via syntactic predicates...
What’s Packrat? <ul><li>Essentially: recursive descent </li></ul><ul><li>Memoization yields O(n) with unlimited lookahead ...
Packrat: Since when? <ul><li>Theory has been formalized since the 70s </li></ul><ul><li>Memoization was too heavy, then. <...
Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>I...
Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>I...
Rockit 0.7.2 <ul><ul><li>Newest available </li></ul></ul><ul><ul><li>Deemed 0.8.0 preview </li></ul></ul><ul><ul><li>Pure ...
Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>I...
Rockit 0.7.2 <ul><li>Arithmetic expression example </li></ul>
Conclusion <ul><li>0.7.2 is interesting, but doesn’t have: </li></ul><ul><ul><li>Syntactic predicates </li></ul></ul><ul><...
Resources <ul><li>These slides and I: </li></ul><ul><ul><li>http:// jayunit.net/rockit </li></ul></ul><ul><ul><li>jason.p....
Upcoming SlideShare
Loading in …5
×

Rockit: A Parser Generator for Ruby

4,224
-1

Published on

Discusses Rockit, a parser generator for the Ruby langauge. Touches on versions 0.3.8 and 0.7.2, which are GLR and PEG, respectively. Describes GLR and PEG. Given for http://www.cs.rit.edu/~ats/lp-2006-2/

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

No Downloads
Views
Total Views
4,224
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
23
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Rockit: A Parser Generator for Ruby

  1. 1. Rockit Jason Morrison Language Processors and Compiler Construction Winter 2006-3
  2. 2. Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>It’s kind of there. </li></ul><ul><li>Let’s see! </li></ul>
  3. 3. It used to be GLR <ul><ul><li>First home I found: </li></ul></ul><ul><ul><ul><li>http://rockit.sourceforge.net/ </li></ul></ul></ul><ul><ul><li>Version 0.3.8, updated October 2001 </li></ul></ul><ul><ul><li>What did it look like? </li></ul></ul>
  4. 4. Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>It’s kind of there. </li></ul><ul><li>Let’s see! </li></ul>
  5. 5. Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><ul><li>What’s that? </li></ul></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>It’s kind of there. </li></ul><ul><li>Let’s see! </li></ul>
  6. 6. What’s GLR? <ul><ul><li>Generalized LR </li></ul></ul><ul><ul><li>Parse tables have multiple transitions </li></ul></ul><ul><ul><li>When it hits S/R or R/R conflict: </li></ul></ul><ul><ul><ul><li>Fork parse stack </li></ul></ul></ul><ul><ul><ul><li>Follow both paths </li></ul></ul></ul><ul><ul><ul><li>Got a rule that produces no transition? Discard that stack. </li></ul></ul></ul>
  7. 7. How well does it work? <ul><ul><li>Run time scales with degree of nondeterminism. </li></ul></ul><ul><ul><li>O(n) on deterministic grammar. </li></ul></ul><ul><ul><li>Optimize: share common stack prefix/suffix. (Leads to a state lattice rather than stack) </li></ul></ul>
  8. 8. Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>It’s kind of there. </li></ul><ul><li>Let’s see! </li></ul>
  9. 9. Maybe in the future it will be PEG. <ul><ul><li>Rockit 0.8.0 </li></ul></ul><ul><ul><li>C-based parser, Ruby production rules </li></ul></ul><ul><ul><li>Unambiguous,  lookahead, O(n) Packrat parsing </li></ul></ul><ul><ul><li>Ruby and Java grammars, analyzers, pretty-printers </li></ul></ul>
  10. 10. Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><ul><li>… PEG? Packrat? </li></ul></ul><ul><li>It’s kind of there. </li></ul><ul><li>Let’s see! </li></ul>
  11. 11. What’s PEG? <ul><li>“Parsing Expression Grammar” </li></ul><ul><li>No separate tokenizing phase </li></ul><ul><li>Unambiguous (one tree for valid parse) </li></ul><ul><li>No left recursion (as with LL) </li></ul>
  12. 12. What’s PEG? <ul><li>Fixes “dangling else” via prioritization </li></ul><ul><li>Infinite lookahead via syntactic predicates </li></ul><ul><li>Let’s hear it from B ryan Ford (coined PEG) </li></ul>http://www.bford.info/pub/lang/peg-slides.pdf
  13. 13. What’s Packrat? <ul><li>Essentially: recursive descent </li></ul><ul><li>Memoization yields O(n) with unlimited lookahead and backtracking </li></ul><ul><li>Packrat parsers: </li></ul><ul><ul><li>Java: Rats! (from xtc, eXTensible C project) </li></ul></ul><ul><ul><li>Haskell: Pappy </li></ul></ul>
  14. 14. Packrat: Since when? <ul><li>Theory has been formalized since the 70s </li></ul><ul><li>Memoization was too heavy, then. </li></ul><ul><li>Now, RAM is cheap; memoization often consumes less than subsequent compilation steps. </li></ul>
  15. 15. Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>It’s kind of there. </li></ul><ul><li>Let’s see! </li></ul>
  16. 16. Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>It’s kind of there. </li></ul><ul><ul><li>What do you mean by that? </li></ul></ul><ul><li>Let’s see! </li></ul>
  17. 17. Rockit 0.7.2 <ul><ul><li>Newest available </li></ul></ul><ul><ul><li>Deemed 0.8.0 preview </li></ul></ul><ul><ul><li>Pure Ruby (=> slow) recursive-descent parser </li></ul></ul><ul><ul><li>Does not support syntactic predicates </li></ul></ul><ul><ul><li>Examples are only documentation </li></ul></ul><ul><ul><li>Unorganized source </li></ul></ul><ul><ul><li>No error hooks </li></ul></ul>
  18. 18. Ruby Rockit: Overview <ul><li>It used to be GLR. </li></ul><ul><li>Maybe in the future it will be PEG. </li></ul><ul><li>It’s kind of there. </li></ul><ul><li>Let’s see! </li></ul><ul><ul><li>Let’s see it anyways! </li></ul></ul>
  19. 19. Rockit 0.7.2 <ul><li>Arithmetic expression example </li></ul>
  20. 20. Conclusion <ul><li>0.7.2 is interesting, but doesn’t have: </li></ul><ul><ul><li>Syntactic predicates </li></ul></ul><ul><ul><li>Memoization </li></ul></ul><ul><li>Still denotes grammar in code. </li></ul><ul><ul><li>Pros: Quick, familiar. </li></ul></ul><ul><ul><li>Cons: Difficult to analyze. </li></ul></ul><ul><li>If 0.8.0 is released as promised, should be great! </li></ul>
  21. 21. Resources <ul><li>These slides and I: </li></ul><ul><ul><li>http:// jayunit.net/rockit </li></ul></ul><ul><ul><li>jason.p.morrison@gmail.com </li></ul></ul><ul><li>PEG ML: </li></ul><ul><ul><li>https:// lists.csail.mit.edu/mailman/listinfo/peg </li></ul></ul><ul><li>Bryan Ford: </li></ul><ul><ul><li>http:// pdos.csail.mit.edu/~baford/packrat </li></ul></ul><ul><li>Wikipedia, Google for: </li></ul><ul><ul><li>GLR parser, PEG grammar, Packrat parser </li></ul></ul>

×