Replies: 2 comments
-
First I'd like to ask, do we? The most impressive PEG DSL I've seen was Parsec, especially if used in There are a few reasons prefix and postfix notation in Peggy is beneficial:
I don't think there's a lot of missing things that should look like operators. (Well, Skepticism aside, there is such a concept as mixfix notation. Generating grammars for it is discussed in linked article. (And it's a good read anyway. Have you ever heard that except "prefix", "postfix" and "infix" there's also a forth option of "closed"?)
In my experiments, there was significant whitespace. Given there are already places in Peggy's grammar where whitespace is significant (
Built-ins are not really needed when there is a way to |
Beta Was this translation helpful? Give feedback.
-
Generally speaking, I doubt that this problem is so extensive that it requires separate discussion. In fact, there are only 4 features that we may want to add to the grammar:
In principle, the last 3 features could be solved by attributes syntax, but I think, it would be better to have dedicated syntax for each of them. I doubt that something else may be needed that cannot be expressed by the attribute. |
Beta Was this translation helpful? Give feedback.
-
I've been talking about syntax extensibility, most recently on #239 and #291 (comment). I'd like to come up with a relatively scalable way for us to add new features in such a way that we don't need a new ASCII character to mark each feature. I would also like to ensure that we have room to parameterize rules (see: pegjs/pegjs#36 and pegjs/pegjs#45) and any other templating features we want eventually.
I really like the way that Pug does mixins. They allow you to pass in formal parameters, other blocks of Pug code, and generic name/value pairs that can be used inside the mixin.
I wonder if we could figure out a syntax that would be similarly useful, but fit within the existing Peggy grammar. In particular, we need at least postfix (like
?
) and prefix (like!
) rules... we could make the expression before and the expression after available, therefore allowing prefix, postfix, or infix as needed. You might need some extra parameters as well.If there was a good enough syntax for this, we could use it for built-ins as well. Perhaps built-ins would start with a capital letter or something to reserve a namespace?
Beta Was this translation helpful? Give feedback.
All reactions