#4316: Getting the lexer state to check for "AlternativeLayoutMode"

Vivian McPhail haskell.vivian.mcphail at gmail.com
Mon Oct 18 00:53:38 EDT 2010


On 18 October 2010 15:37, Vivian McPhail
<haskell.vivian.mcphail at gmail.com>wrote:

> Hi,
>
> In attempting to use the lexer to see whether we are within an alternative
> layout context:
>
> [..]

>
> I have a function which tells us if there is layout going on:
>
> activeContext :: P Bool
> activeContext = do
>   ctxt <- getALRContext
>   expc <- getAlrExpectingOCurly
>   impt <- implicitTokenPending
>   case (ctxt,expc) of
>     ([],Nothing) -> return impt
>     _other       -> return True
>
>
Okay, this function is doing the right thing.  I also tried counting curly
brackets, which also doesn't work for the same reason:

In "AlternativeLayoutMode," when an EOF is encountered and there is an
outstanding context, the context is removed  and a closing curly is inserted

             (ITeof, ALRLayout _ _ : ls, _) ->
                 do setALRContext ls
                    setNextToken t
                    return (L thisLoc ITccurly)

So as it stands, if we simply lex the ghci command line, we will never be
inside a layout context once we see the EOF token.

Vivian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-bugs/attachments/20101017/44349322/attachment.html


More information about the Glasgow-haskell-bugs mailing list