summaryrefslogtreecommitdiffstats
path: root/sql/gen_yy_files.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:24:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:24:36 +0000
commit06eaf7232e9a920468c0f8d74dcf2fe8b555501c (patch)
treee2c7b5777f728320e5b5542b6213fd3591ba51e2 /sql/gen_yy_files.cmake
parentInitial commit. (diff)
downloadmariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.tar.xz
mariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.zip
Adding upstream version 1:10.11.6.upstream/1%10.11.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sql/gen_yy_files.cmake')
-rw-r--r--sql/gen_yy_files.cmake42
1 files changed, 42 insertions, 0 deletions
diff --git a/sql/gen_yy_files.cmake b/sql/gen_yy_files.cmake
new file mode 100644
index 00000000..3ceb60a9
--- /dev/null
+++ b/sql/gen_yy_files.cmake
@@ -0,0 +1,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()