blob: 3ceb60a95defdb0108ad06547518374bfa9b60ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
file(READ "${IN}" data)
file(WRITE "${OUT1}" "")
file(WRITE "${OUT2}" "")
set(where 0)
if(NOT(BISON_VERSION VERSION_LESS "3.0.0"))
string(REPLACE "\n%pure-parser" "\n%define api.pure" data "${data}")
endif()
string(REGEX REPLACE "/\\* sql_yacc\\.yy \\*/" "/* DON'T EDIT THIS FILE. IT'S GENERATED. EDIT sql_yacc.yy INSTEAD */" data "${data}")
while(NOT data STREQUAL "")
string(REGEX MATCH "^(%[ie][^\n]*\n)|((%[^ie\n]|[^%\n])[^\n]*\n)+|\n+" line "${data}")
string(LENGTH "${line}" ll)
string(SUBSTRING "${data}" ${ll} -1 data)
if (line MATCHES "^%ifdef +${VAL1} *\n")
set(where 1)
set(line "\n")
elseif(line MATCHES "^%ifdef +${VAL2} *\n")
set(where 2)
set(line "\n")
elseif(line MATCHES "^%else( *| +.*)\n" AND where GREATER 0)
math(EXPR where "3-${where}")
set(line "\n")
elseif(line MATCHES "^%endif( *| +.*)\n")
set(where 0)
set(line "\n")
endif()
if(where STREQUAL 1)
file(APPEND "${OUT1}" "${line}")
string(REGEX REPLACE "[^\n]+" "" line "${line}")
file(APPEND "${OUT2}" "${line}")
elseif(where STREQUAL 2)
file(APPEND "${OUT2}" "${line}")
string(REGEX REPLACE "[^\n]+" "" line "${line}")
file(APPEND "${OUT1}" "${line}")
else()
file(APPEND "${OUT1}" "${line}")
file(APPEND "${OUT2}" "${line}")
endif()
endwhile()
|