On Sun, May 11, 2014 at 5:00 PM, Prathamesh Kulkarni <bilbotheelffri...@gmail.com> wrote: > On Sun, May 11, 2014 at 8:10 PM, Andreas Schwab <sch...@linux-m68k.org> wrote: >> Prathamesh Kulkarni <bilbotheelffri...@gmail.com> writes: >> >>> a) I am not able to follow why 3 slashes are required here >>> in x_.\\\(D\\\) ? Why does x_.\(D\) not work ? >> >> Two of the three backslashes are eaten by the tcl parser. But actually >> only two backslashes are needed, since the parens are not special to tcl >> (but are special to the regexp engine, so you want a single backslash >> surviving the tcl parser). >> >>> b) The expression after folding would be of the form: >>> t2_<digit> = x_<digit>(D) - y_<digit>(D) >>> I have used the operator "." in the pattern to match digit. >>> While that works in the above case, I think a better >>> idea would be to match using [0-9]. >>> I tried the following but it does not work: >>> t_[0-9] = x_[0-9]\\\(D\\\) - y_[0-9]\\\(D\\\) >>> Neither does \\\[ and \\\] work. >> >> Brackets are special in tcl (including inside double quotes), so they >> need to be quoted. But you want the brackets to appear unquoted to the >> regexp engine, so a single backslash will do the Right Thing. >> >> See tcl(n) for the tcl parsing rules. >> > Thanks. Now I get it, the double backslash \\ is an escape sequence > for \, and special characters like (, [ > retain their meaning in quotes, so to match input text: (D), the > pattern has to be written as: "\\(D\\)". > I believe "\(D\)" would only match D in the input ? > I have modified the test-case. Is this version correct ?
I usually verify that by running the testcase in isolation on a GCC version that should FAIL it and on one that should PASS it (tcl quoting is also try-and-error for me most of the time...). Thus I do gcc/> make check-gcc RUNTESTFLAGS="tree-ssa.exp=match-2.c" <test should FAIL> <patch source tree> gcc/> make cc1 ... compiles cc1 ... gcc/> make check-gcc RUNTESTFLAGS="tree-ssa.exp=match-2.c" <test should PASS> A more complete matching for an SSA name would be (allowing for SSA name versions > 9) _\\d\+ with \\(D\\) appended if suitable (that's usually known from the testcase). \\d\+ should match at least one decimal digit. Richard. > Thanks and Regards, > Prathamesh > > >> Andreas. >> >> -- >> Andreas Schwab, sch...@linux-m68k.org >> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 >> "And now for something completely different."