[openib-general] [PATCH 1/6] osm: QoS parser Lex file
Yevgeny Kliteynik
kliteyn at dev.mellanox.co.il
Wed Jan 17 07:03:58 PST 2007
Hi Hal.
This patch is QoS parser Lex file
Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
---
osm/opensm/osm_qos_parser.l | 245 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 245 insertions(+), 0 deletions(-)
diff --git a/osm/opensm/osm_qos_parser.l b/osm/opensm/osm_qos_parser.l
new file mode 100644
index 0000000..73b2a29
--- /dev/null
+++ b/osm/opensm/osm_qos_parser.l
@@ -0,0 +1,245 @@
+%{
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Lexer of OSM QoS parser.
+ *
+ * Environment:
+ * Linux User Mode
+ *
+ * Author:
+ * Yevgeny Kliteynik, Mellanox
+ */
+
+#include <opensm/osm_qos_parser.h>
+#include <opensm/osm_qos_parser_y.h>
+
+#define SAVE_POS save_pos()
+static void save_pos();
+
+extern int column_num;
+extern int line_num;
+extern FILE * yyin;
+
+%}
+
+XML_VERSION_START <\?
+XML_VERSION_END \?>
+QOS_POLICY_START <qos\-policy>
+QOS_POLICY_END <\/qos\-policy>
+PORT_GROUPS_START <port\-groups>
+PORT_GROUPS_END <\/port\-groups>
+PORT_GROUP_START <port\-group>
+PORT_GROUP_END <\/port\-group>
+NAME_START <name>
+NAME_END <\/name>
+USE_START <use>
+USE_END <\/use>
+PORT_GUID_START <port\-guid>
+PORT_GUID_END <\/port\-guid>
+PORT_NAME_START <port\-name>
+PORT_NAME_END <\/port\-name>
+PARTITION_START <partition>
+PARTITION_END <\/partition>
+NODE_TYPE_START <node\-type>
+NODE_TYPE_END <\/node\-type>
+QOS_SETUP_START <qos\-setup>
+QOS_SETUP_END <\/qos\-setup>
+SL2VL_TABLES_START <sl2vl\-tables>
+SL2VL_TABLES_END <\/sl2vl\-tables>
+SL2VL_SCOPE_START <sl2vl\-scope>
+SL2VL_SCOPE_END <\/sl2vl\-scope>
+GROUP_START <group>
+GROUP_END <\/group>
+FROM_START <from>
+FROM_END <\/from>
+TO_START <to>
+TO_END <\/to>
+SL2VL_TABLE_START <sl2vl\-table>
+SL2VL_TABLE_END <\/sl2vl\-table>
+ACROSS_START <across>
+ACROSS_END <\/across>
+ACROSS_FROM_START <across\-from>
+ACROSS_FROM_END <\/across\-from>
+ACROSS_TO_START <across\-to>
+ACROSS_TO_END <\/across\-to>
+VLARB_TABLES_START <vlarb\-tables>
+VLARB_TABLES_END <\/vlarb\-tables>
+VLARB_SCOPE_START <vlarb\-scope>
+VLARB_SCOPE_END <\/vlarb\-scope>
+VLARB_HIGH_START <vlarb\-high>
+VLARB_HIGH_END <\/vlarb\-high>
+VLARB_LOW_START <vlarb\-low>
+VLARB_LOW_END <\/vlarb\-low>
+VLARB_HIGH_LIMIT_START <vl\-high\-limit>
+VLARB_HIGH_LIMIT_END <\/vl\-high\-limit>
+QOS_LEVELS_START <qos\-levels>
+QOS_LEVELS_END <\/qos\-levels>
+QOS_LEVEL_START <qos\-level>
+QOS_LEVEL_END <\/qos\-level>
+SN_START <sn>
+SN_END <\/sn>
+SL_START <sl>
+SL_END <\/sl>
+CLASS_START <class>
+CLASS_END <\/class>
+MTU_LIMIT_START <mtu\-limit>
+MTU_LIMIT_END <\/mtu\-limit>
+RATE_LIMIT_START <rate\-limit>
+RATE_LIMIT_END <\/rate\-limit>
+QOS_MATCH_RULES_START <qos\-match\-rules>
+QOS_MATCH_RULES_END <\/qos\-match\-rules>
+QOS_MATCH_RULE_START <qos\-match\-rule>
+QOS_MATCH_RULE_END <\/qos\-match\-rule>
+QOS_LEVEL_SN_START <qos\-level\-sn>
+QOS_LEVEL_SN_END <\/qos\-level\-sn>
+SOURCE_START <source>
+SOURCE_END <\/source>
+DESTINATION_START <destination>
+DESTINATION_END <\/destination>
+SERVICE_START <service>
+SERVICE_END <\/service>
+
+WHITE [ \t\n]*
+COMMENT <!--([^-]|-[^-]|--[^>])*-->
+
+%%
+
+{WHITE}{XML_VERSION_START}{WHITE} { SAVE_POS; return TK_XML_VERSION_START; }
+{WHITE}{XML_VERSION_END}{WHITE} { SAVE_POS; return TK_XML_VERSION_END; }
+{WHITE}{QOS_POLICY_START}{WHITE} { SAVE_POS; return TK_QOS_POLICY_START; }
+{WHITE}{QOS_POLICY_END}{WHITE} { SAVE_POS; return TK_QOS_POLICY_END; }
+{WHITE}{PORT_GROUPS_START}{WHITE} { SAVE_POS; return TK_PORT_GROUPS_START; }
+{WHITE}{PORT_GROUPS_END}{WHITE} { SAVE_POS; return TK_PORT_GROUPS_END; }
+{WHITE}{PORT_GROUP_START}{WHITE} { SAVE_POS; return TK_PORT_GROUP_START; }
+{WHITE}{PORT_GROUP_END}{WHITE} { SAVE_POS; return TK_PORT_GROUP_END; }
+{WHITE}{NAME_START}{WHITE} { SAVE_POS; return TK_NAME_START; }
+{WHITE}{NAME_END}{WHITE} { SAVE_POS; return TK_NAME_END; }
+{WHITE}{USE_START}{WHITE} { SAVE_POS; return TK_USE_START; }
+{WHITE}{USE_END}{WHITE} { SAVE_POS; return TK_USE_END; }
+{WHITE}{PORT_GUID_START}{WHITE} { SAVE_POS; return TK_PORT_GUID_START; }
+{WHITE}{PORT_GUID_END}{WHITE} { SAVE_POS; return TK_PORT_GUID_END; }
+{WHITE}{PORT_NAME_START}{WHITE} { SAVE_POS; return TK_PORT_NAME_START; }
+{WHITE}{PORT_NAME_END}{WHITE} { SAVE_POS; return TK_PORT_NAME_END; }
+{WHITE}{PARTITION_START}{WHITE} { SAVE_POS; return TK_PARTITION_START; }
+{WHITE}{PARTITION_END}{WHITE} { SAVE_POS; return TK_PARTITION_END; }
+{WHITE}{NODE_TYPE_START}{WHITE} { SAVE_POS; return TK_NODE_TYPE_START; }
+{WHITE}{NODE_TYPE_END}{WHITE} { SAVE_POS; return TK_NODE_TYPE_END; }
+{WHITE}{QOS_SETUP_START}{WHITE} { SAVE_POS; return TK_QOS_SETUP_START; }
+{WHITE}{QOS_SETUP_END}{WHITE} { SAVE_POS; return TK_QOS_SETUP_END; }
+{WHITE}{SL2VL_TABLES_START}{WHITE} { SAVE_POS; return TK_SL2VL_TABLES_START; }
+{WHITE}{SL2VL_TABLES_END}{WHITE} { SAVE_POS; return TK_SL2VL_TABLES_END; }
+{WHITE}{SL2VL_SCOPE_START}{WHITE} { SAVE_POS; return TK_SL2VL_SCOPE_START; }
+{WHITE}{SL2VL_SCOPE_END}{WHITE} { SAVE_POS; return TK_SL2VL_SCOPE_END; }
+{WHITE}{GROUP_START}{WHITE} { SAVE_POS; return TK_GROUP_START; }
+{WHITE}{GROUP_END}{WHITE} { SAVE_POS; return TK_GROUP_END; }
+{WHITE}{FROM_START}{WHITE} { SAVE_POS; return TK_FROM_START; }
+{WHITE}{FROM_END}{WHITE} { SAVE_POS; return TK_FROM_END; }
+{WHITE}{TO_START}{WHITE} { SAVE_POS; return TK_TO_START; }
+{WHITE}{TO_END}{WHITE} { SAVE_POS; return TK_TO_END; }
+{WHITE}{SL2VL_TABLE_START}{WHITE} { SAVE_POS; return TK_SL2VL_TABLE_START; }
+{WHITE}{SL2VL_TABLE_END}{WHITE} { SAVE_POS; return TK_SL2VL_TABLE_END; }
+{WHITE}{ACROSS_START}{WHITE} { SAVE_POS; return TK_ACROSS_START; }
+{WHITE}{ACROSS_END}{WHITE} { SAVE_POS; return TK_ACROSS_END; }
+{WHITE}{ACROSS_FROM_START}{WHITE} { SAVE_POS; return TK_ACROSS_FROM_START; }
+{WHITE}{ACROSS_FROM_END}{WHITE} { SAVE_POS; return TK_ACROSS_FROM_END; }
+{WHITE}{ACROSS_TO_START}{WHITE} { SAVE_POS; return TK_ACROSS_TO_START; }
+{WHITE}{ACROSS_TO_END}{WHITE} { SAVE_POS; return TK_ACROSS_TO_END; }
+{WHITE}{VLARB_TABLES_START}{WHITE} { SAVE_POS; return TK_VLARB_TABLES_START; }
+{WHITE}{VLARB_TABLES_END}{WHITE} { SAVE_POS; return TK_VLARB_TABLES_END; }
+{WHITE}{VLARB_SCOPE_START}{WHITE} { SAVE_POS; return TK_VLARB_SCOPE_START; }
+{WHITE}{VLARB_SCOPE_END}{WHITE} { SAVE_POS; return TK_VLARB_SCOPE_END; }
+{WHITE}{VLARB_HIGH_START}{WHITE} { SAVE_POS; return TK_VLARB_HIGH_START; }
+{WHITE}{VLARB_HIGH_END}{WHITE} { SAVE_POS; return TK_VLARB_HIGH_END; }
+{WHITE}{VLARB_LOW_START}{WHITE} { SAVE_POS; return TK_VLARB_LOW_START; }
+{WHITE}{VLARB_LOW_END}{WHITE} { SAVE_POS; return TK_VLARB_LOW_END; }
+{WHITE}{VLARB_HIGH_LIMIT_START}{WHITE} { SAVE_POS; return TK_VLARB_HIGH_LIMIT_START; }
+{WHITE}{VLARB_HIGH_LIMIT_END}{WHITE} { SAVE_POS; return TK_VLARB_HIGH_LIMIT_END; }
+{WHITE}{QOS_LEVELS_START}{WHITE} { SAVE_POS; return TK_QOS_LEVELS_START; }
+{WHITE}{QOS_LEVELS_END}{WHITE} { SAVE_POS; return TK_QOS_LEVELS_END; }
+{WHITE}{QOS_LEVEL_START}{WHITE} { SAVE_POS; return TK_QOS_LEVEL_START; }
+{WHITE}{QOS_LEVEL_END}{WHITE} { SAVE_POS; return TK_QOS_LEVEL_END; }
+{WHITE}{SN_START}{WHITE} { SAVE_POS; return TK_SN_START; }
+{WHITE}{SN_END}{WHITE} { SAVE_POS; return TK_SN_END; }
+{WHITE}{SL_START}{WHITE} { SAVE_POS; return TK_SL_START; }
+{WHITE}{SL_END}{WHITE} { SAVE_POS; return TK_SL_END; }
+{WHITE}{CLASS_START}{WHITE} { SAVE_POS; return TK_CLASS_START; }
+{WHITE}{CLASS_END}{WHITE} { SAVE_POS; return TK_CLASS_END; }
+{WHITE}{MTU_LIMIT_START}{WHITE} { SAVE_POS; return TK_MTU_LIMIT_START; }
+{WHITE}{MTU_LIMIT_END}{WHITE} { SAVE_POS; return TK_MTU_LIMIT_END; }
+{WHITE}{RATE_LIMIT_START}{WHITE} { SAVE_POS; return TK_RATE_LIMIT_START; }
+{WHITE}{RATE_LIMIT_END}{WHITE} { SAVE_POS; return TK_RATE_LIMIT_END; }
+{WHITE}{QOS_MATCH_RULES_START}{WHITE} { SAVE_POS; return TK_QOS_MATCH_RULES_START; }
+{WHITE}{QOS_MATCH_RULES_END}{WHITE} { SAVE_POS; return TK_QOS_MATCH_RULES_END; }
+{WHITE}{QOS_MATCH_RULE_START}{WHITE} { SAVE_POS; return TK_QOS_MATCH_RULE_START; }
+{WHITE}{QOS_MATCH_RULE_END}{WHITE} { SAVE_POS; return TK_QOS_MATCH_RULE_END; }
+{WHITE}{QOS_LEVEL_SN_START}{WHITE} { SAVE_POS; return TK_QOS_LEVEL_SN_START; }
+{WHITE}{QOS_LEVEL_SN_END}{WHITE} { SAVE_POS; return TK_QOS_LEVEL_SN_END; }
+{WHITE}{SOURCE_START}{WHITE} { SAVE_POS; return TK_SOURCE_START; }
+{WHITE}{SOURCE_END}{WHITE} { SAVE_POS; return TK_SOURCE_END; }
+{WHITE}{DESTINATION_START}{WHITE} { SAVE_POS; return TK_DESTINATION_START; }
+{WHITE}{DESTINATION_END}{WHITE} { SAVE_POS; return TK_DESTINATION_END; }
+{WHITE}{SERVICE_START}{WHITE} { SAVE_POS; return TK_SERVICE_START; }
+{WHITE}{SERVICE_END}{WHITE} { SAVE_POS; return TK_SERVICE_END; }
+
+{WHITE}{COMMENT}{WHITE} { SAVE_POS; } /* swallow comment */
+
+0[xX][0-9a-fA-F]+ { SAVE_POS; yylval = strdup(yytext); return TK_HEX_NUMBER; }
+[0-9]+ { SAVE_POS; yylval = strdup(yytext); return TK_DEC_NUMBER; }
+[ \t\n]+ { SAVE_POS; yylval = strdup(yytext); return TK_WHITE; }
+- { SAVE_POS; yylval = strdup(yytext); return TK_DASH; }
+: { SAVE_POS; yylval = strdup(yytext); return TK_DOTDOT; }
+, { SAVE_POS; yylval = strdup(yytext); return TK_COMMA; }
+. { SAVE_POS; yylval = strdup(yytext); return TK_TEXT;}
+
+%%
+
+static void save_pos()
+{
+ int i;
+ for (i = 0; i < yyleng; i++)
+ {
+ if (yytext[i] == '\n')
+ {
+ line_num ++;
+ column_num = 1;
+ }
+ else
+ column_num ++;
+ }
+}
+
--
1.4.4.1.GIT
More information about the general
mailing list