Question

I am trying to create a module for parsing vim files which are sectioned in a specific manner. A sample file:

" My section {
    set nocompatible            " be iMproved
    set encoding=utf-8
" }
" vim: set foldmarker={,} foldlevel=0 foldmethod=marker:

While writing the module, I've got stuck at this point:

module Vimrc =
    autoload xfm
    let section = del "\" " "\" " . key /[^\n]+/ . del "\n" "\n" . store /.*/ . del "\" " "\" "
    let lns = [ section . del "\n" "\n" ] *
    let filter = (incl "*.vim")
    let xfm = transform lns filter

I'm aware that there are some other mistakes, but it complains about the regex key /[^\n]+/, saying:

/tmp/aug/vimrc.aug:3.36-.48:exception: The key regexp /[^ ]+/ matches a '/'

I do not understand what the / character has got to do with this.

Was it helpful?

Solution

As the error says, your key regexp matches a slash, which is illegal since / is used as a level separator in the tree.

If your section names can contain slashes, you need to store them as a node value, not label, so instead of:

{ "My section"
  { "set" = "nocompatible" { "#comment" = "be iMproved" } } }

you'll have to do:

{ "section" = "My section"
  { "set" = "nocompatible" { "#comment" = "be iMproved" } } }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top