From: Carl B. <cb...@ad...> - 2007-03-21 07:22:35
|
On Mar 21, 2007, at 12:05 AM, Steve Drake wrote: > I am working on a program to parse C source files. I took the C=20 > grammar from the repository and modified it to add some leaf_node[]=20 > constructs and am parsing it using pt_parse(). When I added ID's to=20 > the rules, such as below, the compilation of the program slowed to a=20= > virtual halt: > =A0 > =A0=A0 enum > =A0=A0 { > =A0=A0=A0=A0=A0 // operators > =A0=A0=A0=A0=A0 eRuleIdLeftBrace, > =A0=A0=A0=A0=A0 eRuleIdRightBrace, > =A0=A0=A0=A0=A0=A0... > =A0=A0=A0}; > =A0 > =A0=A0 ... > > =A0=A0 rule< ScannerT, parser_context<>, = parser_tag<eRuleIdLeftBrace=A0=A0=A0 >=20 > >=A0=A0 LEFT_BRACE; > =A0=A0 rule< ScannerT, parser_context<>, = parser_tag<eRuleIdRightBrace=A0=A0 >=20 > >=A0=A0 RIGHT_BRACE; > What used to compile in a reasonable time (maybe a minute or two?) now=20= > takes so long that I have finally aborted the build after 1.5 HOURS!=20= > My PC is not especially fast (Pentium 4 1.7 GHz with 256MB RAM) but=20 > I've never had anything take this long. The compile seems to want a=20 > lot of RAM so I ordered another 512MB to see if that would help but I=20= > am not optimistic. > =A0 > Have I done something incredibly stupid? (I wouldn't put it past=20 > myself.) The reason I added the ID's is so that I could traverse the=20= > generated parse tree looking for certain constructs (such as=20 > identifiers). > =A0 > The source code is in the attached ZIP file (rename the file extension=20= > to .zip). > =A0 > I am compiling on Windows 2000 with gcc 3.4.2. > =A0 > Thanks in advance for any advice! > The big problem is you have 127 different instances of the template=20= rule< ...>. because you gave everything a tag. Reduce the # of tags to what is=20 important for your traversal, Eliminating A =3D str_p("if") ; rules reduces the=20= template 'space' as well. reducing the tags reduces the compiler 'space' needed:) might also make compile time more managable as well. |