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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
/* igl.l - IG sequence lexer */
%{
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "extern/text.h"
#include "sequence.h"
#include "sequence/igy.h"
%}
%option bison-bridge
%option never-interactive
%option noinput nounput noyywrap
%x HCOM HNAM SEQS
alp [[:alpha:]]
blk [[:blank:]]
dot "."
eol "\n"
min "-"
sem ";"
spc " "
sta "*"
til "~"
txt .{1,80}
nam [^ \t\n]{1,80}
gap ({min}|{dot}|{til})
bas ({alp}|{gap}|{sta}){1,80}
typ [12]
%%
^{eol} ; /* Empty lines ignored */
^{sem}/{txt} { BEGIN HCOM; return SEM; }
^{sem}/{eol} { BEGIN HCOM; return SEM; }
<HCOM>{txt} { yylval->str = xstrdup(yytext, yyleng); return TXT; }
<HCOM>{eol} { BEGIN HNAM; return EOL; }
<HCOM>{eol}/{sem} { BEGIN INITIAL; return EOL; }
<HNAM>{nam} { yylval->str = xstrdup(yytext, yyleng); return NAM; }
<HNAM>^{blk}+ ; /* Leading spaces ignored */
<HNAM>{blk}+/{eol} ; /* Trailing spaces ignored */
<HNAM>{eol} { BEGIN SEQS; return EOL; }
<HNAM>. { return ERR; }
<SEQS>{bas} { yylval->str = xstrdup(yytext, yyleng); return BAS; }
<SEQS>{blk} ; /* Spaces ignored */
<SEQS>{typ} { return TYP; }
<SEQS>{eol} ; /* Newlines ignored */
<SEQS>{eol}/{sem} { BEGIN INITIAL; return END; }
<SEQS><<EOF>> { BEGIN INITIAL; return END; }
<SEQS>. { return ERR; }
<<EOF>> { BEGIN INITIAL; return NUL; }
{eol} { return ERR; }
. { return ERR; }
%%
|