def include(self):
self._lexer.scan_any() # scan include
self._lexer.scan_any() # scan (
try:
filename = self._lexer.scan('STRING')
except:
print >> sys.stderr, "Warning: The file '%s' uses old style syntax for the include command." % self.m_filename
print >> sys.stderr, 'This is not fatal now but will be in the future. You should change the code\nfrom include(filename) to include("filename")\n'
filename = self._lexer.scan('NAME')
fn = os.path.join(self.m_location, filename)
if not os.path.exists(fn):
fn = os.path.join(os.getcwdu(), u'exercises/standard/lesson-files', filename)
s = open(fn, 'rU').read()
p = Dataparser()
p.m_location = self.m_location
p.parse_string(s)
self._lexer.scan(')')
return pt.IncludeStatement(p.tree)
评论列表
文章目录