Re: dtc expressions
From: Stephen Warren <hidden>
Date: 2012-03-17 04:47:15
On 03/15/2012 06:29 PM, David Gibson wrote:
On Wed, Mar 14, 2012 at 09:40:13AM -0600, Stephen Warren wrote:quoted
On 03/14/2012 08:46 AM, David Gibson wrote:quoted
So, in order to actually make progress on the dtc expressions / macros / whatnot stuff, I really think I should dust off my integer (constant) expressions patch, and we can apply that. While we still have disagreements on a bunch of stuff here, I think we're at least agreed on what integer expressions should look like. And even if we change approaches later (e.g. to your ifs and fors in dtc approach) the integer expression syntax won't change, only the implementation.I'd love to see something like that. I've don't think I've actually looked through your patches for that yet; I briefly looked at Jon's since they're in a branch in the dtc repo, but I don't think I managed to track down the patches you sent for this.It was quite a while back that I posted. I've got a version below, but it's *very* bitrotted and won't even go close to applying at present. I'm meaning to update it, but it will take a little time.
That looks like a good set of integer expressions. Do you think it'd be easy to agree on a simple "#define foo (expr)"-like syntax on top of this? I think that'd cover a lot of the use-cases people are looking for right now, which are more about creating/naming/using constants rather than building whole nodes or properties in some programmatic way.
Index: dtc/dtc-lexer.l
...
+<*>"<<" { return DT_LSHIFT; };
+<*>">>" { return DT_RSHIFT; };
+<*>"<=" { return DT_LE; };
+<*>">=" { return DT_GE; };
+<*>"==" { return DT_EQ; };
+<*>"!=" { return DT_NE; };
+<*>"&&" { return DT_AND; };
+<*>"||" { return DT_OR; };For my education, why aren't all the operators in the lexer file? When I first looked at this file, it seemed like a bunch were missing because they're only represented in the parser, as literal strings.