summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/Common/Parsing.py
diff options
context:
space:
mode:
authorGao, Liming <liming.gao@intel.com>2014-07-01 07:10:10 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2014-07-01 07:10:10 +0000
commite4ac870fe95adc7d178a79b73ad2792e0c8bfeb8 (patch)
tree7dc08edb8004fdb21d2450a88c1e7957246e8029 /BaseTools/Source/Python/Common/Parsing.py
parent148af3872273ef476230db1d0df5ea00167853a1 (diff)
downloadedk2-e4ac870fe95adc7d178a79b73ad2792e0c8bfeb8.tar.gz
edk2-e4ac870fe95adc7d178a79b73ad2792e0c8bfeb8.tar.bz2
edk2-e4ac870fe95adc7d178a79b73ad2792e0c8bfeb8.zip
Sync BaseTool trunk (version r2670) into EDKII BaseTools.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Gao, Liming <liming.gao@intel.com> Reviewed-by: Liu, Yingke D (yingke.d.liu@intel.com) git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15605 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/Common/Parsing.py')
-rw-r--r--BaseTools/Source/Python/Common/Parsing.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/BaseTools/Source/Python/Common/Parsing.py b/BaseTools/Source/Python/Common/Parsing.py
index 5bea6941fd..584fc7f3c3 100644
--- a/BaseTools/Source/Python/Common/Parsing.py
+++ b/BaseTools/Source/Python/Common/Parsing.py
@@ -1,7 +1,7 @@
## @file
# This file is used to define common parsing related functions used in parsing INF/DEC/DSC process
#
-# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -877,3 +877,38 @@ def GenMetaDatSectionItem(Key, Value, List):
List[Key] = [Value]
else:
List[Key].append(Value)
+
+## IsValidWord
+#
+# Check whether the word is valid.
+# <Word> ::= (a-zA-Z0-9_)(a-zA-Z0-9_-){0,} Alphanumeric characters with
+# optional
+# dash "-" and/or underscore "_" characters. No whitespace
+# characters are permitted.
+#
+# @param Word: The word string need to be checked.
+#
+def IsValidWord(Word):
+ if not Word:
+ return False
+ #
+ # The first char should be alpha, _ or Digit.
+ #
+ if not Word[0].isalnum() and \
+ not Word[0] == '_' and \
+ not Word[0].isdigit():
+ return False
+
+ LastChar = ''
+ for Char in Word[1:]:
+ if (not Char.isalpha()) and \
+ (not Char.isdigit()) and \
+ Char != '-' and \
+ Char != '_' and \
+ Char != '.':
+ return False
+ if Char == '.' and LastChar == '.':
+ return False
+ LastChar = Char
+
+ return True