petitparser / dart-petitparser

Dynamic parser combinators in Dart.
https://pub.dartlang.org/packages/petitparser
MIT License
457 stars 48 forks source link

Smalltalk parser seems to have some issues #78

Closed xmehaut closed 4 years ago

xmehaut commented 4 years ago

Hello, I'm experimenting with the smalltalk parser, and I experienced issues with some configurations involving blocks as follows (dummy example): var source = '''exampleWithNumber: x |y z x| y := true & false not & (nil isNil) ifFalse: [self halt]. self size + super size.

( #a "a" 1 1.0)

  do: [:each | Transcript show: (each class name);
                           show: ' '.].

x := y ifTrue:[x := 7] ifFalse:[8 essai]. ^ x < y''' the parser doesn't seems to paser th bold line. But if I write this, its works : var source = '''exampleWithNumber: x |y z x| y := true & false not & (nil isNil) ifFalse: [self halt]. self size + super size.

( #a "a" 1 1.0)

  do: [:each | Transcript show: (each class name);
                           show: ' '.].

(x := 5 ifTrue:[x := 7] ifFalse:[8 essai]). ^ x < y'''

any clues?

renggli commented 4 years ago

Thank you for reporting. Does not seem to have to do with blocks, but assignments. Minimal example I could come up with is the following:

example
  a := 1.
  b := 2
xmehaut commented 4 years ago

Thank for your answer ; it fails also for me. Weird :-( I've tried several changes in the grammar, but not yet found the error.

Le lun. 25 mai 2020 à 13:31, Lukas Renggli notifications@github.com a écrit :

Thank you for reporting. Does not seem to have to do with blocks, but assignments. Minimal example I could come up with is the following:

example super example. x := y negate

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/petitparser/dart-petitparser/issues/78#issuecomment-633526738, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADF7AESNSJDIZX4LGQJTWTRTJJHPANCNFSM4NJMHJ3Q .

renggli commented 4 years ago

I've exported this grammar from Pharo Smalltalk and migrated the unit tests, but other than that it has not seen any use. In Pharo the same grammar was used to successfully parse and recompile the complete image; but maybe something got lost when exporting. Unfortunately I can't run my old images anymore, will have a look later tonight if I can spot an obvious problem.

xmehaut commented 4 years ago

Thanks a lot ; I've personally the Cincom image and the parser is quite different.

Le lun. 25 mai 2020 à 13:58, Lukas Renggli notifications@github.com a écrit :

I've exported this grammar from Pharo Smalltalk and migrated the unit tests, but other than that it has not seen any use. In Pharo the same grammar was used to successfully parse and recompile the complete image; but maybe something got lost when exporting. Unfortunately I can't run my old images anymore, will have a look later tonight if I can spot an obvious problem.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/petitparser/dart-petitparser/issues/78#issuecomment-633536842, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADF7AETLL2T3MPQWUMU7VLRTJMOLANCNFSM4NJMHJ3Q .

xmehaut commented 4 years ago

Thanks renggli ; it was indeed subtile (i don't understand the impact :-() ..

moreover, when i look at the equivalent parser in https://github.com/moosetechnology/PetitParser/blob/development/src/PetitSmalltalk/PPSmalltalkGrammar.class.st, I've seen some changes from the dart one...

best regards

renggli commented 4 years ago

The Dart code was auto-exported from Smalltalk over 7 years ago with this commit: 3a424af29bb8a2bd782dfb824ad485a000abbf83 (the bug was already present there, so there is an issue with the exporter). I have not touched the grammar since, other than to make it work with the latest version of PetitParser in Dart (migrate to using the grammar definition builder). Also I have not touched the original Smalltalk code in over 10 years, so I don't know if any changes were made on the Smalltalk side?

xmehaut commented 4 years ago

Nevertheless thanks for the correction. How did you find the bug?

Envoyé de mon iPhone

Le 25 mai 2020 à 17:06, Lukas Renggli notifications@github.com a écrit :

The Dart code was auto-exported from Smalltalk over 7 years ago with this commit: 3a424af. I have not touched the grammar since, other than to make it work with the latest version of PetitParser in Dart (migrate to using the grammar definition builder). Also I have not touched the original Smalltalk code in over 10 years, so I don't know if any changes were made on the Smalltalk side?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

renggli commented 4 years ago

I looked at the parse trace of the two inputs. There I saw that the statement separating dot was consumed as a binary selector token.

xmehaut commented 4 years ago

Ah thx! Nice to have a trace ; it will be easier :)

Envoyé de mon iPhone

Le 25 mai 2020 à 18:27, Lukas Renggli notifications@github.com a écrit :

I looked at the parse trace of the two inputs. There I saw that the statement separating dot was consumed as a binary selector token.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.