File: gcgl.l

package info (click to toggle)
squizz 0.99d%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,772 kB
  • sloc: sh: 4,799; ansic: 2,640; lex: 1,992; yacc: 1,650; makefile: 123
file content (66 lines) | stat: -rw-r--r-- 1,421 bytes parent folder | download | duplicates (3)
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
/* gcgl.l - GCG 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/gcgy.h"

static int init = 0;
%}

%option bison-bridge
%option never-interactive
%option noinput nounput noyywrap

%x HEAD SEQS

alp       [[:alpha:]]
dig       [[:digit:]]
dot       "."
eol       "\n"
exc       "!"
min       "-"
spc       " "
sta       "*"

txt       .{1,80}

tag       {exc}{2}[NA]A_SEQUENCE{spc}{dig}+{dot}{dig}+
bas       ({alp}|{sta}|{min}){1,80}

%%

%{
if (init == 0) { init = 1; BEGIN HEAD; } /* FIXME: Not thread safe !!! */
%}

<*>^{tag}      { BEGIN HEAD; }
<HEAD>{dot}{2}{spc}?/{eol} { BEGIN SEQS; return TER; }
<HEAD>{txt}    { return TXT; }
<HEAD>{txt}/{dot}{dot}{spc}{eol} { return TXT; }
<HEAD>{txt}/{dot}{dot}{eol} { return TXT; }
<HEAD>{eol}    { return EOL; }

<SEQS>^{spc}+/{dig} ; /* Leading spaces ignored */
<SEQS>{spc}+/{eol} ; /* Trailing spaces ignored */
<SEQS>{bas}    { yylval->str = xstrdup(yytext, yyleng); return BAS; }
<SEQS>{dig}+   { return INT; }
<SEQS>{spc}{1,2} { return SPC; }
<SEQS>^{eol}   ; /* Empty sequence line ignored */
<SEQS>{eol}    { return EOL; }
<SEQS><<EOF>>  { init = 0; BEGIN INITIAL; return END; }
<SEQS>.        { return ERR; }

<<EOF>>        { init = 0; BEGIN INITIAL; return NUL; }
{eol}          { return ERR; }
.              { return ERR; }

%%