in reply to Re^5: Is an aXML compiler possible?
in thread Is an aXML compiler possible?

I think it would go something like this

<symbol> ::= <open> <name> <args> <close> <data> <open> <name> <clos +e> <open> ::= <primary> | <secondary> | <teriary> <close> ::= <primary> | <secondary> | <teriary> <name> ::= <string> <args> ::= <key> <equals> <quote> <value> <quote> ... <data> ::= <xml> <primary> ::= <(> | <)> <secondary> ::= <<> | <>> <teriary> ::= <[> | <]>

Something like that, sorry if that's completely wrong I've never used BNF before.

Replies are listed 'Best First'.
Re^7: Is an aXML compiler possible?
by ikegami (Patriarch) on Oct 29, 2011 at 08:00 UTC
    • aXML allows nested "symbols", but your grammar does not. ("Directives" might be a better name.)
    • You're grammar allows <foo], but aXML does not.
    • &lab; is conspicuously absent.
    • None of the rules you gave make sense as the starting rule.
    • Finally, the word "xml' should not appear in there at all. There's absolutely no requirement for aXML to be used for XML, you said.

      Well that's because I've never used BNF before and I don't really know what I'm doing with it.

      As for the special chars, they are not used in aXML, only in the Perl plugins. They exist solely so Perl can correctly work with aXML. aXML itself does not need them or care about them at all, hence they don't belong in a formal specification of aXML.

        Don't make excuses; fix it.

        I don't really know what I'm doing with it

        You're specifying your language's syntax.

        Well that's because I've never used BNF before

        No, you didn't have any problem with BNF. The problem is that you didn't describe aXML.

        As for the special chars, they are not used in aXML, only in the Perl plugins.

        Are you back to saying one has to use

        sub escape { my ($s) = @_; for ($s) { die "\"$1\" can't be produced by aXML safely" if /([<>()\[\]])/; return $_; } }
        instead of
        sub escape { my ($s) = @_; for ($s) { die "\"$1\" can't be produced by aXML safely" if /(&(?:lab|rab|lcb|rcb|lsb|rsb);)/; s/\</&lab;/g; s/\>/&rab;/g; s/\(/&lcb;/g; s/\)/&lcb;/g; s/\[/&lsb;/g; s/\]/&rsb;/g; return $_; } }

        If it's not builtin, then a plugin can't rely on the person using aXML having provided a plugin to handle &lab;, which means you can't use anyone else's plugins, which means you can't reuse code, which means your comparison with TT was an outright lie.

Re^7: Is an aXML compiler possible?
by CountZero (Bishop) on Oct 29, 2011 at 07:51 UTC
    The little I know of BNF, I think your representation is not correct, but I leave it to more experienced Monks to look into it.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James