~ubuntu-branches/ubuntu/raring/ibutils/raring-proposed

« back to all changes in this revision

Viewing changes to ibdm/ibdm/ibnl_scanner.ll

  • Committer: Bazaar Package Importer
  • Author(s): Benoit Mortier
  • Date: 2010-01-11 22:22:00 UTC
  • Revision ID: james.westby@ubuntu.com-20100111222200-53kum2et5nh13rv3
Tags: upstream-1.2-OFED-1.4.2
ImportĀ upstreamĀ versionĀ 1.2-OFED-1.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2004 Mellanox Technologies LTD. All rights reserved.
 
3
 *
 
4
 * This software is available to you under a choice of one of two
 
5
 * licenses.  You may choose to be licensed under the terms of the GNU
 
6
 * General Public License (GPL) Version 2, available from the file
 
7
 * COPYING in the main directory of this source tree, or the
 
8
 * OpenIB.org BSD license below:
 
9
 *
 
10
 *     Redistribution and use in source and binary forms, with or
 
11
 *     without modification, are permitted provided that the following
 
12
 *     conditions are met:
 
13
 *
 
14
 *      - Redistributions of source code must retain the above
 
15
 *        copyright notice, this list of conditions and the following
 
16
 *        disclaimer.
 
17
 *
 
18
 *      - Redistributions in binary form must reproduce the above
 
19
 *        copyright notice, this list of conditions and the following
 
20
 *        disclaimer in the documentation and/or other materials
 
21
 *        provided with the distribution.
 
22
 *
 
23
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
24
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
25
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
26
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 
27
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 
28
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
29
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 
30
 * SOFTWARE.
 
31
 *
 
32
 * $Id$
 
33
 */
 
34
 
 
35
%{
 
36
 
 
37
// #define DEBUG 1
 
38
#define yymaxdepth ibnl_maxdepth
 
39
#define yyparse ibnl_parse
 
40
#define yylex   ibnl_lex
 
41
#define yyerror ibnl_error
 
42
#define yylval  ibnl_lval
 
43
#define yychar  ibnl_char
 
44
#define yydebug ibnl_debug
 
45
#define yypact  ibnl_pact
 
46
#define yyr1    ibnl_r1
 
47
#define yyr2    ibnl_r2
 
48
#define yydef   ibnl_def
 
49
#define yychk   ibnl_chk
 
50
#define yypgo   ibnl_pgo
 
51
#define yyact   ibnl_act
 
52
#define yyexca  ibnl_exca
 
53
#define  yyerrflag ibnl_errflag
 
54
#define  yynerrs        ibnl_nerrs
 
55
#define yyps    ibnl_ps
 
56
#define yypv    ibnl_pv
 
57
#define yys     ibnl_s
 
58
#define yy_yys  ibnl_yys
 
59
#define yystate ibnl_state
 
60
#define yytmp   ibnl_tmp
 
61
#define yyv     ibnl_v
 
62
#define yy_yyv  ibnl_yyv
 
63
#define yyval   ibnl_val
 
64
#define yylloc  ibnl_lloc
 
65
#define yyreds  ibnl_reds
 
66
#define yytoks  ibnl_toks
 
67
#define yylhs   ibnl_yylhs
 
68
#define yylen   ibnl_yylen
 
69
#define yydefred ibnl_yydefred
 
70
#define yydgoto ibnl_yydgoto
 
71
#define yysindex ibnl_yysindex
 
72
#define yyrindex ibnl_yyrindex
 
73
#define yygindex ibnl_yygindex
 
74
#define yytable  ibnl_yytable
 
75
#define yycheck  ibnl_yycheck
 
76
#define yyname   ibnl_yyname
 
77
#define yyrule   ibnl_yyrule
 
78
 
 
79
#include <string.h>
 
80
#include <stdio.h>
 
81
#include "Fabric.h"
 
82
#include "ibnl_parser.h"
 
83
#include "SysDef.h"
 
84
extern long lineNum;
 
85
%}
 
86
 
 
87
%%
 
88
 
 
89
([1-9][0-9]*|0) {
 
90
  yylval.ival = atoi(yytext);
 
91
#ifdef DEBUG
 
92
  printf("INT:%d\n",yylval.ival);
 
93
#endif
 
94
  return INT;
 
95
}
 
96
 
 
97
SYSTEM {
 
98
  yylval.ival = SYSTEM;
 
99
#ifdef DEBUG
 
100
  printf("SYSTEM\n");
 
101
#endif
 
102
  return SYSTEM;
 
103
}
 
104
 
 
105
TOPSYSTEM {
 
106
  yylval.ival = TOPSYSTEM;
 
107
#ifdef DEBUG
 
108
  printf("TOPSYSTEM\n");
 
109
#endif
 
110
  return TOPSYSTEM;
 
111
}
 
112
 
 
113
NODE {
 
114
  yylval.ival = NODE;
 
115
#ifdef DEBUG
 
116
  printf("NODE\n");
 
117
#endif
 
118
  return NODE;
 
119
}
 
120
 
 
121
1x|4x|8x|12x {
 
122
         yylval.sval = (char *)malloc(strlen(yytext) + 1);
 
123
    strcpy(yylval.sval, yytext);
 
124
#ifdef DEBUG
 
125
         printf("WIDTH:%s\n",yylval.sval);
 
126
#endif
 
127
  return WIDTH;
 
128
}
 
129
 
 
130
2.5G|5G|10G {
 
131
         yylval.sval = (char *)malloc(strlen(yytext));
 
132
    strncpy(yylval.sval, yytext, strlen(yytext) - 1);
 
133
    strcat(yylval.sval, "");
 
134
#ifdef DEBUG
 
135
         printf("SPEED:%s\n",yylval.sval);
 
136
#endif
 
137
  return SPEED;
 
138
}
 
139
 
 
140
SUBSYSTEM {
 
141
  yylval.ival = SUBSYSTEM;
 
142
#ifdef DEBUG
 
143
  printf("SUBSYSTEM\n");
 
144
#endif
 
145
  return SUBSYSTEM;
 
146
}
 
147
 
 
148
CFG: {
 
149
  yylval.ival = CFG;
 
150
#ifdef DEBUG
 
151
  printf("CFG\n");
 
152
#endif
 
153
  return CFG;
 
154
}
 
155
 
 
156
(SW|CA|HCA) {
 
157
  if (!strcmp(yytext,"SW")) {
 
158
    yylval.tval = IB_SW_NODE;
 
159
  } else {
 
160
    yylval.tval = IB_CA_NODE;
 
161
  }
 
162
#ifdef DEBUG
 
163
  printf("%s\n", yytext);
 
164
#endif
 
165
  return NODETYPE;
 
166
}
 
167
 
 
168
[A-Za-z][-\[\]\\\*/A-Za-z0-9_.:%@~]+ {
 
169
         yylval.sval = (char *)malloc(strlen(yytext) + 1);
 
170
    strcpy(yylval.sval, yytext);
 
171
#ifdef DEBUG
 
172
         printf("NAME:%s\n",yylval.sval);
 
173
#endif
 
174
         return (NAME);
 
175
}
 
176
 
 
177
\n {
 
178
  lineNum++;
 
179
#ifdef DEBUG
 
180
  printf("LINE\n");
 
181
#endif
 
182
  if(lineNum % 10000==0)
 
183
         fprintf(stderr,"-I- Parsed %ld lines\r",lineNum);
 
184
  yylval.ival = LINE;
 
185
  return(LINE);
 
186
}
 
187
 
 
188
[ \t]+ {}
 
189
 
 
190
. {
 
191
#ifdef DEBUG
 
192
  printf("CHAR:%c\n",yytext[0]);
 
193
#endif
 
194
  return(yytext[0]);
 
195
}
 
196
 
 
197
%%
 
198
 
 
199
int yywrap ()
 
200
{
 
201
  return (1);
 
202
}
 
203