Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %option noyywrap
- %{
- #include <stdlib.h>
- char buf[256];
- int count, pos;
- %}
- %x STRING COMMENT
- %%
- "{" {
- BEGIN(COMMENT);
- }
- <COMMENT>[^}]*
- <COMMENT>"}" {
- BEGIN(INITIAL);
- }
- "'" {
- BEGIN(STRING);
- }
- <STRING>"'" {
- printf("%d: %s\n", count, buf);
- count = pos = 0;
- BEGIN(INITIAL);
- }
- <STRING>[^\'] {
- buf[pos++] = *yytext;
- count++;
- }
- <STRING>"''" {
- buf[pos++] = *yytext;
- count += 2;
- }
- %%
- int main()
- {
- yylex();
- getchar();
- return 0;
- }
Add Comment
Please, Sign In to add comment