,("→", ITrarrow, unicodeSyntaxEnabled)
,("←", ITlarrow, unicodeSyntaxEnabled)
,("⋯", ITdotdot, unicodeSyntaxEnabled)
+
+ ,("⤙", ITlarrowtail, \i -> unicodeSyntaxEnabled i && arrowsEnabled i)
+ ,("⤚", ITrarrowtail, \i -> unicodeSyntaxEnabled i && arrowsEnabled i)
+ ,("⤛", ITLarrowtail, \i -> unicodeSyntaxEnabled i && arrowsEnabled i)
+ ,("⤜", ITRarrowtail, \i -> unicodeSyntaxEnabled i && arrowsEnabled i)
+
+ ,("★", ITstar, unicodeSyntaxEnabled)
+
-- ToDo: ideally, → and ∷ should be "specials", so that they cannot
-- form part of a large operator. This would let us have a better
-- syntax for kinds: ɑ∷*→* would be a legal kind signature. (maybe).
setNextToken t
lexTokenAlr
(_, ALRLayout _ col : ls, Just expectingOCurly)
- | thisCol > col ->
+ | (thisCol > col) ||
+ (thisCol == col &&
+ isNonDecreasingIntentation expectingOCurly) ->
do setAlrExpectingOCurly Nothing
setALRContext (ALRLayout expectingOCurly thisCol : context)
setNextToken t
do setPendingImplicitTokens [t]
setALRContext ls
return (L thisLoc ITccurly)
- (_, ls@(ALRLayout _ col : _), _)
- | newLine && thisCol <= col ->
- do let f ls'@(ALRLayout _ col' : ls'')
- | thisCol < col' = case f ls'' of
- (ts, ls''') ->
- (L thisLoc ITccurly : ts, ls''')
- | thisCol == col' = ([L thisLoc ITsemi], ls')
- | otherwise = ([], ls')
- f ls' = ([], ls')
- case f ls of
- (t' : ts, ls') ->
- do setALRContext ls'
- setPendingImplicitTokens ts
- setNextToken t
- return t'
- _ -> panic "Layout rule: [] when considering newline"
+ (_, ALRLayout _ col : ls, _)
+ | newLine && thisCol == col ->
+ do setNextToken t
+ return (L thisLoc ITsemi)
+ | newLine && thisCol < col ->
+ do setALRContext ls
+ setNextToken t
+ -- Note that we use lastLoc, as we may need to close
+ -- more layouts, or give a semicolon
+ return (L lastLoc ITccurly)
(u, _, _)
| isALRopen u ->
do setALRContext (ALRNoLayout (containsCommas u) : context)
isALRclose ITcubxparen = True
isALRclose _ = False
+isNonDecreasingIntentation :: ALRLayout -> Bool
+isNonDecreasingIntentation ALRLayoutDo = True
+isNonDecreasingIntentation _ = False
+
containsCommas :: Token -> Bool
containsCommas IToparen = True
containsCommas ITobrack = True