75 for libname, tc6fname in StdTC6Libs} |
75 for libname, tc6fname in StdTC6Libs} |
76 StdBlckLst = [{"name": libname, "list": |
76 StdBlckLst = [{"name": libname, "list": |
77 [GetBlockInfos(pous) for pous in lib.getpous()]} |
77 [GetBlockInfos(pous) for pous in lib.getpous()]} |
78 for libname, lib in StdBlckLibs.iteritems()] |
78 for libname, lib in StdBlckLibs.iteritems()] |
79 |
79 |
80 #------------------------------------------------------------------------------- |
80 # ------------------------------------------------------------------------------- |
81 # Test identifier |
81 # Test identifier |
82 #------------------------------------------------------------------------------- |
82 # ------------------------------------------------------------------------------- |
83 |
83 |
84 IDENTIFIER_MODEL = re.compile( |
84 IDENTIFIER_MODEL = re.compile( |
85 "(?:%(letter)s|_(?:%(letter)s|%(digit)s))(?:_?(?:%(letter)s|%(digit)s))*$" % |
85 "(?:%(letter)s|_(?:%(letter)s|%(digit)s))(?:_?(?:%(letter)s|%(digit)s))*$" % |
86 {"letter": "[a-zA-Z]", "digit": "[0-9]"}) |
86 {"letter": "[a-zA-Z]", "digit": "[0-9]"}) |
87 |
87 |
90 """ |
90 """ |
91 Test if identifier is valid |
91 Test if identifier is valid |
92 """ |
92 """ |
93 return IDENTIFIER_MODEL.match(identifier) is not None |
93 return IDENTIFIER_MODEL.match(identifier) is not None |
94 |
94 |
95 #------------------------------------------------------------------------------- |
95 # ------------------------------------------------------------------------------- |
96 # Standard functions list generation |
96 # Standard functions list generation |
97 #------------------------------------------------------------------------------- |
97 # ------------------------------------------------------------------------------- |
98 |
98 |
99 |
99 |
100 def csv_file_to_table(file): |
100 def csv_file_to_table(file): |
101 """ |
101 """ |
102 take a .csv file and translate it it a "csv_table" |
102 take a .csv file and translate it it a "csv_table" |
283 ", ".join(["%s:%s" % (output[1], output[0]) |
283 ", ".join(["%s:%s" % (output[1], output[0]) |
284 for output in desc["outputs"]]))) |
284 for output in desc["outputs"]]))) |
285 BlkLst = StdBlckDct.setdefault(desc["name"], []) |
285 BlkLst = StdBlckDct.setdefault(desc["name"], []) |
286 BlkLst.append((section["name"], desc)) |
286 BlkLst.append((section["name"], desc)) |
287 |
287 |
288 #------------------------------------------------------------------------------- |
288 # ------------------------------------------------------------------------------- |
289 # Languages Keywords |
289 # Languages Keywords |
290 #------------------------------------------------------------------------------- |
290 # ------------------------------------------------------------------------------- |
291 |
291 |
292 # Keywords for Pou Declaration |
292 # Keywords for Pou Declaration |
293 POU_BLOCK_START_KEYWORDS = ["FUNCTION", "FUNCTION_BLOCK", "PROGRAM"] |
293 POU_BLOCK_START_KEYWORDS = ["FUNCTION", "FUNCTION_BLOCK", "PROGRAM"] |
294 POU_BLOCK_END_KEYWORDS = ["END_FUNCTION", "END_FUNCTION_BLOCK", "END_PROGRAM"] |
294 POU_BLOCK_END_KEYWORDS = ["END_FUNCTION", "END_FUNCTION_BLOCK", "END_PROGRAM"] |
295 POU_KEYWORDS = ["EN", "ENO", "F_EDGE", "R_EDGE"] + POU_BLOCK_START_KEYWORDS + POU_BLOCK_END_KEYWORDS |
295 POU_KEYWORDS = ["EN", "ENO", "F_EDGE", "R_EDGE"] + POU_BLOCK_START_KEYWORDS + POU_BLOCK_END_KEYWORDS |