code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
expr = make_typecast(TYPE.ubyte, p[2], p.lineno(1))
p[0] = make_sentence('ON_' + p[3], expr, *p[4]) | def p_on_goto(p) | statement : ON expr goto label_list | 13.080999 | 11.270522 | 1.160638 |
p[0] = p[1]
entry = check_and_make_label(p[3], p.lineno(3))
p[1].append(entry) | def p_label_list_list(p) | label_list : label_list COMMA ID
| label_list COMMA NUMBER | 5.602915 | 5.719975 | 0.979535 |
if not FUNCTION_LEVEL: # At less one level, otherwise, this return is from a GOSUB
p[0] = make_sentence('RETURN')
return
if FUNCTION_LEVEL[-1].kind != KIND.sub:
syntax_error(p.lineno(1), 'Syntax Error: Functions must RETURN a value, or use EXIT FUNCTION instead.')
p[0] = N... | def p_return(p) | statement : RETURN | 11.921975 | 11.29665 | 1.055355 |
if not FUNCTION_LEVEL: # At less one level
syntax_error(p.lineno(1), 'Syntax Error: Returning value out of FUNCTION')
p[0] = None
return
if FUNCTION_LEVEL[-1].kind is None: # This function was not correctly declared.
p[0] = None
return
if FUNCTION_LEVEL[-1].k... | def p_return_expr(p) | statement : RETURN expr | 3.587158 | 3.501323 | 1.024515 |
p[0] = make_sentence('PAUSE',
make_typecast(TYPE.uinteger, p[2], p.lineno(1))) | def p_pause(p) | statement : PAUSE expr | 18.491669 | 12.852 | 1.438816 |
i = 2 if isinstance(p[2], Symbol) or p[2] is None else 3
if p[i] is None or p[i + 2] is None:
p[0] = None
return
p[0] = make_sentence('POKE',
make_typecast(TYPE.uinteger, p[i], p.lineno(i + 1)),
make_typecast(TYPE.ubyte, p[i + 2], p.line... | def p_poke(p) | statement : POKE expr COMMA expr
| POKE LP expr COMMA expr RP | 4.381898 | 4.023418 | 1.089098 |
i = 2 if isinstance(p[2], Symbol) or p[2] is None else 3
if p[i + 1] is None or p[i + 3] is None:
p[0] = None
return
p[0] = make_sentence('POKE',
make_typecast(TYPE.uinteger, p[i + 1], p.lineno(i + 2)),
make_typecast(p[i], p[i + 3], p.li... | def p_poke2(p) | statement : POKE numbertype expr COMMA expr
| POKE LP numbertype expr COMMA expr RP | 4.184278 | 3.760634 | 1.112652 |
p[0] = make_sentence('OUT',
make_typecast(TYPE.uinteger, p[2], p.lineno(3)),
make_typecast(TYPE.ubyte, p[4], p.lineno(4))) | def p_out(p) | statement : OUT expr COMMA expr | 8.113892 | 6.494341 | 1.249379 |
p[0] = make_sentence(p[1], make_typecast(TYPE.ubyte, p[2], p.lineno(1))) | def p_simple_instruction(p) | statement : ITALIC expr
| BOLD expr
| INK expr
| PAPER expr
| BRIGHT expr
| FLASH expr
| OVER expr
| INVERSE expr | 13.803857 | 13.618524 | 1.013609 |
if p[2].type_ != TYPE.string:
api.errmsg.syntax_error_expected_string(p.lineno(1), p[2].type_)
if len(p) == 5:
if p[3].upper() not in ('SCREEN', 'SCREEN$'):
syntax_error(p.lineno(3), 'Unexpected "%s" ID. Expected "SCREEN$" instead' % p[3])
return None
else:
... | def p_save_code(p) | statement : SAVE expr CODE expr COMMA expr
| SAVE expr ID
| SAVE expr ARRAY_ID | 6.570807 | 6.26389 | 1.048998 |
if p[2].type_ != TYPE.string:
api.errmsg.syntax_error_expected_string(p.lineno(1), p[2].type_)
if len(p) != 4:
entry = SYMBOL_TABLE.access_id(p[4], p.lineno(4))
if entry is None:
p[0] = None
return
entry.accessed = True
access = entry
... | def p_save_data(p) | statement : SAVE expr DATA
| SAVE expr DATA ID
| SAVE expr DATA ID LP RP | 4.100258 | 3.914079 | 1.047566 |
if p[2].type_ != TYPE.string:
api.errmsg.syntax_error_expected_string(p.lineno(3), p[2].type_)
if len(p) == 4:
if p[3].upper() not in ('SCREEN', 'SCREEN$', 'CODE'):
syntax_error(p.lineno(3), 'Unexpected "%s" ID. Expected "SCREEN$" instead' % p[3])
return None
... | def p_load_code(p) | statement : load_or_verify expr ID
| load_or_verify expr CODE
| load_or_verify expr CODE expr
| load_or_verify expr CODE expr COMMA expr | 3.688293 | 3.542309 | 1.041211 |
p[0] = make_binary(p.lineno(2), 'PLUS', p[1], p[3], lambda x, y: x + y) | def p_expr_plus_expr(p) | expr : expr PLUS expr | 4.711815 | 3.787695 | 1.243979 |
p[0] = make_binary(p.lineno(2), 'MINUS', p[1], p[3], lambda x, y: x - y) | def p_expr_minus_expr(p) | expr : expr MINUS expr | 5.100906 | 3.920805 | 1.300984 |
p[0] = make_binary(p.lineno(2), 'MUL', p[1], p[3], lambda x, y: x * y) | def p_expr_mul_expr(p) | expr : expr MUL expr | 4.91337 | 3.746676 | 1.311394 |
p[0] = make_binary(p.lineno(2), 'DIV', p[1], p[3], lambda x, y: x / y) | def p_expr_div_expr(p) | expr : expr DIV expr | 4.793365 | 3.647138 | 1.314281 |
p[0] = make_binary(p.lineno(2), 'MOD', p[1], p[3], lambda x, y: x % y) | def p_expr_mod_expr(p) | expr : expr MOD expr | 4.670169 | 3.607288 | 1.294648 |
p[0] = make_binary(p.lineno(2), 'POW',
make_typecast(TYPE.float_, p[1], p.lineno(2)),
make_typecast(TYPE.float_, p[3], p.lexer.lineno),
lambda x, y: x ** y) | def p_expr_pow_expr(p) | expr : expr POW expr | 5.001103 | 4.319982 | 1.157668 |
if p[1] is None or p[3] is None:
p[0] = None
return
if p[1].type_ in (TYPE.float_, TYPE.fixed):
p[1] = make_typecast(TYPE.ulong, p[1], p.lineno(2))
p[0] = make_binary(p.lineno(2), 'SHL', p[1],
make_typecast(TYPE.ubyte, p[3], p.lineno(2)),
... | def p_expr_shl_expr(p) | expr : expr SHL expr | 3.840609 | 3.693069 | 1.039951 |
p[0] = make_binary(p.lineno(2), 'EQ', p[1], p[3], lambda x, y: x == y) | def p_expr_EQ_expr(p) | expr : expr EQ expr | 4.409044 | 3.68931 | 1.195086 |
p[0] = make_binary(p.lineno(2), 'LT', p[1], p[3], lambda x, y: x < y) | def p_expr_LT_expr(p) | expr : expr LT expr | 4.529357 | 3.601475 | 1.25764 |
p[0] = make_binary(p.lineno(2), 'LE', p[1], p[3], lambda x, y: x <= y) | def p_expr_LE_expr(p) | expr : expr LE expr | 4.350905 | 3.514384 | 1.238028 |
p[0] = make_binary(p.lineno(2), 'GT', p[1], p[3], lambda x, y: x > y) | def p_expr_GT_expr(p) | expr : expr GT expr | 4.536518 | 3.645022 | 1.244579 |
p[0] = make_binary(p.lineno(2), 'GE', p[1], p[3], lambda x, y: x >= y) | def p_expr_GE_expr(p) | expr : expr GE expr | 4.382434 | 3.619401 | 1.210818 |
p[0] = make_binary(p.lineno(2), 'NE', p[1], p[3], lambda x, y: x != y) | def p_expr_NE_expr(p) | expr : expr NE expr | 4.71502 | 3.767809 | 1.251396 |
p[0] = make_binary(p.lineno(2), 'OR', p[1], p[3], lambda x, y: x or y) | def p_expr_OR_expr(p) | expr : expr OR expr | 4.483342 | 3.600883 | 1.245067 |
p[0] = make_binary(p.lineno(2), 'BOR', p[1], p[3], lambda x, y: x | y) | def p_expr_BOR_expr(p) | expr : expr BOR expr | 4.225009 | 3.551007 | 1.189806 |
p[0] = make_binary(p.lineno(2), 'XOR', p[1], p[3], lambda x, y: (x and not y) or (not x and y)) | def p_expr_XOR_expr(p) | expr : expr XOR expr | 4.0563 | 3.537721 | 1.146586 |
p[0] = make_binary(p.lineno(2), 'BXOR', p[1], p[3], lambda x, y: x ^ y) | def p_expr_BXOR_expr(p) | expr : expr BXOR expr | 4.400171 | 3.66864 | 1.199401 |
p[0] = make_binary(p.lineno(2), 'AND', p[1], p[3], lambda x, y: x and y) | def p_expr_AND_expr(p) | expr : expr AND expr | 4.497256 | 3.689404 | 1.218966 |
p[0] = make_binary(p.lineno(2), 'BAND', p[1], p[3], lambda x, y: x & y) | def p_expr_BAND_expr(p) | expr : expr BAND expr | 4.648108 | 3.894215 | 1.193593 |
p[0] = make_number(PI, lineno=p.lineno(1), type_=TYPE.float_) | def p_expr_PI(p) | bexpr : PI | 13.398783 | 11.884665 | 1.127401 |
entry = SYMBOL_TABLE.access_var(p[1], p.lineno(1), default_type=TYPE.string)
p[0] = None
if entry is None:
return
entry.accessed = True
p[0] = make_strslice(p.lineno(1), entry, p[2][0], p[2][1]) | def p_expr_id_substr(p) | string : ID substr | 6.106311 | 6.002986 | 1.017212 |
if p[2].type_ != TYPE.string:
syntax_error(p.lexer.lineno,
"Expected a string type expression. "
"Got %s type instead" % TYPE.to_string(p[2].type_))
p[0] = None
else:
p[0] = make_strslice(p.lexer.lineno, p[2], p[4][0], p[4][1]) | def p_string_expr_lp(p) | string : LP expr RP substr | 4.432902 | 4.065531 | 1.090362 |
p[0] = (make_typecast(TYPE.uinteger, p[2], p.lineno(1)),
make_typecast(TYPE.uinteger, p[4], p.lineno(3))) | def p_subind_str(p) | substr : LP expr TO expr RP | 5.527137 | 4.669818 | 1.183587 |
p[0] = (make_typecast(TYPE.uinteger, make_number(0, lineno=p.lineno(2)),
p.lineno(1)),
make_typecast(TYPE.uinteger, p[3], p.lineno(2))) | def p_subind_strTO(p) | substr : LP TO expr RP | 6.882591 | 6.240368 | 1.102914 |
p[0] = (make_typecast(TYPE.uinteger,
make_number(0, lineno=p.lineno(2)),
p.lineno(1)),
make_typecast(TYPE.uinteger,
make_number(gl.MAX_STRSLICE_IDX, lineno=p.lineno(3)),
p.lineno(2))) | def p_subind_TO(p) | substr : LP TO RP | 7.368354 | 6.798721 | 1.083785 |
entry = SYMBOL_TABLE.access_id(p[1], p.lineno(1), default_class=CLASS.var)
if entry is None:
p[0] = None
return
entry.accessed = True
if entry.type_ == TYPE.auto:
entry.type_ = _TYPE(gl.DEFAULT_TYPE)
api.errmsg.warning_implicit_type(p.lineno(1), p[1], entry.type_)
... | def p_id_expr(p) | bexpr : ID
| ARRAY_ID | 5.204002 | 5.160819 | 1.008367 |
entry = SYMBOL_TABLE.access_id(p[2], p.lineno(2))
if entry is None:
p[0] = None
return
entry.accessed = True
result = make_unary(p.lineno(1), 'ADDRESS', entry, type_=_TYPE(gl.PTR_TYPE))
if is_dynamic(entry):
p[0] = result
else:
p[0] = make_constexpr(p.linen... | def p_addr_of_id(p) | bexpr : ADDRESSOF ID
| ADDRESSOF ARRAY_ID | 6.523564 | 6.542233 | 0.997146 |
# This can be a function call or a string index
p[0] = make_call(p[1], p.lineno(1), p[2])
if p[0] is None:
return
if p[0].token in ('STRSLICE', 'VAR', 'STRING'):
entry = SYMBOL_TABLE.access_call(p[1], p.lineno(1))
entry.accessed = True
return
# TODO: Check that ar... | def p_idcall_expr(p) | func_call : ID arg_list %prec UMINUS | 8.876058 | 9.246631 | 0.959923 |
# This is an array access
p[0] = make_call(p[1], p.lineno(1), p[2])
if p[0] is None:
return
entry = SYMBOL_TABLE.access_call(p[1], p.lineno(1))
entry.accessed = True | def p_arr_access_expr(p) | func_call : ARRAY_ID arg_list | 6.008319 | 5.657715 | 1.061969 |
i = 2 if p[1].upper() == 'LET' else 1
id_ = p[i]
arg_list = p[i + 1]
substr = p[i + 2]
expr_ = p[i + 4]
p[0] = make_array_substr_assign(p.lineno(i), id_, arg_list, substr, expr_) | def p_let_arr_substr(p) | statement : LET ARRAY_ID arg_list substr EQ expr
| ARRAY_ID arg_list substr EQ expr | 4.14689 | 3.152788 | 1.315309 |
i = 2 if p[1].upper() == 'LET' else 1
id_ = p[i]
arg_list = p[i + 2]
substr = (arg_list.children.pop().value,
make_number(gl.MAX_STRSLICE_IDX, lineno=p.lineno(i + 3)))
expr_ = p[i + 6]
p[0] = make_array_substr_assign(p.lineno(i), id_, arg_list, substr, expr_) | def p_let_arr_substr_in_args(p) | statement : LET ARRAY_ID LP arguments TO RP EQ expr
| ARRAY_ID LP arguments TO RP EQ expr | 6.682819 | 5.961768 | 1.120946 |
i = 2 if p[1].upper() == 'LET' else 1
id_ = p[i]
arg_list = p[i + 2]
top_ = p[i + 5]
substr = (make_number(0, lineno=p.lineno(i + 4)), top_)
expr_ = p[i + 8]
p[0] = make_array_substr_assign(p.lineno(i), id_, arg_list, substr, expr_) | def p_let_arr_substr_in_args2(p) | statement : LET ARRAY_ID LP arguments COMMA TO expr RP EQ expr
| ARRAY_ID LP arguments COMMA TO expr RP EQ expr | 5.289701 | 4.502932 | 1.174724 |
i = 2 if p[1].upper() == 'LET' else 1
id_ = p[i]
arg_list = p[i + 2]
substr = (make_number(0, lineno=p.lineno(i + 4)),
make_number(gl.MAX_STRSLICE_IDX, lineno=p.lineno(i + 3)))
expr_ = p[i + 7]
p[0] = make_array_substr_assign(p.lineno(i), id_, arg_list, substr, expr_) | def p_let_arr_substr_in_args3(p) | statement : LET ARRAY_ID LP arguments COMMA TO RP EQ expr
| ARRAY_ID LP arguments COMMA TO RP EQ expr | 5.898282 | 5.108395 | 1.154625 |
i = 2 if p[1].upper() == 'LET' else 1
id_ = p[i]
arg_list = p[i + 2]
substr = (arg_list.children.pop().value, p[i + 4])
expr_ = p[i + 7]
p[0] = make_array_substr_assign(p.lineno(i), id_, arg_list, substr, expr_) | def p_let_arr_substr_in_args4(p) | statement : LET ARRAY_ID LP arguments TO expr RP EQ expr
| ARRAY_ID LP arguments TO expr RP EQ expr | 4.855766 | 4.173727 | 1.163413 |
p[0] = None
if p[3] is None:
return
result = make_array_access(p[2], p.lineno(2), p[3])
if result is None:
return
result.entry.accessed = True
p[0] = make_unary(p.lineno(1), 'ADDRESS', result, type_=_TYPE(gl.PTR_TYPE)) | def p_addr_of_array_element(p) | bexpr : ADDRESSOF ARRAY_ID arg_list | 7.588006 | 7.225612 | 1.050154 |
args = make_arg_list(make_argument(p[2], p.lineno(2)))
p[0] = make_call(p[1], p.lineno(1), args)
if p[0] is None:
return
if p[0].token in ('STRSLICE', 'VAR', 'STRING'):
entry = SYMBOL_TABLE.access_call(p[1], p.lineno(1))
entry.accessed = True
return
# TODO: Che... | def p_bexpr_func(p) | bexpr : ID bexpr | 8.14694 | 8.119308 | 1.003403 |
if p[1] is None or p[3] is None:
p[0] = None
else:
p[0] = make_arg_list(p[1], make_argument(p[3], p.lineno(2))) | def p_arguments(p) | arguments : arguments COMMA expr | 3.386444 | 3.181715 | 1.064345 |
if p[1] is None:
p[0] = None
return
p[0] = p[1]
p[0].local_symbol_table = SYMBOL_TABLE.table[SYMBOL_TABLE.current_scope]
p[0].locals_size = SYMBOL_TABLE.leave_scope()
FUNCTION_LEVEL.pop()
p[0].entry.body = p[2]
entry = p[0].entry
entry.forwarded = False | def p_funcdecl(p) | function_declaration : function_header function_body | 5.795475 | 5.014967 | 1.155636 |
if p[2] is None:
if FUNCTION_LEVEL:
FUNCTION_LEVEL.pop()
return
if p[2].entry.forwarded:
syntax_error(p.lineno(1), "duplicated declaration for function '%s'" % p[2].name)
p[2].entry.forwarded = True
SYMBOL_TABLE.leave_scope()
FUNCTION_LEVEL.pop() | def p_funcdeclforward(p) | function_declaration : DECLARE function_header_pre | 5.587156 | 5.219336 | 1.070473 |
if p[1] is None or p[2] is None:
p[0] = None
return
forwarded = p[1].entry.forwarded
p[0] = p[1]
p[0].appendChild(p[2])
p[0].params_size = p[2].size
lineno = p.lineno(3)
previoustype_ = p[0].type_
if not p[3].implicit or p[0].entry.type_ is None or p[0].entry.type... | def p_function_header_pre(p) | function_header_pre : function_def param_decl typedef | 3.405586 | 3.339495 | 1.019791 |
p[0] = make_func_declaration(p[3], p.lineno(3))
SYMBOL_TABLE.enter_scope(p[3])
FUNCTION_LEVEL.append(SYMBOL_TABLE.get_entry(p[3]))
FUNCTION_LEVEL[-1].convention = p[2]
if p[0] is not None:
kind = KIND.sub if p[1] == 'SUB' else KIND.function # Must be 'function' or 'sub'
FUNCTI... | def p_function_def(p) | function_def : FUNCTION convention ID
| SUB convention ID | 4.992749 | 4.27156 | 1.168835 |
p[0] = p[1]
if p[0] is not None:
p[0].byref = OPTIONS.byref.value | def p_param_definition(p) | param_definition : param_def | 6.533885 | 6.129395 | 1.065992 |
if p[2] is not None:
api.check.check_type_is_explicit(p.lineno(1), p[1], p[2])
p[0] = make_param_decl(p[1], p.lineno(1), p[2]) | def p_param_def_type(p) | param_def : ID typedef | 4.50899 | 4.165435 | 1.082477 |
if not FUNCTION_LEVEL:
syntax_error(p.lineno(3), "Unexpected token 'END %s'. No Function or Sub has been defined." % p[2])
p[0] = None
return
a = FUNCTION_LEVEL[-1].kind
if a not in (KIND.sub, KIND.function): # This function/sub was not correctly declared, so exit now
... | def p_function_body(p) | function_body : program_co END FUNCTION
| program_co END SUB
| statements_co END FUNCTION
| statements_co END SUB
| co_statements_co END FUNCTION
| co_statements_co END SUB
| END FUNCTION
... | 4.607241 | 4.333879 | 1.063076 |
# Epsilon. Defaults to float
p[0] = make_type(_TYPE(gl.DEFAULT_TYPE).name, p.lexer.lineno, implicit=True) | def p_type_def_empty(p) | typedef : | 28.659843 | 25.763851 | 1.112405 |
if p[2].type_ == TYPE.string:
p[0] = make_builtin(p.lineno(1), 'USR_STR', p[2], type_=TYPE.uinteger)
else:
p[0] = make_builtin(p.lineno(1), 'USR',
make_typecast(TYPE.uinteger, p[2], p.lineno(1)),
type_=TYPE.uinteger) | def p_expr_usr(p) | bexpr : USR bexpr %prec UMINUS | 4.084735 | 3.798563 | 1.075337 |
p[0] = make_builtin(p.lineno(1), 'PEEK',
make_typecast(TYPE.uinteger, p[2], p.lineno(1)),
type_=TYPE.ubyte) | def p_expr_peek(p) | bexpr : PEEK bexpr %prec UMINUS | 11.84656 | 10.616777 | 1.115834 |
p[0] = make_builtin(p.lineno(1), 'PEEK',
make_typecast(TYPE.uinteger, p[5], p.lineno(4)),
type_=p[3]) | def p_expr_peektype_(p) | bexpr : PEEK LP numbertype COMMA expr RP | 11.902032 | 8.938004 | 1.331621 |
entry = SYMBOL_TABLE.access_array(p[3], p.lineno(3))
if entry is None:
p[0] = None
return
entry.accessed = True
if p[1] == 'LBOUND':
p[0] = make_number(entry.bounds[OPTIONS.array_base.value].lower,
p.lineno(3), TYPE.uinteger)
else:
p[... | def p_expr_lbound(p) | bexpr : LBOUND LP ARRAY_ID RP
| UBOUND LP ARRAY_ID RP | 4.239104 | 3.919416 | 1.081565 |
entry = SYMBOL_TABLE.access_array(p[3], p.lineno(3))
if entry is None:
p[0] = None
return
entry.accessed = True
num = make_typecast(TYPE.uinteger, p[5], p.lineno(6))
if is_number(num):
if num.value == 0: # 0 => Number of dims
p[0] = make_number(len(entry.b... | def p_expr_lbound_expr(p) | bexpr : LBOUND LP ARRAY_ID COMMA expr RP
| UBOUND LP ARRAY_ID COMMA expr RP | 3.110783 | 3.066242 | 1.014526 |
arg = p[2]
if arg is None:
p[0] = None
elif isinstance(arg, symbols.VAR) and arg.class_ == CLASS.array:
p[0] = make_number(len(arg.bounds), lineno=p.lineno(1)) # Do constant folding
elif arg.type_ != TYPE.string:
api.errmsg.syntax_error_expected_string(p.lineno(1), TYPE.to_... | def p_len(p) | bexpr : LEN bexpr %prec UMINUS | 4.991635 | 4.812018 | 1.037327 |
if TYPE.to_type(p[3].lower()) is not None:
p[0] = make_number(TYPE.size(TYPE.to_type(p[3].lower())),
lineno=p.lineno(3))
else:
entry = SYMBOL_TABLE.get_id_or_make_var(p[3], p.lineno(1))
p[0] = make_number(TYPE.size(entry.type_), lineno=p.lineno(3)) | def p_sizeof(p) | bexpr : SIZEOF LP type RP
| SIZEOF LP ID RP
| SIZEOF LP ARRAY_ID RP | 4.187574 | 4.23591 | 0.988589 |
if is_number(p[2]): # A constant is converted to string directly
p[0] = symbols.STRING(str(p[2].value), p.lineno(1))
else:
p[0] = make_builtin(p.lineno(1), 'STR',
make_typecast(TYPE.float_, p[2], p.lineno(1)),
type_=TYPE.string) | def p_str(p) | string : STR expr %prec UMINUS | 7.638995 | 7.120584 | 1.072805 |
arg_list = make_arg_list(make_argument(p[2], p.lineno(1)))
arg_list[0].value = make_typecast(TYPE.ubyte, arg_list[0].value, p.lineno(1))
p[0] = make_builtin(p.lineno(1), 'CHR', arg_list, type_=TYPE.string) | def p_chr_one(p) | string : CHR bexpr %prec UMINUS | 5.976623 | 5.721181 | 1.044648 |
if len(p[2]) < 1:
syntax_error(p.lineno(1), "CHR$ function need at less 1 parameter")
p[0] = None
return
for i in range(len(p[2])): # Convert every argument to 8bit unsigned
p[2][i].value = make_typecast(TYPE.ubyte, p[2][i].value, p.lineno(1))
p[0] = make_builtin(p.li... | def p_chr(p) | string : CHR arg_list | 5.837439 | 5.422186 | 1.076584 |
def val(s):
try:
x = float(s)
except:
x = 0
warning(p.lineno(1), "Invalid string numeric constant '%s' evaluated as 0" % s)
return x
if p[2].type_ != TYPE.string:
api.errmsg.syntax_error_expected_string(p.lineno(1), TYPE.to_string(p[2].t... | def p_val(p) | bexpr : VAL bexpr %prec UMINUS | 6.270342 | 5.976487 | 1.049169 |
def asc(x):
if len(x):
return ord(x[0])
return 0
if p[2] is None:
p[0] = None
return
if p[2].type_ != TYPE.string:
api.errmsg.syntax_error_expected_string(p.lineno(1), TYPE.to_string(p[2].type_))
p[0] = None
else:
p[0] = make_b... | def p_code(p) | bexpr : CODE bexpr %prec UMINUS | 5.65918 | 5.551692 | 1.019361 |
sgn = lambda x: x < 0 and -1 or x > 0 and 1 or 0 # noqa
if p[2].type_ == TYPE.string:
syntax_error(p.lineno(1), "Expected a numeric expression, got TYPE.string instead")
p[0] = None
else:
if is_unsigned(p[2]) and not is_number(p[2]):
warning(p.lineno(1), "Sign of u... | def p_sgn(p) | bexpr : SGN bexpr %prec UMINUS | 5.600882 | 5.287463 | 1.059276 |
p[0] = make_builtin(p.lineno(1), p[1],
make_typecast(TYPE.float_, p[2], p.lineno(1)),
{'SIN': math.sin,
'COS': math.cos,
'TAN': math.tan,
'ASN': math.asin,
'ACS': ... | def p_expr_trig(p) | bexpr : math_fn bexpr %prec UMINUS | 3.772734 | 3.663732 | 1.029752 |
if is_unsigned(p[2]):
p[0] = p[2]
warning(p.lineno(1), "Redundant operation ABS for unsigned value")
return
p[0] = make_builtin(p.lineno(1), 'ABS', p[2], lambda x: x if x >= 0 else -x) | def p_abs(p) | bexpr : ABS bexpr %prec UMINUS | 5.265609 | 4.889056 | 1.07702 |
if not is_static(lower, upper):
syntax_error(lineno, 'Array bounds must be constants')
return None
if isinstance(lower, SymbolVAR):
lower = lower.value
if isinstance(upper, SymbolVAR):
upper = upper.value
lower.value = int(lower.... | def make_node(lower, upper, lineno) | Creates an array bound | 2.849437 | 2.692198 | 1.058405 |
s = [ord(x) for x in str(number)] + [14] # Bytes of string representation in bytes
if number == int(number) and abs(number) < 65536: # integer form?
sign = 0xFF if number < 0 else 0
b = [0, sign] + self.numberLH(number) + [0]
else: # Float form
(C... | def number(self, number) | Returns a floating point (or integer) number for a BASIC
program. That is: It's ASCII representation followed by 5 bytes
in floating point or integer format (if number in (-65535 + 65535) | 4.958018 | 4.504028 | 1.100796 |
result = []
def shift(string_):
string_ = string_.strip() # Remove spaces and tabs
if not string_: # Avoid empty strings
return '', ''
i = string_.find(' ')
if i == -1:
command_ = string_
... | def parse_sentence(self, string) | Parses the given sentence. BASIC commands must be
types UPPERCASE and as SEEN in ZX BASIC. e.g. GO SUB for gosub, etc... | 4.184609 | 3.903068 | 1.072133 |
result = [TOKENS[sentence[0]]]
for i in sentence[1:]: # Remaining bytes
if isinstance(i, str):
result.extend(self.literal(i))
elif isinstance(i, float) or isinstance(i, int): # A number?
result.extend(self.number(i))
else:
... | def sentence_bytes(self, sentence) | Return bytes of a sentence.
This is a very simple parser. Sentence is a list of strings and numbers.
1st element of sentence MUST match a token. | 4.818674 | 3.954213 | 1.218617 |
if line_number is None:
line_number = self.current_line + 10
self.current_line = line_number
sep = []
result = []
for sentence in sentences:
result.extend(sep)
result.extend(self.sentence_bytes(sentence))
sep = [ord(':')]
... | def line(self, sentences, line_number=None) | Return the bytes for a basic line.
If no line number is given, current one + 10 will be used
Sentences if a list of sentences | 4.786629 | 4.187497 | 1.143076 |
self.bytes += self.line(sentences, line_number) | def add_line(self, sentences, line_number=None) | Add current line to the output.
See self.line() for more info | 13.230838 | 9.740096 | 1.358389 |
offset = 0
# Now we must typecast each argument to a u16 (POINTER) type
# i is the dimension ith index, b is the bound
for i, b in zip(self.arglist, self.entry.bounds):
tmp = i.children[0]
if is_number(tmp) or is_const(tmp):
if offset is n... | def offset(self) | If this is a constant access (e.g. A(1))
return the offset in bytes from the beginning of the
variable in memory.
Otherwise, if it's not constant (e.g. A(i))
returns None | 8.535506 | 8.091328 | 1.054896 |
assert isinstance(arglist, SymbolARGLIST)
variable = gl.SYMBOL_TABLE.access_array(id_, lineno)
if variable is None:
return None
if len(variable.bounds) != len(arglist):
syntax_error(lineno, "Array '%s' has %i dimensions, not %i" %
... | def make_node(cls, id_, arglist, lineno) | Creates an array access. A(x1, x2, ..., xn) | 5.521015 | 5.287175 | 1.044228 |
r';'
t.lexer.push_state('asmcomment')
t.type = 'TOKEN'
t.value = ';'
return t | def t_INITIAL_COMMENT(self, t) | r'; | 10.788827 | 9.163746 | 1.177338 |
r'\r?\n'
t.lexer.lineno += 1
t.lexer.pop_state()
return t | def t_prepro_define_defargs_defargsopt_defexpr_pragma_NEWLINE(self, t) | r'\r?\n | 7.573233 | 4.712564 | 1.60703 |
r'[_\\]\r?\n'
t.lexer.lineno += 1
t.value = t.value[1:]
t.type = 'NEWLINE'
return t | def t_prepro_define_pragma_defargs_defargsopt_CONTINUE(self, t) | r'[_\\]\r?\n | 8.02008 | 3.439822 | 2.331539 |
r'[_a-zA-Z][_a-zA-Z0-9]*' # preprocessor directives
t.type = reserved_directives.get(t.value.lower(), 'ID')
if t.type == 'DEFINE':
t.lexer.begin('define')
elif t.type == 'PRAGMA':
t.lexer.begin('pragma')
return t | def t_prepro_ID(self, t) | r'[_a-zA-Z][_a-zA-Z0-9]* | 3.261953 | 3.093597 | 1.054421 |
r'\#' # Only matches if at beginning of line and "#"
if t.value == '#' and self.find_column(t) == 1:
t.lexer.push_state('prepro') | def t_INIIAL_sharp(self, t) | r'\# | 12.955275 | 9.94838 | 1.30225 |
return '%s#line %i "%s"\n' % (prefix, self.lex.lineno, os.path.basename(self.filestack[-1][0])) | def put_current_line(self, prefix='') | Returns line and file for include / end of include sequences. | 6.924366 | 5.376084 | 1.287994 |
if filename != STDIN and filename in [x[0] for x in self.filestack]: # Already included?
self.warning(' Recursive inclusion')
self.filestack.append([filename, 1, self.lex, self.input_data])
self.lex = lex.lex(object=self)
result = self.put_current_line() # First #... | def include(self, filename) | Changes FILENAME and line count | 4.964256 | 4.75024 | 1.045054 |
assert isinstance(entry, SymbolVAR)
self.aliased_by.append(entry) | def add_alias(self, entry) | Adds id to the current list 'aliased_by' | 17.979586 | 9.208713 | 1.952454 |
entry.add_alias(self)
self.alias = entry
self.scope = entry.scope # Local aliases can be "global" (static)
self.byref = entry.byref
self.offset = entry.offset
self.addr = entry.addr | def make_alias(self, entry) | Make this variable an alias of another one | 7.387589 | 6.80212 | 1.086072 |
# This can be done 'cause LABEL is just a dummy descent of VAR
assert isinstance(var_instance, SymbolVAR)
from symbols import LABEL
var_instance.__class__ = LABEL
var_instance.class_ = CLASS.label
var_instance._scope_owner = []
return var_instance | def to_label(var_instance) | Converts a var_instance to a label one | 17.435301 | 17.378731 | 1.003255 |
assert isinstance(var_instance, SymbolVAR)
from symbols import FUNCTION
var_instance.__class__ = FUNCTION
var_instance.class_ = CLASS.function
var_instance.reset(lineno=lineno)
return var_instance | def to_function(var_instance, lineno=None) | Converts a var_instance to a function one | 7.037368 | 7.14356 | 0.985135 |
assert isinstance(var_instance, SymbolVAR)
from symbols import BOUNDLIST
from symbols import VARARRAY
assert isinstance(bounds, BOUNDLIST)
var_instance.__class__ = VARARRAY
var_instance.class_ = CLASS.array
var_instance.bounds = bounds
return var_... | def to_vararray(var_instance, bounds) | Converts a var_instance to a var array one | 6.19634 | 6.352321 | 0.975445 |
output = []
oper = ins.quad[1]
indirect = (oper[0] == '*')
if indirect:
oper = oper[1:]
I = int(oper)
if I >= 0:
I += 4 # Return Address + "push IX"
output.append('push ix')
output.append('pop hl')
output.append('ld de, %i' % I)
output.append('add hl, de'... | def _paddr(ins) | Returns code sequence which points to
local variable or parameter (HL) | 4.866277 | 4.831728 | 1.007151 |
output = []
indirect = offset[0] == '*'
if indirect:
offset = offset[1:]
I = int(offset)
if I >= 0: # If it is a parameter, round up to even bytes
I += 4 + (size % 2 if not indirect else 0) # Return Address + "push IX"
ix_changed = (indirect or size < 5) and (abs(I) + s... | def _pload(offset, size) | Generic parameter loading.
Emmits output code for setting IX at the right location.
size = Number of bytes to load:
1 => 8 bit value
2 => 16 bit value / string
4 => 32 bit value / f16 value
5 => 40 bit value | 3.572556 | 3.517706 | 1.015593 |
output = _pload(ins.quad[2], 4)
output.append('push de')
output.append('push hl')
return output | def _pload32(ins) | Loads from stack pointer (SP) + X, being
X 2st parameter.
1st operand must be a SIGNED integer.
2nd operand cannot be an immediate nor an address. | 11.639693 | 17.752546 | 0.655663 |
output = _pload(ins.quad[2], 5)
output.extend(_fpush())
return output | def _ploadf(ins) | Loads from stack pointer (SP) + X, being
X 2st parameter.
1st operand must be a SIGNED integer. | 19.983324 | 28.334488 | 0.705265 |
output = _pload(ins.quad[2], 2)
if ins.quad[1][0] != '$':
output.append('call __LOADSTR')
REQUIRES.add('loadstr.asm')
output.append('push hl')
return output | def _ploadstr(ins) | Loads from stack pointer (SP) + X, being
X 2st parameter.
1st operand must be a SIGNED integer.
2nd operand cannot be an immediate nor an address. | 12.955679 | 16.693541 | 0.776089 |
output = _pload(ins.quad[2], 2)
if ins.quad[1][0] != '$':
output.append('call __LOADSTR')
REQUIRES.add('loadstr.asm')
return output | def _fploadstr(ins) | Loads from stack pointer (SP) + X, being
X 2st parameter.
1st operand must be a SIGNED integer.
Unlike ploadstr, this version does not push the result
back into the stack. | 15.357583 | 19.834904 | 0.774271 |
value = ins.quad[2]
offset = ins.quad[1]
indirect = offset[0] == '*'
size = 0
if indirect:
offset = offset[1:]
size = 1
I = int(offset)
if I >= 0:
I += 4 # Return Address + "push IX"
if not indirect:
I += 1 # F flag ignored
if is_int(v... | def _pstore8(ins) | Stores 2nd parameter at stack pointer (SP) + X, being
X 1st parameter.
1st operand must be a SIGNED integer. | 3.777392 | 3.802476 | 0.993403 |
value = ins.quad[2]
offset = ins.quad[1]
indirect = offset[0] == '*'
size = 1
if indirect:
offset = offset[1:]
I = int(offset)
if I >= 0:
I += 4 # Return Address + "push IX"
if is_int(value):
output = []
else:
output = _16bit_oper(value)
i... | def _pstore16(ins) | Stores 2nd parameter at stack pointer (SP) + X, being
X 1st parameter.
1st operand must be a SIGNED integer. | 3.780642 | 3.84485 | 0.9833 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.