Some slightly random musings on device tree expression syntax
David Gibson
david at gibson.dropbear.id.au
Tue Mar 13 10:57:43 EST 2012
On Mon, Mar 12, 2012 at 08:53:05AM -0500, Jon Loeliger wrote:
> > I was thinking some more about how to expand the device tree syntax to
> > allow expressions.
>
> Excellent!
>
> > I wondered if we should use a concept/syntax more
> > inspired by template processors. Playing with jinja2 and gpp led me
> > towards (...) being an inline expression syntax that can calculate
> > integers or strings and get replaced by the string representation of the
> > expression, and ! at the start of a line introducing a statement
> > context. So, below are my somewhat wandering thoughts on the matter.
> > However, the idea still raises a lot of questions that'd need to be
> > resolved.
> >
> > I note a few things:
> >
> > * Using the (...) syntax to indicate which parts of the file should be
> > evaluated and the substituted solves the issue that David had with Jon's
> > proposal re: how do you know when a node name is literal text vs.
> > concatenated to some expression.
>
> So the M4 solution then.
Erm.. use of (...) to disambiguate expressions seems an independent
matter from whether we use m4 or a macro preprocessor versus
in-dtc-proper expression evaluation.
> > * As an aside, I wonder if we couldn't transparently allow <1 2 3> or
> > <1, 2, 3> for cell list syntax, thus not requiring the brackets in
> > previously proposed <(1 + 0) (1 + 1) (4 - 1)> syntax, but rather <1 + 0,
> > 1 + 1, 4 - 1>?
>
> That's the sort of direction I advocated earlier.
Hrm. I don't think this is a good idea. Having two different cell
list formats seems to me to encourage confusions for minimal benefit.
I think (...) will generally delimit expressions more readably anyway.
Especially since it would match using that syntax to distinguish
expressions in other places, like node or property names.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
More information about the devicetree-discuss
mailing list