5
\$\begingroup\$

This question is mostly about grammar, not about code:

PEG.js grammar for parsing CSS selectors

In my mind, reviews do not belong on Code Review. Does Meta agree?

\$\endgroup\$
  • \$\begingroup\$ Are you also wanting to know if the [grammar] tag should be burninated? \$\endgroup\$ – Jamal Dec 27 '13 at 0:47
  • \$\begingroup\$ My mouse finger paused a few seconds over that tag and then I thought 'Nah', however, it seems that today is a good day to burninate in general. \$\endgroup\$ – konijn Dec 27 '13 at 1:19
  • 1
    \$\begingroup\$ We'll see what the community thinks. Although, after looking at the keywords "valid syntax" in the tag wiki, it does seem off-topic. Questions with invalid syntax are already considered non-working. \$\endgroup\$ – Jamal Dec 27 '13 at 1:31
6
\$\begingroup\$

Questions about grammar probably are off-topic; for instance, "Does this CSS code have correct syntax?" and "Where is the syntax error in this CSS code?" and "How do I express this in CSS?" and "Is my new language as cool as CSS?" are not about working code or its quality. The post you linked is not for a review of CSS (or any other language) grammar, however; it's a request for a review of the quality of a PEG source.

PEG.js is a parser generator, of which JavaScript code may be a part, and which emits JavaScript. A parser, as we all know, is a program that de-serializes a string into a more useful abstraction for some purpose. Functions that perform other useful transformations on user text seem to be kosher for CR (e.g. Decimal/binary/hex converter). Perhaps PEG is not an acceptable language to review?

Suppose PEG.js was run on the PEG source, generating the parser in JavaScript, and said JavaScript was posted as a question instead of the PEG source itself. This would certainly be as on-topic as any other JS posted here. Doing so, however, would result in less readable code for review.

It was also possible to achieve the same task with regular expressions in JS or any other language that supports them. Again, as JS code, unquestionably on-topic, but next to impossible to read and thus review.

Just my take on it; if meta disagrees, I will be happy to replace the PEG with one of those more preferable forms.

\$\endgroup\$
  • \$\begingroup\$ +1: A language grammar is very much code. Recalling introductory theorethical computer science, it's a description of an automaton – i.e. the thingie that transforms input into output that we use to reason about computation. (You could play the semantics game and argue that about everything you feed a computer, but it's clearly not necessary with language grammars.) \$\endgroup\$ – millimoose Jan 8 '14 at 5:13
  • \$\begingroup\$ @millimoose Sh! Someone will show up with a reductio ad absurdness proving that my argument leads to "every txt file is a program for printing itself", and my question will get deleted! (just kidding. Thanks, though I do like playing the semantics game all the same.) \$\endgroup\$ – sqykly Jan 9 '14 at 16:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .