File: foreign-pajek-lexer.l

package info (click to toggle)
r-cran-igraph 1.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 14,984 kB
  • sloc: ansic: 117,319; cpp: 22,287; fortran: 4,551; yacc: 1,150; tcl: 931; lex: 478; makefile: 149; sh: 9
file content (148 lines) | stat: -rw-r--r-- 6,806 bytes parent folder | download
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* 
   IGraph library.
   Copyright (C) 2006-2012  Gabor Csardi <csardi.gabor@gmail.com>
   334 Harvard st, Cambridge, MA, 02138 USA
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc.,  51 Franklin Street, Fifth Floor, Boston, MA 
   02110-1301 USA

*/

%{

/* 
   IGraph library.
   Copyright (C) 2006-2012  Gabor Csardi <csardi.gabor@gmail.com>
   334 Harvard st, Cambridge, MA, 02138 USA
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc.,  51 Franklin Street, Fifth Floor, Boston, MA 
   02110-1301 USA

*/

#include "config.h"
#include <stdlib.h>
#include "foreign-pajek-header.h"
#include "foreign-pajek-parser.h"
#define YY_EXTRA_TYPE igraph_i_pajek_parsedata_t*
#define YY_USER_ACTION yylloc->first_line = yylineno;
/* We assume that 'file' is 'stderr' here. */
#ifdef USING_R
#define fprintf(file, msg, ...) (1)
#endif
#ifdef stdout 
#  undef stdout
#endif
#define stdout 0
#define exit(code) igraph_error("Fatal error in DL parser", __FILE__, \
				__LINE__, IGRAPH_PARSEERROR);
%}

%option noyywrap
%option prefix="igraph_pajek_yy"
%option outfile="lex.yy.c"
%option nounput
%option noinput
%option nodefault
%option reentrant
%option bison-bridge
%option bison-locations

digit [0-9]
word [^ \t\r\n]

%%

[ \t]*          { }
%[^\n]*\n[\r]*  { }
%[^\n]*\r[\n]*  { }
\*[Nn][eE][Tt]                         { return NETWORKLINE; }
\*[Nn][Ee][Tt][Ww][Oo][Rr][Kk]         { return NETWORKLINE; }
\*[Vv][Ee][Rr][Tt][Ii][Cc][Ee][Ss]     { return VERTICESLINE; }
\*[Aa][Rr][Cc][Ss]                     { return ARCSLINE; }
\*[Ee][Dd][Gg][Ee][Ss]                 { return EDGESLINE; }
\*[Aa][Rr][Cc][Ss][Ll][Ii][Ss][Tt]     { return ARCSLISTLINE; }
\*[Ee][Dd][Gg][Ee][Ss][Ll][Ii][Ss][Tt] { return EDGESLISTLINE; }
\*[Mm][Aa][Tt][Rr][Ii][Xx]             { return MATRIXLINE; }
\n\r|\r\n|\n|\r   { yyextra->mode=0; return NEWLINE; }
\"[^\"]*\"        { return QSTR; }
\([^\)]*\)        { return PSTR; }
\-?{digit}+(\.{digit}+)?([eE](\+|\-)?{digit}+)? { 
                    return NUM; }

[Xx]_[Ff][Aa][Cc][Tt]/[ \t\n\r]  { if (yyextra->mode==1) { return VP_X_FACT; } else { return ALNUM; } }
[Yy]_[Ff][Aa][Cc][Tt]/[ \t\n\r]  { if (yyextra->mode==1) { return VP_Y_FACT; } else { return ALNUM; } }
[Ii][Cc]/[ \t\n\r]               { if (yyextra->mode==1) { return VP_IC; } else { return ALNUM; } }
[Bb][Cc]/[ \t\n\r]               { if (yyextra->mode==1) { return VP_BC; } else { return ALNUM; } }
[Bb][Ww]/[ \t\n\r]               { if (yyextra->mode==1) { return VP_BW; } else { return ALNUM; } }
[Pp][Hh][Ii]/[ \t\n\r]           { if (yyextra->mode==1) { return VP_PHI; } else { return ALNUM; } }
[Rr]/[ \t\n\r]                   { if (yyextra->mode==1) { return VP_R; } else { return ALNUM; } }
[Qq]/[ \t\n\r]                   { if (yyextra->mode==1) { return VP_Q; } else { return ALNUM; } }
[Ff][Oo][Nn][Tt]/[ \t\n\r]       { if (yyextra->mode==1) { return VP_FONT; } else { return ALNUM; } }
[Uu][Rr][Ll]/[ \t\n\r]           { if (yyextra->mode==1) { return VP_URL; } else { return ALNUM; } }

[Cc]/[ \t\n\r]       { if (yyextra->mode==2) { return EP_C; } else { return ALNUM; } }
[Pp]/[ \t\n\r]       { if (yyextra->mode==2) { return EP_P; } else { return ALNUM; } }
[Ss]/[ \t\n\r]       { if (yyextra->mode==2) { return EP_S; } else { return ALNUM; } }
[Aa]/[ \t\n\r]       { if (yyextra->mode==2) { return EP_A; } else { return ALNUM; } }
[Ww]/[ \t\n\r]       { if (yyextra->mode==2) { return EP_W; } else { return ALNUM; } }
[Hh]1/[ \t\n\r]      { if (yyextra->mode==2) { return EP_H1; } else { return ALNUM; } }
[Hh]2/[ \t\n\r]      { if (yyextra->mode==2) { return EP_H2; } else { return ALNUM; } }
[Aa]1/[ \t\n\r]      { if (yyextra->mode==2) { return EP_A1; } else { return ALNUM; } }
[Aa]2/[ \t\n\r]      { if (yyextra->mode==2) { return EP_A2; } else { return ALNUM; } }
[Kk]1/[ \t\n\r]      { if (yyextra->mode==2) { return EP_K1; } else { return ALNUM; } }
[Kk]2/[ \t\n\r]      { if (yyextra->mode==2) { return EP_K2; } else { return ALNUM; } }
[Aa][Pp]/[ \t\n\r]   { if (yyextra->mode==2) { return EP_AP; } else { return ALNUM; } }
[Ll]/[ \t\n\r]       { if (yyextra->mode==2) { return EP_L; } else { return ALNUM; } }
[Ll][Pp]/[ \t\n\r]   { if (yyextra->mode==2) { return EP_LP; } else { return ALNUM; } }

[Ll][Pp][Hh][Ii]/[ \t\n\r] { if (yyextra->mode==1) { return VP_LPHI; } else
                             if (yyextra->mode==2) { return EP_LPHI; } else { return ALNUM; } }
[Ll][Cc]/[ \t\n\r]         { if (yyextra->mode==1) { return VP_LC; } else
                             if (yyextra->mode==2) { return EP_LC; } else { return ALNUM; } }
[Ll][Rr]/[ \t\n\r]         { if (yyextra->mode==1) { return VP_LR; } else
                             if (yyextra->mode==2) { return EP_LR; } else { return ALNUM; } }
[Ll][Aa]/[ \t\n\r]         { if (yyextra->mode==1) { return VP_LA; } else
                             if (yyextra->mode==2) { return EP_LA; } else { return ALNUM; } }
[Ss][Ii][Zz][Ee]/[ \t\n\r] { if (yyextra->mode==1) { return VP_SIZE; } else 
                             if (yyextra->mode==2) { return EP_SIZE; } else { return ALNUM; } }
[Ff][Oo][Ss]/[ \t\n\r]     { if (yyextra->mode==1) { return VP_FOS; } else 
                             if (yyextra->mode==2) { return EP_FOS; } else { return ALNUM; } }
                             
{word}+           { return ALNUM; }

<<EOF>>           { if (yyextra->eof) {
                       yyterminate();
                    } else {
                       yyextra->eof=1;
                       return NEWLINE; 
                    }
                  }

.                 { return ERROR; }

%%