projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
259cb7d
)
Tweak alternative layout rule
author
Ian Lynagh
<igloo@earth.li>
Wed, 25 Nov 2009 19:38:54 +0000
(19:38 +0000)
committer
Ian Lynagh
<igloo@earth.li>
Wed, 25 Nov 2009 19:38:54 +0000
(19:38 +0000)
compiler/parser/Lexer.x
patch
|
blob
|
history
diff --git
a/compiler/parser/Lexer.x
b/compiler/parser/Lexer.x
index
2c98f22
..
00926bd
100644
(file)
--- a/
compiler/parser/Lexer.x
+++ b/
compiler/parser/Lexer.x
@@
-1998,6
+1998,15
@@
alternativeLayoutRuleToken t
setALRContext (ALRLayout expectingOCurly thisCol : context)
setNextToken t
return (L thisLoc ITocurly)
setALRContext (ALRLayout expectingOCurly thisCol : context)
setNextToken t
return (L thisLoc ITocurly)
+ -- We do the [] cases earlier than in the spec, as we
+ -- have an actual EOF token
+ (ITeof, ALRLayout _ _ : ls, _) ->
+ do setALRContext ls
+ setNextToken t
+ return (L thisLoc ITccurly)
+ (ITeof, _, _) ->
+ return t
+ -- the other ITeof case omitted; general case below covers it
(ITin, ALRLayout ALRLayoutLet _ : ls, _)
| newLine ->
do setPendingImplicitTokens [t]
(ITin, ALRLayout ALRLayoutLet _ : ls, _)
| newLine ->
do setPendingImplicitTokens [t]
@@
-2014,7
+2023,8
@@
alternativeLayoutRuleToken t
f ls' = ([], ls')
case f ls of
(t' : ts, ls') ->
f ls' = ([], ls')
case f ls of
(t' : ts, ls') ->
- do setPendingImplicitTokens ts
+ do setALRContext ls'
+ setPendingImplicitTokens ts
setNextToken t
return t'
_ -> panic "Layout rule: [] when considering newline"
setNextToken t
return t'
_ -> panic "Layout rule: [] when considering newline"
@@
-2055,13
+2065,6
@@
alternativeLayoutRuleToken t
setPendingImplicitTokens [t]
return (L thisLoc ITccurly)
-- the other ITwhere case omitted; general case below covers it
setPendingImplicitTokens [t]
return (L thisLoc ITccurly)
-- the other ITwhere case omitted; general case below covers it
- -- The first [] case comes before the general case, as we
- -- have an actual EOF token
- (ITeof, ALRLayout _ _ : ls, _) ->
- do setALRContext ls
- setNextToken t
- return (L thisLoc ITccurly)
- -- the other ITeof case omitted; general case below covers it
(_, _, _) -> return t
isALRopen :: Token -> Bool
(_, _, _) -> return t
isALRopen :: Token -> Bool