Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %option noyywrap
- %{
- int Nr=1;
- int Licz=0;
- int pom = 0;
- char liczby = '0';
- void komunikat1(char);
- void komunikat2();
- void komunikat3();
- void komunikat4();
- %}
- %start slc10
- %start slc16
- %start slrst
- %start slrzm
- %start blad
- Lc10 [0-9]+
- Lc16 [0-9A-F]+
- Lrst [0-9]+\.[0-9]+
- Lrzm [0-9]+\.[0-9]+E(\+|\-)[0-9]+
- %%
- <INITIAL>{Lc10} {Licz++; BEGIN(slc10); };
- <INITIAL>{Lc16} {Licz++; BEGIN(slc16); };
- <INITIAL>{Lrst} {Licz++; BEGIN(slrst); };
- <INITIAL>{Lrzm} {Licz++; BEGIN(slrzm); };
- <INITIAL>\n {komunikat2(); };
- <slc10>{Lc10} {Licz++; BEGIN(slc10); };
- <slc10>{Lc16} {komunikat3(); };
- <slc10>{Lrst} {komunikat3(); };
- <slc10>{Lrzm} {komunikat3(); };
- <slc10>\n {komunikat1('a'); };
- <slc16>{Lc10} {komunikat3(); };
- <slc16>{Lc16} {Licz++; BEGIN(slc16); };
- <slc16>{Lrst} {komunikat3(); };
- <slc16>{Lrzm} {komunikat3(); };
- <slc16>\n {komunikat1('b'); };
- <slrst>{Lc10} {komunikat3(); };
- <slrst>{Lc16} {komunikat3(); };
- <slrst>{Lrst} {Licz++; BEGIN(slrst); };
- <slrst>{Lrzm} {komunikat3(); };
- <slrst>\n {komunikat1('c'); };
- <slrzm>{Lc10} {komunikat3(); };
- <slrzm>{Lc16} {komunikat3(); };
- <slrzm>{Lrst} {komunikat3(); };
- <slrzm>{Lrzm} {Licz++; BEGIN(slrzm); };
- <slrzm>\n {komunikat1('d'); };
- [\r\t] ;
- %%
- void komunikat1(char c)
- {
- printf("wiersz: %d; liczby: %c; ilosc: %d\n", Nr++, c, Licz);
- Licz=0;
- BEGIN INITIAL;
- }
- void komunikat2()
- {
- printf("To jest wiersz pusty\n");
- Nr++;
- BEGIN INITIAL;
- }
- void komunikat3()
- {
- printf("Wiersz ma niejednorodna postac\n");
- Nr++;
- Licz++;
- BEGIN INITIAL;
- }
- void komunikat4()
- {
- printf("To nie jest liczba kategorii a, b, c lub d\n");
- Nr++;
- BEGIN INITIAL;
- }
- int main()
- {
- yylex();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement