1 %option nounput
2 %option noinput
3 
4 %{ /* -*- C -*- */
5 /*
6  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
7  *                         University Research and Technology
8  *                         Corporation.  All rights reserved.
9  * Copyright (c) 2004-2006 The University of Tennessee and The University
10  *                         of Tennessee Research Foundation.  All rights
11  *                         reserved.
12  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
13  *                         University of Stuttgart.  All rights reserved.
14  * Copyright (c) 2004-2005 The Regents of the University of California.
15  *                         All rights reserved.
16  * Copyright (c) 2008      Voltaire. All rights reserved
17  * Copyright (c) 2013      Los Alamos National Security, LLC.
18  *                         All rights reserved.
19  * Copyright (c) 2015      Research Organization for Information Science
20  *                         and Technology (RIST). All rights reserved.
21  *
22  * $COPYRIGHT$
23  *
24  * Additional copyrights may follow
25  *
26  * $HEADER$
27  */
28 #include "orte_config.h"
29 
30 #include <stdio.h>
31 #ifdef HAVE_UNISTD_H
32 #include <unistd.h>
33 #endif
34 
35 #include "orte/mca/rmaps/rank_file/rmaps_rank_file_lex.h"
36 #include "opal/util/output.h"
37 
38 BEGIN_C_DECLS
39 
40 int orte_rmaps_rank_file_yywrap(void);
41 
42 END_C_DECLS
43 
44 /*
45  * global variables
46  */
47 int orte_rmaps_rank_file_line=1;
48 orte_rmaps_rank_file_value_t orte_rmaps_rank_file_value = {0};
49 bool orte_rmaps_rank_file_done = false;
50 
51 %}
52 
53 WHITE       [\f\t\v ]
54 
55 %x comment
56 
57 %%
58 
59 {WHITE}*\n         { orte_rmaps_rank_file_line++;
60                      return ORTE_RANKFILE_NEWLINE; }
61 #.*\n              { orte_rmaps_rank_file_line++;
62                      return ORTE_RANKFILE_NEWLINE; }
63 "//".*\n           { orte_rmaps_rank_file_line++;
64                      return ORTE_RANKFILE_NEWLINE; }
65 
66 "/*"               { BEGIN(comment);
67                      return ORTE_RANKFILE_NEWLINE; }
68 <comment>[^*\n]*       ; /* Eat up non '*'s */
69 <comment>"*"+[^*/\n]*  ; /* Eat '*'s not followed by a '/' */
70 <comment>\n        { orte_rmaps_rank_file_line++;
71                      return ORTE_RANKFILE_NEWLINE; }
72 <comment>"*"+"/"   { BEGIN(INITIAL); /* Done with Block Comment */
73                      return ORTE_RANKFILE_NEWLINE; }
74 
75 \"[^\"]*\"         { orte_rmaps_rank_file_value.sval = yytext;
76                      return ORTE_RANKFILE_QUOTED_STRING; }
77 
78 {WHITE}+           ;
79 
80 "="                { return ORTE_RANKFILE_EQUAL; }
81 
82 rank                { orte_rmaps_rank_file_value.sval = yytext;
83                      return ORTE_RANKFILE_RANK; }
84 slot               { orte_rmaps_rank_file_value.sval = yytext;
85                      return ORTE_RANKFILE_SLOT; }
86 slots              { orte_rmaps_rank_file_value.sval = yytext;
87                      return ORTE_RANKFILE_SLOT; }
88 
89 username           { orte_rmaps_rank_file_value.sval = yytext;
90                      return ORTE_RANKFILE_USERNAME; }
91 "user-name"        { orte_rmaps_rank_file_value.sval = yytext;
92                      return ORTE_RANKFILE_USERNAME; }
93 "user_name"        { orte_rmaps_rank_file_value.sval = yytext;
94                      return ORTE_RANKFILE_USERNAME; }
95 
96 [0-9]+             { orte_rmaps_rank_file_value.ival = atol(yytext);
97                      return ORTE_RANKFILE_INT; }
98 %{ /* First detect hosts as standard Strings (but without ".")
99     * then username@IPv4 or IPV4, then username@IPv6 or IPv6,
100     * followed by username@hostname or hostname
101     */
102 %}
103 
104 [A-Za-z0-9_\-,\;:*@]*  { orte_rmaps_rank_file_value.sval = yytext;
105                          return ORTE_RANKFILE_STRING; }
106 
107 ([A-Za-z0-9][A-Za-z0-9_\-]*"@")?([0-9]{1,3}"."){3}[0-9]{1,3} {
108                       orte_rmaps_rank_file_value.sval = yytext;
109                       return ORTE_RANKFILE_IPV4; }
110 
111 ([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} {
112                       orte_rmaps_rank_file_value.sval = yytext;
113                       return ORTE_RANKFILE_IPV6; }
114 
115 ([A-Za-z0-9][A-Za-z0-9_\-]*"@")?[A-Za-z][A-Za-z0-9_\-\.]*  {
116                      orte_rmaps_rank_file_value.sval = yytext;
117                      return ORTE_RANKFILE_HOSTNAME; }
118 
119 \+n[0-9]+           { orte_rmaps_rank_file_value.sval = yytext;
120 					 return ORTE_RANKFILE_RELATIVE; }
121 
122 .                  { orte_rmaps_rank_file_value.sval = yytext;
123                      return ORTE_RANKFILE_ERROR; }
124 
125 %%
126 
127 /* Old flex (2.5.4a? and older) does not define a destroy function */
128 #if !defined(YY_FLEX_SUBMINOR_VERSION)
129 #define YY_FLEX_SUBMINOR_VERSION 0
130 #endif
131 
132 #if (YY_FLEX_MAJOR_VERSION < 2) || (YY_FLEX_MAJOR_VERSION == 2 && (YY_FLEX_MINOR_VERSION < 5 || (YY_FLEX_MINOR_VERSION == 5 && YY_FLEX_SUBMINOR_VERSION < 5)))
133 int orte_rmaps_rank_file_lex_destroy (void)
134 {
135     if (NULL != YY_CURRENT_BUFFER) {
136         yy_delete_buffer(YY_CURRENT_BUFFER);
137 #if defined(YY_CURRENT_BUFFER_LVALUE)
138         YY_CURRENT_BUFFER_LVALUE = NULL;
139 #else
140         YY_CURRENT_BUFFER = NULL;
141 #endif  /* YY_CURRENT_BUFFER_LVALUE */
142     }
143     return YY_NULL;
144 }
145 #endif
146 
147 int orte_rmaps_rank_file_wrap(void)
148 {
149     orte_rmaps_rank_file_done = true;
150     return 1;
151 }
152