regexp for the (custom makefiles project) makefile parser

Alexander Neundorf neundorf at
Wed Dec 7 21:53:04 UTC 2005


the custom project part tries to parse the makefiles to find the targets from 
the makefiles.
It uses the following QRegExp:

QRegExp re("^([^($%.#][^)\\s]+) *:.*$");

Do I understand correctly that this means:

1) beginning of line
2) then one character which is not ($%.#
3) the at least one character which is not )\\s
4) some space or not
5) the character :

This seems to have several problems:
1) it should exclude a \\tab from the first position
2) why does it exclude the % from the first position ?

        echo "target with percent"

$ make %target_with_percent
echo "target with percent"
target with percent

This appparently works on my system.

3) why does it exclude the ( from the first position ?

        echo "target mit klammer auf"

$ make "(target_mit_klammer_auf"
echo "target mit klammer auf"
target mit klammer auf

Works on my system.

4) why does it exclude the ")" from the target ?

        echo "klammer zu"

$ make "target_mit_klammer_zu)"
echo "klammer zu"
klammer zu

Works on my system.

5) it excludes spaces before the name of the target. This too works apparently 
on my system.

I think the following regexp is better, and I committed it to the kdevelop 3.4 
branch. What do you think about it ?

QRegExp re("^ *([^\\t$.#]\\S+) *:.*$");

the old one was: "QRegExp re("^([^($%.#][^)\\s]+) *:.*$");"

Work: alexander.neundorf at -
Home: neundorf at                -
      alex at               -

More information about the KDevelop-devel mailing list