code
string | signature
string | docstring
string | loss_without_docstring
float64 | loss_with_docstring
float64 | factor
float64 |
---|---|---|---|---|---|
output = []
output.extend(_8bit_oper(ins.quad[2], ins.quad[3]))
output.append('call __LTI8')
output.append('push af')
REQUIRES.add('lti8.asm')
return output
|
def _lti8(ins)
|
Compares & pops top 2 operands out of the stack, and checks
if the 1st operand < 2nd operand (top of the stack).
Pushes 0 if False, 1 if True.
8 bit signed version
| 12.948892 | 17.318489 | 0.747692 |
output = _8bit_oper(ins.quad[2], ins.quad[3], reversed_=True)
output.append('cp h')
output.append('sbc a, a')
output.append('push af')
return output
|
def _gtu8(ins)
|
Compares & pops top 2 operands out of the stack, and checks
if the 1st operand > 2nd operand (top of the stack).
Pushes 0 if False, 1 if True.
8 bit unsigned version
| 15.649663 | 18.646549 | 0.839279 |
if is_int(ins.quad[3]):
output = _8bit_oper(ins.quad[2])
n = int8(ins.quad[3])
if n:
if n == 1:
output.append('dec a')
else:
output.append('sub %i' % n)
else:
output = _8bit_oper(ins.quad[2], ins.quad[3])
output.append('sub h')
output.append('sub 1') # Sets Carry only if 0
output.append('sbc a, a')
output.append('push af')
return output
|
def _eq8(ins)
|
Compares & pops top 2 operands out of the stack, and checks
if the 1st operand == 2nd operand (top of the stack).
Pushes 0 if False, 1 if True.
8 bit un/signed version
| 6.098963 | 6.414364 | 0.950829 |
output = _8bit_oper(ins.quad[2], ins.quad[3], reversed_=True)
output.append('sub h') # Carry if H > A
output.append('ccf') # Negates => Carry if H <= A
output.append('sbc a, a')
output.append('push af')
return output
|
def _leu8(ins)
|
Compares & pops top 2 operands out of the stack, and checks
if the 1st operand <= 2nd operand (top of the stack).
Pushes 0 if False, 1 if True.
8 bit unsigned version
| 14.908493 | 16.881315 | 0.883136 |
output = _8bit_oper(ins.quad[2], ins.quad[3])
output.append('call __LEI8')
output.append('push af')
REQUIRES.add('lei8.asm')
return output
|
def _lei8(ins)
|
Compares & pops top 2 operands out of the stack, and checks
if the 1st operand <= 2nd operand (top of the stack).
Pushes 0 if False, 1 if True.
8 bit signed version
| 16.315004 | 19.752224 | 0.825983 |
output = _8bit_oper(ins.quad[2], ins.quad[3], reversed_=True)
output.append('call __LEI8')
output.append('push af')
REQUIRES.add('lei8.asm')
return output
|
def _gei8(ins)
|
Compares & pops top 2 operands out of the stack, and checks
if the 1st operand >= 2nd operand (top of the stack).
Pushes 0 if False, 1 if True.
8 bit signed version
| 20.849369 | 24.478733 | 0.851734 |
op1, op2 = tuple(ins.quad[2:])
if _int_ops(op1, op2) is not None:
op1, op2 = _int_ops(op1, op2)
output = _8bit_oper(op1) # Pops the stack (if applicable)
if op2 != 0: # X and True = X
output.append('push af')
return output
# False and X = False
output.append('xor a')
output.append('push af')
return output
output = _8bit_oper(op1, op2)
# output.append('call __AND8')
lbl = tmp_label()
output.append('or a')
output.append('jr z, %s' % lbl)
output.append('ld a, h')
output.append('%s:' % lbl)
output.append('push af')
# REQUIRES.add('and8.asm')
return output
|
def _and8(ins)
|
Pops top 2 operands out of the stack, and checks
if 1st operand AND (logical) 2nd operand (top of the stack),
pushes 0 if False, not 0 if True.
8 bit un/signed version
| 6.214202 | 6.316106 | 0.983866 |
op1, op2 = tuple(ins.quad[2:])
if _int_ops(op1, op2) is not None:
op1, op2 = _int_ops(op1, op2)
output = _8bit_oper(op1)
if op2 == 0xFF: # X & 0xFF = X
output.append('push af')
return output
if op2 == 0: # X and 0 = 0
output.append('xor a')
output.append('push af')
return output
op1, op2 = tuple(ins.quad[2:])
output = _8bit_oper(op1, op2)
output.append('and h')
output.append('push af')
return output
|
def _band8(ins)
|
Pops top 2 operands out of the stack, and does
1st AND (bitwise) 2nd operand (top of the stack),
pushes the result.
8 bit un/signed version
| 4.035406 | 4.104582 | 0.983147 |
op1, op2 = tuple(ins.quad[2:])
if _int_ops(op1, op2) is not None:
op1, op2 = _int_ops(op1, op2)
output = _8bit_oper(op1) # True or X = not X
if op2 == 0: # False xor X = X
output.append('push af')
return output
output.append('sub 1')
output.append('sbc a, a')
output.append('push af')
return output
output = _8bit_oper(op1, op2)
output.append('call __XOR8')
output.append('push af')
REQUIRES.add('xor8.asm')
return output
|
def _xor8(ins)
|
Pops top 2 operands out of the stack, and checks
if 1st operand XOR (logical) 2nd operand (top of the stack),
pushes 0 if False, 1 if True.
8 bit un/signed version
| 5.886494 | 6.139095 | 0.958854 |
output = _8bit_oper(ins.quad[2])
output.append('sub 1') # Gives carry only if A = 0
output.append('sbc a, a') # Gives FF only if Carry else 0
output.append('push af')
return output
|
def _not8(ins)
|
Negates (Logical NOT) top of the stack (8 bits in AF)
| 16.919756 | 14.605633 | 1.15844 |
output = _8bit_oper(ins.quad[2])
output.append('cpl') # Gives carry only if A = 0
output.append('push af')
return output
|
def _bnot8(ins)
|
Negates (BITWISE NOT) top of the stack (8 bits in AF)
| 26.229639 | 19.993259 | 1.311924 |
output = _8bit_oper(ins.quad[2])
output.append('neg')
output.append('push af')
return output
|
def _neg8(ins)
|
Negates top of the stack (8 bits in AF)
| 20.178024 | 16.061539 | 1.256295 |
output = _8bit_oper(ins.quad[2])
output.append('call __ABS8')
output.append('push af')
REQUIRES.add('abs8.asm')
return output
|
def _abs8(ins)
|
Absolute value of top of the stack (8 bits in AF)
| 22.198065 | 21.70241 | 1.022839 |
op1, op2 = tuple(ins.quad[2:])
if is_int(op2):
op2 = int8(op2)
output = _8bit_oper(op1)
if op2 == 0:
output.append('push af')
return output
if op2 < 4:
output.extend(['srl a'] * op2)
output.append('push af')
return output
label = tmp_label()
output.append('ld b, %i' % int8(op2))
output.append('%s:' % label)
output.append('srl a')
output.append('djnz %s' % label)
output.append('push af')
return output
if is_int(op1) and int(op1) == 0:
output = _8bit_oper(op2)
output.append('xor a')
output.append('push af')
return output
output = _8bit_oper(op1, op2, True)
label = tmp_label()
label2 = tmp_label()
output.append('or a')
output.append('ld b, a')
output.append('ld a, h')
output.append('jr z, %s' % label2)
output.append('%s:' % label)
output.append('srl a')
output.append('djnz %s' % label)
output.append('%s:' % label2)
output.append('push af')
return output
|
def _shru8(ins)
|
Shift 8bit unsigned integer to the right. The result is pushed onto the stack.
Optimizations:
* If 1nd or 2nd op is 0 then
do nothing
* If 2nd op is < 4 then
unroll loop
| 2.788625 | 2.832646 | 0.984459 |
if symbolTable is None:
symbolTable = self.table
return symbolTable.defined(self.id_)
|
def is_defined(self, symbolTable=None)
|
True if this macro has been defined
| 6.335392 | 5.973838 | 1.060523 |
''' Creates an array BOUND LIST.
'''
if node is None:
return cls.make_node(SymbolBOUNDLIST(), *args)
if node.token != 'BOUNDLIST':
return cls.make_node(None, node, *args)
for arg in args:
if arg is None:
continue
node.appendChild(arg)
return node
|
def make_node(cls, node, *args)
|
Creates an array BOUND LIST.
| 7.369787 | 4.6968 | 1.569108 |
global LABELS
global LET_ASSIGNMENT
global PRINT_IS_USED
global SYMBOL_TABLE
global ast
global data_ast
global optemps
global OPTIONS
global last_brk_linenum
LABELS = {}
LET_ASSIGNMENT = False
PRINT_IS_USED = False
last_brk_linenum = 0
ast = None
data_ast = None # Global Variables AST
optemps = OpcodesTemps()
gl.INITS.clear()
del gl.FUNCTION_CALLS[:]
del gl.FUNCTION_LEVEL[:]
del gl.FUNCTIONS[:]
SYMBOL_TABLE = gl.SYMBOL_TABLE = api.symboltable.SymbolTable()
OPTIONS = api.config.OPTIONS
# DATAs info
gl.DATA_LABELS.clear()
gl.DATA_IS_USED = False
del gl.DATAS[:]
gl.DATA_PTR_CURRENT = api.utils.current_data_label()
gl.DATA_FUNCTIONS = []
gl.error_msg_cache.clear()
|
def init()
|
Initializes parser state
| 7.932689 | 7.934425 | 0.999781 |
return symbols.NUMBER(value, type_=type_, lineno=lineno)
|
def make_number(value, lineno, type_=None)
|
Wrapper: creates a constant number node.
| 10.688004 | 9.666857 | 1.105634 |
assert isinstance(type_, symbols.TYPE)
return symbols.TYPECAST.make_node(type_, node, lineno)
|
def make_typecast(type_, node, lineno)
|
Wrapper: returns a Typecast node
| 7.378911 | 7.254114 | 1.017204 |
return symbols.BINARY.make_node(operator, left, right, lineno, func, type_)
|
def make_binary(lineno, operator, left, right, func=None, type_=None)
|
Wrapper: returns a Binary node
| 9.040821 | 7.967941 | 1.13465 |
return symbols.UNARY.make_node(lineno, operator, operand, func, type_)
|
def make_unary(lineno, operator, operand, func=None, type_=None)
|
Wrapper: returns a Unary node
| 8.669894 | 6.858951 | 1.264026 |
if operands is None:
operands = []
assert isinstance(operands, Symbol) or isinstance(operands, tuple) or isinstance(operands, list)
# TODO: In the future, builtin functions will be implemented in an external library, like POINT or ATTR
__DEBUG__('Creating BUILTIN "{}"'.format(fname), 1)
if not isinstance(operands, collections.Iterable):
operands = [operands]
return symbols.BUILTIN.make_node(lineno, fname, func, type_, *operands)
|
def make_builtin(lineno, fname, operands, func=None, type_=None)
|
Wrapper: returns a Builtin function node.
Can be a Symbol, tuple or list of Symbols
If operand is an iterable, they will be expanded.
| 7.584505 | 6.736498 | 1.125882 |
return symbols.STRSLICE.make_node(lineno, s, lower, upper)
|
def make_strslice(lineno, s, lower, upper)
|
Wrapper: returns String Slice node
| 6.337815 | 5.2761 | 1.201231 |
return symbols.SENTENCE(*([sentence] + list(args)), **kwargs)
|
def make_sentence(sentence, *args, **kwargs)
|
Wrapper: returns a Sentence node
| 12.193191 | 10.747928 | 1.134469 |
return symbols.FUNCDECL.make_node(func_name, lineno, type_=type_)
|
def make_func_declaration(func_name, lineno, type_=None)
|
This will return a node with the symbol as a function.
| 9.074233 | 7.040556 | 1.288852 |
if expr is None:
return # There were a syntax / semantic error
if byref is None:
byref = OPTIONS.byref.value
return symbols.ARGUMENT(expr, lineno=lineno, byref=byref)
|
def make_argument(expr, lineno, byref=None)
|
Wrapper: Creates a node containing an ARGUMENT
| 9.005135 | 8.507712 | 1.058467 |
return symbols.CALL.make_node(id_, params, lineno)
|
def make_sub_call(id_, lineno, params)
|
This will return an AST node for a sub/procedure call.
| 13.248963 | 11.833914 | 1.119576 |
return symbols.FUNCCALL.make_node(id_, params, lineno)
|
def make_func_call(id_, lineno, params)
|
This will return an AST node for a function call.
| 11.140858 | 11.214095 | 0.993469 |
return symbols.ARRAYACCESS.make_node(id_, arglist, lineno)
|
def make_array_access(id_, lineno, arglist)
|
Creates an array access. A(x1, x2, ..., xn).
This is an RVALUE (Read the element)
| 14.646219 | 20.728714 | 0.706567 |
assert isinstance(args, symbols.ARGLIST)
entry = SYMBOL_TABLE.access_call(id_, lineno)
if entry is None:
return None
if entry.class_ is CLASS.unknown and entry.type_ == TYPE.string and len(args) == 1 and is_numeric(args[0]):
entry.class_ = CLASS.var # A scalar variable. e.g a$(expr)
if entry.class_ == CLASS.array: # An already declared array
arr = symbols.ARRAYLOAD.make_node(id_, args, lineno)
if arr is None:
return None
if arr.offset is not None:
offset = make_typecast(TYPE.uinteger,
make_number(arr.offset, lineno=lineno),
lineno)
arr.appendChild(offset)
return arr
if entry.class_ == CLASS.var: # An already declared/used string var
if len(args) > 1:
api.errmsg.syntax_error_not_array_nor_func(lineno, id_)
return None
entry = SYMBOL_TABLE.access_var(id_, lineno)
if entry is None:
return None
if len(args) == 1:
return symbols.STRSLICE.make_node(lineno, entry, args[0].value, args[0].value)
entry.accessed = True
return entry
return make_func_call(id_, lineno, args)
|
def make_call(id_, lineno, args)
|
This will return an AST node for a function call/array access.
A "call" is just an ID followed by a list of arguments.
E.g. a(4)
- a(4) can be a function call if 'a' is a function
- a(4) can be a string slice if a is a string variable: a$(4)
- a(4) can be an access to an array if a is an array
This function will inspect the id_. If it is undeclared then
id_ will be taken as a forwarded function.
| 5.483416 | 5.257292 | 1.043011 |
assert isinstance(typename, str)
if not SYMBOL_TABLE.check_is_declared(typename, lineno, 'type'):
return None
type_ = symbols.TYPEREF(SYMBOL_TABLE.get_entry(typename), lineno, implicit)
return type_
|
def make_type(typename, lineno, implicit=False)
|
Converts a typename identifier (e.g. 'float') to
its internal symbol table entry representation.
Creates a type usage symbol stored in a AST
E.g. DIM a As Integer
will access Integer type
| 6.141107 | 7.924435 | 0.774958 |
return symbols.BOUND.make_node(lower, upper, lineno)
|
def make_bound(lower, upper, lineno)
|
Wrapper: Creates an array bound
| 15.740012 | 17.428747 | 0.903106 |
entry = SYMBOL_TABLE.declare_label(id_, lineno)
if entry:
gl.DATA_LABELS[id_] = gl.DATA_PTR_CURRENT # This label points to the current DATA block index
return entry
|
def make_label(id_, lineno)
|
Creates a label entry. Returns None on error.
| 15.698487 | 13.913423 | 1.128298 |
global last_brk_linenum
if not OPTIONS.enableBreak.value or lineno == last_brk_linenum or is_null(p):
return None
last_brk_linenum = lineno
return make_sentence('CHKBREAK', make_number(lineno, lineno, TYPE.uinteger))
|
def make_break(lineno, p)
|
Checks if --enable-break is set, and if so, calls
BREAK keyboard interruption for this line if it has not been already
checked
| 12.669161 | 12.568929 | 1.007975 |
global ast, data_ast
user_data = make_label('.ZXBASIC_USER_DATA', 0)
make_label('.ZXBASIC_USER_DATA_LEN', 0)
if PRINT_IS_USED:
zxbpp.ID_TABLE.define('___PRINT_IS_USED___', 1)
# zxbasmpp.ID_TABLE.define('___PRINT_IS_USED___', 1)
if zxblex.IN_STATE:
p.type = 'NEWLINE'
p_error(p)
sys.exit(1)
ast = p[0] = p[1]
__end = make_sentence('END', make_number(0, lineno=p.lexer.lineno))
if not is_null(ast):
ast.appendChild(__end)
else:
ast = __end
SYMBOL_TABLE.check_labels()
SYMBOL_TABLE.check_classes()
if gl.has_errors:
return
__DEBUG__('Checking pending labels', 1)
if not api.check.check_pending_labels(ast):
return
__DEBUG__('Checking pending calls', 1)
if not api.check.check_pending_calls():
return
data_ast = make_sentence('BLOCK', user_data)
# Appends variable declarations at the end.
for var in SYMBOL_TABLE.vars_:
data_ast.appendChild(make_var_declaration(var))
# Appends arrays declarations at the end.
for var in SYMBOL_TABLE.arrays:
data_ast.appendChild(make_array_declaration(var))
|
def p_start(p)
|
start : program
| 7.002413 | 6.904109 | 1.014238 |
p[0] = make_block(p[1], p[2], make_break(p.lineno(2), p[2]))
|
def p_program(p)
|
program : program program_line
| 5.942556 | 5.324666 | 1.116043 |
if len(p) == 2:
p[0] = make_block(p[1])
else:
p[0] = make_block(p[1], p[2])
|
def p_statements_statement(p)
|
statements : statement
| statements_co statement
| 2.383148 | 2.043341 | 1.1663 |
lbl = make_label(p[1], p.lineno(1))
p[0] = make_block(lbl, p[2]) if len(p) == 3 else lbl
|
def p_program_line_label(p)
|
label_line : LABEL statements
| LABEL co_statements
| 4.34675 | 3.685514 | 1.179415 |
lbl = make_label(p[1], p.lineno(1))
p[0] = make_block(lbl, p[2]) if len(p) == 3 else lbl
|
def p_label_line_co(p)
|
label_line_co : LABEL statements_co
| LABEL co_statements_co
| LABEL
| 4.276609 | 4.268099 | 1.001994 |
for vardata in p[2]:
SYMBOL_TABLE.declare_variable(vardata[0], vardata[1], p[3])
p[0] = None
|
def p_var_decl(p)
|
var_decl : DIM idlist typedef
| 5.721358 | 5.469853 | 1.04598 |
p[0] = None
if len(p[2]) != 1:
syntax_error(p.lineno(1),
'Only one variable at a time can be declared this way')
return
idlist = p[2][0]
entry = SYMBOL_TABLE.declare_variable(idlist[0], idlist[1], p[3])
if entry is None:
return
if p[5].token == 'CONST':
tmp = p[5].expr
if tmp.token == 'UNARY' and tmp.operator == 'ADDRESS': # Must be an ID
if tmp.operand.token == 'VAR':
entry.make_alias(tmp.operand)
elif tmp.operand.token == 'ARRAYACCESS':
if tmp.operand.offset is None:
syntax_error(p.lineno(4), 'Address is not constant. Only constant subscripts are allowed')
return
entry.make_alias(tmp.operand)
entry.offset = tmp.operand.offset
else:
syntax_error(p.lineno(4), 'Only address of identifiers are allowed')
return
elif not is_number(p[5]):
syntax_error(p.lineno(4), 'Address must be a numeric constant expression')
return
else:
entry.addr = str(make_typecast(_TYPE(gl.STR_INDEX_TYPE), p[5], p.lineno(4)).value)
entry.accessed = True
if entry.scope == SCOPE.local:
SYMBOL_TABLE.make_static(entry.name)
|
def p_var_decl_at(p)
|
var_decl : DIM idlist typedef AT expr
| 4.731373 | 4.408374 | 1.073269 |
p[0] = None
if len(p[2]) != 1:
syntax_error(p.lineno(1),
"Initialized variables must be declared one by one.")
return
if p[5] is None:
return
if not is_static(p[5]):
if isinstance(p[5], symbols.UNARY):
p[5] = make_constexpr(p.lineno(4), p[5]) # Delayed constant evaluation
if p[3].implicit:
p[3] = symbols.TYPEREF(p[5].type_, p.lexer.lineno, implicit=True)
value = make_typecast(p[3], p[5], p.lineno(4))
defval = value if is_static(p[5]) else None
if p[1] == 'DIM':
SYMBOL_TABLE.declare_variable(p[2][0][0], p[2][0][1], p[3],
default_value=defval)
else:
SYMBOL_TABLE.declare_const(p[2][0][0], p[2][0][1], p[3],
default_value=defval)
if defval is None: # Okay do a delayed initialization
p[0] = make_sentence('LET', SYMBOL_TABLE.access_var(p[2][0][0], p.lineno(1)), value)
|
def p_var_decl_ini(p)
|
var_decl : DIM idlist typedef EQ expr
| CONST idlist typedef EQ expr
| 4.834812 | 4.538009 | 1.065404 |
if len(p[2]) != 1:
syntax_error(p.lineno(1), "Array declaration only allows one variable name at a time")
else:
id_, lineno = p[2][0]
SYMBOL_TABLE.declare_array(id_, lineno, p[6], p[4])
p[0] = p[2][0]
|
def p_decl_arr(p)
|
var_arr_decl : DIM idlist LP bound_list RP typedef
| 4.481827 | 4.402495 | 1.01802 |
def check_bound(boundlist, remaining):
lineno = p.lineno(8)
if not boundlist: # Returns on empty list
if not isinstance(remaining, list):
return True # It's OK :-)
syntax_error(lineno, 'Unexpected extra vector dimensions. It should be %i' % len(remaining))
if not isinstance(remaining, list):
syntax_error(lineno, 'Mismatched vector size. Missing %i extra dimension(s)' % len(boundlist))
return False
if len(remaining) != boundlist[0].count:
syntax_error(lineno, 'Mismatched vector size. Expected %i elements, got %i.' % (boundlist[0].count,
len(remaining)))
return False # It's wrong. :-(
for row in remaining:
if not check_bound(boundlist[1:], row):
return False
return True
if p[8] is None:
p[0] = None
return
if check_bound(p[4].children, p[8]):
id_, lineno = p[2][0]
SYMBOL_TABLE.declare_array(id_, lineno, p[6], p[4], default_value=p[8])
p[0] = None
|
def p_arr_decl_initialized(p)
|
var_arr_decl : DIM idlist LP bound_list RP typedef RIGHTARROW const_vector
| DIM idlist LP bound_list RP typedef EQ const_vector
| 5.040039 | 4.800141 | 1.049977 |
p[0] = make_bound(make_number(OPTIONS.array_base.value,
lineno=p.lineno(1)), p[1], p.lexer.lineno)
|
def p_bound(p)
|
bound : expr
| 12.765911 | 11.304193 | 1.129308 |
if p[1] is None:
return
if not is_static(p[1]):
if isinstance(p[1], symbols.UNARY):
tmp = make_constexpr(p.lineno(1), p[1])
else:
api.errmsg.syntax_error_not_constant(p.lexer.lineno)
p[0] = None
return
else:
tmp = p[1]
p[0] = [tmp]
|
def p_const_vector_elem_list(p)
|
const_number_list : expr
| 5.198276 | 5.060384 | 1.027249 |
if p[1] is None or p[3] is None:
return
if not is_static(p[3]):
if isinstance(p[3], symbols.UNARY):
tmp = make_constexpr(p.lineno(2), p[3])
else:
api.errmsg.syntax_error_not_constant(p.lineno(2))
p[0] = None
return
else:
tmp = p[3]
if p[1] is not None:
p[1].append(tmp)
p[0] = p[1]
|
def p_const_vector_elem_list_list(p)
|
const_number_list : const_number_list COMMA expr
| 4.209883 | 4.047883 | 1.040021 |
if len(p[3]) != len(p[1][0]):
syntax_error(p.lineno(2), 'All rows must have the same number of elements')
p[0] = None
return
p[0] = p[1] + [p[3]]
|
def p_const_vector_vector_list(p)
|
const_vector_list : const_vector_list COMMA const_vector
| 3.578379 | 3.693376 | 0.968864 |
p[0] = make_sentence('BORDER',
make_typecast(TYPE.ubyte, p[2], p.lineno(1)))
|
def p_statement_border(p)
|
statement : BORDER expr
| 22.071447 | 16.854486 | 1.30953 |
p[0] = make_sentence('PLOT',
make_typecast(TYPE.ubyte, p[2], p.lineno(3)),
make_typecast(TYPE.ubyte, p[4], p.lineno(3)))
|
def p_statement_plot(p)
|
statement : PLOT expr COMMA expr
| 7.613324 | 6.361716 | 1.196741 |
p[0] = make_sentence('PLOT',
make_typecast(TYPE.ubyte, p[3], p.lineno(4)),
make_typecast(TYPE.ubyte, p[5], p.lineno(4)), p[2])
|
def p_statement_plot_attr(p)
|
statement : PLOT attr_list expr COMMA expr
| 7.876998 | 7.262105 | 1.084671 |
p[0] = make_sentence('DRAW3',
make_typecast(TYPE.integer, p[2], p.lineno(3)),
make_typecast(TYPE.integer, p[4], p.lineno(5)),
make_typecast(TYPE.float_, p[6], p.lineno(5)))
|
def p_statement_draw3(p)
|
statement : DRAW expr COMMA expr COMMA expr
| 4.570899 | 4.038651 | 1.131788 |
p[0] = make_sentence('DRAW3',
make_typecast(TYPE.integer, p[3], p.lineno(4)),
make_typecast(TYPE.integer, p[5], p.lineno(6)),
make_typecast(TYPE.float_, p[7], p.lineno(6)), p[2])
|
def p_statement_draw3_attr(p)
|
statement : DRAW attr_list expr COMMA expr COMMA expr
| 4.80293 | 4.660244 | 1.030618 |
p[0] = make_sentence('DRAW',
make_typecast(TYPE.integer, p[2], p.lineno(3)),
make_typecast(TYPE.integer, p[4], p.lineno(3)))
|
def p_statement_draw(p)
|
statement : DRAW expr COMMA expr
| 6.246336 | 5.163878 | 1.209621 |
p[0] = make_sentence('DRAW',
make_typecast(TYPE.integer, p[3], p.lineno(4)),
make_typecast(TYPE.integer, p[5], p.lineno(4)), p[2])
|
def p_statement_draw_attr(p)
|
statement : DRAW attr_list expr COMMA expr
| 6.505994 | 5.980498 | 1.087868 |
p[0] = make_sentence('CIRCLE',
make_typecast(TYPE.byte_, p[2], p.lineno(3)),
make_typecast(TYPE.byte_, p[4], p.lineno(5)),
make_typecast(TYPE.byte_, p[6], p.lineno(5)))
|
def p_statement_circle(p)
|
statement : CIRCLE expr COMMA expr COMMA expr
| 4.685649 | 3.963087 | 1.182323 |
p[0] = make_sentence('CIRCLE',
make_typecast(TYPE.byte_, p[3], p.lineno(4)),
make_typecast(TYPE.byte_, p[5], p.lineno(6)),
make_typecast(TYPE.byte_, p[7], p.lineno(6)), p[2])
|
def p_statement_circle_attr(p)
|
statement : CIRCLE attr_list expr COMMA expr COMMA expr
| 5.039825 | 4.611659 | 1.092844 |
p[0] = make_sentence('RANDOMIZE', make_number(0, lineno=p.lineno(1), type_=TYPE.ulong))
|
def p_statement_randomize(p)
|
statement : RANDOMIZE
| 16.702524 | 13.506885 | 1.236593 |
p[0] = make_sentence('RANDOMIZE', make_typecast(TYPE.ulong, p[2], p.lineno(1)))
|
def p_statement_randomize_expr(p)
|
statement : RANDOMIZE expr
| 16.095369 | 11.592763 | 1.388398 |
p[0] = make_sentence('BEEP', make_typecast(TYPE.float_, p[2], p.lineno(1)),
make_typecast(TYPE.float_, p[4], p.lineno(3)))
|
def p_statement_beep(p)
|
statement : BEEP expr COMMA expr
| 6.780757 | 4.964706 | 1.365792 |
if len(p) > 2 and p[2] is None:
p[0] = None
elif len(p) == 2:
entry = SYMBOL_TABLE.get_entry(p[1])
if not entry or entry.class_ in (CLASS.label, CLASS.unknown):
p[0] = make_label(p[1], p.lineno(1))
else:
p[0] = make_sub_call(p[1], p.lineno(1), make_arg_list(None))
else:
p[0] = make_sub_call(p[1], p.lineno(1), p[2])
|
def p_statement_call(p)
|
statement : ID arg_list
| ID arguments
| ID
| 3.043025 | 3.039309 | 1.001223 |
global LET_ASSIGNMENT
LET_ASSIGNMENT = False # Mark we're no longer using LET
p[0] = None
q = p[1:]
i = 1
if q[1] is None:
return
if isinstance(q[1], symbols.VAR) and q[1].class_ == CLASS.unknown:
q[1] = SYMBOL_TABLE.access_var(q[1].name, p.lineno(i))
q1class_ = q[1].class_ if isinstance(q[1], symbols.VAR) else CLASS.unknown
variable = SYMBOL_TABLE.access_id(q[0], p.lineno(i), default_type=q[1].type_, default_class=q1class_)
if variable is None:
return # HINT: This only happens if variable was not declared with DIM and --strict flag is in use
if variable.class_ == CLASS.unknown: # The variable is implicit
variable.class_ = CLASS.var
if variable.class_ not in (CLASS.var, CLASS.array):
api.errmsg.syntax_error_cannot_assing_not_a_var(p.lineno(i), variable.name)
return
if variable.class_ == CLASS.var and q1class_ == CLASS.array:
syntax_error(p.lineno(i), 'Cannot assign an array to an scalar variable')
return
if variable.class_ == CLASS.array:
if q1class_ != variable.class_:
syntax_error(p.lineno(i), 'Cannot assign an scalar to an array variable')
return
if q[1].type_ != variable.type_:
syntax_error(p.lineno(i), 'Arrays must have the same element type')
return
if variable.memsize != q[1].memsize:
syntax_error(p.lineno(i), "Arrays '%s' and '%s' must have the same size" %
(variable.name, q[1].name))
return
if variable.count != q[1].count:
warning(p.lineno(i), "Arrays '%s' and '%s' don't have the same number of dimensions" %
(variable.name, q[1].name))
else:
for b1, b2 in zip(variable.bounds, q[1].bounds):
if b1.count != b2.count:
warning(p.lineno(i), "Arrays '%s' and '%s' don't have the same dimensions" %
(variable.name, q[1].name))
break
# Array copy
p[0] = make_sentence('ARRAYCOPY', variable, q[1])
return
expr = make_typecast(variable.type_, q[1], p.lineno(i))
p[0] = make_sentence('LET', variable, expr)
|
def p_assignment(p)
|
statement : lexpr expr
| 3.421714 | 3.392555 | 1.008595 |
global LET_ASSIGNMENT
LET_ASSIGNMENT = True # Mark we're about to start a LET sentence
if p[1] == 'LET':
p[0] = p[2]
i = 2
else:
p[0] = p[1]
i = 1
SYMBOL_TABLE.access_id(p[i], p.lineno(i))
|
def p_lexpr(p)
|
lexpr : ID EQ
| LET ID EQ
| ARRAY_ID EQ
| LET ARRAY_ID EQ
| 6.029499 | 5.861233 | 1.028708 |
i = 2 if p[1].upper() == 'LET' else 1
id_ = p[i]
arg_list = p[i + 1]
expr = p[i + 3]
p[0] = None
if arg_list is None or expr is None:
return # There were errors
entry = SYMBOL_TABLE.access_call(id_, p.lineno(i))
if entry is None:
return
if entry.type_ == TYPE.string:
variable = gl.SYMBOL_TABLE.access_array(id_, p.lineno(i))
if len(variable.bounds) + 1 == len(arg_list):
ss = arg_list.children.pop().value
p[0] = make_array_substr_assign(p.lineno(i), id_, arg_list, (ss, ss), expr)
return
arr = make_array_access(id_, p.lineno(i), arg_list)
if arr is None:
return
expr = make_typecast(arr.type_, expr, p.lineno(i))
if entry is None:
return
p[0] = make_sentence('LETARRAY', arr, expr)
|
def p_arr_assignment(p)
|
statement : ARRAY_ID arg_list EQ expr
| LET ARRAY_ID arg_list EQ expr
| 5.265649 | 4.945099 | 1.064822 |
# This can be only a substr assignment like a$(i + 3) = ".", since arrays
# have ARRAY_ID already
entry = SYMBOL_TABLE.access_call(p[1], p.lineno(1))
if entry is None:
return
if entry.class_ == CLASS.unknown:
entry.class_ = CLASS.var
if p[6].type_ != TYPE.string:
api.errmsg.syntax_error_expected_string(p.lineno(5), p[6].type_)
lineno = p.lineno(2)
base = make_number(OPTIONS.string_base.value, lineno, _TYPE(gl.STR_INDEX_TYPE))
substr = make_typecast(_TYPE(gl.STR_INDEX_TYPE), p[3], lineno)
p[0] = make_sentence('LETSUBSTR', entry,
make_binary(lineno, 'MINUS', substr, base, func=lambda x, y: x - y),
make_binary(lineno, 'MINUS', substr, base, func=lambda x, y: x - y),
p[6])
|
def p_substr_assignment_no_let(p)
|
statement : ID LP expr RP EQ expr
| 9.188406 | 8.704207 | 1.055628 |
if p[3] is None or p[5] is None:
return # There were errors
p[0] = None
entry = SYMBOL_TABLE.access_call(p[2], p.lineno(2))
if entry is None:
return
if entry.class_ == CLASS.unknown:
entry.class_ = CLASS.var
assert entry.class_ == CLASS.var and entry.type_ == TYPE.string
if p[5].type_ != TYPE.string:
api.errmsg.syntax_error_expected_string(p.lineno(4), p[5].type_)
if len(p[3]) > 1:
syntax_error(p.lineno(2), "Accessing string with too many indexes. Expected only one.")
return
if len(p[3]) == 1:
substr = (
make_typecast(_TYPE(gl.STR_INDEX_TYPE), p[3][0].value, p.lineno(2)),
make_typecast(_TYPE(gl.STR_INDEX_TYPE), p[3][0].value, p.lineno(2)))
else:
substr = (make_typecast(_TYPE(gl.STR_INDEX_TYPE),
make_number(gl.MIN_STRSLICE_IDX,
lineno=p.lineno(2)),
p.lineno(2)),
make_typecast(_TYPE(gl.STR_INDEX_TYPE),
make_number(gl.MAX_STRSLICE_IDX,
lineno=p.lineno(2)),
p.lineno(2)))
lineno = p.lineno(2)
base = make_number(OPTIONS.string_base.value, lineno, _TYPE(gl.STR_INDEX_TYPE))
p[0] = make_sentence('LETSUBSTR', entry,
make_binary(lineno, 'MINUS', substr[0], base, func=lambda x, y: x - y),
make_binary(lineno, 'MINUS', substr[1], base, func=lambda x, y: x - y),
p[5])
|
def p_substr_assignment(p)
|
statement : LET ID arg_list EQ expr
| 3.763718 | 3.677683 | 1.023394 |
if p[1].upper() != 'LET':
q = p[1]
r = p[4]
s = p[2]
lineno = p.lineno(3)
else:
q = p[2]
r = p[5]
s = p[3]
lineno = p.lineno(4)
if q is None or s is None:
p[0] = None
return
if r.type_ != TYPE.string:
api.errmsg.syntax_error_expected_string(lineno, r.type_)
entry = SYMBOL_TABLE.access_var(q, lineno, default_type=TYPE.string)
if entry is None:
p[0] = None
return
p[0] = make_sentence('LETSUBSTR', entry, s[0], s[1], r)
|
def p_str_assign(p)
|
statement : ID substr EQ expr
| LET ID substr EQ expr
| 4.791351 | 4.319894 | 1.109136 |
entry = check_and_make_label(p[2], p.lineno(2))
if entry is not None:
p[0] = make_sentence(p[1].upper(), entry)
else:
p[0] = None
|
def p_goto(p)
|
statement : goto NUMBER
| goto ID
| 5.078885 | 5.003222 | 1.015123 |
cond_ = p[1]
if len(p) == 6:
lbl = make_label(p[3], p.lineno(3))
stat_ = make_block(lbl, p[4])
endif_ = p[5]
elif len(p) == 5:
stat_ = p[3]
endif_ = p[4]
else:
stat_ = make_nop()
endif_ = p[3]
p[0] = make_sentence('IF', cond_, make_block(stat_, endif_), lineno=p.lineno(2))
|
def p_if_sentence(p)
|
statement : if_then_part NEWLINE program_co endif
| if_then_part NEWLINE endif
| if_then_part NEWLINE statements_co endif
| if_then_part NEWLINE co_statements_co endif
| if_then_part NEWLINE LABEL statements_co endif
| 3.227384 | 3.381415 | 0.954448 |
cond_ = p[1]
stat_ = p[2]
endif_ = p[3]
p[0] = make_sentence('IF', cond_, make_block(stat_, endif_), lineno=p.lineno(1))
|
def p_statement_if_then_endif(p)
|
statement : if_then_part statements_co endif
| if_then_part co_statements_co endif
| 4.933388 | 5.182218 | 0.951984 |
cond_ = p[1]
stat_ = p[2]
p[0] = make_sentence('IF', cond_, stat_, lineno=p.lineno(1))
|
def p_single_line_if(p)
|
if_inline : if_then_part statements %prec ID
| if_then_part co_statements_co %prec NEWLINE
| if_then_part statements_co %prec NEWLINE
| if_then_part co_statements %prec ID
| 5.687667 | 6.952027 | 0.818131 |
cond_ = p[1]
stats_ = p[3] if len(p) == 5 else make_nop()
eliflist = p[4] if len(p) == 5 else p[3]
p[0] = make_sentence('IF', cond_, stats_, eliflist, lineno=p.lineno(2))
|
def p_if_elseif(p)
|
statement : if_then_part NEWLINE program_co elseiflist
| if_then_part NEWLINE elseiflist
| 4.846964 | 4.435759 | 1.092702 |
if p[1] == 'ELSEIF':
label_ = make_nop() # No label
cond_ = p[2]
else:
label_ = make_label(p[1], p.lineno(1))
cond_ = p[3]
p[0] = label_, cond_
|
def p_elseif_part(p)
|
elseif_expr : ELSEIF expr then
| LABEL ELSEIF expr then
| 5.130171 | 4.610179 | 1.112792 |
label_, cond_ = p[1]
then_ = p[2]
else_ = p[3]
if isinstance(else_, list): # it's an else part
else_ = make_block(*else_)
else:
then_ = make_block(then_, else_)
else_ = None
p[0] = make_block(label_, make_sentence('IF', cond_, then_, else_, lineno=p.lineno(1)))
|
def p_elseif_list(p)
|
elseiflist : elseif_expr program_co endif
| elseif_expr program_co else_part
| 4.42933 | 4.24386 | 1.043703 |
label_, cond_ = p[1]
then_ = p[2]
else_ = p[3]
p[0] = make_block(label_, make_sentence('IF', cond_, then_, else_, lineno=p.lineno(1)))
|
def p_elseif_elseiflist(p)
|
elseiflist : elseif_expr program_co elseiflist
| 4.989252 | 5.080045 | 0.982127 |
if p[2] == '\n':
if len(p) == 4:
p[0] = [make_nop(), p[3]]
elif len(p) == 6:
p[0] = [make_label(p[3], p.lineno(3)), p[4], p[5]]
else:
p[0] = [p[3], p[4]]
else:
p[0] = [p[2], p[3]]
|
def p_else_part_endif(p)
|
else_part_inline : ELSE NEWLINE program_co endif
| ELSE NEWLINE statements_co endif
| ELSE NEWLINE co_statements_co endif
| ELSE NEWLINE endif
| ELSE NEWLINE LABEL statements_co endif
| ELSE NEWLINE LABEL co_statements_co endif
| ELSE statements_co endif
| ELSE co_statements_co endif
| 2.307885 | 2.448145 | 0.942708 |
lbl = make_label(p[1], p.lineno(1))
p[0] = [make_block(lbl, p[3]), p[4]]
|
def p_else_part_label(p)
|
else_part : LABEL ELSE program_co endif
| LABEL ELSE statements_co endif
| LABEL ELSE co_statements_co endif
| 4.864051 | 4.535889 | 1.072348 |
if is_number(p[2]):
api.errmsg.warning_condition_is_always(p.lineno(1), bool(p[2].value))
p[0] = p[2]
|
def p_if_then_part(p)
|
if_then_part : IF expr then
| 10.876682 | 10.962524 | 0.992169 |
cond_ = p[1]
then_ = p[3]
else_ = p[4][0]
endif = p[4][1]
p[0] = make_sentence('IF', cond_, then_, make_block(else_, endif), lineno=p.lineno(2))
|
def p_if_else(p)
|
statement : if_then_part NEWLINE program_co else_part
| 4.663681 | 4.426946 | 1.053476 |
p[0] = p[1]
if is_null(p[0]):
return
p[1].appendChild(make_block(p[2], p[3]))
gl.LOOPS.pop()
|
def p_for_sentence(p)
|
statement : for_start program_co label_next
| for_start co_statements_co label_next
| 8.238317 | 8.532762 | 0.965493 |
if p[1] == 'NEXT':
p1 = make_nop()
p3 = p[2]
else:
p1 = make_label(p[1], p.lineno(1))
p3 = p[3]
if p3 != gl.LOOPS[-1][1]:
api.errmsg.syntax_error_wrong_for_var(p.lineno(2), gl.LOOPS[-1][1], p3)
p[0] = make_nop()
return
p[0] = p1
|
def p_next1(p)
|
label_next : LABEL NEXT ID
| NEXT ID
| 4.692103 | 4.48729 | 1.045643 |
gl.LOOPS.append(('FOR', p[2]))
p[0] = None
if p[4] is None or p[6] is None or p[7] is None:
return
if is_number(p[4], p[6], p[7]):
if p[4].value != p[6].value and p[7].value == 0:
warning(p.lineno(5), 'STEP value is 0 and FOR might loop forever')
if p[4].value > p[6].value and p[7].value > 0:
warning(p.lineno(5), 'FOR start value is greater than end. This FOR loop is useless')
if p[4].value < p[6].value and p[7].value < 0:
warning(p.lineno(2), 'FOR start value is lower than end. This FOR loop is useless')
id_type = common_type(common_type(p[4], p[6]), p[7])
variable = SYMBOL_TABLE.access_var(p[2], p.lineno(2), default_type=id_type)
if variable is None:
return
variable.accessed = True
expr1 = make_typecast(variable.type_, p[4], p.lineno(3))
expr2 = make_typecast(variable.type_, p[6], p.lineno(5))
expr3 = make_typecast(variable.type_, p[7], p.lexer.lineno)
p[0] = make_sentence('FOR', variable, expr1, expr2, expr3)
|
def p_for_sentence_start(p)
|
for_start : FOR ID EQ expr TO expr step
| 3.252173 | 3.146719 | 1.033512 |
q = make_number(0, lineno=p.lineno(1)) if len(p) == 2 else p[2]
p[0] = make_sentence('END', q)
|
def p_end(p)
|
statement : END expr
| END
| 6.510886 | 6.084955 | 1.069997 |
q = make_number(1, lineno=p.lineno(2))
r = make_binary(p.lineno(1), 'MINUS',
make_typecast(TYPE.ubyte, p[2], p.lineno(1)), q,
lambda x, y: x - y)
p[0] = make_sentence('ERROR', r)
|
def p_error_raise(p)
|
statement : ERROR expr
| 8.958942 | 8.017915 | 1.117366 |
q = make_number(9, lineno=p.lineno(1)) if len(p) == 2 else p[2]
z = make_number(1, lineno=p.lineno(1))
r = make_binary(p.lineno(1), 'MINUS',
make_typecast(TYPE.ubyte, q, p.lineno(1)), z,
lambda x, y: x - y)
p[0] = make_sentence('STOP', r)
|
def p_stop_raise(p)
|
statement : STOP expr
| STOP
| 6.531615 | 6.184954 | 1.056049 |
if len(p) == 4:
q = make_block(p[2], p[3])
else:
q = p[2]
if p[1] == 'DO':
gl.LOOPS.append(('DO',))
if q is None:
warning(p.lineno(1), 'Infinite empty loop')
# An infinite loop and no warnings
p[0] = make_sentence('DO_LOOP', q)
gl.LOOPS.pop()
|
def p_do_loop(p)
|
statement : do_start program_co label_loop
| do_start label_loop
| DO label_loop
| 7.141396 | 6.653656 | 1.073304 |
label_ = make_label(gl.DATA_PTR_CURRENT, lineno=p.lineno(1))
datas_ = []
funcs = []
if p[2] is None:
p[0] = None
return
for d in p[2].children:
value = d.value
if is_static(value):
datas_.append(d)
continue
new_lbl = '__DATA__FUNCPTR__{0}'.format(len(gl.DATA_FUNCTIONS))
entry = make_func_declaration(new_lbl, p.lineno(1), type_=value.type_)
if not entry:
continue
func = entry.entry
func.convention = CONVENTION.fastcall
SYMBOL_TABLE.enter_scope(new_lbl)
func.local_symbol_table = SYMBOL_TABLE.table[SYMBOL_TABLE.current_scope]
func.locals_size = SYMBOL_TABLE.leave_scope()
gl.DATA_FUNCTIONS.append(func)
sent = make_sentence('RETURN', func, value)
func.body = make_block(sent)
datas_.append(entry)
funcs.append(entry)
gl.DATAS.append([label_, datas_])
id_ = api.utils.current_data_label()
gl.DATA_PTR_CURRENT = id_
|
def p_data(p)
|
statement : DATA arguments
| 6.444692 | 6.35155 | 1.014664 |
if len(p) == 2:
id_ = '__DATA__{0}'.format(len(gl.DATAS))
else:
id_ = p[2]
lbl = check_and_make_label(id_, p.lineno(1))
p[0] = make_sentence('RESTORE', lbl)
|
def p_restore(p)
|
statement : RESTORE
| RESTORE ID
| RESTORE NUMBER
| 7.479067 | 7.458977 | 1.002693 |
gl.DATA_IS_USED = True
reads = []
if p[2] is None:
return
for arg in p[2]:
entry = arg.value
if entry is None:
p[0] = None
return
if isinstance(entry, symbols.VARARRAY):
api.errmsg.syntax_error(p.lineno(1), "Cannot read '%s'. It's an array" % entry.name)
p[0] = None
return
if isinstance(entry, symbols.VAR):
if entry.class_ != CLASS.var:
api.errmsg.syntax_error_cannot_assing_not_a_var(p.lineno(2), entry.name)
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(2), p[2], entry.type_)
reads.append(make_sentence('READ', entry))
continue
if isinstance(entry, symbols.ARRAYLOAD):
reads.append(make_sentence('READ', symbols.ARRAYACCESS(entry.entry, entry.args, entry.lineno)))
continue
api.errmsg.syntax_error(p.lineno(1), "Syntax error. Can only read a variable or an array element")
p[0] = None
return
p[0] = make_block(*reads)
|
def p_read(p)
|
statement : READ arguments
| 4.425122 | 4.241477 | 1.043297 |
if len(p) == 6:
q = make_block(p[2], p[3])
r = p[5]
else:
q = p[2]
r = p[4]
if p[1] == 'DO':
gl.LOOPS.append(('DO',))
p[0] = make_sentence('DO_WHILE', r, q)
gl.LOOPS.pop()
if is_number(r):
api.errmsg.warning_condition_is_always(p.lineno(3), bool(r.value))
if q is None:
api.errmsg.warning_empty_loop(p.lineno(3))
|
def p_do_loop_while(p)
|
statement : do_start program_co label_loop WHILE expr
| do_start label_loop WHILE expr
| DO label_loop WHILE expr
| 5.429265 | 5.231165 | 1.037869 |
r = p[1]
q = p[2]
if q == 'LOOP':
q = None
p[0] = make_sentence('WHILE_DO', r, q)
gl.LOOPS.pop()
if is_number(r):
api.errmsg.warning_condition_is_always(p.lineno(2), bool(r.value))
|
def p_do_while_loop(p)
|
statement : do_while_start program_co LOOP
| do_while_start co_statements_co LOOP
| do_while_start LOOP
| 11.783964 | 11.319669 | 1.041017 |
gl.LOOPS.pop()
q = make_block(p[2], p[3])
if is_number(p[1]) and p[1].value:
if q is None:
warning(p[1].lineno, "Condition is always true and leads to an infinite loop.")
else:
warning(p[1].lineno, "Condition is always true and might lead to an infinite loop.")
p[0] = make_sentence('WHILE', p[1], q)
|
def p_while_sentence(p)
|
statement : while_start co_statements_co label_end_while
| while_start program_co label_end_while
| 5.800477 | 6.100562 | 0.95081 |
p[0] = p[2]
gl.LOOPS.append(('WHILE',))
if is_number(p[2]) and not p[2].value:
api.errmsg.warning_condition_is_always(p.lineno(1))
|
def p_while_start(p)
|
while_start : WHILE expr
| 11.961918 | 10.578426 | 1.130784 |
q = p[2]
p[0] = make_sentence('EXIT_%s' % q)
for i in gl.LOOPS:
if q == i[0]:
return
syntax_error(p.lineno(1), 'Syntax Error: EXIT %s out of loop' % q)
|
def p_exit(p)
|
statement : EXIT WHILE
| EXIT DO
| EXIT FOR
| 9.004395 | 8.969726 | 1.003865 |
if p[1] in ('BOLD', 'ITALIC'):
p[0] = make_sentence(p[1] + '_TMP',
make_typecast(TYPE.ubyte, p[2], p.lineno(1)))
else:
p[0] = p[1]
|
def p_print_list_expr(p)
|
print_elem : expr
| print_at
| print_tab
| attr
| BOLD expr
| ITALIC expr
| 8.233985 | 6.772344 | 1.215825 |
# ATTR_LIST are used by drawing commands: PLOT, DRAW, CIRCLE
# BOLD and ITALIC are ignored by them, so we put them out of the
# attr definition so something like DRAW BOLD 1; .... will raise
# a syntax error
p[0] = make_sentence(p[1] + '_TMP',
make_typecast(TYPE.ubyte, p[2], p.lineno(1)))
|
def p_attr(p)
|
attr : OVER expr
| INVERSE expr
| INK expr
| PAPER expr
| BRIGHT expr
| FLASH expr
| 21.969961 | 20.87598 | 1.052404 |
p[0] = p[1]
p[0].eol = (p[3] is not None)
if p[3] is not None:
p[0].appendChild(p[3])
|
def p_print_list(p)
|
print_list : print_list SC print_elem
| 3.548031 | 3.248275 | 1.092282 |
p[0] = p[1]
p[0].eol = (p[3] is not None)
p[0].appendChild(make_sentence('PRINT_COMMA'))
if p[3] is not None:
p[0].appendChild(p[3])
|
def p_print_list_comma(p)
|
print_list : print_list COMMA print_elem
| 4.436068 | 4.251694 | 1.043365 |
p[0] = make_sentence('PRINT_AT',
make_typecast(TYPE.ubyte, p[2], p.lineno(1)),
make_typecast(TYPE.ubyte, p[4], p.lineno(3)))
|
def p_print_list_at(p)
|
print_at : AT expr COMMA expr
| 7.674461 | 6.276006 | 1.222826 |
p[0] = make_sentence('PRINT_TAB',
make_typecast(TYPE.ubyte, p[2], p.lineno(1)))
|
def p_print_list_tab(p)
|
print_tab : TAB expr
| 18.348238 | 15.020764 | 1.221525 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.