regexp for the (custom makefiles project) makefile parser

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


Hi, 

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 ?

%target_with_percent:
        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 ?

(target_mit_klammer_auf:
        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 ?

target_mit_klammer_zu):
        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]+) *:.*$");"

Bye
Alex
-- 
Work: alexander.neundorf at jenoptik.com - http://www.jenoptik-los.de
Home: neundorf at kde.org                - http://www.kde.org
      alex at neundorf.net               - http://www.neundorf.net




More information about the KDevelop-devel mailing list