18 from .platform
import PY3
19 from .robottypes
import is_string
28 _CONTROL_WORDS = frozenset((
'ELSE',
'ELSE IF',
'AND',
'WITH NAME'))
32 _SEQUENCES_TO_BE_ESCAPED = (
'\\',
'${',
'@{',
'%{',
'&{',
'*{',
'=')
38 if item
in _CONTROL_WORDS:
40 for seq
in _SEQUENCES_TO_BE_ESCAPED:
42 item = item.replace(seq,
'\\' + seq)
47 if not (
is_string(item)
and '\\' in item):
60 yield finder.before + finder.backslashes
61 if finder.escaped
and finder.text:
62 yield self.
_unescape_unescape(finder.text)
74 unescaper = getattr(self,
'_unescaper_for_' + escape)
75 except AttributeError:
78 return unescaper(text[1:])
82 if text.startswith(
' '):
107 return char + text[length:]
110 if len(text) < length
or not text.isalnum():
112 ordinal =
int(text, 16)
114 if ordinal > 0x10FFFF:
118 return eval(
"u'\\U%08x'" % ordinal)
126 _escaped = re.compile(
r'(\\+)([^\\]*)')
129 res = self.
_escaped_escaped.search(string)
131 escape_chars = len(res.group(1))
135 self.
afterafter = string[res.end():]
139 if not is_string(string)
or '=' not in string:
144 return string[:index], string[index+1:]
148 while '=' in string[index:]:
149 index += string[index:].index(
'=')
156 backslashes = len(name) - len(name.rstrip(
'\\'))
157 return backslashes % 2 == 0
def __init__(self, string)
def _yield_unescaped(self, string)
def _unescape_character(self, text, length, escape)
def unescape(self, string)
def _unescape(self, text)
def _get_character(self, text, length)
def _unescaper_for_x(self, text)
def _unescaper_for_n(self, text)
def _unescaper_for_U(self, text)
def _unescaper_for_u(self, text)
def _unescaper_for_r(self, text)
def _unescaper_for_t(self, text)
def split_from_equals(string)
def _get_split_index(string)