Merge pull request #25 from yihuang/fix-regex

add regex to filter comment lines
This commit is contained in:
adisbladis 2022-01-10 20:29:16 +12:00 committed by GitHub
commit fc5adcc530
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,17 +10,15 @@ let
stripLines = initialLines: foldl' (acc: f: f acc) initialLines [
# Strip comments
(lines: map
(l:
let
m = match "(.*)( )?//.*" l;
hasComment = m != null;
in
stripStr (if hasComment then elemAt m 0 else l))
(l: stripStr (elemAt (splitString "//" l) 0))
lines)
# Strip leading tabs characters
(lines: map (l: elemAt (match "(\t)?(.*)" l) 1) lines)
# Strip comment lines
(filter (l: match "[ \t]*//.*" l != null))
# Filter empty lines
(filter (l: l != ""))
];