Dear friends,
I am trying to parse a bibtex file with structure like:
@Book{ab01,
Author="Author 1 and Author 2",
Editor="sm1",
Title="A book title",
Year="2012"
}
I am trying to parse bibtex file with many such unit
%{
#include <stdio.h>
#include <stdlib.h>
%}
%{
char yylval;
int YEAR;
%}
%x author
%x year
%%
@[a-zA-Z][a-zA-Z0-9]* { printf("%s",yytext);}
Author= {BEGIN(author);}
<author>\"[a-zA-Z\/.]+\" { printf("%s",yytext);
BEGIN(INITIAL);}
Year= {BEGIN(year);}
<year>\"[0-9]*\" {printf("%s",yytext);
BEGIN(INITIAL);}
[a-zA-Z0-9\/.-]+ printf("ENTRY TYPE ");
\" printf("QUOTE ");
\{ printf(" ");
\} printf(" ");
; printf("SEMICOLON ");
\n printf("\n");
[\,\n\}][\,\}] printf("\nNEWENTRY");
%%
What I am trying to achieve is to have each string of Author in a array,
say fauth[i], and like that.
I tried something like
<author>\"[a-zA-Z\/.]+\" { return fauth;printf("%s",fauth);
BEGIN(INITIAL);}
but it failed.
I will be grateful if some one kindly help me.
|