【发布时间】:2018-05-27 09:27:28
【问题描述】:
你好我正在尝试在flex中使用以下模式来匹配
形式的信息-
ss:Name="string"(字符串必须在“”中) -
ss:Name="Number"(实字号) ss:Workshop
当我编译它时,它会显示规则无法匹配的警告错误。我的代码是这样的:
%{
#include "y.tab.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
%}
%option noyywrap
letter [a-zA-Z]
digit [0-9]
other_characters [./-_]
whitespace [ \t]
newline [\n]
string ({letter}|{digit}|{other_characters})({letter}|{digit}|{other_characters})+
%%
{string}({whitespace}|{string}) {printf ("%s", yytext); return TEXTMSG;}
"ss\:Workshop" {printf("%s", yytext); return WORKSHOP;}
"ss\:Name\=\"Number\""|"ss\:Name\="\"{string}\"| {printf("%s", yytext); return NAME;}
关于为什么这不正常的任何线索?在这里弯曲有点新,所以我相信我错过了一些东西,但不确定是什么
【问题讨论】:
标签: parsing flex-lexer