fixed multiline

This commit is contained in:
Armin Friedl 2016-08-29 14:43:13 +02:00
parent acf48765ff
commit 077b5a3f37

View file

@ -228,16 +228,30 @@ getReads i s@(c:ss)
where v = getRead i s where v = getRead i s
getWrite :: Int -> String -> Maybe (String, Slice, Bool) getWrite :: Int -> String -> Maybe (String, Slice, Bool)
getWrite offset s = ((Tdfa.matchOnceText §~ "^(\\**[[:word:]]+)[[:blank:]]*=") s) >>= matchToA getWrite offset s = ((Tdfa.matchOnceText regex) s) >>= matchToA
where matchToA (before, match, after) = where matchToA (before, match, after) =
let m = match ! 1 -- extract the match group (0 = the whole match) let m = match ! 1 -- extract the match group (0 = the whole match)
in Just (fst m, (offset+(fst (snd m)), offset+(length (fst m))), False) in Just (fst m, (offset+(fst (snd m)), offset+(length (fst m))), False)
regex = Tdfa.makeRegexOpts compOpt Tdfa.defaultExecOpt "^(\\**[[:word:]]+)[[:blank:]]*="
compOpt = Tdfa.CompOption { Tdfa.caseSensitive = True
, Tdfa.multiline = False
, Tdfa.rightAssoc = True
, Tdfa.newSyntax = True
, Tdfa.lastStarGreedy = False
}
getRead :: Int -> String -> Maybe (String, Slice) getRead :: Int -> String -> Maybe (String, Slice)
getRead offset s = ((Tdfa.matchOnceText §~ "^(\\**[[:word:]]+)") s) >>= matchToString getRead offset s = ((Tdfa.matchOnceText regex) s) >>= matchToString
where matchToString (before, match, after) = where matchToString (before, match, after) =
let m = match ! 1 -- extract the match group (0 = the whole match) let m = match ! 1 -- extract the match group (0 = the whole match)
in Just (fst m, (offset+(fst (snd m)), offset+(length (fst m)))) in Just (fst m, (offset+(fst (snd m)), offset+(length (fst m))))
regex = Tdfa.makeRegexOpts compOpt Tdfa.defaultExecOpt "^(\\**[[:word:]]+)"
compOpt = Tdfa.CompOption { Tdfa.caseSensitive = True
, Tdfa.multiline = False
, Tdfa.rightAssoc = True
, Tdfa.newSyntax = True
, Tdfa.lastStarGreedy = False
}
isUnassigned :: (String,Slice) -> [(String,Slice,Bool)] -> Bool isUnassigned :: (String,Slice) -> [(String,Slice,Bool)] -> Bool
isUnassigned (s,_) = null . filter (\(t,_,_) -> t == s) isUnassigned (s,_) = null . filter (\(t,_,_) -> t == s)