2023-11-18 10:59:00 -07:00
|
|
|
"""
|
|
|
|
Constants for the ast_generator
|
|
|
|
|
|
|
|
#TODO this could be a dict that can be loaded from a yaml file and thus make this fuzzer more general
|
|
|
|
"""
|
|
|
|
|
|
|
|
Grammar = dict[str, list[str]]
|
|
|
|
GAZ_VOID_TYPE = 'void'
|
|
|
|
VOID_TYPE = 'void'
|
|
|
|
GAZ_BLOCK_TAG = 'block'
|
|
|
|
GAZ_LHS_TAG = 'lhs'
|
|
|
|
GAZ_RHS_TAG = 'rhs'
|
|
|
|
GAZ_RETURN_KEY = "return_type"
|
|
|
|
VAR_NAMES = ['alsdjf', 'asldfjlks', 'qowiuut', 'qoiur', 'qwioue', 'qoyiyut', 'llkjfg', 'kdjkdjf', 'asdjkfeey',
|
|
|
|
'jdhjfjheee']
|
|
|
|
ROUTINE_NAMES = ['bees', 'beans', 'hell']
|
|
|
|
GAZ_INT_OPS = ['*', '+', '-', '/', '%']
|
|
|
|
GAZ_TYPES = ['int']
|
|
|
|
GAZ_FLOAT_KEY = 'float'
|
|
|
|
GAZ_INT_KEY = 'int'
|
|
|
|
GAZ_FUNCTION_TAG = 'function'
|
|
|
|
GAZ_PROCEDURE_TAG = 'procedure'
|
|
|
|
GAZ_OPERATOR_TAG = "operator"
|
|
|
|
GAZ_UNARY_OPERATOR_TAG = "unary"
|
|
|
|
GAZ_LIT_TAG = "literal"
|
|
|
|
GAZ_VAR_TAG = "variable"
|
|
|
|
GAZ_OP_KEY = "op"
|
|
|
|
GAZ_NAME_KEY = "name"
|
|
|
|
GAZ_QUALIFIER_KEY = "mut"
|
|
|
|
GAZ_VAL_KEY = "value"
|
|
|
|
GAZ_TY_KEY = "type"
|
|
|
|
ANY_TYPE = "any"
|
|
|
|
GAZ_DECLARATION_TAG = "declaration"
|
|
|
|
GAZ_IN_STREAM = "std_input"
|
|
|
|
GAZ_OUT_STREAM = "std_output"
|
|
|
|
GAZ_STREAM_TAG = "stream"
|
|
|
|
GAZ_ASSIGNMENT_TAG = "assignment"
|
|
|
|
GAZ_RETURN_TAG = "return"
|
|
|
|
GAZ_MAIN = "main"
|
|
|
|
GAZ_BOOL_KEY = "bool"
|
|
|
|
GAZ_IF_TAG = "conditional"
|
|
|
|
GAZ_LOOP_TAG = "loop"
|
|
|
|
GAZ_TRUE_BLOCK_TAG = "true"
|
|
|
|
GAZ_FALSE_BLOCK_TAG = "false"
|
|
|
|
GAZ_ARG_TAG = "argument"
|
2023-11-18 12:21:52 -07:00
|
|
|
GAZ_STRING_KEY = "string"
|
|
|
|
GAZ_CHAR_KEY = "char"
|
2023-11-21 20:40:50 -07:00
|
|
|
GAZ_BRACKET_TAG = "brackets"
|
2023-11-22 13:50:56 -07:00
|
|
|
GAZ_BREAK_TAG = "break"
|
2023-11-24 07:33:30 -07:00
|
|
|
GAZ_ATOMIC_TYPE_KEY = "atomic"
|
|
|
|
GAZ_COMPOSITE_TYPE_KEY = "composite"
|
|
|
|
GAZ_COMPOSITE_KEY = "composite"
|
|
|
|
GAZ_VECTOR_KEY = "vector"
|
|
|
|
GAZ_TUPLE_KEY = "tuple"
|
|
|
|
GAZ_MATRIX_KEY = "matrix"
|
2023-11-22 20:33:34 -07:00
|
|
|
|
|
|
|
|
|
|
|
class NoneTagException(Exception):
|
|
|
|
|
|
|
|
def __init__(self, message, xml):
|
|
|
|
super().__init__(message)
|
|
|
|
self.xml = xml
|
|
|
|
|
2023-11-24 09:31:18 -07:00
|
|
|
class GazTypeError(Exception):
|
|
|
|
|
|
|
|
def __init__(self, message, op, ty1, ty2):
|
|
|
|
super().__init__(message)
|
|
|
|
self.op = op
|
|
|
|
self.ty1 = ty1
|
|
|
|
self.ty2 = ty2
|
|
|
|
|