- Timestamp:
- Jan 5, 2011, 2:35:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mpy.py
r4 r5 25 25 # TODO add unitary tests 26 26 # TODO add [ and { despecialization 27 # TODO save the directory exploration to do it only once per session 28 # ------------------------------------------------------------------------------------------------- 29 _date = '2009-12-30 16:00' 30 _version = '1.07' 27 # ------------------------------------------------------------------------------------------------- 28 _date = '2011-01-05 14:30' 29 _version = '1.08' 31 30 _authors = 'Franck Wajsburt' 32 31 _organization = '(UPMC/LIP6/SOC)' … … 40 39 ===========================================================================''' 41 40 42 import os, sys, pdb 41 import os, sys, pdb, math, re 43 42 from optparse import OptionParser 44 43 from datetime import datetime … … 287 286 # test if buf is a file name, if yes includes file 288 287 # therefore pushes the current file and opens the new 289 incname = _mpyfindfile(buf,mpyidir) 290 if incname != '': 291 if mpydebug == True: 292 _mpylog("\nInclude to %s from %s" % (mpyout, incname)) 293 294 # push known parameters of the current opened file 295 opened_mpyin.append((mpyin, mpybuf, mpyfname, 288 289 if re.match("\w*(\.\w*)+",buf): 290 incname = _mpyfindfile(buf,mpyidir) 291 if incname != '': 292 if mpydebug == True: 293 _mpylog("\nInclude to %s from %s" % (mpyout, incname)) 294 295 # push known parameters of the current opened file 296 opened_mpyin.append((mpyin, mpybuf, mpyfname, 296 297 mpylineno, mpycharno, mpylength)) 297 298 298 # old values required for test of recursivity just below299 oldmpyfname = mpyfname300 oldmpylineno = mpylineno301 302 # open the include file303 mpyin, mpyfname = _mpyopen(realfname = incname)304 mpybuf = mpyin.read(-1)305 mpylineno = 1306 mpycharno = 0307 mpylength = len(mpybuf)308 level = 0309 buf = mode = ''310 311 # test recursive include312 for f in opened_mpyin[:-1]:313 if mpyfname in f:314 _exit ("%s[%d]: forbidden recursive inclusion on %s"315 % (oldmpyfname, oldmpylineno, mpyfname))299 # old values required for test of recursivity just below 300 oldmpyfname = mpyfname 301 oldmpylineno = mpylineno 302 303 # open the include file 304 mpyin, mpyfname = _mpyopen(realfname = incname) 305 mpybuf = mpyin.read(-1) 306 mpylineno = 1 307 mpycharno = 0 308 mpylength = len(mpybuf) 309 level = 0 310 buf = mode = '' 311 312 # test recursive include 313 for f in opened_mpyin[:-1]: 314 if mpyfname in f: 315 _exit ("%s[%d]: forbidden recursive inclusion on %s" 316 % (oldmpyfname, oldmpylineno, mpyfname)) 316 317 317 318 # just evaluate buf … … 431 432 432 433 # ------------------------------------------------------------------------------------------------- 434 435 def log2(x): 436 return int(math.ceil(math.log(x,2))) 437 438 # ------------------------------------------------------------------------------------------------- 433 439 # define globals dictionnary 434 440 # -------------------------------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.