--- /root/creole/creole/lint/creolelint.py	2011-09-09 11:11:55.221923117 +0200
+++ creole/lint/creolelint.py	2011-09-09 11:06:21.412917999 +0200
@@ -81,7 +81,8 @@
         warnno = 1
         warncomment = "Undefined comment"
         """ Implementation of the singleton interface """
-        def set_config(self, eoledirs=None, distrib_dir=None, conffile=None, dtddir=None):
+        def set_config(self, eoledirs=None, distrib_dir=None, conffile=None, \
+                                    dtddir=None):
             if eoledirs != None and type(eoledirs) != list:
                 raise TypeError('eoledirs doit être une liste')
             if distrib_dir != None and type(distrib_dir) != str:
@@ -210,7 +211,8 @@
         def _collect_vars_in_dicos(self):
             if self.eoledirs == None or self.distrib_dir == None:
                 raise Exception('Utiliser la methode set_config avant')
-            dic = EoleDict(templatedir=self.distrib_dir, logfile='/dev/null', linter=True)
+            dic = EoleDict(templatedir=self.distrib_dir, logfile='/dev/null',
+                            linter=True)
             dic.read_dir(self.eoledirs)
             return dic
 
@@ -256,10 +258,11 @@
             else:
                 dvar[var] = TmplVar(name=var, fd=fd, line=linenb)
 
-        def _collect_vars_in(self, expr, dvar, fd, linenb, exists=False):
-            varcreole = re.compile(varstarttoken+'([a-zA-Z0-9_\.{}]+)')
-            varcreole2 = re.compile(varstarttoken+'(\w+)')
-            varcreolebr = re.compile(varstarttoken+'{(\w+)}')
+        def _collect_vars_in(self, expr, dvar, fd, linenb, tvarstarttoken,
+                            exists=False):
+            varcreole = re.compile(tvarstarttoken+'([a-zA-Z0-9_\.{}]+)')
+            varcreole2 = re.compile(tvarstarttoken+'(\w+)')
+            varcreolebr = re.compile(tvarstarttoken+'{(\w+)}')
             varmulti = re.compile('(\w+)\.(\w+)')
             for var in varcreole.findall(expr):
 
@@ -270,97 +273,215 @@
                     self._collect_var_in(dvar, ret.group(2), fd, linenb, exists)
                 else:
                     #%%var
-                    for var2 in varcreole2.findall(varstarttoken+var):
+                    for var2 in varcreole2.findall(tvarstarttoken+var):
                         self._collect_var_in(dvar, var2, fd, linenb, exists)
                     #%%{var}
-                    for var2 in varcreolebr.findall(varstarttoken+var):
+                    for var2 in varcreolebr.findall(tvarstarttoken+var):
                         self._collect_var_in(dvar, var2, fd, linenb, exists)
 
         def _collect_for_vars(self):
             if self.forvars == None:
                 self.forvars = {}
                 self.brokenfor = []
-                pattern = re.compile(starttoken+'for (.+) in (.*)')
+                tpattern = 'for (.+) in (.*)'
+                tstarttoken = ''
+                tvarstarttoken = ''
                 for tmplfd in self._list_tmpl_files():
                     fh = open(tmplfd, 'r')
                     lines = fh.readlines()
                     length = len(lines)
+                    settings = False
+                    if tstarttoken != starttoken or \
+                                    tvarstarttoken != varstarttoken:
+                        pattern = re.compile(starttoken+tpattern)
+                    tstarttoken = starttoken
+                    tvarstarttoken = varstarttoken
                     for linenb in range(length):
                         line = lines[linenb]
-                        ret = pattern.match(line.strip())
-                        if ret != None:
-                            self._collect_vars_in(ret.group(1), self.forvars, tmplfd, linenb)
-                            if ret.group(1).strip()[:2] != varstarttoken:
-                                self.brokenfor.append(TmplVar(name=line.strip(), fd=tmplfd, line=linenb))
+                        if line.strip() == '%compiler-settings':
+                            settings = True
+                        if settings and line.strip() == \
+                                            '%end compiler-settings'.strip():
+                            settings = False
+                        if not settings:
+                            ret = pattern.match(line.strip())
+                            if ret != None:
+                                self._collect_vars_in(ret.group(1),
+                                            self.forvars, tmplfd, linenb,
+                                            tvarstarttoken)
+                                if ret.group(1).strip()[:2] != tvarstarttoken:
+                                    self.brokenfor.append(TmplVar(
+                                                    name=line.strip(),
+                                                    fd=tmplfd, line=linenb))
+                        else:
+                            tline = line.split('=')
+                            tkey = tline[0].strip()
+                            if tkey == 'cheetahVarStartToken':
+                                tvarstarttoken = tline[1].strip()
+                            elif tkey == 'directiveStartToken':
+                                tstarttoken = tline[1].strip()
+                                pattern = re.compile(tstarttoken+tpattern)
 
                     fh.close()
 
         def _collect_def_vars(self):
             if self.defvars == None:
                 self.defvars = {}
-                pattern = re.compile(starttoken+'def (.*)\((.*)\)')
+                tpattern = 'def (.*)\((.*)\)'
+                tstarttoken = None
+                tvarstarttoken = None
                 for tmplfd in self._list_tmpl_files():
                     fh = open(tmplfd, 'r')
                     lines = fh.readlines()
                     length = len(lines)
+                    settings = False
+                    if tstarttoken != starttoken or \
+                                    tvarstarttoken != varstarttoken:
+                        pattern = re.compile(starttoken+tpattern)
+                    tstarttoken = starttoken
+                    tvarstarttoken = varstarttoken
                     for linenb in range(length):
                         line = lines[linenb]
-                        ret = pattern.match(line)
-                        if ret != None:
-                            self._collect_var_in(self.defvars, ret.group(1).strip(), tmplfd, linenb)
-                            self._collect_vars_in(ret.group(2), self.defvars, tmplfd, linenb)
+                        if line.strip() == '%compiler-settings':
+                            settings = True
+                        if settings and line.strip() == \
+                                        '%end compiler-settings'.strip():
+                            settings = False
+                        if not settings:
+                            ret = pattern.match(line)
+                            if ret != None:
+                                self._collect_var_in(self.defvars,
+                                        ret.group(1).strip(), tmplfd, linenb)
+                                self._collect_vars_in(ret.group(2),
+                                        self.defvars, tmplfd, linenb,
+                                        tvarstarttoken)
+                        else:
+                            tline = line.split('=')
+                            tkey = tline[0].strip()
+                            if tkey == 'cheetahVarStartToken':
+                                tvarstarttoken = tline[1].strip()
+                            elif tkey == 'directiveStartToken':
+                                tstarttoken = tline[1].strip()
+                                pattern = re.compile(tstarttoken+tpattern)
 
                     fh.close()
 
         def _collect_set_vars(self):
             if self.setvars == None:
                 self.setvars = {}
-                pattern = re.compile(starttoken+'set (.*)=.*')
+                tpattern = 'set (.*)=.*'
+                tstarttoken = None
+                tvarstarttoken = None
                 for tmplfd in self._list_tmpl_files():
                     if not isfile(tmplfd):
                         raise Exception('fichier template déclaré mais inexistant %s'%tmplfd)
                     fh = open(tmplfd, 'r')
                     lines = fh.readlines()
                     length = len(lines)
+                    settings = False
+                    if tstarttoken != starttoken or \
+                                    tvarstarttoken != varstarttoken:
+                        pattern = re.compile(starttoken+tpattern)
+                    tstarttoken = starttoken
+                    tvarstarttoken = varstarttoken
                     for linenb in range(length):
                         line = lines[linenb]
-                        ret = pattern.match(line)
-                        if ret != None:
-                            self._collect_vars_in(ret.group(1), self.setvars, tmplfd, linenb)
+                        if line.strip() == '%compiler-settings':
+                            settings = True
+                        if settings and line.strip() == \
+                                        '%end compiler-settings'.strip():
+                            settings = False
+                        if not settings:
+                            ret = pattern.match(line)
+                            if ret != None:
+                                self._collect_vars_in(ret.group(1),
+                                            self.setvars, tmplfd, linenb,
+                                            tvarstarttoken)
+                        else:
+                            tline = line.split('=')
+                            tkey = tline[0].strip()
+                            if tkey == 'cheetahVarStartToken':
+                                tvarstarttoken = tline[1].strip()
+                            elif tkey == 'directiveStartToken':
+                                tstarttoken = tline[1].strip()
+                                pattern = re.compile(tstarttoken+tpattern)
 
                     fh.close()
 
         def _collect_define_vars(self):
             if self.var_with_is_defined == None:
                 self.var_with_is_defined = {}
-                pattern = re.compile('%s(elif|if) %sis_defined\(\'(\w+)\'\) and'%(starttoken, varstarttoken))
+                tpattern = '%s(elif|if) %sis_defined\(\'(\w+)\'\) and'
+                tstarttoken = None
+                ttvarstarttoken = None
                 for tmplfd in self._list_tmpl_files():
                     fh = open(tmplfd, 'r')
                     lines = fh.readlines()
                     length = len(lines)
+                    settings = False
+                    if tstarttoken != starttoken or \
+                                        tvarstarttoken != varstarttoken:
+                        pattern = re.compile(tpattern%(starttoken, 
+                                                varstarttoken))
+                    tstarttoken = starttoken
+                    tvarstarttoken = varstarttoken
                     for linenb in range(length):
                         line = lines[linenb]
-                        ret = pattern.match(line)
-                        if ret != None:
-                            self._collect_var_in(self.var_with_is_defined, ret.group(1), tmplfd, linenb)
+                        if line.strip() == '%compiler-settings':
+                            settings = True
+                        if settings and line.strip() == \
+                                            '%end compiler-settings'.strip():
+                            settings = False
+                        if not settings:
+                            ret = pattern.match(line)
+                            if ret != None:
+                                self._collect_var_in(self.var_with_is_defined,
+                                                ret.group(1), tmplfd, linenb)
+                        else:
+                            tline = line.split('=')
+                            tkey = tline[0].strip()
+                            if tkey == 'cheetahVarStartToken':
+                                tvarstarttoken = tline[1].strip()
+                                pattern = re.compile(tpattern%(tstarttoken, 
+                                                            tvarstarttoken))
+                            elif tkey == 'directiveStartToken':
+                                tstarttoken = tline[1].strip()
+                                pattern = re.compile(tpattern%(tstarttoken, 
+                                                            tvarstarttoken))
                     fh.close()
 
         def _collect_vars_in_tmplfiles(self):
             if self.eoledirs == None or self.distrib_dir == None:
                 raise Exception('Utiliser la methode set_config avant')
             # XXX ".eolvars" is a good placeholder for var names to be kept in touch
+
             self.tmplvars = {}
             for tmplfd in self._list_tmpl_files():
                 fh = open(tmplfd, 'r')
                 lines = fh.readlines()
                 length = len(lines)
+                settings = False
+                tvarstarttoken = varstarttoken
                 for linenb in range(length):
                     line = lines[linenb]
                     #FIXME: err
-                    self._collect_vars_in(line, self.tmplvars, tmplfd, linenb, True)
+                    if line.strip() == '%compiler-settings':
+                        settings = True
+                    if settings and line.strip() == \
+                                            '%end compiler-settings'.strip():
+                        settings = False
+                    if not settings:
+                        self._collect_vars_in(line, self.tmplvars, tmplfd,
+                                                linenb, tvarstarttoken, True)
+                    else:
+                        tline = line.split('=')
+                        tkey = tline[0].strip()
+                        if tkey == 'cheetahVarStartToken':
+                            tvarstarttoken = tline[1].strip()
+                        #elif tkey == 'directiveStartToken':
+                        #    tstarttoken = tline[1].strip()
 
                 fh.close()
-                # XXX cheetahVarStartToken may redefine the beginswith variable
 
     # storage for the instance reference
     __instance = None
