예제 #1
0
 def p_conditional(self, t):
     """conditional : if_else_parts
     | if_else_parts else_block"""
     parts = t[1]
     if len(t) > 2:
         parts.append(t[2])
     t[0] = conditional.ConditionalList(parts)
예제 #2
0
파일: actionD.py 프로젝트: OpenTTD/nml
def parse_ternary_op(assignment):
    assert isinstance(assignment.value, expression.TernaryOp)
    actions = parse_actionD(ParameterAssignment(assignment.param, assignment.value.expr2))
    cond_block = conditional.Conditional(
        assignment.value.guard, [ParameterAssignment(assignment.param, assignment.value.expr1)], None
    )
    actions.extend(conditional.ConditionalList([cond_block]).get_action_list())
    return actions
예제 #3
0
파일: actionD.py 프로젝트: OpenTTD/nml
def parse_boolean(assignment):
    assert isinstance(assignment.value, expression.Boolean)
    actions = parse_actionD(ParameterAssignment(assignment.param, expression.ConstantNumeric(0)))
    expr = nmlop.CMP_NEQ(assignment.value.expr, 0)
    cond_block = conditional.Conditional(
        expr, [ParameterAssignment(assignment.param, expression.ConstantNumeric(1))], None
    )
    actions.extend(conditional.ConditionalList([cond_block]).get_action_list())
    return actions
예제 #4
0
파일: actionD.py 프로젝트: OpenTTD/nml
def parse_hasbit(assignment):
    assert isinstance(assignment.value, expression.BinOp) and (
        assignment.value.op == nmlop.HASBIT or assignment.value.op == nmlop.NOTHASBIT
    )
    actions = parse_actionD(ParameterAssignment(assignment.param, expression.ConstantNumeric(0)))
    cond_block = conditional.Conditional(
        assignment.value, [ParameterAssignment(assignment.param, expression.ConstantNumeric(1))], None
    )
    actions.extend(conditional.ConditionalList([cond_block]).get_action_list())
    return actions
예제 #5
0
파일: actionD.py 프로젝트: OpenTTD/nml
def parse_abs_op(assignment):
    assert isinstance(assignment.value, expression.AbsOp)
    actions = parse_actionD(ParameterAssignment(assignment.param, assignment.value.expr))
    cond_block = conditional.Conditional(
        nmlop.CMP_LT(assignment.value.expr, 0),
        [ParameterAssignment(assignment.param, nmlop.SUB(0, assignment.value.expr))],
        None,
    )
    actions.extend(conditional.ConditionalList([cond_block]).get_action_list())
    return actions