From 7350e8a4cdccae85e99feb2f9658ed3fd2bc7949 Mon Sep 17 00:00:00 2001 From: Armin Friedl Date: Sun, 28 Aug 2016 19:24:08 +0200 Subject: [PATCH] stubs for invalid access --- src/App/Fontifier.hs | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/App/Fontifier.hs b/src/App/Fontifier.hs index 822a213..2b18060 100644 --- a/src/App/Fontifier.hs +++ b/src/App/Fontifier.hs @@ -32,10 +32,6 @@ type Slices = [Slice] type MatchResult = [Tdfa.MatchArray] type CheckString = String type Regex = Tdfa.Regex -data BlockSlice = BS Slice String -data AccessSlice = AS Slice String -type BlockSlices = [BlockSlice] -type AccessSlices = [AccessSlice] {---- Infix Operators ----} @@ -68,9 +64,9 @@ fontMap = [ (attrName "assignment" , fg Vty.blue) , (attrName "string" , fg Vty.cyan) , (attrName "err_brackets" , bg Vty.red) -- unbalanced brackets , (attrName "err_quotes" , Vty.withStyle (fg Vty.red) Vty.underline) -- unbalanced quotes - , (attrName "err_unterm" , Vty.withStyle (fg Vty.red) Vty.underline) -- missing ; - , (attrName "err_read" , Vty.withStyle (fg Vty.red) Vty.underline) -- invalid read + , (attrName "err_read" , Vty.withStyle (fg Vty.yellow) Vty.underline) -- invalid read , (attrName "err_write" , Vty.withStyle (fg Vty.red) Vty.underline) -- invalid write + , (attrName "err_access" , Vty.withStyle (fg Vty.red) Vty.underline) -- invalid access (alternative if easier than invalid read/invalid write separated) ] fontify :: CheckString -> Fontifications @@ -78,9 +74,6 @@ fontify = concatApply [ assignments, strings , returns, guards, comments , mismatchedBrackets , mismatchedQuotes] --- , untermStrings --- , untermAssignments --- , untermReturns concatApply :: [Fontifier] -> CheckString -> Fontifications concatApply [] _ = [] @@ -102,11 +95,13 @@ guards = slicesToFT §: "guard" §. matchGrpStripCmts 1 §~ "\\[([^ {- Custom/Function-Based -} -untermStrings = slicesToFT §: "err_unterm" §. unterm §~ "\"[^%]*\"[^\\;]" -untermAssignments s = slicesToFT §: "err_unterm" §. prune (assignments s) $ (unterm §~ "\\**[^%]+=[^;%]+[^\\;]") s -untermReturns s = slicesToFT §: "err_unterm" §. prune (returns s) $ (unterm §~ "\\^[^;%]+[^\\;]") s +mismatchedBrackets s = concatMap (mismatched §: "err_brackets" $ s) [('(',')'),('[',']'),('{','}')] -mismatchedBrackets s = concatMap (mismatched §: "err_brackets" $ s) [('(',')'),('[',']'),('{','}')] +invalidAccess s = (slicesToFT §: "err_read" $ invalidReads s) ++ + (slicesToFT §: "err_write" $ invalidWrites s) + +-- (alternative if easier than invalid read/invalid write separated) +-- invalidAccess = slicesToFT §: "err_access" $ invAcc {--- Utility Functions ---} @@ -172,6 +167,17 @@ mismatchedQuotes s = slicesToFT §: "err_quotes" $ firstChar untermed | not $ isFontified curSlice checkFts = curSlice: negPrune checkFts slices | otherwise = negPrune checkFts slices +-- ::CheckString -> Slices == ::String -> [(Int,Int)] +invalidReads :: CheckString -> Slices +invalidReads s = [] -- do magic here + +invalidWrites :: CheckString -> Slices +invalidWrites s = [] -- do magic here + +-- (alternative if easier than invalid read/invalid write separated) +-- invAcc :: CheckString -> Slices +-- invAcc s = [] -- do magic here + {- General Fontification Utilities -}