From c3f885a5b631427724a88168939c16bbf0b94019 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Mon, 10 Jan 2022 15:52:14 +0800 Subject: [PATCH] fix comments filter --- builder/parser.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/builder/parser.nix b/builder/parser.nix index 88bcffa..feea4f9 100644 --- a/builder/parser.nix +++ b/builder/parser.nix @@ -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 != "")) ];