From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 26 Oct 2007 11:28:32 +1000 From: David Gibson To: Jon Loeliger Subject: Re: [PATCH 4/4] DTC: Begin the path to sane literals and expressions. Message-ID: <20071026012832.GC457@localhost.localdomain> References: <20071020084737.GG26642@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: Cc: linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Thu, Oct 25, 2007 at 01:24:57PM -0500, Jon Loeliger wrote: > 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. Ok. [snip] > > 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: Ah... I think I see the source of our misunderstanding. Sorry if I was unclear. I'm not saying that the version token would be invisible to the parser, just that it would be recognized by the lexer first. So, the grammar would still need to specify that the magic version token comes first, of course. A file which had it in the middle would lex very strangely, but it wouldn't matter because it will never pass the parser anyway. > /