import copy\r
from Common.DataType import *\r
import sys\r
+from random import sample\r
+import string\r
\r
ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].'\r
ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].'\r
#\r
def SplitString(String):\r
# There might be escaped quote: "abc\"def\\\"ghi", 'abc\'def\\\'ghi'\r
+ RanStr = ''.join(sample(string.ascii_letters + string.digits, 8))\r
+ String = String.replace('\\\\', RanStr).strip()\r
RetList = []\r
InSingleQuote = False\r
InDoubleQuote = False\r
raise BadExpression(ERR_STRING_TOKEN % Item)\r
if Item:\r
RetList.append(Item)\r
+ for i, ch in enumerate(RetList):\r
+ if RanStr in ch:\r
+ RetList[i] = ch.replace(RanStr,'\\\\')\r
return RetList\r
\r
def SplitPcdValueString(String):\r
# There might be escaped comma in GUID() or DEVICE_PATH() or " "\r
# or ' ' or L' ' or L" "\r
+ RanStr = ''.join(sample(string.ascii_letters + string.digits, 8))\r
+ String = String.replace('\\\\', RanStr).strip()\r
RetList = []\r
InParenthesis = 0\r
InSingleQuote = False\r
raise BadExpression(ERR_STRING_TOKEN % Item)\r
if Item:\r
RetList.append(Item)\r
+ for i, ch in enumerate(RetList):\r
+ if RanStr in ch:\r
+ RetList[i] = ch.replace(RanStr,'\\\\')\r
return RetList\r
\r
def IsValidCName(Str):\r
elif not Val:\r
Val = False\r
RealVal = '""'\r
- elif not Val.startswith('L"') and not Val.startswith('{') and not Val.startswith("L'"):\r
+ elif not Val.startswith('L"') and not Val.startswith('{') and not Val.startswith("L'") and not Val.startswith("'"):\r
Val = True\r
RealVal = '"' + RealVal + '"'\r
\r