From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: To: David Gibson Subject: Re: [PATCH 4/4] DTC: Begin the path to sane literals and expressions. In-Reply-To: Your message of "Sat, 20 Oct 2007 18:47:37 +1000." <20071020084737.GG26642@localhost.localdomain> References: <20071020084737.GG26642@localhost.localdomain> Date: Thu, 25 Oct 2007 13:24:57 -0500 From: Jon Loeliger Message-Id: Cc: linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , So, like, the other day David Gibson mumbled: > > Use of "d#', "o#", "h#" and "b#" are gone in version 1. > > Also good. We might want to keep b#, since there's no C way of doing > binary literals, but in that case I'd suggest recognizing it at the > lexical level, not the grammar level as we do now (which would mean a > space between the b# and the digits would no longer be permissible). I added 0(b|B)[01]+ literal support. > Now my big concern with this patch: the dts_version global, set by the > parser, used by the lexer. I assume you've tested this and it works > in practice, Yes. > but you're relying on the semantic action from the .y > file being executed before the lexer meets any token that depends on > it. Of course that is how it works. No problem. > I don't know about you, but I have to think pretty hard about how flow > of control will move between lexer and parser rules in a shift-reduce > parser at the best of times. With the %glr-parser option, bison will > use the Tomita algorithm. That means the parser state could be split > if there are ambiguities, or non-LALR(1) portions of the grammar > (which there are). In that case the execution of the parser rules > will be delayed until after the split is resolved again, however many > tokens down the track. So, I removed the ambiguity. > Therefore, I'd prefer that instead of having this general version > number, we introduce a separate token for each new version. So > /dts-version-1/ or whatever. Any new, incompatible, dts version is a > big deal in any case - not something we want to happen often - so a > new token for each version is not a big deal, I think. With this > approach, the version flag can be tripped in the lexer, and the > ordering of lexer rule execution is obvious. I don't see how this will work at the purely lexical level in a reliable way. Sure, I see the lexer matching the token and setting some variable (dts_version = 0 or 1) as needed. But there is no really good way to enforce that this happens at an early enough state that it covers the rest of the file short of having a staged lexical context state machine. And that just seems way hacky to me. With it in the grammar, we can enforce it being early in the file and can be assured of it happening in time to affect the rest of the parse. Personally, I think having it be a general statement like: /