Skip to content

Commit

Permalink
Use custom prefix for Bison/Flex scripts in SeriousSkaStudio.
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamyCecil committed Jul 9, 2024
1 parent 4875d45 commit 42218e7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Sources/SeriousSkaStudio/Parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ BOOL bCompresion = FALSE;// is animation is using compresions
#define YYERROR_VERBOSE 1

// if error occurs in parsing
void yyerror(const char *strFormat, ...)
void SKAyyerror(const char *strFormat, ...)
{
va_list arg;
va_start(arg, strFormat);
Expand Down
6 changes: 6 additions & 0 deletions Sources/SeriousSkaStudio/ParsingSymbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */

#define yylex SKAyylex
#define yyerror SKAyyerror
#define yyparse SKAyyparse
#define yyrestart SKAyyrestart
#define yylval SKAyylval

// needed for parser and scanner
extern int yylex(void);
extern void yyerror(const char *strFormat, ...);
Expand Down
19 changes: 10 additions & 9 deletions Sources/SeriousSkaStudio/Scanner.l
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
%option prefix="SKAyy"
%{
#include "StdAfx.h"
#include "ParsingSymbols.h"
Expand All @@ -9,7 +10,7 @@
#include <Engine/Templates/DynamicStackArray.cpp>

extern "C" {
int yywrap(void)
int SKAyywrap(void)
{
// no more buffers
return 1;
Expand Down Expand Up @@ -143,8 +144,8 @@ EXP_FLT (({DIGIT}+("."({DIGIT}*)?)?)("E"|"e")("+"|"-")?{DIGIT}+)
else
{
fclose(yyin);
yy_delete_buffer( YY_CURRENT_BUFFER );
yy_switch_to_buffer( include_stack[include_stack_ptr] );
SKAyy_delete_buffer( YY_CURRENT_BUFFER );
SKAyy_switch_to_buffer( include_stack[include_stack_ptr] );
strCurentFileName = include_fnStack[include_stack_ptr];
yyin = include_FileStack[include_stack_ptr];
_yy_iLine = include_lineStack[include_stack_ptr];
Expand All @@ -156,19 +157,19 @@ EXP_FLT (({DIGIT}+("."({DIGIT}*)?)?)("E"|"e")("+"|"-")?{DIGIT}+)
return(yytext[0]);}

/* constants */
"-"?{DIGIT}+ { yylval.i = atoi(yytext); return(c_int); }
"0x"{HEXDIGIT}+ { yylval.i = strtoul(yytext+2, NULL, 16); return(c_int);}
"-"?{NONEXP_FLT}("f"|"F")? { yylval.f = (float) atof(yytext); return(c_float); }
"-"?{EXP_FLT}("f"|"F")? { yylval.f = (float) atof(yytext); return(c_float); }
"-"?{DIGIT}+ { SKAyylval.i = atoi(yytext); return(c_int); }
"0x"{HEXDIGIT}+ { SKAyylval.i = strtoul(yytext+2, NULL, 16); return(c_int);}
"-"?{NONEXP_FLT}("f"|"F")? { SKAyylval.f = (float) atof(yytext); return(c_float); }
"-"?{EXP_FLT}("f"|"F")? { SKAyylval.f = (float) atof(yytext); return(c_float); }
"\""{STRINGCONTENT}*"\"" {
CTString &strNew = astrText.Push();
char *pstrNew;
// remove double-quotes
yytext[strlen(yytext)-1] = 0;
pstrNew = yytext+1;
//yylval.str = strNew.ConstData();
//SKAyylval.str = strNew.ConstData();
strNew = (const char*)pstrNew;
yylval.str = strNew.ConstData();
SKAyylval.str = strNew.ConstData();
return(c_string);
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/SeriousSkaStudio/SeriousSkaStudio.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,12 @@
<CustomBuild Include="Parser.y">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">pushd $(SolutionDir)
bison -o$(ProjectName)/Parser.c $(ProjectName)/Parser.y -d
bison -pSKAyy -o$(ProjectName)/Parser.c $(ProjectName)/Parser.y -d
popd
copy %(RootDir)%(Directory)\Parser.c %(RootDir)%(Directory)\Parser.cpp
del %(RootDir)%(Directory)\Parser.c /q</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">pushd $(SolutionDir)
bison -o$(ProjectName)/Parser.c $(ProjectName)/Parser.y -d
bison -pSKAyy -o$(ProjectName)/Parser.c $(ProjectName)/Parser.y -d
popd
copy %(RootDir)%(Directory)\Parser.c %(RootDir)%(Directory)\Parser.cpp
del %(RootDir)%(Directory)\Parser.c /q</Command>
Expand All @@ -365,12 +365,12 @@ del %(RootDir)%(Directory)\Parser.c /q</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(InputDir)Parser.cpp;$(InputDir)Parser.h;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(InputDir)Parser.cpp;$(InputDir)Parser.h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">pushd $(SolutionDir)
bison -o$(ProjectName)/Parser.c $(ProjectName)/Parser.y -d
bison -pSKAyy -o$(ProjectName)/Parser.c $(ProjectName)/Parser.y -d
popd
copy %(RootDir)%(Directory)\Parser.c %(RootDir)%(Directory)\Parser.cpp
del %(RootDir)%(Directory)\Parser.c /q</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">pushd $(SolutionDir)
bison -o$(ProjectName)/Parser.c $(ProjectName)/Parser.y -d
bison -pSKAyy -o$(ProjectName)/Parser.c $(ProjectName)/Parser.y -d
popd
copy %(RootDir)%(Directory)\Parser.c %(RootDir)%(Directory)\Parser.cpp
del %(RootDir)%(Directory)\Parser.c /q</Command>
Expand Down

0 comments on commit 42218e7

Please sign in to comment.