[Cuis-dev] No regex in parser

Hernan Wilkinson hernan.wilkinson at 10pines.com
Tue Sep 24 01:13:06 PDT 2019


Hi Casey,
 the Smalltalk parser does not use any special regex library. You can see
the Scanner hierarchy to see how it is implemented and the Compiler class
to see how it is used. I think it is a LALR or similar kind of parser with
a two ahead read. Too complicated from my point of view to parse Smalltalk
:-), I think a recursive descendent parser would do the trick, but I
haven't try it.
 If you want to use regex, you can use the String message #match:. It has
some examples in its implementation.
 A nice parser library is PetitParser, it is a powerful
recursive descendent parser, very easy to use. I haven't try it on Cuis.
 The book I learned about parsers and compilers is the famous Aho
book,Compilers: Principles, Techniques, and Tools... a long time ago :-)

Hope it helps
Hernan.


On Tue, Sep 24, 2019 at 12:16 AM Casey Ransberger via Cuis-dev <
cuis-dev at lists.cuis.st> wrote:

> 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?
>
> * 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.
>
> Thanks in advance,
> —Casey Ransberger
>
>
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>


-- 

*Hernán WilkinsonAgile Software Development, Teaching & Coaching*
*Phone: +54-011*-4893-2057
*Twitter: @HernanWilkinson*
*site: http://www.10Pines.com <http://www.10pines.com/>*
Address: Alem 896, Floor 6, Buenos Aires, Argentina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20190924/1adc920d/attachment.htm>


More information about the Cuis-dev mailing list