pharo icon indicating copy to clipboard operation
pharo copied to clipboard

Parse expression should never return a sequence node

Open guillep opened this issue 5 years ago • 3 comments

Describe the bug

RBParser >> parseExpression: could return a sequence node.

To Reproduce

RBParser parseExpression: '
  1+2.
  2+3.'

Expected behavior An error

Version information: Pharo 9.0.0 Build information: Pharo-9.0.0+build.634.sha.658326a3eb4f26b45dc0efe988aa945d5470876b (64 Bit)

guillep avatar Sep 02 '20 12:09 guillep

I think this is because for a "Doit" or "PrintIt" you actually can select multiple lines (more than an expression).

This is parsed with parseExpression:,

I guess this is why the ST80 Compiler used "parse without method pattern" as a terminology... (see #noPattern:)

MarcusDenker avatar Sep 08 '20 12:09 MarcusDenker

Not sure if it's a bug. Bad terminology at most.

"Expression" seems to be user rather broadly in Pharo as any piece of code you might execute or expect a value. This could be a contamination from languages where sequences of expressions are also expressions. What was the context where you wanted a real expression and not a sequence (if you remember)?

To add to the confusion, the parser also offers a parseDoIt that injects a synthetic return node at the last statement. parseDoIt seems to be the one used for DoIt or PrintIt and for OpalCompiler#>>evaluate:

The terminology "noPattern" is so much bad that it might underflow.

Calypso, Rubric and Spec2-Code seems to use the terminology isScripting (only in a boolean form?). That is not that bad. But I'm not sure if it is worth the hassle to rename for the sake of renaming, but it could be an opportunity in case there is an unrelated API change.

privat avatar Mar 14 '23 12:03 privat

I get a "RBSequenceNode(1 + 2. 2 + 3)"

So this could be closed (or renamed)?

hernanmd avatar Jan 31 '24 10:01 hernanmd