[augeas-devel] Inexpressible Language

Yclept Nemo orbisvicis at gmail.com
Thu Jun 26 04:50:56 UTC 2014


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):

    let br_l        = del /\[/ "["
    let br_r        = del /\]/ "]"
    let ws          = del /[ \t]*/ ""
    let sep         = del /:/ ":"
    let comment     = del /.*/ ""
    let eol         = del /\n/ "\n"
    let option      = key /[A-Z]+/
    let value       = sep . ws . store /[[:alnum:]]/ . ws
    let values      = [ seq "value" . value ] +
    let setting     = [ br_l . option . values . br_r ]
    let record      = setting . comment
    let lns         = ( record | comment ) . eol
    (*
    let lns         = ( setting?. comment . eol )
    *)

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:

    let lns     = del ( /[[]/ "[" ) . P1 | del ( /[^[]/ ) .  NP
    let P1      = key ( /[A-Z]+/ ) . P2 | del ( /[^A-Z]/ ) . NP
    let P2      = del ( /[:]/ ":" ) . P3 | del ( /[^:]/ "" ) . NP
    let P3      = del ( /[ \t]*/ "" ) . P4
    let P4      = store /[[:alnum:]]+/ . P5 | del ( /[^[:alnum:]]/ "" ) . NP
    let P5      = del ( /[ \t]*/ "" ) . P2
    let NP      = del ( /[^\n]*/ . /\n/ ) ""

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:


    let lns     = del ( /[[]/ "[" ) . P1 | del ( /[^[]/ ) .  NP
    let P1      = key ( /[A-Z]+/ ) . P2 | del ( /[^A-Z]/ ) . NP
    let P2      = del ( /[:]/ ":" ) . P3 | del ( /[^:]/ "" ) . NP
    let P3      = del ( /[ \t]*/ "" ) . P4
    let P4      = store /[[:alnum:]]+/ . P5 | del ( /[^[:alnum:]]/ "" ) . NP
    let P5      = del ( /[ \t]*/ "" ) . P6
    let P6      = del ( /[:]/ ":" ) . P3 | del ( /[]]/ "]" END | [^]:] NP
    let END      = [^\n]* \n
    let P7      = <big problem> END


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.

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.

However, the operators proposed in [2] ("||", "..", "**") and my addition,
"??" would nicely solve this dilemma.

Sincerely,




[1] "
Change this to turn sound off.

[SOUND:YES]
[FONT:curses_640x300.png]
[RESIZABLE:YES]You may disable window resizing if you wish.

[PRINT_MODE:2D]
    Mode examples:
[SINGLE_BUFFER:NO]
[EMBARK_RECTANGLE:4:4]

Change these numbers to set the default weights for traffic designations.
If you make the last numbers too large, pathfinding might lag.
The format is (PATH_COST:<high>:<normal>:<low>:<restricted>).
[PATH_COST:1:2:5:25]
"

[2] http://www.redhat.com/archives/augeas-devel/2010-September/msg00027.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20140626/ffde087e/attachment.htm>


More information about the augeas-devel mailing list