我在一个小语言/ IDE工作.我需要知道如何配置flex和bison以协同工作,但不使用任何全局或静态变量.我需要传递给我的AST指针.我也需要野牛通过我的AST来弯曲.这是一个线程环境,但我不需要任何线程同步.我需要为每个yyparse()调用一个separete yylineno变量.我读到了%define api.pure,%parse-param和%option reentrant.但我不知道如何让他们一起工作......先提前......
我试过这个:
scanner.l:
%{
#include <iostream>
#include <sstream>
#include "parser.tab.h"
#define YY_DECL extern "C" int yylex(YYSTYPE * lvalp, yyscan_t scanner)
extern void yyerror(yyscan_t scanner, NBloco * bloco, const char *s);
%}
%option noyywrap
%option yylineno
%option reentrant
%option bison-bridge
%%
//...scanner code
Run Code Online (Sandbox Code Playgroud)
parser.y:
%{
#include <iostream>
#include "AST.h"
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void* yyscan_t;
#endif
extern "C" int yylex(YYSTYPE * lvalp, yyscan_t scanner);
extern "C" FILE *yyin;
extern int yylineno;
void yyerror(yyscan_t scanner, NBloco * …Run Code Online (Sandbox Code Playgroud) 我是perl语言的新手.
所以我写了这个:
use threads;
lock($lock);
cond_wait($full,$lock) while($threads == $max_thread);
$threads++;
unlock($lock);
Run Code Online (Sandbox Code Playgroud)
运行此代码后,我收到错误:
Undefined subroutine &main::unlock called at ./pages.pl line 222, <FH> line 1.`
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?