diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2025-07-12 23:14:40 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2025-07-12 23:14:40 +0200 |
| commit | 0866223c2b51cc1eed9b23fe56b1bd2ead9eee54 (patch) | |
| tree | faaf91afb78cb4b4b8015b35860bbec04eea215a /Toks.hs | |
| download | werge-0866223c2b51cc1eed9b23fe56b1bd2ead9eee54.tar.gz werge-0866223c2b51cc1eed9b23fe56b1bd2ead9eee54.tar.bz2 | |
initial somewhat works
Diffstat (limited to 'Toks.hs')
| -rw-r--r-- | Toks.hs | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -0,0 +1,33 @@ +module Toks where + +import Data.Char +import Data.Function +import Data.List + +escape '\\' = "\\\\" +escape '\n' = "\\n" +escape x = pure x + +unescape [] = [] +unescape ('\\':'\\':xs) = '\\' : unescape xs +unescape ('\\':'n':xs) = '\n' : unescape xs +unescape ('\\':_) = error "bad escape?" +unescape (x:xs) = x : unescape xs + +markSpace [] = error "wat" +markSpace s@(c:_) + | isSpace c = '.' : s + | otherwise = '|' : s + +unmarkSpace ('.':s) = s +unmarkSpace ('|':s) = s +unmarkSpace _ = error "wat" + +split = + unlines + . map (concatMap escape . markSpace) + . groupBy ((==) `on` generalCategory) + +glueToks = concatMap (unmarkSpace . unescape) + +glue = glueToks . lines |
