Skip to content
Snippets Groups Projects
Commit 1b169516 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Manage include path for Fortran preproc

parent 82a249d5
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@ THE SOFTWARE.
from loopy.diagnostic import LoopyError
def c_preprocess(source, defines=None, filename="<floopy source>"):
def c_preprocess(source, defines=None, filename=None, include_paths=None):
"""
:arg source: a string, possibly containing C preprocessor constructs
:arg defines: a list of strings as they might occur after a
......@@ -38,10 +38,22 @@ def c_preprocess(source, defines=None, filename="<floopy source>"):
except ImportError:
raise LoopyError("Using the C preprocessor requires PLY to be installed")
input_dirname = None
if filename is None:
filename = "<floopy source>"
else:
from os.path import dirname
input_dirname = dirname(filename)
lexer = lex.lex(cpp)
from ply.cpp import Preprocessor
p = Preprocessor(lexer)
if input_dirname is not None:
p.add_path(input_dirname)
if include_paths:
for inc_path in include_paths:
p.add_path(inc_path)
if defines:
for d in defines:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment