-- ==========================================================--
-- === end                                       Lexer.hs ===--
-- ==========================================================--

-- ==========================================================--
-- === Keyword spotting, and offside rule implementation  ===--
-- ===                                          Layout.hs ===--
-- ==========================================================--

--module Layout

-- ==========================================================--
--
laKeyword :: Token -> Token

laKeyword (l, n, what, text) 
   = let
        f Lvarop "="      = Lequals
        f Lvarop "|"      = Lbar
        f Lvarop "\\"     = Lslash

        f Lvar "module"   = Lmodule
        f Lvar "infix"    = Linfix
        f Lvar "infixl"   = Linfixl
        f Lvar "infixr"   = Linfixr
        f Lvar "ext"      = Lext
        f Lvar "data"     = Ldata
        f Lvar "if"       = Lif
        f Lvar "then"     = Lthen
        f Lvar "else"     = Lelse
        f Lvar "let"      = Llet
        f Lvar "in"       = Lin
        f Lvar "case"     = Lcase
        f Lvar "of"       = Lof
        f Lvar "where"    = Lwhere

        f item words      = item
        
     in
         (l, n, f what text, text)
laKeyword :: Token -> Token
laKeyword (l, n, what, text) 
   = let
        f Lvarop "="      = Lequals
        f Lvarop "|"      = Lbar
        f Lvarop "\\"     = Lslash

        f Lvar "module"   = Lmodule
        f Lvar "infix"    = Linfix
        f Lvar "infixl"   = Linfixl
        f Lvar "infixr"   = Linfixr
        f Lvar "ext"      = Lext
        f Lvar "data"     = Ldata
        f Lvar "if"       = Lif
        f Lvar "then"     = Lthen
        f Lvar "else"     = Lelse
        f Lvar "let"      = Llet
        f Lvar "in"       = Lin
        f Lvar "case"     = Lcase
        f Lvar "of"       = Lof
        f Lvar "where"    = Lwhere

        f item words      = item
        
     in
         (l, n, f what text, text)
laKeyword (l, n, what, text) 
   = let
        f Lvarop "="      = Lequals
        f Lvarop "|"      = Lbar
        f Lvarop "\\"     = Lslash

        f Lvar "module"   = Lmodule
        f Lvar "infix"    = Linfix
        f Lvar "infixl"   = Linfixl
        f Lvar "infixr"   = Linfixr
        f Lvar "ext"      = Lext
        f Lvar "data"     = Ldata
        f Lvar "if"       = Lif
        f Lvar "then"     = Lthen
        f Lvar "else"     = Lelse
        f Lvar "let"      = Llet
        f Lvar "in"       = Lin
        f Lvar "case"     = Lcase
        f Lvar "of"       = Lof
        f Lvar "where"    = Lwhere

        f item words      = item
        
     in
         (l, n, f what text, text)