File: hostfile_lex.l

package info (click to toggle)
openmpi 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 99,912 kB
  • ctags: 55,589
  • sloc: ansic: 525,999; f90: 18,307; makefile: 12,062; sh: 6,583; java: 6,278; asm: 3,515; cpp: 2,227; perl: 2,136; python: 1,350; lex: 734; fortran: 52; tcl: 12
file content (185 lines) | stat: -rw-r--r-- 7,048 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
%option nounput
%option noinput

%{ /* -*- C -*- */
/*
 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2006 The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
 *                         University of Stuttgart.  All rights reserved.
 * Copyright (c) 2004-2005 The Regents of the University of California.
 *                         All rights reserved.
 * Copyright (c) 2011      Cisco Systems, Inc.  All rights reserved.
 * Copyright (c) 2015      Research Organization for Information Science
 *                         and Technology (RIST). All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */
#include "orte_config.h"

#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#include "orte/util/hostfile/hostfile_lex.h"

/*
 * local functions
 */
BEGIN_C_DECLS

int orte_util_hostfile_wrap(void);

END_C_DECLS

int orte_util_hostfile_wrap(void)
{
    orte_util_hostfile_done = true;
    return 1;
}

/*
 * global variables
 */
int orte_util_hostfile_line=1;
orte_hostfile_value_t orte_util_hostfile_value = {0};
bool orte_util_hostfile_done = false;

%}

WHITE       [\f\t\v ]

%x comment

%%

{WHITE}*\n         { orte_util_hostfile_line++;
                     return ORTE_HOSTFILE_NEWLINE; }
#.*\n              { orte_util_hostfile_line++;
                     return ORTE_HOSTFILE_NEWLINE; }
"//".*\n           { orte_util_hostfile_line++;
                     return ORTE_HOSTFILE_NEWLINE; }

"/*"               { BEGIN(comment);
                     return ORTE_HOSTFILE_NEWLINE; }
<comment>[^*\n]*       ; /* Eat up non '*'s */
<comment>"*"+[^*/\n]*  ; /* Eat '*'s not followed by a '/' */
<comment>\n        { orte_util_hostfile_line++;
                     return ORTE_HOSTFILE_NEWLINE; }
<comment>"*"+"/"   { BEGIN(INITIAL); /* Done with Block Comment */
                     return ORTE_HOSTFILE_NEWLINE; }

\"[^\"]*\"         { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_QUOTED_STRING; }

{WHITE}+           ;			/* whitespace */

"="                { return ORTE_HOSTFILE_EQUAL; }

cpu                { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_CPU; }
count              { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_COUNT; }
slots              { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS; }
"slots-max"        { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS_MAX; }
slots_max          { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS_MAX; }
"max-slots"        { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS_MAX; }
max_slots          { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS_MAX; }
"cpu-max"          { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS_MAX; }
cpu_max            { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS_MAX; }
"max-cpu"          { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS_MAX; }
max_cpu            { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS_MAX; }
"count-max"        { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS_MAX; }
count_max          { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS_MAX; }
"max-count"        { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS_MAX; }
max_count          { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOTS_MAX; }

rank                { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_RANK; }
slot               { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SLOT; }

username           { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_USERNAME; }
"user-name"        { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_USERNAME; }
"user_name"        { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_USERNAME; }

boards             { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_BOARDS; }

sockets            { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SOCKETS_PER_BOARD; }

sockets_per_board  { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SOCKETS_PER_BOARD; }

"sockets-per-board" { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_SOCKETS_PER_BOARD; }

cores              { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_CORES_PER_SOCKET; }

cores_per_socket   { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_CORES_PER_SOCKET; }

"cores-per-socket" { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_CORES_PER_SOCKET; }

\+n[0-9]+	   { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_RELATIVE; }
\+[eE][\:][0-9]+   { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_RELATIVE; }
\+[eE]             { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_RELATIVE; }


[0-9]+             { orte_util_hostfile_value.ival = atol(yytext);
                     return ORTE_HOSTFILE_INT; }
%{ /* First detect hosts as standard Strings (but without ".")
    * then username@IPv4 or IPV4, then username@IPv6 or IPv6,
    * followed by username@hostname or hostname
    */
%}

[A-Za-z0-9_\-,:*@]*  { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_STRING; }

([A-Za-z0-9][A-Za-z0-9_\-]*"@")?([0-9]{1,3}"."){3}[0-9]{1,3} {
                      orte_util_hostfile_value.sval = yytext;
                      return ORTE_HOSTFILE_IPV4; }

([A-Za-z0-9][A-Za-z0-9_\-]*"@")?([A-Fa-f0-9]{0,4}":")+[":"]*([A-Fa-f0-9]{0,4}":")+[A-Fa-f0-9]{1,4} {
                      orte_util_hostfile_value.sval = yytext;
                      return ORTE_HOSTFILE_IPV6; }

(\^?[A-Za-z0-9][A-Za-z0-9_\-]*"@")?[A-Za-z0-9][A-Za-z0-9_\-\.]*  {
                     orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_HOSTNAME; }

.                  { orte_util_hostfile_value.sval = yytext;
                     return ORTE_HOSTFILE_ERROR; }

%%