From: Jaben Carsey <jaben.carsey@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>, Yonghong Zhu <yonghong.zhu@intel.com>
Subject: [PATCH v1 1/3] BaseTools: move RegEx to root of file and share it
Date: Wed, 4 Apr 2018 13:56:55 -0700 [thread overview]
Message-ID: <5215e0ea57bad69db3ebed53bc1c25a85d53712b.1522874754.git.jaben.carsey@intel.com> (raw)
In-Reply-To: <cover.1522874754.git.jaben.carsey@intel.com>
In-Reply-To: <cover.1522874754.git.jaben.carsey@intel.com>
make it easy to import and use by others
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
BaseTools/Source/Python/Common/Expression.py | 4 ++--
BaseTools/Source/Python/Common/RangeExpression.py | 5 ++---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 320f0015009b..462e8f93f883 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -43,6 +43,7 @@ ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARC
__ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')
_ReLabel = re.compile('LABEL\((\w+)\)')
_ReOffset = re.compile('OFFSET_OF\((\w+)\)')
+PcdPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$')
## SplitString
# Split string to list according double quote
@@ -214,7 +215,6 @@ class ValueExpression(object):
NonLetterOpLst = ['+', '-', '*', '/', '%', '&', '|', '^', '~', '<<', '>>', '!', '=', '>', '<', '?', ':']
- PcdPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$')
SymbolPattern = re.compile("("
"\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"
@@ -616,7 +616,7 @@ class ValueExpression(object):
raise BadExpression(ERR_EMPTY_TOKEN)
# PCD token
- if self.PcdPattern.match(self._Token):
+ if PcdPattern.match(self._Token):
if self._Token not in self._Symb:
Ex = BadExpression(ERR_PCD_RESOLVE % self._Token)
Ex.Pcd = self._Token
diff --git a/BaseTools/Source/Python/Common/RangeExpression.py b/BaseTools/Source/Python/Common/RangeExpression.py
index 5fcc8a432a56..5ee59184e66e 100644
--- a/BaseTools/Source/Python/Common/RangeExpression.py
+++ b/BaseTools/Source/Python/Common/RangeExpression.py
@@ -16,6 +16,7 @@ from Common.GlobalData import *
from CommonDataClass.Exceptions import BadExpression
from CommonDataClass.Exceptions import WrnExpression
import uuid
+from Common.Expression import PcdPattern
ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].'
ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].'
@@ -209,8 +210,6 @@ class RangeExpression(object):
NonLetterOpLst = ['+', '-', '&', '|', '^', '!', '=', '>', '<']
- PcdPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$')
-
RangePattern = re.compile(r'[0-9]+ - [0-9]+')
def preProcessRangeExpr(self, expr):
@@ -573,7 +572,7 @@ class RangeExpression(object):
raise BadExpression(ERR_EMPTY_TOKEN)
# PCD token
- if self.PcdPattern.match(self._Token):
+ if PcdPattern.match(self._Token):
if self._Token not in self._Symb:
Ex = BadExpression(ERR_PCD_RESOLVE % self._Token)
Ex.Pcd = self._Token
--
2.16.2.windows.1
next prev parent reply other threads:[~2018-04-04 20:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-04 20:56 [PATCH v1 0/3] BaseTools: refactor and cleanup Jaben Carsey
2018-04-04 20:56 ` Jaben Carsey [this message]
2018-04-04 20:56 ` [PATCH v1 2/3] BaseTools: Autogen - change from list to set Jaben Carsey
2018-04-04 20:56 ` [PATCH v1 3/3] BaseTools: small cleanup Jaben Carsey
2018-04-08 8:20 ` [PATCH v1 0/3] BaseTools: refactor and cleanup Zhu, Yonghong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5215e0ea57bad69db3ebed53bc1c25a85d53712b.1522874754.git.jaben.carsey@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox