--- a/generate_IEC_std.py Mon Apr 04 11:57:18 2011 +0200
+++ b/generate_IEC_std.py Tue Apr 05 15:18:35 2011 +0200
@@ -4,7 +4,7 @@
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
#based on the plcopen standard.
#
-#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
+#Copyright (C) 2007-2011: Edouard TISSERANT and Laurent BESSARD
#
#See COPYING file for copyrights details.
#
@@ -23,20 +23,18 @@
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
-
THIS CODE GENARATES C++ CODE FOR IEC2C COMPILER
- GENERATED CODE IS :
-
-function_type_decl.h - the long enumeration of std function types
-get_function_type_decl.c - the funct that return enumerated according function name
-st_code_gen.c - part of generate_c_st_c::visit(function_invocation)
- responsible to generate C code for std lib calls
-il_code_gen.c - part of generate_c_il_c::visit(il_function_call)
- responsible to generate C code for std lib calls
-search_type_code.c - called by search_expression_type_c::visit(function_invocation)
- return type symbol for std function invocation
-
-"""
+"""
+
+file_list = [
+ ('absyntax_utils', 'function_type_decl','h' ),
+ ('absyntax_utils', 'get_function_type_decl','c' ),
+ ('absyntax_utils', 'search_type_code','c' ),
+ ('stage4/generate_c', 'st_code_gen','c' ),
+ ('stage4/generate_c', 'il_code_gen','c' ),
+ ('stage1_2', 'standard_function_names','c' ),
+ ('lib', 'iec_std_lib_generated','h' )
+ ]
# Get definitions
from plcopen.structures import *
@@ -49,26 +47,22 @@
#pp = pprint.PrettyPrinter(indent=4)
matiec_header = """/*
- * (c) 2008 Edouard TISSERANT
- *
- * Offered to the public 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.
- *
- * This code is made available on the understanding that it will not be
- * used in safety-critical situations without a full and competent review.
- */
-
-/*
- * An IEC 61131-3 IL and ST compiler.
- *
- * Based on the
- * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
+ * Copyright (C) 2007-2011: Edouard TISSERANT and Laurent BESSARD
+ *
+ * See COPYING and COPYING.LESSER files for copyright details.
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
@@ -80,19 +74,23 @@
"""
matiec_lesser_header = """/*
- * (c) 2008 Edouard TISSERANT
- *
- * Offered to the public under the terms of the GNU Lesser 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 Lesser
- * General Public License for more details.
- *
- * This code is made available on the understanding that it will not be
- * used in safety-critical situations without a full and competent review.
+ * Copyright (C) 2007-2011: Edouard TISSERANT and Laurent BESSARD
+ *
+ * See COPYING and COPYING.LESSER files for copyright details.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
/****
@@ -286,7 +284,7 @@
official_order = []
for section in std_decl:
for fdecl in section["list"]:
- if len(official_order)==0 or official_order[-1] != fdecl["name"]:
+ if len(official_order)==0 or fdecl["name"] not in official_order:
official_order.append(fdecl["name"])
# store all func by name in a dict
std_fdecls_fdecl_name = std_fdecls.get(fdecl["name"], {})
@@ -522,15 +520,7 @@
break
# Now, print that out, or write to files from sys.argv
-for path, name, ext in [
- ('absyntax_utils','function_type_decl','h'),
- ('absyntax_utils','get_function_type_decl','c'),
- ('stage4/generate_c','st_code_gen','c'),
- ('stage4/generate_c','il_code_gen','c'),
- ('absyntax_utils','search_type_code','c'),
- ('stage1_2','standard_function_names','c'),
- ('lib', 'iec_std_lib_generated','h')
- ]:
+for path, name, ext in file_list :
fd = open(os.path.join(sys.argv[1], path, name+'.'+ext),'w')
fd.write(eval(name))
fd.close()