def s_core_and(env, *items): res = types.SBoolean(True) for item in items: if not item.to_boolean(): return types.SResult(env, types.SBoolean(False)) else: res = item return types.SResult(env, res)
def s_equal(env, *items): count = len(items) if count == 0 or count == 1: return types.SResult(env, types.SBoolean(True)) for i in range(count - 1): if not items[i].equal(items[i + 1]): return types.SResult(env, types.SBoolean(False)) return types.SResult(env, types.SBoolean(True))
def s_core_less(env, *items): count = len(items) if count <= 1: return types.SResult(env, types.SBoolean(True)) else: for i in range(count - 1): if items[i].value >= items[i + 1].value: return types.SResult(env, types.SBoolean(False)) return types.SResult(env, types.SBoolean(True))
def t_BOOLEAN(t): r'(true)|(false)' if t.value == 'true': t.value = True else: t.value = False t.value = types.SBoolean(t.value) return t
def s_core_or(env, *items): for item in items: if item.to_boolean(): return types.SResult(env, item) return types.SResult(env, types.SBoolean(False))