With all these complications in the formulation, I'm wondering if it would be useful to also define (not necessarily as part of the SRFI) some sort of formulation for translation of our extensions over BNF into some kind of code.
On Sun, Dec 16, 2012 at 11:39 AM, David A. Wheeler <dwhee...@dwheeler.com> wrote: > I'm trying to tweak the BNF language so that the BNF rules we give are simple > and clear (and easy to implement). I have a crazy idea that I think helps: > preventative productions. > > File spec-almkglor.txt has some rules for defining our various extensions > e.g.: > (i-expr lvl) -> SPLICE head eol-comment-lines > (if (= (length $2) 1) > (car $2) > $2) > > The problem is that this kind of rule is ambiguous compared to this: > (i-expr lvl) -> head eol-comment-lines > (if (= (length $1) 1) > (car $1) > $1) > > ... because the obvious implementation of "head" would gobble up SPLICE. The > precedence rules in theory handle this, but fails when things are in a longer > sequence. E.G.: > a b $ c d > needs to have a completely different interpretation from: > a b {$} c d > With a "preventative production" I can clearly state that head must NOT > consume "$" and "\\", and then the i-expr rules stay much clearer, as shown > below. I also have an idea of how to implement this that's really simple, > keeping the whole code simple (and thus more likely to be actually correct). > > Thoughts? > > --- David A. Wheeler > > ======================== > > A preventative production is defined using "::=!" instead of "::="; > a preventative production defines a term > sequence that must <i>not</i> match a production of that name, > even if it would have otherwise (see below). > > ... > > ; A "head" is forbidden from including certain special markers. > ; Preventative production definitions are not a normal feature of BNF. > ; However, by specifying it this way, the BNF is much, much simpler; > ; we can declare these cases here and then use these markers in the i-expr > ; production. > ; You can implement this, if "head" is a procedure, by having the procedure > ; return two values, the "special marker" ('none if none) and list > ; of head items up to (but not including) the marker. > ; Note that these only match to the LITERAL characters; {$} doesn't match! > head ::=! DOLLAR terminate-n-expr > head ::=! BACKSLASH BACKSLASH terminate-n-expr > > ... > > ; Initial "\\" - ignore it. > i-expr ::= BACKSLASH BACKSLASH hspace+ i-expr > > > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > _______________________________________________ > Readable-discuss mailing list > Readable-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/readable-discuss ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss