#BEGIN_LEGAL # #Copyright (c) 2020 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #END_LEGAL import re macro_def_pattern = \ re.compile(r'^MACRO_DEF[ \t]*[:][ \t]*(?P[_A-Za-z0-9]+)[ \t]*$') macro_use_pattern = \ re.compile(r'^MACRO_USE[ \t]*[:][ \t]*(?P[_A-Za-z0-9]+)[(](?P[^)]+)[)][ \t]*$') xed_reg_pattern = re.compile(r'(?PXED_REG_[A-Za-z0-9_]+)') nt_name_pattern = re.compile(r'^(?P[A-Za-z_0-9]+)[(][)]') ntluf_name_pattern = re.compile(r'^(?P[A-Za-z_0-9]+)[(]OUTREG[)]') nt_pattern = re.compile(r'^(?P[A-Za-z_0-9]+)[(][)]::') ntluf_pattern = re.compile(r'^(?P[A-Za-z0-9_]+)\s+(?P[A-Za-z_0-9]+)[(][)]::') # for the decode rule, the rhs might be empty decode_rule_pattern = re.compile(r'(?P.+)[|](?P.*)') comment_pattern = re.compile(r'#.*$') leading_whitespace_pattern = re.compile(r'^\s+') full_line_comment_pattern = re.compile(r'^\s*#') arrow_pattern = re.compile(r'(?P.+)->(?P.+)') curly_pattern = re.compile(r'(?P[{}])') left_curly_pattern = re.compile(r'^[{]$') # whole line right_curly_pattern = re.compile(r'^[}]$') # whole line delete_iclass_pattern = re.compile('^DELETE') delete_iclass_full_pattern = \ re.compile(r'^DELETE[ ]*[:][ ]*(?P[A-Za-z_0-9]+)') udelete_pattern = re.compile('^UDELETE') udelete_full_pattern = \ re.compile(r'^UDELETE[ ]*[:][ ]*(?P[A-Za-z_0-9]+)') iclass_pattern = re.compile(r'^ICLASS\s*[:]\s*(?P[A-Za-z0-9_]+)') uname_pattern = re.compile(r'^UNAME\s*[:]\s*(?P[A-Za-z0-9_]+)') ipattern_pattern = re.compile(r'^PATTERN\s*[:]\s*(?P.+)') operand_pattern = re.compile(r'^OPERANDS\s*[:]\s*(?P.+)') no_operand_pattern = re.compile(r'^OPERANDS\s*[:]\s*$') real_opcode_pattern = re.compile(r'^REAL_OPCODE\s*[:]\s*(?P[A-Za-z0-9_]+)') extension_pattern = re.compile(r'^EXTENSION\s*[:]\s*(?P[A-Za-z0-9_]+)') isa_set_pattern = re.compile(r'^ISA_SET\s*[:]\s*(?P[A-Za-z0-9_]+)') equals_pattern = re.compile(r'(?P[^!]+)=(?P.+)') return_pattern = re.compile(r'return[ ]+(?P[^ ]+)') not_equals_pattern = re.compile(r'(?P[^!]+)!=(?P.+)') bit_expand_pattern = re.compile(r'(?P[a-z])/(?P\d{1,2})') rhs_pattern = re.compile(r'[!]?=.*$') lhs_capture_pattern = re.compile(r'(?P[A-Za-z_0-9]+)[\[](?P[a-z]+)]') lhs_capture_pattern_end = re.compile(r'(?P[A-Za-z_0-9]+)[\[](?P[a-z01_]+)]$') lhs_pattern = re.compile(r'(?P[A-Za-z_0-9]+)[!=]') hex_pattern = re.compile(r'0[xX][0-9a-fA-F]+') decimal_pattern = re.compile(r'^[0-9]+$') binary_pattern = re.compile(r"^0b(?P[01_]+$)") # only 1's and 0's old_binary_pattern = re.compile(r"B['](?P[01_]+)") # Explicit leading "B'" bits_pattern = re.compile(r'^[10]+$') bits_and_underscores_pattern = re.compile(r'^[10_]+$') bits_and_letters_pattern = re.compile(r'^[10a-z]+$') bits_and_letters_underscore_pattern = re.compile(r'^[10a-z_]+$') sequence_pattern = re.compile(r'^SEQUENCE[ \t]+(?P[A-Za-z_0-9]+)') encoding_template_pattern = re.compile(r'[a-z01]+') letter_pattern = re.compile(r'^[a-z]+$') letter_and_underscore_pattern = re.compile(r'^[a-z_]+$') simple_number_pattern = re.compile(r'^[0-9]+$')