stubs for invalid access

This commit is contained in:
Armin Friedl 2016-08-28 19:24:08 +02:00
parent 76472ca357
commit 7350e8a4cd

View file

@ -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 -}