ietf-mta-filters
[Top] [All Lists]

"extensible" grammar

1998-01-21 01:47:04
Out of curiosity, I put together a grammar for the "extensible" grammar
being discussed.  If there are any conflicts, let me know.  I didn't run
this through an ABNF parser because I just wanted to get an idea as to what
it looked like.  I'll stare at it more when we figure out what we're going
to do with it.

This cuts over 30 lines off the formal grammar.  Anyone claiming this
reduces complexity is wrong; it merely moves it out of the parser and up a
level to where the script can't be essentially validated by the parser.

Note that this also adds a couple lines for "tags", which are intended for
optional LISP-style tagged arguments.

        vacation :days 6 "I'm on vacation until Oct. 19th; bye.";

(This is all that's required since the syntax is so liberal.)  I want these
regardless as it would seriously clean up size, vacation, and the
comparator stuff (which is currently broken).

I'm not sure what my opinion is on this.  At some level, trying to prevent
people from doing arbitrarily stupid things is a nice idea, but they're
going to do them anyway.  At the same time, giving someone an unlimited
supply of rope is probably not exactly the greatest thing in the world.

Should probably be a 31-character limit on identifiers (replace the * with
*30).

-- 
                                          Tim Showalter 
tjs+(_at_)andrew(_dot_)cmu(_dot_)edu

--- cut here ---

action = identifier WSP *(argument WSP) [WSP] ";"

argument = string / string-list / number / tag

block = "{" [WSP] commands [WSP] "}"
        ;; C-style block

CHAR-NOT-DOT = (%x01-2d / %x2f-%xff)
        ;; all the characters that aren't "."

control-structure = identifier WSP
                        *(argument /
                          "(" [WSP] test [WSP] ")")
                        block

command = ( action ";" ) / block / control-structure

commands = *([WSP] command [WSP])

comment = "#" *VCHAR CRLF

identifier = (ALPHA / "_") *(ALPHA DIGIT "_")

multi-line = "text:" [WSP] CRLF
        *((1*CHAR-NOT-DOT *CHAR CRLF) / ("." 1*CHAR-NOT-DOT *CHAR CRLF) /
          (".." *CHAR CRLF) / CRLF)
        "." CRLF
        ;; Note when used,
        ;; a leading ".." on a line is mapped to ".".

number = 1*DIGIT [QUANTIFIER]
        ;; quantifier is a multiplier (or bit shift)

QUANTIFIER = "K" / "M" / "G"
        ;; K == 2^10; M == 2^20; G = 2^30

quoted-string = DQUOTE *CHAR DQUOTE
        ;; \e" inside a string maps to "
        ;; \e\e inside a string maps to \e
        ;; All other characters map to themselves.
        ;; Note that newlines and other weird characters
        ;; are all allowed strings.

string = quoted-string / multi-line

string-list = "(" [WSP] *(string [WSP] "," [WSP]) string [WSP] ")" / string
        ;; if there is only a single string, the parens are optional

tag = ":" identifier

test = identifier *(WSP argument) [WSP test-list]

test-list = [WSP] "(" [WSP] *(test [WSP] "," [WSP])
    test [WSP] ")" [WSP]

WSP = 1*(SP / CRLF / HTAB) / comment
        ;; just whitespace.  anyplace this is allowed, a comment is
        ;; as well



<Prev in Thread] Current Thread [Next in Thread>