Line 156... |
Line 156... |
return self.current;
|
return self.current;
|
self.current = self.pending;
|
self.current = self.pending;
|
self.pending = list();
|
self.pending = list();
|
continue;
|
continue;
|
# Otherwise, this line belongs to the body of the preceding directive.
|
# Otherwise, this line belongs to the body of the preceding directive.
|
|
if not self.pending:
|
|
self.pending.append(fp['fp'].name);
|
|
self.pending.append(fp['line']);
|
if not self.current:
|
if not self.current:
|
self.current += self.pending[0:2];
|
self.current += self.pending[0:2];
|
self.current += self.pending[2:];
|
self.current += self.pending[2:];
|
self.current.append(line);
|
self.current.append(line);
|
self.pending = list();
|
self.pending = list();
|
Line 194... |
Line 197... |
otherwise return None.
|
otherwise return None.
|
"""
|
"""
|
# look for single-digit 0
|
# look for single-digit 0
|
if inString == '0':
|
if inString == '0':
|
return 0;
|
return 0;
|
# look for decimal value
|
# look for a binary value
|
a = re.match(r'[+\-]?[1-9]\d*$',inString);
|
a = re.match(r'0b[01_]+$',inString);
|
if a:
|
if a:
|
return int(a.group(0),10);
|
b = re.sub(r'_','',a.group(0)[2:]);
|
|
return int(b,2);
|
# look for an octal value
|
# look for an octal value
|
a = re.match(r'0[0-7]+$',inString);
|
a = re.match(r'0[0-7_]+$',inString);
|
if a:
|
if a:
|
return int(a.group(0),8);
|
return int(a.group(0)[1:],8);
|
|
# look for decimal value
|
|
a = re.match(r'[+\-]?[1-9_]\d*$',inString);
|
|
if a:
|
|
return int(a.group(0),10);
|
# look for a hex value
|
# look for a hex value
|
a = re.match(r'0x[0-9A-Fa-f]+$',inString);
|
a = re.match(r'0x[0-9A-Fa-f_]+$',inString);
|
if a:
|
if a:
|
return int(a.group(0),16);
|
return int(a.group(0)[2:],16);
|
# Everything else is an error
|
# Everything else is an error
|
return None;
|
return None;
|
|
|
def ParseChar(inchar):
|
def ParseChar(inchar):
|
"""
|
"""
|
Line 314... |
Line 322... |
raise AsmException('Malformed computed value at %s: "%s"' % (flc_loc,raw,));
|
raise AsmException('Malformed computed value at %s: "%s"' % (flc_loc,raw,));
|
if type(tParseNumber) != int:
|
if type(tParseNumber) != int:
|
raise AsmException('Malformed single-byte value at %s' % flc_loc);
|
raise AsmException('Malformed single-byte value at %s' % flc_loc);
|
return dict(type='value', value=tParseNumber, loc=flc_loc);
|
return dict(type='value', value=tParseNumber, loc=flc_loc);
|
# look for a repeated single-byte numeric value (N*M where M is the repeat count)
|
# look for a repeated single-byte numeric value (N*M where M is the repeat count)
|
matchString=r'(0|[+\-]?[1-9]\d*|0[0-7]+|0x[0-9A-Fa-f]{1,2})\*([1-9]\d*|C_\w+|\$\{\S+\})$';
|
matchString=r'(0|0b[01_]+|0[0-7]+|[+\-]?[1-9]\d*|0x[0-9A-Fa-f]{1,2})\*([1-9]\d*|C_\w+|\$\{\S+\})$';
|
a = re.match(matchString,raw);
|
a = re.match(matchString,raw);
|
if a:
|
if a:
|
if 'multivalue' not in allowed:
|
if 'multivalue' not in allowed:
|
raise AsmException('Multi-byte value not allowed at %s' % flc_loc);
|
raise AsmException('Multi-byte value not allowed at %s' % flc_loc);
|
b = re.findall(matchString,a.group(0));
|
b = re.findall(matchString,a.group(0));
|
Line 348... |
Line 356... |
raise AsmException('Repeat count must be positive at %s' % fl_loc2);
|
raise AsmException('Repeat count must be positive at %s' % fl_loc2);
|
for ix in range(repeatCount):
|
for ix in range(repeatCount):
|
tValue.append(tParseNumber);
|
tValue.append(tParseNumber);
|
return dict(type='value', value=tValue, loc=flc_loc);
|
return dict(type='value', value=tValue, loc=flc_loc);
|
# look for a single-byte numeric value
|
# look for a single-byte numeric value
|
a = re.match(r'(0|[+\-]?[1-9]\d*|0[07]+|0x[0-9A-Fa-f]+)$',raw);
|
a = re.match(r'(0|0b[01_]+|0[0-7]+|[+\-]?[1-9]\d*|0x[0-9A-Fa-f]+)$',raw);
|
if a:
|
if a:
|
if 'singlevalue' not in allowed:
|
if 'singlevalue' not in allowed:
|
raise AsmException('Value not allowed at %s' % flc_loc);
|
raise AsmException('Value not allowed at %s' % flc_loc);
|
try:
|
try:
|
tParseNumber = ParseNumber(raw);
|
tParseNumber = ParseNumber(raw);
|