-- -*- haskell -*- { {- The Ott website: http://www.cl.cam.ac.uk/~pes20/ott -} {-# OPTIONS -w #-} module Yi.Lexer.Ott ( initState, alexScanToken ) where import Yi.Lexer.Alex import Yi.Style ( Style ( .. ) , StyleName ) import Yi.Style } @reservedid = metavar | indexvar | grammar | embed | subrules | contextrules | substitutions | single | multiple | freevars | defns | defn | by | homs | funs | fun | parsing | left | right @reservedop = "::" | "::=" | "_::" | "<::" | "<=" | "/>" | "//" | " $white+ ; <0> { $white+ ; -- whitespace "%"[^\n]* { c commentStyle } ">>" { m (subtract 1) commentStyle } @reservedid { c keywordStyle } @reservedop { c operatorStyle } "|" $white+ { c operatorStyle } "(+" { m (const bindspec) numberStyle } "{{" { m (const beginHom) stringStyle } . { c defaultStyle } } { ">>" { m (subtract 1) commentStyle } "<<" { m (+1) commentStyle } $white+ ; -- whitespace . { c commentStyle } } { "bind" | "in" | "union" | "{" | "}" { c numberStyle } $white+ ; -- whitespace "+)" { m (const 0) numberStyle } . { c defaultStyle } } { $white+ ; -- whitespace @homid { m (const hom) typeStyle } "}}" { m (const 0) stringStyle } . { m (const hom) defaultStyle } } { "[[" { m (const splice) stringStyle } $white+ ; -- whitespace "}}" { m (const 0) stringStyle } . { c defaultStyle } } { "]]" { m (const hom) stringStyle } $white+ ; -- whitespace . { c defaultStyle } } { type HlState = Int stateToInit x | x < 0 = nestcomm | otherwise = x initState :: HlState initState = 0 type Token = StyleName #include "common.hsinc" }