Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

handle more edge cases

  • Loading branch information...
commit b8fab914975f915adec79542f86ad9b2cdc466e7 1 parent 2083382
@domenkozar authored
Showing with 32 additions and 3 deletions.
  1. +32 −3 bacula.aug
View
35 bacula.aug
@@ -24,13 +24,16 @@ About: Examples
module Bacula =
autoload xfm
- let val = del /"?/ "\"" . store /[a-zA-Z0-9]/ . del /"?;?/ "\""
+ let val = del /"?/ "\"" . store /[^# \t\n"]([^#\n"]*[^;# \t\n"])?/ . del /"?;?/ "\""
+
+ let indent = Util.del_opt_ws "\t"
+ let equal = del /[ \t]*=[ \t]*/ " = "
(* TODO: support whitespace in key name *)
- let line = [ Util.del_ws_tab . key /[a-zA-Z0-9]+/ . del /[ \t]*=[ \t*]/ " = " . val . Util.comment_or_eol ]
+ let line = indent . Build.key_value_line_comment Rx.word equal val Util.comment_eol
(* TODO: support file includes *)
- let content = del /[ \t]*\{/ " {" . Util.comment_or_eol . line . del /[ \t]*\}/ "}"
+ let content = del /[ \t]*\{/ " {" . Util.comment_or_eol . (line)+ . del /[ \t]*\}/ "}"
(* TODO: support nested directives *)
let directive = [ key /[a-zA-Z]+/ . content ]
@@ -46,3 +49,29 @@ module Bacula =
{"Storage"
{"Name" = "kaki-sd"}
}
+
+ test Bacula.lns get "Storage {\n Name = \"kaki sd\"\n}" =
+ {"Storage"
+ {"Name" = "kaki sd"}
+ }
+
+ test Bacula.lns get "Storage {\n Name = kaki-sd;\n}" =
+ {"Storage"
+ {"Name" = "kaki-sd"}
+ }
+
+ test Bacula.lns get "Storage {\n Name = kaki-sd; # just a comment\n}" =
+ {"Storage"
+ {"Name" = "kaki-sd"
+ { "#comment" = "just a comment"}
+ }
+ }
+
+ test Bacula.lns get "Storage {
+ Name = kaki sd
+ Foo = moo
+}" =
+ {"Storage"
+ {"Name" = "kaki sd"}
+ {"Foo" = "moo"}
+ }
Please sign in to comment.
Something went wrong with that request. Please try again.