<div dir="ltr"><div><div>The following language ([1], example), as far as I can tell, is unable to be meaningfully represented within Augeas (pardon the possibly horrendous syntax, as I'm new to Augeaus):<br></div><div>
<br>    let br_l        = del /\[/ "["<br>    let br_r        = del /\]/ "]"<br>    let ws          = del /[ \t]*/ ""<br>    let sep         = del /:/ ":"<br>    let comment     = del /.*/ ""<br>
    let eol         = del /\n/ "\n"<br>    let option      = key /[A-Z]+/<br>    let value       = sep . ws . store /[[:alnum:]]/ . ws<br>    let values      = [ seq "value" . value ] +<br>    let setting     = [ br_l . option . values . br_r ]<br>
    let record      = setting . comment<br>    let lns         = ( record | comment ) . eol<br>    (*<br>    let lns         = ( setting?. comment . eol )<br>    *)<br><br></div>I posted an ambiguous grammar first because it is easier to comprehend - always use the leftmost rule/union of lns to generate the tree and backtrack if necessary. The following is an unambiguous grammar of the same language which is useless to Augeas:<br>
<br>    let lns     = del ( /[[]/ "[" ) . P1 | del ( /[^[]/ ) .  NP<br>    let P1      = key ( /[A-Z]+/ ) . P2 | del ( /[^A-Z]/ ) . NP<br>    let P2      = del ( /[:]/ ":" ) . P3 | del ( /[^:]/ "" ) . NP<br>
    let P3      = del ( /[ \t]*/ "" ) . P4<br>    let P4      = store /[[:alnum:]]+/ . P5 | del ( /[^[:alnum:]]/ "" ) . NP<br>    let P5      = del ( /[ \t]*/ "" ) . P2<br>    let NP      = del ( /[^\n]*/ . /\n/ ) ""<br>
<br></div><div>The shortcoming is the second rule of P2. While a valid tree, as a parser it is unable to differentiate and recall a valid closing brace from junk. The following grammar solves this:<br><br><br>    let lns     = del ( /[[]/ "[" ) . P1 | del ( /[^[]/ ) .  NP<br>
    let P1      = key ( /[A-Z]+/ ) . P2 | del ( /[^A-Z]/ ) . NP<br>    let P2      = del ( /[:]/ ":" ) . P3 | del ( /[^:]/ "" ) . NP<br>    let P3      = del ( /[ \t]*/ "" ) . P4<br>    let P4      = store /[[:alnum:]]+/ . P5 | del ( /[^[:alnum:]]/ "" ) . NP<br>
</div><div>    let P5      = del ( /[ \t]*/ "" ) . P6<br></div><div>    let P6      = del ( /[:]/ ":" ) . P3 | del ( /[]]/ "]" END | [^]:] NP<br></div><div>    let END      = [^\n]* \n<br></div>
<div>    let P7      = <big problem> END<br><br><br></div><div>Since the previous two grammars no longer backtrack, augeas will generate invalid key/value nodes, remembered values, and subtrees. The idea is to have these deleted in P7, which is clearly not possible. Furthermore since the language implemented by Augeas is relatively pure, it isn't possible to imperatively set flags in rules P1-P6 and generate all the necessary keys, values and subtrees in END. I've also experimented with the regex_match and lens_ctype builtin functions, and the regex subtraction operator (which is unintuitive) to no avail.<br>
</div><div><br></div><div>In other words, there is no meaningful or worthwhile expression of this configuration syntax in Augeas schema - at least not without repeating the patterns/regexes at least three(!) times, which is a maintainer's nightmare.<br>
<br></div><div>However, the operators proposed in [2] ("||", "..", "**") and my addition, "??" would nicely solve this dilemma.<br></div><div><br></div><div>Sincerely,<br></div><div>
<div><br><br><br><br>[1] "<br>Change this to turn sound off.<br><br>[SOUND:YES]<br>[FONT:curses_640x300.png]<br>[RESIZABLE:YES]You may disable window resizing if you wish.<br><br>[PRINT_MODE:2D]<br>    Mode examples:<br>
[SINGLE_BUFFER:NO]<br>[EMBARK_RECTANGLE:4:4]<br><br>Change these numbers to set the default weights for traffic designations.  If you make the last numbers too large, pathfinding might lag.<br>The format is (PATH_COST:<high>:<normal>:<low>:<restricted>).<br>
[PATH_COST:1:2:5:25]<br>"<br><br>[2] <a href="http://www.redhat.com/archives/augeas-devel/2010-September/msg00027.html">http://www.redhat.com/archives/augeas-devel/2010-September/msg00027.html</a><br></div></div></div>