This commit is contained in:
parent
f857751606
commit
aae2e8e05f
168 changed files with 11625 additions and 0 deletions
66
Utils/Parser Generator/SOURCE/yycpcrea.cpp
Normal file
66
Utils/Parser Generator/SOURCE/yycpcrea.cpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
/************************************************************
|
||||
yycpcrea.cpp
|
||||
This file can be freely modified for the generation of
|
||||
custom code.
|
||||
|
||||
Copyright (c) 1999 Bumble-Bee Software Ltd.
|
||||
************************************************************/
|
||||
|
||||
#include "cyacc.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
int yyparser::yycreate(yylexer YYFAR* lexerptr)
|
||||
{
|
||||
yylexerptr = lexerptr;
|
||||
|
||||
// stack
|
||||
if (yysstack_size != 0) {
|
||||
size_t stackcharsize;
|
||||
size_t attributestackcharsize;
|
||||
|
||||
stackcharsize = yysstack_size * sizeof(yystack_t);
|
||||
if ((int)(stackcharsize / sizeof(yystack_t)) != yysstack_size) {
|
||||
return 0; // integer overflow
|
||||
}
|
||||
attributestackcharsize = yysstack_size * yyattribute_size;
|
||||
if ((int)(attributestackcharsize / yyattribute_size) != yysstack_size) {
|
||||
return 0; // integer overflow
|
||||
}
|
||||
|
||||
yysstackptr = (yystack_t YYFAR*)malloc(stackcharsize);
|
||||
if (yysstackptr == NULL) {
|
||||
return 0;
|
||||
}
|
||||
yysattributestackptr = malloc(attributestackcharsize);
|
||||
if (yysattributestackptr == NULL) {
|
||||
free(yysstackptr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
yysstackptr = NULL;
|
||||
yysattributestackptr = NULL;
|
||||
}
|
||||
yystack_size = yysstack_size;
|
||||
yystackptr = yysstackptr;
|
||||
yyattributestackptr = yysattributestackptr;
|
||||
|
||||
// yylval
|
||||
yylvalptr = malloc(yyattribute_size);
|
||||
if (yylvalptr == NULL) {
|
||||
free(yysstackptr);
|
||||
free(yysattributestackptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// yyval ($$)
|
||||
yyvalptr = malloc(yyattribute_size);
|
||||
if (yyvalptr == NULL) {
|
||||
free(yysstackptr);
|
||||
free(yysattributestackptr);
|
||||
free(yylvalptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue