나는 초보자입니다. flex/bison을 사용하여 bibtex 파일을 구문 분석하고 싶습니다.들소와 함께 bibtex 구문 분석
@Book{a1,
author="amook",
Title="ASR",
Publisher="oxf",
Year="2010",
Add="UK",
Edition="1",
}
@Article{a2,
Author="Rudra Banerjee",
Title={FeNiMo},
Publisher={P{\"R}B},
Issue="12",
Page="36690",
Year="2011",
Add="UK",
Edition="1",
}
이 구문 분석을 위해 나는 다음과 같은 코드를 작성했습니다 : 샘플 하여 BibTex입니다
%{
#include <stdio.h>
#include <stdlib.h>
%}
%{
char yylval;
int YEAR,i;
//char array_author[1000];
%}
%x author
%x title
%x pub
%x year
%%
@ printf("\nNEWENTRY\n");
[a-zA-Z][a-zA-Z0-9]* {printf("%s",yytext);
BEGIN(INITIAL);}
author= {BEGIN(author);}
<author>\"[a-zA-Z\/.]+\" {printf("%s",yytext);
BEGIN(INITIAL);}
year= {BEGIN(year);}
<year>\"[0-9]+\" {printf("%s",yytext);
BEGIN(INITIAL);}
title= {BEGIN(title);}
<title>\"[a-zA-Z\/.]+\" {printf("%s",yytext);
BEGIN(INITIAL);}
publisher= {BEGIN(pub);}
<pub>\"[a-zA-Z\/.]+\" {printf("%s",yytext);
BEGIN(INITIAL);}
[a-zA-Z0-9\/.-]+= printf("ENTRY TYPE ");
\" printf("QUOTE ");
\{ printf("LCB ");
\} printf(" RCB");
; printf("SEMICOLON ");
\n printf("\n");
%%
int main(){
yylex();
//char array_author[1000];
//printf("%d%s",&i,array_author[i]);
i++;
return 0;
}
문제는 내가 다른 변수 키와 val 분리에 저장하려는입니다 어떤 장소 (배열일지도 모른다). 통찰력을 가질 수 있습니까?
가능한 중복 (http://stackoverflow.com/questions/15305789/parse-bibtex-with-flexbison-revisited) –