Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
RE/Flex:在c中从用户获取Flex模式_C_Flex Lexer_Lex_Lexical Analysis_Lexical - Fatal编程技术网

RE/Flex:在c中从用户获取Flex模式

RE/Flex:在c中从用户获取Flex模式,c,flex-lexer,lex,lexical-analysis,lexical,C,Flex Lexer,Lex,Lexical Analysis,Lexical,我是flex新手,我知道我们可以定义如下硬编码模式: pattern "hello world" %% {pattern} {some actions} %% some c code %{ #include <stdio.h> char pattern[20]; %} %% {pattern} {some actions} %% int main(){ printf("enter pattern: "); scanf(

我是flex新手,我知道我们可以定义如下硬编码模式:

pattern   "hello world"

%%
{pattern}  {some actions}
%%

some c code
%{
#include <stdio.h>
char pattern[20];
%}

%%

{pattern}   {some actions}

%%

int main(){

printf("enter pattern: ");
scanf("%s",pattern);

yylex();

return 0;
}
但是我想要运行时模式。大概是这样的:

pattern   "hello world"

%%
{pattern}  {some actions}
%%

some c code
%{
#include <stdio.h>
char pattern[20];
%}

%%

{pattern}   {some actions}

%%

int main(){

printf("enter pattern: ");
scanf("%s",pattern);

yylex();

return 0;
}
%{
#包括
字符模式[20];
%}
%%
{模式}{一些动作}
%%
int main(){
printf(“输入模式:”);
扫描频率(“%s”,模式);
yylex();
返回0;
}

如何使用正则表达式库执行此操作?

。Lex扫描程序编译为C,而不是动态的。