#4316: Getting the lexer state to check for
"AlternativeLayoutMode"
Simon Marlow
marlowsd at gmail.com
Tue Oct 19 07:52:27 EDT 2010
On 18/10/2010 05:53, Vivian McPhail wrote:
>
>
> On 18 October 2010 15:37, Vivian McPhail
> <haskell.vivian.mcphail at gmail.com
> <mailto: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.
Right, so you need to lex up to the end of the line, but without letting
the lexer see the EOF token, presumably?
Cheers,
Simon
More information about the Glasgow-haskell-bugs
mailing list