Click here to Skip to main content
15,867,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I write a program that recognizes from a .txt elements enclosed by "{" and "}". The program print the result in another .txt file. When I run the command lex b4.l I have two errors on line 9
"bad character class" and "unrecognized rule"

What I have tried:

%{
#include<stdio.h>
%}
word [ab]+" "
nr [3-9][0-9][0-9]|[1-9][0,9]{3,}
el {nr}|([a-z][a-z})*[a-z}
list "{"{el}(,{el})+"}"
%%
{list} {printf("%s\n",yylex);}
(.*{word}.*){2,}\n {ECHO;}
.|\n;
%%
int main(int argc, char**argv){
FILE *g;
if(argc>0)
yyin = fopen(argv[1], "r");
if(!(g=fopen("a.txt", "w")))
fprintf(stderr, "error");
else
yyout=g;
yylex();
}
Posted
Updated 13-Dec-18 8:04am

1 solution

Quote:
el {nr}|([a-z][a-z})*[a-z}
The above rule looks incorrect to me (what is [a-z} ?).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900