@@ -1180,6 +1180,7 @@ def preprocess(
1180
1180
pp_defs : dict = None ,
1181
1181
include_dirs : set = None ,
1182
1182
debug : bool = False ,
1183
+ pp_parse_intel : bool = False ,
1183
1184
) -> tuple [list , list ]:
1184
1185
if pp_defs is None :
1185
1186
pp_defs = {}
@@ -1275,6 +1276,7 @@ def parse(
1275
1276
pp_defs = pp_defs ,
1276
1277
include_dirs = include_dirs ,
1277
1278
debug = debug ,
1279
+ pp_parse_intel = pp_parse_intel ,
1278
1280
)
1279
1281
for pp_reg in pp_skips :
1280
1282
file_ast .start_ppif (pp_reg [0 ])
@@ -2051,6 +2053,35 @@ def replace_ops(expr: str):
2051
2053
2052
2054
return expr
2053
2055
2056
+ def replace_intel_ops (expr : str ):
2057
+ expr = expr .replace ("/=" , " != " )
2058
+ expr = expr .replace (".AND." , " && " )
2059
+ expr = expr .replace (".LT." , " < " )
2060
+ expr = expr .replace (".GT." , " > " )
2061
+ expr = expr .replace (".EQ." , " == " )
2062
+ expr = expr .replace (".LE." , " <= " )
2063
+ expr = expr .replace (".GE." , " >= " )
2064
+ expr = expr .replace (".NE." , " != " )
2065
+ expr = expr .replace (".EQV." , " == " )
2066
+ expr = expr .replace (".NEQV." , " != " )
2067
+ expr = expr .replace (".NOT." , "!" )
2068
+ expr = expr .replace (".OR." , " || " )
2069
+ expr = expr .replace (".XOR." , " != " ) # admittedly a hack...
2070
+ expr = expr .replace (".and." , " && " )
2071
+ expr = expr .replace (".lt." , " < " )
2072
+ expr = expr .replace (".gt." , " > " )
2073
+ expr = expr .replace (".eq." , " == " )
2074
+ expr = expr .replace (".le." , " <= " )
2075
+ expr = expr .replace (".ge." , " >= " )
2076
+ expr = expr .replace (".ne." , " != " )
2077
+ expr = expr .replace (".eqv." , " == " )
2078
+ expr = expr .replace (".neqv." , " != " )
2079
+ expr = expr .replace (".not." , "!" )
2080
+ expr = expr .replace (".or." , " || " )
2081
+ expr = expr .replace (".xor." , " != " ) # admittedly a hack...
2082
+
2083
+ return expr
2084
+
2054
2085
def replace_defined (line : str ):
2055
2086
i0 = 0
2056
2087
out_line = ""
@@ -2083,6 +2114,9 @@ def replace_vars(line: str):
2083
2114
defs = {}
2084
2115
2085
2116
out_line = text
2117
+ if pp_parse_intel :
2118
+ out_line = replace_intel_ops (out_line )
2119
+
2086
2120
out_line = replace_defined (out_line )
2087
2121
out_line = replace_vars (out_line )
2088
2122
try :
@@ -2119,13 +2153,13 @@ def replace_vars(line: str):
2119
2153
continue
2120
2154
# Handle conditional statements
2121
2155
match = FRegex .PP_REGEX .match (line )
2122
- if match and check_pp_prefix (match .group (1 )):
2156
+ if match and check_pp_prefix (match .group (1 ), pp_parse_intel ):
2123
2157
output_file .append (line )
2124
2158
def_name = None
2125
2159
if_start = False
2126
2160
# Opening conditional statements
2127
2161
if match .group (2 ).lower () == "if " :
2128
- is_path = eval_pp_if (line [match .end (2 ) :], defs_tmp )
2162
+ is_path = eval_pp_if (line [match .end (2 ) :], defs_tmp , pp_parse_intel )
2129
2163
if_start = True
2130
2164
elif match .group (2 ).lower () == "ifdef" :
2131
2165
if_start = True
@@ -2161,7 +2195,7 @@ def replace_vars(line: str):
2161
2195
exc_continue = True
2162
2196
if pp_stack [- 1 ][0 ] < 0 :
2163
2197
pp_stack [- 1 ][0 ] = i + 1
2164
- elif eval_pp_if (line [match .end (2 ) :], defs_tmp ):
2198
+ elif eval_pp_if (line [match .end (2 ) :], defs_tmp , pp_parse_intel ):
2165
2199
pp_stack [- 1 ][1 ] = i + 1
2166
2200
pp_skips .append (pp_stack .pop ())
2167
2201
pp_stack_group [- 1 ][1 ] = True
0 commit comments