Nothing Special   »   [go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout: patching of columns leads to misalignment #345

Closed
andreasabel opened this issue Mar 6, 2021 · 0 comments
Closed

Layout: patching of columns leads to misalignment #345

andreasabel opened this issue Mar 6, 2021 · 0 comments
Assignees
Labels
bug Haskell layout Concerning layout (keywords)
Milestone

Comments

@andreasabel
Copy link
Member

The layout mechanism adjust columns of subsequent tokens on the same line when inserting braces and semicolons. This leads to misalignment and subsequent parse errors.
E.g. this parses in haskell but is rejected by the grammar of #344:

f = g + h where g = 3; h = i where i = j
                                   j = 2

Suggested fix: just remove the incrGlobal mechanism, simplifying addToken:

, "-- | Insert a new symbol token at the begninning of a list of tokens."
, "addToken :: Position -- ^ Position of the new token."
, " -> String -- ^ Symbol in the new token."
, " -> [Token] -- ^ The rest of the tokens. These will have their"
, " -- positions updated to make room for the new token."
, " -> [Token]"
, "addToken p s ts = sToken p s : map (incrGlobal p (length s)) ts"

, "-- | Add to the global and column positions of a token."
, "-- The column position is only changed if the token is on"
, "-- the same line as the given position."
, "incrGlobal :: Position -- ^ If the token is on the same line"
, " -- as this position, update the column position."
, " -> Int -- ^ Number of characters to add to the position."
, " -> Token -> Token"
, "incrGlobal (Pn _ l0 _) i (PT (Pn g l c) t) ="
, " if l /= l0 then PT (Pn (g + i) l c) t"
, " else PT (Pn (g + i) l (c + i)) t"
, "incrGlobal _ _ p = error $ \"cannot add token at \" ++ show p"

@andreasabel andreasabel added bug Haskell layout Concerning layout (keywords) labels Mar 6, 2021
@andreasabel andreasabel added this to the 2.9.2 milestone Mar 6, 2021
@andreasabel andreasabel self-assigned this Mar 6, 2021
andreasabel added a commit that referenced this issue Apr 9, 2021
andreasabel added a commit that referenced this issue Apr 9, 2021
moveAlong used 'last', and the abstraction was slightly obstructing
comprehension.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Haskell layout Concerning layout (keywords)
Projects
None yet
Development

No branches or pull requests

1 participant