![]() |
| | #1 (permalink) | ||
| Registered User Join Date: Apr 2006 | [FLEX] problema
Am o problema cu urmatorul program : %{ #include <fcntl.h> #include <sys/stat.h> #include <unistd.h> #include <sys/types.h> #include <stdio.h> #include <stdlib.h> int num_lines = 0, num_chars = 0;int cuvinte = 0; int nume[100];int prenume[100], contor=0,cnt=0; %} %s NUM s1 PRENUM s2 CodIBAN s3 STARE_X NumarCONT s4 SEP [ \t\n]+ LITERA [A-Za-z] CIFRA [0-9] nume [a-zA-Z]+ prenume {nume}|{nume}"-"{nume} INDICATIV_TARA '"RO"' INDICATIV_BANCA {LITERA}{2}| {LITERA}{3} | {LITERA}{4} CodIBAN {INDICATIV_TARA}{CIFRA}{2}{INDICATIV_BANCA}{CIFRA}{16} NUMAR_CARD {CIFRA}{4}"-"{CIFRA}{4}"-"{CIFRA}{4}"-"{CIFRA}{4} %% <INITIAL> {nume} { contor++;cnt++BEGIN (NUM); } <NUM> { BEGIN (s1); } <s1> {SEP} { cnt++;BEGIN (PRENUM); } <PRENUM> {prenume} BEGIN (s2); <s2> {SEP} { cnt++;BEGIN (INITIAL); } %% main(int argc, char ** argv){ yyin = fopen("intrare.txt","r"); FILE * fout = fopen("iesire.txt","wt"); yylex(); fprintf(fout,"# of persons = %d, # of white spaces = %d", contor,cnt); } Problema e ca nu stiu de ce intra doar prin starea initial pentru un fisier de intrare care contine liniile urmatoare: MIHAELA MIHAI ANTON ROMAN DEA BUNEA Rezultat : "# of persons = 1, # of white spaces = 1" Any idea,anyone? Multumesc. | ||
|
| Advertisment | |
![]() |
|
| Thread Tools | |
|
|