You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.4 KiB

6 years ago
  1. """SCons.Scanner.D
  2. Scanner for the Digital Mars "D" programming language.
  3. Coded by Andy Friesen
  4. 17 Nov 2003
  5. """
  6. #
  7. # Copyright (c) 2001 - 2017 The SCons Foundation
  8. #
  9. # Permission is hereby granted, free of charge, to any person obtaining
  10. # a copy of this software and associated documentation files (the
  11. # "Software"), to deal in the Software without restriction, including
  12. # without limitation the rights to use, copy, modify, merge, publish,
  13. # distribute, sublicense, and/or sell copies of the Software, and to
  14. # permit persons to whom the Software is furnished to do so, subject to
  15. # the following conditions:
  16. #
  17. # The above copyright notice and this permission notice shall be included
  18. # in all copies or substantial portions of the Software.
  19. #
  20. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  21. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  22. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. #
  28. __revision__ = "src/engine/SCons/Scanner/D.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
  29. import SCons.Scanner
  30. def DScanner():
  31. """Return a prototype Scanner instance for scanning D source files"""
  32. ds = D()
  33. return ds
  34. class D(SCons.Scanner.Classic):
  35. def __init__ (self):
  36. SCons.Scanner.Classic.__init__ (
  37. self,
  38. name = "DScanner",
  39. suffixes = '$DSUFFIXES',
  40. path_variable = 'DPATH',
  41. regex = '(?:import\s+)([\w\s=,.]+)(?:\s*:[\s\w,=]+)?(?:;)'
  42. )
  43. def find_include(self, include, source_dir, path):
  44. # translate dots (package separators) to slashes
  45. inc = include.replace('.', '/')
  46. i = SCons.Node.FS.find_file(inc + '.d', (source_dir,) + path)
  47. if i is None:
  48. i = SCons.Node.FS.find_file (inc + '.di', (source_dir,) + path)
  49. return i, include
  50. def find_include_names(self, node):
  51. includes = []
  52. for iii in self.cre.findall(node.get_text_contents()):
  53. for jjj in iii.split(','):
  54. kkk = jjj.split('=')[-1]
  55. includes.append(kkk.strip())
  56. return includes
  57. # Local Variables:
  58. # tab-width:4
  59. # indent-tabs-mode:nil
  60. # End:
  61. # vim: set expandtab tabstop=4 shiftwidth=4: