#!/usr/bin/env runhaskell -- | -- Module : $Header$ -- Copyright : (c) 2013-2014 Galois, Inc. -- License : BSD3 -- Maintainer : cryptol@galois.com -- Stability : provisional -- Portability : portable import Cryptol.Parser.Lexer import Cryptol.Utils.PP main :: IO () main = interact (wrap . concat . map toHTML . fst . primLexer defaultConfig) wrap :: String -> String wrap txt = "
" ++ sty ++ "" ++ txt ++ "" toHTML :: Located Token -> String toHTML tok = "" ++ concatMap esc (tokenText (thing tok)) ++ "" where pos = show (pp (srcRange tok)) ++ " " ++ show (tokenType (thing tok)) cl = case tokenType (thing tok) of Num {} -> "number" Ident {} -> "identifier" KW {} -> "keyword" Op {} -> "operator" Sym {} -> "symbol" Virt {} -> "virtual" White Space -> "white" White _ -> "comment" Err {} -> "error" EOF -> "eof" StrLit {} -> "text" ChrLit {} -> "text" esc c = case c of '<' -> "<" '>' -> ">" '&' -> "&" ' ' -> " " '\n' -> "