@echo off
chcp 1251 >nul
pushd
chdir /d %1
if not exist release\ mkdir release
set srcname=%3.%2
goto %2
:grm
bison -orelease\y.tab.cpp %srcname%
if errorlevel 1 goto quit
set srcname=release\y.tab.cpp
goto cpp
:lex
reflex --flex -orelease\lex.yy.cpp %srcname%
if errorlevel 1 goto quit
set srcname=release\lex.yy.cpp
goto cpp
:caio
caio -orelease\ %srcname%
if errorlevel 1 goto quit
set srcname=release\%3.cpp
goto cpp
:c
:h
if not "%6" == "" gcc -std=c11 -finput-charset=windows-1251 -fexec-charset=windows-1251 -I. -Irelease %~4 %6
gcc -std=c11 -pedantic -finput-charset=windows-1251 -fexec-charset=windows-1251 -W -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wwrite-strings -Wcast-qual -I. -Irelease %~4 %~5 -S -o nul -c %srcname%
if errorlevel 1 goto quit
cppcheck -I . -I release --enable=all %srcname%
goto quit
:cpp
:hpp
if not "%6" == "" g++ -std=c++20 -finput-charset=windows-1251 -fexec-charset=windows-1251 -I. -Irelease %~4 %6
g++ -W -Wall -Wshadow -finput-charset=windows-1251 -fexec-charset=windows-1251 -Wwrite-strings -Wold-style-cast -Woverloaded-virtual -std=c++20 -pedantic -I. -Irelease %~4 %~5 -S -o nul -c %srcname%
if errorlevel 1 goto quit
cppcheck -I . -I release --enable=all %srcname%
goto quit
:quit
set errcode=%ERRORLEVEL%
popd
exit /B %errcode%
