grammarware / software-evolution

Software Evolution
MIT License
1 stars 0 forks source link

least number of "fixes and whitespace insignificance #17

Open guissalustiano opened 5 months ago

guissalustiano commented 5 months ago

In the whitespace insignificance examples on level 2 you say:

assuming that ACCOUNTNUMBER, ACCOUNT-NUMBER, ACCOUNT and NUMBER are all defined fields, MOVE 42 TO ACCOUNT NUM BER. is invalid since whitespace information is not clear enough to disambiguate.

And in issue #2 you say:

the usual way to disambiguate is to look for the least number of "fixes" that the parser needs to do

The two possible ways to parse MOVE 42 TO ACCOUNT NUM BER. that I can think is:

  1. ["MOVE", "42", "TO", "ACCOUNT", "NUMBER"]
  2. ["MOVE", "42", "TO", "ACCOUNT", "NUM", "BER"]

However, we have NUMBER defined, so we can use this to disambiguate for the first way and not raise an error, right?

grammarware commented 5 months ago

My way of reasoning for MOVE 42 TO ACCOUNT NUM BER was that both MOVE 42 TO ACCOUNTNUMBER and MOVE 42 TO ACCOUNT NUMBER are valid interpretations if whitespace is insignificant.

Your way of reasoning is more applicable to something like MOVE 42 TO USER NUM BER, where indeed there is one way to disambiguate, with two "fixes":

  1. Interpret NUM BER as NUMBER since NUMBER is already defined in the DATA DIVISION
  2. Assume USER IS PICTURE XXXX and make it implicitly defined.
guissalustiano commented 5 months ago

That makes much more sense. Thanks!