SLIF style guide / best practices?

33 views
Skip to first unread message

Paul Bennett

unread,
Nov 22, 2015, 1:39:11 AM11/22/15
to marpa-...@googlegroups.com
Is there such a document?

My specific scenario...

I have a grammar broken up into chunks (corresponding more or less
with similarity of meaning in the official SGML spec) at
https://github.com/PWBENNETT/MarpaX-SGML/tree/master/lib/MarpaX/SGML/Grammar

My specific question...

Within each file, is it polite to other (human) readers to sort the
productions alphanumerically, or to cluster them so that things that
refer to each other are near each other, or something else?


Thanks,


--
Paul

Ruslan Shvedov

unread,
Nov 22, 2015, 2:07:22 AM11/22/15
to marpa-...@googlegroups.com
‘to cluster them so that things that refer to each other are near each other’ and even top-down seems to be more or less the current common practice according to:


Jeffrey Kegler

unread,
Nov 22, 2015, 2:51:40 AM11/22/15
to Marpa Parser Mailing LIst
I don't think I'll ever write a style guide -- I prefer to see what others come up with.

My order of productions is (I think) similar to the traditional BNF, that you still see in standards.  This tries to be top down, but also to keep similar things together.  Unfortunately the two goals are not always the same thing, so finding things can be difficult.

My suspicion is that current style is dictated by what's easier to write, not what is easier to read.

Alphanumeric order is very non-standard, and would be harder to write, but would have the decided advantage that you could actually find things in a predictable, systematic way.

I don't think anybody has ever written anything on BNF style.  Now that you can actually *do* something with your BNF, it may be time for a look at style issues.

Ron Savage

unread,
Nov 22, 2015, 4:10:54 PM11/22/15
to marpa parser
I always try to write the ::= rules top-down, and then list the ~ rules alphabetically. This has turned out very well, for me at least.

Paul Bennett

unread,
Nov 22, 2015, 8:42:07 PM11/22/15
to marpa-...@googlegroups.com

On Nov 22, 2015 4:10 PM, "Ron Savage" <r...@savage.net.au> wrote:
>
> I always try to write the ::= rules top-down, and then list the ~ rules alphabetically. This has turned out very well, for me at least.
>

Sounds sensible. In my (admittedly gargantuan) grammar linked above, do any of you have specific examples of ways you can make it better? The idea is basically to concatenate the separate files together into one big grammar, but to split that monstrosity into ... I guess ... "functionally similar" slices, to allow Processing Instructions to come along and maybe mutate the tag L0 terminals (for instance) without having to glark the whole grammar.

If there's a better way to modify the grammar more or less on the fly, I'd like to know about it too...

Thanks,

--
P/PW/PWBENNETT

Ron Savage

unread,
Nov 23, 2015, 12:49:45 AM11/23/15
to marpa parser
My first though is make it work and then optimize it (if that's possible). Classic anti-premature-optimization-101!

Reply all
Reply to author
Forward
0 new messages