Re: [PATCH 1/2] dtc: allow label on root node of devicetree -- request help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Mon, Feb 26, 2018 at 08:26:10AM +0100, Julia Lawall wrote:
> 
> 
> On Sun, 25 Feb 2018, frowand.list@xxxxxxxxx wrote:
> 
> > From: Frank Rowand <frank.rowand@xxxxxxxx>
> >
> > From: Frank Rowand <frowand.list@xxxxxxxxx>
> >
> > Signed-off-by: Frank Rowand <frowand.list@xxxxxxxxx>
> > ---
> >
> > This patch does not work.
> >
> > After applying this patch, I get a syntax error when I try to
> > compile a devicetree source with a label on the root node:
> >
> >    $ dtc -O dts junk_lab.dts >junk
> >    Error: junk_lab.dts:3.9-10 syntax error
> >    FATAL ERROR: Unable to parse input tree
> 
> You have some shift reduce conflicts.  It is making a choice that is
> diffeernt than what you expect.  The problem seems to be with memreserves.
> That comes just before a devicetree and can also start with a DT_LABEL, so
> when it sees a DT_LABEL, it doesn't know if it is for memreserves or for
> devicetree.
> 
> I figured this out using bison --verbose dtc-parser.y.  This gives you a
> dtc-parser.output file.  But no one likes looking at these...

Ah, thanks for the analysis Julia.  I was guessing we had a parser
conflict at play here, but hadn't had a chance to investigate.  Frank
if you see errors from Bison during the build, that's generally not
something you should ignore..

So, you could probably fix this by adding the Bison %glr-parser
option.  We used to have that, but we managed to re-arrange the
grammar to avoid it, which gives us wider parser generator
compatibility.

As Julia says, the problem is roughly that when the parser sees a
label it doesn't know if a memreserve or the root node is eventually
going to follow it, so it doesn't know which branch of the grammar to
go down.

In a bit more detail, without %glr-parser, Bison generates a LALR(1)
parser.  That means the parser is able to look ahead 1 token to work
out what rules to use.  Because you can have multiple labels before
either a memreserve or the root node with your grammar, 1 token isn't
enough - there could be an arbitrary number of tokens before it sees
either the '/memreserve/' or '/' tokens which let it know which way to
go.


> 
> julia
> 
> >
> >
> >
> >  dtc-parser.y | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/dtc-parser.y b/dtc-parser.y
> > index 44af170abfea..821dba228d79 100644
> > --- a/dtc-parser.y
> > +++ b/dtc-parser.y
> > @@ -162,6 +162,11 @@ devicetree:
> >  		{
> >  			$$ = name_node($2, "");
> >  		}
> > +	| DT_LABEL devicetree
> > +		{
> > +			add_label(&$2->labels, $1);
> > +			$$ = $2;
> > +		}
> >  	| devicetree '/' nodedef
> >  		{
> >  			$$ = merge_nodes($1, $3);
> >
> >

-- 
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

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux