[Cuis-dev] No regex in parser

Mariano Montone marianomontone at gmail.com
Tue Sep 24 04:54:45 PDT 2019


Hello,

El 24/9/19 a las 00:16, Casey Ransberger via Cuis-dev escribió:
> First, I should say I’m aware that there are external packages that do regular expressions. I’m interested in how we get by without them. 
> 
> Found myself marveling again tonight that the Smalltalk parsers of the world generally haven’t used them. That really astounded me at first, as I had been raised on lex/flex for lexical analysis. Later I learned about parsing expression grammars and saw those used for both scanning and parsing.
> 
> I still don’t know how to write a scanner without either of those tools, I’m afraid. I’m also honestly not terribly familiar with how the various Smalltalks go about this.
> 
> For context: I’ve run across a case where I want to build a scanner in a language that lacks any regular expression support at all, and thought I might look to Cuis for a good example of how to go about it. Sorry that this is only tangentially on-topic.
> 
> Questions: 
> 
> * What classes / methods should I look at to see the magic?

Smalltalk uses all sorts of magic in different areas, but I don't think
there's anything special about how it handles parsing. The Scanner and
Parser classes are implemented manually.
> 
> * Is there a formal name for the kind of pattern matching that Cuis does when tokenizing input? Asking because I’d like to track down research papers as a matter of habit.

If you are willing to reasearch, then I would look at Parsing Expression
Grammars. Smalltalk implemention of PEGs is PetitParser from Lukas
Renggli. PetitParser combines PEGs with a combinators api; it is
somewhat special, not easily found in other programming languages. The
PetitParser package for Cuis works very nicely. And this is cool
Smalltalk stuff using them: http://scg.unibe.ch/research/helvetia

Cheers,

Mariano


More information about the Cuis-dev mailing list