isa_parser.py (5250:42577371ff31) isa_parser.py (5543:3af77710f397)
1# Copyright (c) 2003-2005 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 102 unchanged lines hidden (view full) ---

111t_LESS = r'\<'
112t_GREATER = r'\>'
113t_EQUALS = r'='
114t_COMMA = r','
115t_SEMI = r';'
116t_DOT = r'\.'
117t_COLON = r':'
118t_DBLCOLON = r'::'
1# Copyright (c) 2003-2005 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 102 unchanged lines hidden (view full) ---

111t_LESS = r'\<'
112t_GREATER = r'\>'
113t_EQUALS = r'='
114t_COMMA = r','
115t_SEMI = r';'
116t_DOT = r'\.'
117t_COLON = r':'
118t_DBLCOLON = r'::'
119t_ASTERISK = r'\*'
119t_ASTERISK = r'\*'
120
121# Identifiers and reserved words
122reserved_map = { }
123for r in reserved:
124 reserved_map[r.lower()] = r
125
126def t_ID(t):
127 r'[A-Za-z_]\w*'

--- 347 unchanged lines hidden (view full) ---

475 # with positional_param_list and keyword_param_list.
476 t[0] = [t[1] + t[2]]
477
478# End of format definition-related rules.
479##############
480
481#
482# A decode block looks like:
120
121# Identifiers and reserved words
122reserved_map = { }
123for r in reserved:
124 reserved_map[r.lower()] = r
125
126def t_ID(t):
127 r'[A-Za-z_]\w*'

--- 347 unchanged lines hidden (view full) ---

475 # with positional_param_list and keyword_param_list.
476 t[0] = [t[1] + t[2]]
477
478# End of format definition-related rules.
479##############
480
481#
482# A decode block looks like:
483# decode <field1> [, <field2>]* [default <inst>] { ... }
483# decode <field1> [, <field2>]* [default <inst>] { ... }
484#
485def p_decode_block(t):
486 'decode_block : DECODE ID opt_default LBRACE decode_stmt_list RBRACE'
487 default_defaults = defaultStack.pop()
488 codeObj = t[5]
489 # use the "default defaults" only if there was no explicit
490 # default statement in decode_stmt_list
491 if not codeObj.has_decode_default:

--- 652 unchanged lines hidden (view full) ---

1144 for (ext, (desc, size)) in userDict.iteritems():
1145 if desc == 'signed int':
1146 ctype = 'int%d_t' % size
1147 is_signed = 1
1148 elif desc == 'unsigned int':
1149 ctype = 'uint%d_t' % size
1150 is_signed = 0
1151 elif desc == 'float':
484#
485def p_decode_block(t):
486 'decode_block : DECODE ID opt_default LBRACE decode_stmt_list RBRACE'
487 default_defaults = defaultStack.pop()
488 codeObj = t[5]
489 # use the "default defaults" only if there was no explicit
490 # default statement in decode_stmt_list
491 if not codeObj.has_decode_default:

--- 652 unchanged lines hidden (view full) ---

1144 for (ext, (desc, size)) in userDict.iteritems():
1145 if desc == 'signed int':
1146 ctype = 'int%d_t' % size
1147 is_signed = 1
1148 elif desc == 'unsigned int':
1149 ctype = 'uint%d_t' % size
1150 is_signed = 0
1151 elif desc == 'float':
1152 is_signed = 1 # shouldn't really matter
1152 is_signed = 1 # shouldn't really matter
1153 if size == 32:
1154 ctype = 'float'
1155 elif size == 64:
1156 ctype = 'double'
1157 elif desc == 'twin64 int':
1158 is_signed = 0
1159 ctype = 'Twin64_t'
1160 elif desc == 'twin32 int':

--- 429 unchanged lines hidden (view full) ---

1590 # <cls_name> as a subclass of <base_cls> with the attributes
1591 # in tmp_dict, just as if we evaluated a class declaration.
1592 operandNameMap[op_name] = type(cls_name, (base_cls,), tmp_dict)
1593
1594 # Define operand variables.
1595 operands = userDict.keys()
1596
1597 operandsREString = (r'''
1153 if size == 32:
1154 ctype = 'float'
1155 elif size == 64:
1156 ctype = 'double'
1157 elif desc == 'twin64 int':
1158 is_signed = 0
1159 ctype = 'Twin64_t'
1160 elif desc == 'twin32 int':

--- 429 unchanged lines hidden (view full) ---

1590 # <cls_name> as a subclass of <base_cls> with the attributes
1591 # in tmp_dict, just as if we evaluated a class declaration.
1592 operandNameMap[op_name] = type(cls_name, (base_cls,), tmp_dict)
1593
1594 # Define operand variables.
1595 operands = userDict.keys()
1596
1597 operandsREString = (r'''
1598 (?<![\w\.]) # neg. lookbehind assertion: prevent partial matches
1598 (?<![\w\.]) # neg. lookbehind assertion: prevent partial matches
1599 ((%s)(?:\.(\w+))?) # match: operand with optional '.' then suffix
1599 ((%s)(?:\.(\w+))?) # match: operand with optional '.' then suffix
1600 (?![\w\.]) # neg. lookahead assertion: prevent partial matches
1600 (?![\w\.]) # neg. lookahead assertion: prevent partial matches
1601 '''
1602 % string.join(operands, '|'))
1603
1604 global operandsRE
1605 operandsRE = re.compile(operandsREString, re.MULTILINE|re.VERBOSE)
1606
1607 # Same as operandsREString, but extension is mandatory, and only two
1608 # groups are returned (base and ext, not full name as above).

--- 431 unchanged lines hidden ---
1601 '''
1602 % string.join(operands, '|'))
1603
1604 global operandsRE
1605 operandsRE = re.compile(operandsREString, re.MULTILINE|re.VERBOSE)
1606
1607 # Same as operandsREString, but extension is mandatory, and only two
1608 # groups are returned (base and ext, not full name as above).

--- 431 unchanged lines hidden ---