-DivisionByZeroError
+DivisionByZeroError on line 2
in get_divided_answer
in __main__
return expression.variable
def generate_function_call_for_fur_infix_operator(expression):
- return 'operator${}(stack, jump)'.format(
+ return 'operator${}(stack, jump, {})'.format(
expression.name,
+ expression.metadata.line,
)
def generate_structure_literal_expression(expression):
NormalInfixExpression = collections.namedtuple(
'NormalInfixExpression',
[
+ 'metadata',
'order',
'operator',
],
NormalVariableInitializationStatement(
variable=center_variable,
expression=NormalInfixExpression(
+ metadata=expression.metadata,
order=expression.order,
operator=expression.operator,
),
counter, boolean_expression_prestatements, boolean_expression = normalize_boolean_expression(
counter,
parsing.FurInfixExpression(
+ metadata=expression.left.metadata,
order='and_level',
operator='and',
left=parsing.FurInfixExpression(
+ metadata=expression.left.metadata,
order='comparison_level',
operator=expression.left.operator,
left=NormalVariableExpression(variable=left_variable),
right=NormalVariableExpression(variable=middle_variable),
),
right=parsing.FurInfixExpression(
+ metadata=expression.metadata,
order='comparison_level',
operator=expression.operator,
left=NormalVariableExpression(variable=middle_variable),
return result_parser
+NodeMetadata = collections.namedtuple(
+ 'NodeMetadata',
+ [
+ 'index',
+ 'line',
+ ],
+)
+
FurIntegerLiteralExpression = collections.namedtuple(
'FurIntegerLiteralExpression',
[
FurInfixExpression = collections.namedtuple(
'FurInfixExpression',
[
+ 'metadata',
'order',
'operator',
'left',
if success:
result = FurInfixExpression(
+ metadata=NodeMetadata(
+ index=tokens[index].index,
+ line=tokens[index].line,
+ ),
order=order,
operator=tokens[index].match,
left=result,
}
// TODO Make this conditionally added
-Object operator$concatenate(Stack* stack, jmp_buf parent_jump)
+Object operator$concatenate(Stack* stack, jmp_buf parent_jump, size_t line)
{
Object right = Stack_pop(stack);
Object left = Stack_pop(stack);
}
{% for id in infix_declarations %}
-Object operator${{ id.name }}(Stack* stack, jmp_buf parent_jump)
+Object operator${{ id.name }}(Stack* stack, jmp_buf parent_jump, size_t line)
{
Object right = Stack_pop(stack);
Object left = Stack_pop(stack);
{% if id.name == 'integerDivide' or id.name == 'modularDivide' %}
if(right.instance.integer == 0)
{
- fprintf(stderr, "DivisionByZeroError\n");
+ fprintf(stderr, "DivisionByZeroError on line %zu\n", line);
longjmp(parent_jump, 1);
}
{% endif %}
CFunctionCallForFurInfixOperator = collections.namedtuple(
'CFunctionCallForFurInfixOperator',
[
+ 'metadata',
'name',
],
)
def transform_infix_operator_without_c_equivalent(accumulators, expression):
return CFunctionCallForFurInfixOperator(
+ metadata=expression.metadata,
name='concatenate',
)
accumulators.operator_set.add(FUR_INFIX_OPERATOR_TO_C_INFIX_OPERATOR[expression.operator])
return CFunctionCallForFurInfixOperator(
+ metadata=expression.metadata,
name=FUR_INFIX_OPERATOR_TO_C_INFIX_OPERATOR[expression.operator].name,
)