How do i better understand how SmaCC uses the 'isMethod' functionality in regular expressions?

67 views Asked by At

The 'isMethod' support in SmaCC regular expressions isn't clear to me.

These two sources essentially say the same thing

<isMethod>  Copies the characters where Character>>isMethod returns true into 
the current regular expression. For example, instead of using \d, we could use 
<isDigit> since Character>>isDigit returns true for digits. 

There isn't much to go on, so I have a few questions:

  • Does this mean I can use isWhitespace, isNotWhitespace etc. ? (How do I know the names?)
  • Does this mean I can use my own tokens? (like isVariable, isMultiLineComment if I define these?)
  • Are there some good places for me to better understand this?

Thanks for your time

2

There are 2 answers

1
Sean DeNigris On BEST ANSWER

The comment could admittedly be a little clearer, but starting from its example - #isDigit - there is only one implementor in the image: Character. Thus, the likely meaning is that you can put any message which Character understands between the brackets.

To answer your specific questions:

  • You can't use #isWhitespace because there is no such message, but #isSeparator seems to do that

  • You learn the available names by exploring Character e.g. in the browser.

  • Yes, you can use your own tokens by implementing them in Character (or its superclasses)

  • As @Stephan Eggermont suggested, GT's Discord is a good place to ask. Pharo MLs and Discord are generally helpful, and a question like this would likely easily be answered there, but as you dive deeper into Smacc, you'll find fewer experts and the GT community currently uses Smacc heavily.

0
Stephan Eggermont On

The GToolkit Discord is a better place for this question, as one of the original authors hangs out there