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 69 70 71 72 73 74 75 76
|
/* clustall.l - CLUSTAL alignment lexer */
%{
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "extern/text.h"
#include "align.h"
#include "align/clustaly.h"
%}
%option bison-bridge
%option never-interactive
%option noinput nounput noyywrap
%x HDRTAG SEQTAG CONTAG
alp [[:alpha:]]
blk [[:blank:]]
dig [[:digit:]]
dot "."
eol "\n"
min "-"
que "?"
spc " "
sta "*"
tab "\t"
til "~"
txt .{1,80}
tag (CLUSTAL|[Cc]lustal)
nam [^ \t\n]{1,50}
msk !(SS|GM)_{nam}
gap ({dot}|{min}|{que}|{til})
bas ({alp}|{gap}|{sta}){1,10}
con ({blk}|{dot}|{sta}|":"){1,10}
%%
^{blk}*{eol} ; /* Empty lines ignored */
^{blk}*{eol}+/{tag} ; /* Empty lines ignored */
^{blk}+ ; /* Empty lines at EOF ignored */
^{tag} { BEGIN HDRTAG; return TAG; }
<HDRTAG>{txt} { return TXT; }
<HDRTAG>{eol} { BEGIN INITIAL; return EOL; }
<HDRTAG>{eol}/{nam} { BEGIN SEQTAG; return EOL; }
^{spc}*{eol}+/{nam} { BEGIN SEQTAG; return EOL; }
<SEQTAG>^{msk}.*{eol} /* Ignore masks lines */
<SEQTAG>^{nam} { yylval->str = xstrdup(yytext, yyleng); return NAM; }
<SEQTAG>{bas} { yylval->str = xstrdup(yytext, yyleng); return BAS; }
<SEQTAG>{dig}+ { return INT; }
<SEQTAG>{blk}+ { return SPC; }
<SEQTAG>{blk}+/{eol} ; /* Trailing spaces ignored */
<SEQTAG>{eol}/{nam} { return EOL; }
<SEQTAG>{eol}/{con} { BEGIN CONTAG; return EOL; }
<SEQTAG>{eol} { BEGIN INITIAL; return EOL; }
<SEQTAG><<EOF>> { BEGIN INITIAL; return EOL; }
<SEQTAG>. { return ERR; }
<CONTAG>{con} { return CON; }
<CONTAG>{eol} { BEGIN INITIAL; return EOL; }
<CONTAG><<EOF>> { BEGIN INITIAL; return EOL; }
<CONTAG>. { return ERR; }
<<EOF>> { return END; }
{eol} { return ERR; }
. { return ERR; }
%%
|