[augeas-devel] Look for consequtive variable matches

Mol, Xavier (SCC) xavier.mol at kit.edu
Thu Feb 11 09:16:28 UTC 2016


Hello Augeas experts,

at the end, I have pasted a broken Augeas module definition, which demonstrates what I want to achieve. Currently, the below pasted module, instead of adding subsequent members to the same group, always creates a new tree node with one child node. However, given a source text, I want to look for repetitions and bundle them together in a subtree. The problem is, that part of the repeated pattern is variable. Can I somehow memorize a matched string in Augeas and use it for pattern matching?

Thank you for your time,
Xavier.


module Test_for_consecutive_matches =

let source =
"create group1
create group2
addto group1 memberA
addto group1 memberB
addto group2 memberX
addto group2 memberY
addto group2 memberZ
"

let create = [ key "create" . Sep.space . store Rx.word . Util.eol ]

let addto = [ key "addto" . Sep.space . store Rx.word . Sep.space .
              counter "members" . [ seq "members" . store Rx.word ] .
              Util.eol
            ]

let lns = ( create | addto )*

test lns get source =
{ "create" = "group1" }
{ "create" = "group2" }
{ "addto" = "group1"
  { "1" = "memberA" }
  { "2" = "memberB" }
}
{ "addto" = "group2"
  { "1" = "memberX" }
  { "2" = "memberY" }
  { "3" = "memberZ" }
}



****
Karlsruher Institute of Technology (KIT)
Steinbuch Centre for Computing (SCC)

B. Sc. Xavier Mol
GridKa Storage Administrator and Support Manager

Hermann-von-Helmholtz-Platz 1
Geb. 449
76344 Eggenstein-Leopoldshafen
Phone: +49 721 608 23041
Email: xavier.mol at kit.edu
www.kit.edu
KIT - University of the State of Baden-Württemberg and National Large-scale Research Center of the Helmholtz Association
"Since 2010, the KIT has been certified as a family-friendly university."
****

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6401 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20160211/a8e3eed5/attachment.p7s>


More information about the augeas-devel mailing list