--- a/plcopen/structures.py Wed Mar 06 17:05:56 2013 +0900
+++ b/plcopen/structures.py Wed Mar 06 10:47:06 2013 +0100
@@ -1,8 +1,6 @@
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
#based on the plcopen standard.
@@ -24,6 +22,7 @@
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import string, os, sys, re LANGUAGES = ["IL","ST","FBD","LD","SFC"]
@@ -375,20 +374,13 @@
#-------------------------------------------------------------------------------
+IDENTIFIER_MODEL = re.compile( + "(?:%(letter)s|_(?:%(letter)s|%(digit)s))(?:_?(?:%(letter)s|%(digit)s))*$" % + {"letter": "[a-zA-Z]", "digit": "[0-9]"}) # Test if identifier is valid
def TestIdentifier(identifier):
- if identifier[0].isdigit():
- words = identifier.split('_')
- for i, word in enumerate(words):
- if len(word) == 0 and i != 0:
- if len(word) != 0 and not word.isalnum():
+ return IDENTIFIER_MODEL.match(identifier) is not None #-------------------------------------------------------------------------------
# Standard functions list generation