Preface
I'm designing a templating language (please skip the don't/why?? speech). One of the major goals of this language is to be extensible. There are 2 main elements in my language. "Tags" and "Directives". Tags, for the most part, map 1-to-1 to HTML tags, with the exception of a few of them which do a bit more. "Directives" are things like conditionals and for/while loops.
"Tags" are simple, because they all follow the same structure: tag_name(arg1=val1, arg2=val2) { content }
.
Directives are more complicated because they look like this: directive(anything-can-go-here) { content }
.
Question
I'm trying to decide how to let users (other devs using the templating language) write their own directive -- i.e., define the "anything can go here" part.
I'm using Irony to parse my language. Should I give them the same level of access, and define their own BnfExpression
(requiring them to learn a bit of Irony/EBNF), or should I just toss them a string (the stuff between (
and )
) and let them parse it however they want?
My Concerns
The former is perhaps more powerful and easier to work with (once you know it), but it would also potentially give them too much power (they wouldn't have to stop at the next )
-- well, unless I stripped out the inner string first and then basically let them define a sub-grammar to parse only that).
Not sure how to approach this.
More About Tags
For reference, users can define "tags" like this:
class ANode : HtmlNode
{
public ANode(AttrDict attrs, params TagNode[] children)
: base("a", attrs, children) { }
}
Would be the most basic example, which just extends the HtmlNode I've already defined. A more complicated one might define some default attributes or do something fancy with the child elements, or generate multiple html tags.