summaryrefslogtreecommitdiff
path: root/biblio/bibtex/utils/mkbib/src/scan.l
blob: 7d1f26d93f23626fab516ab07fe429bb4d56c90e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
%{
#include "bib.h"
  int line;
%}

%option noyywrap

%x braceV

%%

<braceV>[^{}]* { yylval.sval = strdup(yytext); return VALUE; }
<braceV>[{}]   { return *yytext; }

[A-Za-z][A-Za-z0-9_":]* 	{ yylval.sval = strdup(yytext); return KEY; }
\".*\"              	{ yylval.sval = strndup(yytext+1, yyleng-2); return VALUE; }
[0-9]+                  	{ yylval.sval = strdup(yytext); return VALUE; }
@[A-Za-z][A-Za-z]+      	{ yylval.sval = strdup(yytext+1); return ENTRYTYPE; }
[ \t\n]                 	; /* ignore whitespace */
[{}=,]                  	{ return *yytext; }
#.                       	{ fprintf(stderr, "Unrecognized character %c in input\n", *yytext); }
\n				{line++;printf("%d",line);}

%%

void lex_brace() {
    BEGIN(braceV);
}
void lex_normal() {
    BEGIN(0);
}