本文整理匯總了C++中yy_delete_buffer函數的典型用法代碼示例。如果您正苦於以下問題:C++ yy_delete_buffer函數的具體用法?C++ yy_delete_buffer怎麽用?C++ yy_delete_buffer使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了yy_delete_buffer函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: jsgf_parse_string
jsgf_t *
jsgf_parse_string(const char *string, jsgf_t * parent)
{
yyscan_t yyscanner;
jsgf_t *jsgf;
int yyrv;
YY_BUFFER_STATE buf;
yylex_init(&yyscanner);
buf = yy_scan_string(string, yyscanner);
jsgf = jsgf_grammar_new(parent);
if (!parent)
jsgf_set_search_path(jsgf, NULL);
yyrv = yyparse(yyscanner, jsgf);
if (yyrv != 0) {
E_ERROR("Failed to parse JSGF grammar from input string\n");
jsgf_grammar_free(jsgf);
yy_delete_buffer(buf, yyscanner);
yylex_destroy(yyscanner);
return NULL;
}
yy_delete_buffer(buf, yyscanner);
yylex_destroy(yyscanner);
return jsgf;
}
示例2: yywrap
int yywrap() {
if (!include_app) { /* all input files and strings get a newline appended to them */
include_app = 1;
yy_scan_string("\n");
return 0;
} else {
include_app = 0;
if (inpfile) { /* (this is just an informal input text for printing-out...) */
FREE(inpfile); inpfile = NULL;
}
/* delete the input buffer, and possibly close the input file */
yy_delete_buffer(YY_CURRENT_BUFFER);
#if CLOSE_AFTER_FLEX>0
if (include_stack_file[include_stack_ptr])
fclose(include_stack_file[include_stack_ptr]);
#endif
/* pop the previous saved state from the stack */
if (--include_stack_ptr>=0) {
yy_switch_to_buffer(include_stack[include_stack_ptr]);
inpfile = include_stack_fn[include_stack_ptr];
inpline = include_stack_ln[include_stack_ptr];
yy_pop_state();
return 0;
} /*** else yyterminate(); does not work ??? ***/
}
return 1; /* (means the end of current input) */
}
示例3: yy_scan_bytes
void Text::CreateFromXML(const string& XML)
{
::pText = this;
YY_BUFFER_STATE buffer = yy_scan_bytes(XML.c_str(), XML.size());
yyparse();
yy_delete_buffer(buffer);
}
示例4: source_parse_file
int source_parse_file(source *src, const char *filename, const char *modname)
{
YY_BUFFER_STATE bufstate;
int r;
if (NULL == (yyin = fopen(filename,"r"))) {
perror(filename);
return -1;
}
yyfilename = filename;
yyfileno = add_parsedfile(src,filename); ////yyfileno is the index in the src->parsedfiles
yylloc.first_line = 1;
bufstate = yy_create_buffer(yyin,YY_BUF_SIZE);
yy_switch_to_buffer(bufstate);
parse_src = src;
parse_modname = modname ? modname : "";
r = yyparse();
yy_delete_buffer(bufstate);
#if HAVE_YYLEX_DESTROY
yylex_destroy();
#endif
if (yyin)
fclose(yyin);
return r;
}
示例5: guard
t_sip_message *t_parser::parse(const string &s, list<string> &parse_errors_) {
t_mutex_guard guard(mtx_parser);
int ret;
struct yy_buffer_state *b;
msg = NULL;
parse_errors.clear();
string x = unfold(s);
b = yy_scan_string(x.c_str());
ret = yyparse();
yy_delete_buffer(b);
if (ret != 0) {
if (msg) {
MEMMAN_DELETE(msg);
delete msg;
msg = NULL;
}
throw ret;
}
parse_errors_ = parse_errors;
return msg;
}
示例6: yy_scan_string
ModuleNode *getAST(const char *expr)
{
ModuleNode *expression;
yyscan_t scanner;
YY_BUFFER_STATE state;
if (yylex_init(&scanner)) {
// couldn't initialize
return NULL;
}
state = yy_scan_string(expr, scanner);
yydebug = 0;
if (yyparse(&expression, scanner)) {
// error parsing
return NULL;
}
yy_delete_buffer(state, scanner);
yylex_destroy(scanner);
return expression;
}
示例7: yyparse
pt_node *buildAST(const char *expr) {
extern int yyparse(pt_node **, yyscan_t);
FILE *file;
yyscan_t scanner;
pt_node *node = NULL;
YY_BUFFER_STATE state;
if(yylex_init(&scanner)) {
fprintf(stderr, "Failed to initialize parser.\n");
exit(-1);
}
file = fopen(expr, "r");
if(file == NULL) {
perror("fopen");
exit(-1);
}
state = yy_create_buffer(file, 1024, scanner);
yy_switch_to_buffer(state, scanner);
if(yyparse(&node, scanner)) {
fprintf(stderr, "Error parsing input.\n");
exit(-1);
}
yy_delete_buffer(state, scanner);
yylex_destroy(scanner);
return node;
}
示例8: __declspec
//////////////////////////////////////////////////////////////////////////
// EXPORTED FUNCTIONS
//////////////////////////////////////////////////////////////////////////
__declspec(dllexport) BYTE* CompileBuffer(BYTE* Buffer, char* Source, DWORD BufferSize, DWORD* CompiledSize){
YY_BUFFER_STATE state;
BYTE* ret = NULL;
if(Buffer==NULL){
if(CompiledSize)*CompiledSize = 0;
return NULL;
}
state = yy_scan_bytes(Buffer, BufferSize);
lineno=1;
yyparse();
yy_delete_buffer(state);
if(errorCheck()) goto finish_error;
weedSCRIPTCOLLECTION(thescriptcollection);
if(errorCheck()) goto finish_error;
symSCRIPTCOLLECTION(thescriptcollection);
if(errorCheck()) goto finish_error;
ret = opcodeSCRIPTCOLLECTION(thescriptcollection, Source, CompiledSize);
if(errorCheck()) goto finish_error;
FinalCleanup();
return ret;
finish_error:
if(ret!=NULL) free(ret);
*CompiledSize = 0;
FinalCleanup();
return NULL;
}
示例9: como_ast_create
int como_ast_create(const char *filename)
{
ast_node* statements;
yyscan_t scanner;
YY_BUFFER_STATE state;
char* text;
text = file_get_contents(filename);
if(!text) {
printf("file '%s' not found\n", filename);
return 1;
}
if(yylex_init(&scanner)) {
como_error_noreturn("yylex_init returned NULL");
}
state = yy_scan_string(text, scanner);
if(yyparse(&statements, scanner)) {
como_error_noreturn("yyparse returned NULL");
}
yy_delete_buffer(state, scanner);
yylex_destroy(scanner);
como_compile_ast(statements, filename);
return 0;
}
示例10: ne_parse
int ne_parse(const char *formula)
{
int err;
struct symbol_table *sym;
ne.buf = yy_scan_string(formula, ne.scanner);
yyset_lineno(1, ne.scanner);
yyset_column(1, ne.scanner);
__ne_clear_error(&ne);
err = yyparse(&ne);
if (!err) {
__ne_put_result(&ne, eval(&ne, ne.root));
sym = get_sym(&ne, "y");
if (sym && sym->dirty) {
__ne_put_result(&ne, __ne_get_y(&ne));
clean_output_sym(&ne);
}
}
if (ne.error != 0)
err = ne.error;
else if (ne.warrning != 0)
err = ne.warrning;
free_ast(ne.root);
ne.root = NULL;
ne.stop = 0;
yy_delete_buffer(ne.buf, ne.scanner);
return err;
}
示例11: getAST
ltl_formula *
getAST (const char *input)
{
ltl_formula *formula;
yyscan_t scanner;
YY_BUFFER_STATE state;
if (yylex_init (&scanner))
{
// couldn't initialize
return NULL;
}
state = yy_scan_string (input, scanner);
if (yyparse (&formula, scanner))
{
// error parsing
return NULL;
}
yy_delete_buffer (state, scanner);
yylex_destroy (scanner);
return formula;
}
示例12: dbg_parse
// -----------------------------------------------------------------------
int dbg_parse(char *c)
{
YY_BUFFER_STATE yb = yy_scan_string(c);
int res = yyparse();
yy_delete_buffer(yb);
return res;
}
示例13: runCommand
/**
* @function runCommand
*
* @abstract Parses and executes a command given a NULL terminated string.
* @discussion Parses the command and adds it to the history if it is
* nontrivial.
*
* @param cmd_buffer Pointer to NULL terminated string containing
* the user input.
* @result Returns nothing, but runs a command, most likely printing to
* the terminal.
*/
void runCommand(char* cmd_buffer) {
Command *command = NULL;
yyscan_t scanner;
YY_BUFFER_STATE state;
// Check if there is anything in the line. It is useless to store
// a history of empty lines. If it is not empty, then add it to our
// history. Also don't want to record line rerun calls.
if ((cmd_buffer[0] != 0) && (cmd_buffer[0] != '!')) {
add_history(cmd_buffer);
}
state = yy_scan_string(cmd_buffer);
if (yyparse(&command, scanner)) {
printf("Error in parsing command.\n");
deleteCommand(command);
return;
}
executeCommand(command, -1);
deleteCommand(command);
// Wait on all child processes
while (wait(NULL) > 0) {}
yy_delete_buffer(state);
yylex_destroy();
return;
}
示例14: FILESTATUS
char *PCCloseentity(void) {
char * pc;
PEntRec per;
#ifdef DEBUGGING
FILESTATUS(stdout,"stdout");
MsgKwS(msgTRACE,"Closing the current entity ...",NULL);
MsgKwS(msgTRACE,"PCCloseentity() called ...",NULL);
FILESTATUS(stdout,"stdout");
FILESTATUS(stdin,"stdin");
FILESTATUS(stderr,"stderr");
FILESTATUS(yyin,"yyin");
#endif
if (cEntCur > 0) {
per = rgEntities[cEntCur];
pc = per->pcEntname;
if (per->fExtern)
fclose(yyin);
/* close yyin. We don't need to reset it,
that happens in yy_switch_to_buffer, below */
yy_delete_buffer(YY_CURRENT_BUFFER);
yy_switch_to_buffer(rgBuffers[--cEntCur]);
/* reset pcEntpos and fRdexternal */
if (cEntCur > 0) {
per = rgEntities[cEntCur];
if (per->fExtern) {
fRdexternal = 1;
pcEntpos = "";
} else {
fRdexternal = 0;
pcEntpos = rgPCPos[cEntCur];
}
} else { /* back to stdin */
fRdexternal = 1;
pcEntpos = "";
}
cLinecount = rgILine[cEntCur];
fnCurrent = rgPCFn[cEntCur];
#ifdef DEBUGGING
FILESTATUS(stdout,"stdout");
FILESTATUS(stdin,"stdin");
FILESTATUS(stderr,"stderr");
FILESTATUS(yyin,"yyin");
#endif
return pc;
} else {
#ifdef DEBUGGING
FILESTATUS(stdout,"stdout");
FILESTATUS(stdin,"stdin");
FILESTATUS(stderr,"stderr");
FILESTATUS(yyin,"yyin");
#endif
return NULL;
}
}
示例15: command_parse_string
int command_parse_string( const char *buffer )
{
typedef struct yy_buffer_state* YY_BUFFER_STATE;
extern YY_BUFFER_STATE yy_scan_string( const char *yy_str );
extern void yy_delete_buffer( YY_BUFFER_STATE state );
int rv = 1;
YY_BUFFER_STATE state = yy_scan_string( (char*)buffer );
switch ( yylex() ) {
case SET:
/* get the next token */
rv = command_parse_set();
break;
case UNSET:
case BIND:
case MACRO:
/* ignore this stuff for now. */
rv = 1;
break;
case NUMBER: {
const char *number = get_token();
if ( number[0] == '+' ) {
source_vscroll( if_get_sview(), atoi( number+1 ));
rv = 0;
} else if ( number[0] == '-' ) {
source_vscroll( if_get_sview(), -atoi( number+1 ));
rv = 0;
} else {
source_set_sel_line(if_get_sview(), atoi( number ));
rv = 0;
}
if_draw();
} break;
case IDENTIFIER: {
COMMANDS *command = get_command( get_token() );
if ( command ) {
command->action(command->param);
rv = 0;
} else {
rv = 1;
}
} break;
case EOL:
/* basically just an empty line, don't do nothin. */
rv = 0;
break;
default:
rv = 1;
break;
}
yy_delete_buffer( state );
return rv;
}