gracelang / language

Design of the Grace language and its libraries
GNU General Public License v2.0
6 stars 1 forks source link

Rules for indentation #167

Closed apblack closed 6 years ago

apblack commented 6 years ago

I have added rules for indentation to the spec. These are (I believe) the rules that are implemented in SmallGrace. I'm in the process of implementing them in minigrace.

I probably should have made this change in a branch, and then issued a pull request. I didn't do so because that process seems to get no comments, and thus makes no progress. Should I have done it anyway?

KimBruce commented 6 years ago

Your rules seem fine — at least until they break one of my programs!

Kim

On Jun 18, 2018, at 4:48 PM, Andrew Black notifications@github.com wrote:

I have added rules for indentation http://web.cecs.pdx.edu/%7Egrace/doc/lang-spec/#layout to the spec. These are (I believe) the rules that are implemented in SmallGrace. I'm in the process of implementing them in minigrace.

I probably should have made this change in a branch, and then issued a pull request. I didn't do so because that process seems to get no comments, and thus makes no progress. Should I have done it anyway?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gracelang/language/issues/167, or mute the thread https://github.com/notifications/unsubscribe-auth/ABuh-gdQT-BIRWWdAiHUnbgU3V6R72VHks5t-DxLgaJpZM4Uso_j.

apblack commented 6 years ago

In writing tests for the layout rules, I found that one was not implemented correctly. This has now been fixed, but as a result some programs that used to compile might now fail.

The test is _js/tests/t006_lexertest.grace. The issue was with continuations. The spec says that

Further physical lines at the same (or greater) indentation are treated as part of the same logical line. The continuation ends either when the indentation decreases, or when the continuation line contains an unmatched brace.

However, decreases in indentation were not being taken as ending the continuation; it went on until the indentation returned to the opening level. So a block of continuation lines could wander all over the page, rather than having a strictly increasing indentation. I still think that the rule as written is correct, but if we decide that insisting on consent or increasing indentation is too strict, we could change the rule.

Note that a separate rule says that, at the end of a continuation,

The indentation must return to that of the line that began ... the continued line ...