I've never really tried to use Augeas before yesterday and I've been unable to find lenses for the /etc/auto.master and autofs(5) config files, so I decided to try to write my own.
I've looked at the step by step directions and eventually simplified things by using pre-existing lenses as examples. http://augeas.net/page/Creating_a_lens_step_by_step As a first stab at automaster(5), this is what I've come up with, although it's not complete: module Automaster = autoload xfm let eol = Util.eol let comment = Util.comment let empty = Util.empty let comma = Sep.comma let colon = Sep.colon let sep_spc = Sep.space let word = /[^,:#\n\t ]+/ let record = [ seq "automap" . [ label "key" . store word ] . sep_spc . ( [ label "map-type" . store word ] . comma )? . ( [ label "format" . store word ] . colon )? . ( [ label "map" . store word ] . sep_spc )? . ( [ label "options" . store word ] . sep_spc )? ] (* removed eol as I think sep_spc will consume \n * let lns = ( empty | comment | record ) * let filter = incl "/etc/auto.master" let xfm = transform lns filter There is an error in this grammar in the whitespace handling but it's not jump out at me. The error message: $ augtool --version augtool 0.9.0 <http://augeas.net/> Copyright (C) 2009-2010 David Lutterkort License LGPLv2+: GNU LGPL version 2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by David Lutterkort $ augparse automaster.aug Syntax error in lens definition automaster.aug:16.4-22.4:Failed to compile record automaster.aug:16.19-21.71:exception: ambiguous concatenation First regexp: /(([^,:#=\n\t ]+))([ \t]+)(((([^,:#=\n\t ]+))(,))?)(((([^,:#=\n\t ]+))(:))?)(((([^,:#=\n\t ]+))([ \t]+))?)/ Second regexp: /((([^,:#=\n\t ]+))([ \t]+))?/ 'A A ' can be split into 'A |=|A ' and 'A A |=|' First lens: automaster.aug:16.19-20.67: Second lens: automaster.aug:21.24-.71: So it appears that /[ ]/ can consume a newline in this regex dialect? What is the proper way to structure this grammar so that whitespace handling isn't ambiguous? Thanks, -Josh -- _______________________________________________ augeas-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/augeas-devel
