A Parser
              in my
             Pocket
Martin McClure
ESUG 2010
Once upon a
  time...
Smalltalk PEG-Based Parsers
●   Xstreams PEG parser
●   OMeta
●   PetitParser
●
    ...?
The rest of this talk
●   Grammars, PEGs
●   OMeta2 with Examples
●   Parser Combinators and PetitParser
Context-free grammars
conditional ::=
“if” cond “then” statement
| “if” cond “then” statement “else” statement


Works for...
PEG
                Ordered Choice
conditional =
“if” cond “then” statement “else” statement
| “if” cond “then” statement
...
Example 1

     File Server
Incremental Backup
time ( rsync -aHxi --numeric-ids --delete
--link-dest=/mnt/backup/caboodle1/2010-08-03
/caboodle1/ /mnt/backup/caboodle1/2...
For more information on Ometa:
             http://tinlizzie.org/ometa/
http://tinlizzie.org/~awarth/ometa/ometa2.html
   ...
http://www.lukas-renggli.ch/blog/petitparser-1

http://source.lukas-renggli.ch/petit.html
BNF
ID ::= letter { letter | digit } ;
BNF
ID ::= letter { letter | digit } ;


Ometa2
id = letter (letter | digit)*
BNF
ID ::= letter { letter | digit } ;


Ometa2
id = letter (letter | digit)*


PetitParser
id := #letter asParser ,
   (#...
id := #letter asParser ,
   (#letter asParser / #digit asParser) star
¿     questions   ?
Martin McClure
ESUG 2010
A Parser in my Pocket
A Parser in my Pocket
A Parser in my Pocket
A Parser in my Pocket
A Parser in my Pocket
A Parser in my Pocket
A Parser in my Pocket
A Parser in my Pocket
Upcoming SlideShare
Loading in …5
×

A Parser in my Pocket

972 views
906 views

Published on

Martin McClure: A Parser in my Pocket. ESUG 2010, Barcelona, Spain

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

  • Be the first to like this

No Downloads
Views
Total views
972
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

A Parser in my Pocket

  1. 1. A Parser in my Pocket Martin McClure ESUG 2010
  2. 2. Once upon a time...
  3. 3. Smalltalk PEG-Based Parsers ● Xstreams PEG parser ● OMeta ● PetitParser ● ...?
  4. 4. The rest of this talk ● Grammars, PEGs ● OMeta2 with Examples ● Parser Combinators and PetitParser
  5. 5. Context-free grammars conditional ::= “if” cond “then” statement | “if” cond “then” statement “else” statement Works for generation, but not sufficient for recognition
  6. 6. PEG Ordered Choice conditional = “if” cond “then” statement “else” statement | “if” cond “then” statement Makes recognition unambiguous
  7. 7. Example 1 File Server Incremental Backup
  8. 8. time ( rsync -aHxi --numeric-ids --delete --link-dest=/mnt/backup/caboodle1/2010-08-03 /caboodle1/ /mnt/backup/caboodle1/2010-09-08 )
  9. 9. For more information on Ometa: http://tinlizzie.org/ometa/ http://tinlizzie.org/~awarth/ometa/ometa2.html http://www.squeaksource.com/OMeta/
  10. 10. http://www.lukas-renggli.ch/blog/petitparser-1 http://source.lukas-renggli.ch/petit.html
  11. 11. BNF ID ::= letter { letter | digit } ;
  12. 12. BNF ID ::= letter { letter | digit } ; Ometa2 id = letter (letter | digit)*
  13. 13. BNF ID ::= letter { letter | digit } ; Ometa2 id = letter (letter | digit)* PetitParser id := #letter asParser , (#letter asParser / #digit asParser) star
  14. 14. id := #letter asParser , (#letter asParser / #digit asParser) star
  15. 15. ¿ questions ? Martin McClure ESUG 2010

×