Example:

<pre>
{switch $boo}
{case 0}
...
{case 1, 2}
...
{default}
...
{/switch}
</pre>

might generate

<pre>
switch (opt_data.boo) {
case 0:
...
break;
case 1:
case 2:
...
break;
default:
...
}
</pre>
199948
@Override
  protected void visitSwitchNode(SwitchNode node) {

    Expression switchOn = coerceTypeForSwitchComparison(node.getExpr());
    SwitchBuilder switchBuilder = switchValue(switchOn);
    for (SoyNode child : node.getChildren()) {
      if (child instanceof SwitchCaseNode) {
        SwitchCaseNode scn = (SwitchCaseNode) child;
        ImmutableList.Builder<Expression> caseChunks = ImmutableList.builder();
        for (ExprNode caseExpr : scn.getExprList()) {
          Expression caseChunk = translateExpr(caseExpr);
          caseChunks.add(caseChunk);
        }
        Statement body = visitChildrenReturningCodeChunk(scn);
        switchBuilder.addCase(caseChunks.build(), body);
      } else if (child instanceof SwitchDefaultNode) {
        Statement body = visitChildrenReturningCodeChunk((SwitchDefaultNode) child);
        switchBuilder.setDefault(body);
      } else {
        throw new AssertionError();
      }
    }
    jsCodeBuilder.append(switchBuilder.build());
  }
743107
function(path, value, data , op, computed){
    var computed = this.computed,
      op = op || "=", prev, 
      computedProperty = computed? computed[path]:null;

    if(op !== '='){
      prev = computedProperty? computedProperty.get(this): data[path];
      switch(op){
        case "+=":
          value = prev + value;
          break;
        case "-=":
          value = prev - value;
          break;
        case "*=":
          value = prev * value;
          break;
        case "/=":
          value = prev / value;
          break;
        case "%=":
          value = prev % value;
          break;
      }
    }
    if(computedProperty) {
      if(computedProperty.set) return computedProperty.set(this, value);
    }
    data[path] = value;
    return value;
  }
382076
function(data, convertCaseOptions) {

    let converted;

    if (_.isArray(data) || _.isPlainObject(data)) {
      converted = _.transform(data, (result, value, key) => {
        if (_.isArray(value) || _.isPlainObject(value)) {
          result[this._convertCase(key, convertCaseOptions)] = this._convertCase(value, convertCaseOptions);
        } else {
          result[this._convertCase(key, convertCaseOptions)] = value;
        }
      });
    } else {
      switch (convertCaseOptions) {
      case 'snake_case':
        converted = _.snakeCase(data);
        break;
      case 'kebab-case':
        converted = _.kebabCase(data);
        break;
      case 'camelCase':
        converted = _.camelCase(data);
        break;
      default:
        converted = data;
        break;
      }
    }

    return converted;
  }
1274407
def expand_optionally_negative_switches(switches)
      switches.reduce([]) do |memo, val|
        if val =~ /\[no-\]/
          memo << val.gsub(/\[no-\]/, '')
          memo << val.gsub(/\[no-\]/, 'no-')
        else
          memo << val
        end
      end
    end
317134
def p_Case(p):
    '''
    
    '''
    if p[1] == 'case':
        p[0] = Case(p[1], p[2], p[4], p[5])
    else:
        p[0] = Case(p[1], None, p[3], p[4])
1192835
function(node){
    if ('default' == node.expr) {
      this.buf.push('default:');
    } else {
      this.buf.push('case ' + node.expr + ':');
    }
    if (node.block) {
      this.visit(node.block, node);
      this.buf.push('  break;');
    }
  }
1096417
def supports_atomic_switch?
      major, minor, tiny = version_string.split('.').map(&:to_i)

      case major
      when 4 then return false if minor and minor < 2
      when 5
        case minor
        when 0 then return false if tiny and tiny < 52
        when 1 then return false
        when 4 then return false if tiny and tiny < 4
        when 5 then return false if tiny and tiny < 3
        end
      when 6
        case minor
        when 0 then return false if tiny and tiny < 11
        end
      end
      true
    end
42345
private boolean isUselessCase(
      Node caseNode, @Nullable Node previousCase, @Nullable Node defaultCase) {
    checkState(previousCase == null || previousCase.getNext() == caseNode);
    // A case isn't useless if a previous case falls through to it unless it happens to be the last
    // case in the switch.
    Node switchNode = caseNode.getParent();
    if (switchNode.getLastChild() != caseNode && previousCase != null) {
      Node previousBlock = previousCase.getLastChild();
      if (!previousBlock.hasChildren()
          || !isExit(previousBlock.getLastChild())) {
        return false;
      }
    }

    Node executingCase = caseNode;
    while (executingCase != null) {
      checkState(executingCase.isDefaultCase() || executingCase.isCase());
      // We only expect a DEFAULT case if the case we are checking is the
      // DEFAULT case.  Otherwise, we assume the DEFAULT case has already
      // been removed.
      checkState(caseNode == executingCase || !executingCase.isDefaultCase());
      if (!executingCase.isDefaultCase() && mayHaveSideEffects(executingCase.getFirstChild())) {
        // The case falls thru to a case whose condition has a potential side-effect,
        // removing the candidate case would skip that side-effect, so don't.
        return false;
      }
      Node block = executingCase.getLastChild();
      checkState(block.isBlock());
      if (block.hasChildren()) {
        for (Node blockChild : block.children()) {
          // If this is a block with a labelless break, it is useless.
          switch (blockChild.getToken()) {
            case BREAK:
              // A case with a single labelless break is useless if it is the default case or if
              // there is no default case. A break to a different control structure isn't useless.
              return !blockChild.hasChildren()
                  && (defaultCase == null || defaultCase == executingCase);
            case VAR:
              if (blockChild.hasOneChild()
                  && blockChild.getFirstFirstChild() == null) {
                // Variable declarations without initializations are OK.
                continue;
              }
              return false;
            default:
              return false;
          }
        }
      }
      // Look at the fallthrough case
      executingCase = executingCase.getNext();
    }
    return true;
  }
464043
function(opt) {
  var strings = (opt.string || "").split(","),
      abbr, full, metavar;
  for (var i = 0; i < strings.length; i++) {
    var string = strings[i].trim(),
        matches;
    if (matches = string.match(/^\-([^-])(?:\s+(.*))?$/)) {
      abbr = matches[1];
      metavar = matches[2];
    }
    else if (matches = string.match(/^\-\-(.+?)(?:[=\s]+(.+))?$/)) {
      full = matches[1];
      metavar = metavar || matches[2];
    }
  }

  matches = matches || [];
  var abbr = opt.abbr || abbr,   // e.g. v from -v
      full = opt.full || full, // e.g. verbose from --verbose
      metavar = opt.metavar || metavar;  // e.g. PATH from '--config=PATH'

  var string;
  if (opt.string) {
    string = opt.string;
  }
  else if (opt.position === undefined) {
    string = "";
    if (abbr) {
      string += "-" + abbr;
      if (metavar)
        string += " " + metavar
      string += ", ";
    }
    string += "--" + (full || opt.name);
    if (metavar) {
      string += " " + metavar;
    }
  }

  opt = _(opt).extend({
    name: opt.name || full || abbr,
    string: string,
    abbr: abbr,
    full: full,
    metavar: metavar,
    matches: function(arg) {
      return opt.full == arg || opt.abbr == arg || opt.position == arg
        || opt.name == arg || (opt.list && arg >= opt.position);
    }
  });
  return opt;
}
210020
public function isOptionalWithNoDefault(): bool
    {
        if (((string)$this->parameter['choice']) !== 'opt') {
            return false;
        }
        if (!$this->hasDefaultValue()) {
            return true;
        }

        $initializer = $this->getInitializer();
        // Some default value have weird values. For instance, first parameter of "mb_internal_encoding" has default value "mb_internal_encoding()"
        if ($initializer !== 'array()' && strpos($initializer, '(') !== false) {
            return true;
        }
        return false;
    }
753178
def generate(options, command: nil)
      # First, enable `always_trace`, to show the stack trace
      always_trace!

      used_switches = []
      options.each do |option|
        next if option.description.to_s.empty? # "private" options
        next unless option.display_in_shell

        short_switch = option.short_option
        key = option.key
        validate_short_switch(used_switches, short_switch, key)

        type = option.data_type

        # We added type: Hash to code generation, but Ruby's OptionParser doesn't like that
        # so we need to switch that to something that is supported, luckily, we have an `is_string`
        # property and if that is false, we'll default to nil
        if type == Hash
          type = option.is_string ? String : nil
        end

        # Boolean is a fastlane thing, it's either TrueClass, or FalseClass, but we won't know
        # that until runtime, so nil is the best we get
        if type == Fastlane::Boolean
          type = nil
        end

        # This is an important bit of trickery to solve the boolean option situation.
        #
        # Typically, boolean command line flags do not accept trailing values. If the flag
        # is present, the value is true, if it is missing, the value is false. fastlane
        # supports this style of flag. For example, you can specify a flag like `--clean`,
        # and the :clean option will be true.
        #
        # However, fastlane also supports another boolean flag style that accepts trailing
        # values much like options for Strings and other value types. That looks like
        # `--include_bitcode false` The problem is that this does not work out of the box
        # for Commander and OptionsParser. So, we need to get tricky.
        #
        # The value_appendix below acts as a placeholder in the switch definition that
        # states that we expect to have a trailing value for our options. When an option
        # declares a data type, we use the name of that data type in all caps like:
        # "--devices ARRAY". When the data type is nil, this implies that we're going
        # to be doing some special handling on that value. One special thing we do
        # automatically in Configuration is to coerce special Strings into boolean values.
        #
        # If the data type is nil, the trick we do is to specify a value placeholder, but
        # we wrap it in [] brackets to mark it as optional. That means that the trailing
        # value may or may not be present for this flag. If the flag is present, but the
        # value is not, we get a value of `true`. Perfect for the boolean flag base-case!
        # If the value is there, we'll actually get it back as a String, which we can
        # later coerce into a boolean.
        #
        # In this way we support handling boolean flags with or without trailing values.
        value_appendix = (type || '[VALUE]').to_s.upcase
        long_switch = "--#{option.key} #{value_appendix}"

        description = option.description
        description += " (#{option.env_name})" unless option.env_name.to_s.empty?

        # We compact this array here to remove the short_switch variable if it is nil.
        # Passing a nil value to global_option has been shown to create problems with
        # option parsing!
        #
        # See: https://github.com/fastlane/fastlane_core/pull/89
        #
        # If we don't have a data type for this option, we tell it to act like a String.
        # This allows us to get a reasonable value for boolean options that can be
        # automatically coerced or otherwise handled by the ConfigItem for others.
        args = [short_switch, long_switch, (type || String), description].compact

        if command
          command.option(*args)
        else
          # This is the call to Commander to set up the option we've been building.
          global_option(*args)
        end
      end
    end
1139089
def BinaryBool(pred):
    
    class Predicate(Bool):
        def __init__(self, value, ignore_case=False):
            self.value = caseless(value) if ignore_case else value
            self.ignore_case = ignore_case

        def __call__(self, data):
            if not isinstance(data, list):
                data = [data]
            for d in data:
                try:
                    if pred(caseless(d) if self.ignore_case else d, self.value):
                        return True
                except:
                    pass
            return False
    return Predicate
1314086
def option(opts, *args)
      long_opt_symbol = long_opt_symbol(args)
      args += Array(OptionsHelp::TEXT[long_opt_symbol])
      opts.on(*args) do |arg|
        @options[long_opt_symbol] = arg
        yield arg if block_given?
      end
    end
998414
private Op compile(Token tok, Op next, boolean reverse) {
		Op ret;
		switch (tok.type) {
		case Token.DOT:
			ret = Op.createDot();
			ret.next = next;
			break;

		case Token.CHAR:
			ret = Op.createChar(tok.getChar());
			ret.next = next;
			break;

		case Token.ANCHOR:
			ret = Op.createAnchor(tok.getChar());
			ret.next = next;
			break;

		case Token.RANGE:
		case Token.NRANGE:
			ret = Op.createRange(tok);
			ret.next = next;
			break;

		case Token.CONCAT:
			ret = next;
			if (!reverse) {
				for (int i = tok.size() - 1; i >= 0; i--) {
					ret = compile(tok.getChild(i), ret, false);
				}
			} else {
				for (int i = 0; i < tok.size(); i++) {
					ret = compile(tok.getChild(i), ret, true);
				}
			}
			break;

		case Token.UNION:
			Op.UnionOp uni = Op.createUnion(tok.size());
			for (int i = 0; i < tok.size(); i++) {
				uni.addElement(compile(tok.getChild(i), next, reverse));
			}
			ret = uni; // ret.next is null.
			break;

		case Token.CLOSURE:
		case Token.NONGREEDYCLOSURE:
			Token child = tok.getChild(0);
			int min = tok.getMin();
			int max = tok.getMax();
			if (min >= 0 && min == max) { // {n}
				ret = next;
				for (int i = 0; i < min; i++) {
					ret = compile(child, ret, reverse);
				}
				break;
			}
			if (min > 0 && max > 0)
				max -= min;
			if (max > 0) {
				// X{2,6} -> XX(X(X(XX?)?)?)?
				ret = next;
				for (int i = 0; i < max; i++) {
					Op.ChildOp q = Op
							.createQuestion(tok.type == Token.NONGREEDYCLOSURE);
					q.next = next;
					q.setChild(compile(child, ret, reverse));
					ret = q;
				}
			} else {
				Op.ChildOp op;
				if (tok.type == Token.NONGREEDYCLOSURE) {
					op = Op.createNonGreedyClosure();
				} else { // Token.CLOSURE
					op = Op.createClosure(this.numberOfClosures++);
				}
				op.next = next;
				op.setChild(compile(child, op, reverse));
				ret = op;
			}
			if (min > 0) {
				for (int i = 0; i < min; i++) {
					ret = compile(child, ret, reverse);
				}
			}
			break;

		case Token.EMPTY:
			ret = next;
			break;

		case Token.STRING:
			ret = Op.createString(tok.getString());
			ret.next = next;
			break;

		case Token.BACKREFERENCE:
			ret = Op.createBackReference(tok.getReferenceNumber());
			ret.next = next;
			break;

		case Token.PAREN:
			if (tok.getParenNumber() == 0) {
				ret = compile(tok.getChild(0), next, reverse);
			} else if (reverse) {
				next = Op.createCapture(tok.getParenNumber(), next);
				next = compile(tok.getChild(0), next, reverse);
				ret = Op.createCapture(-tok.getParenNumber(), next);
			} else {
				next = Op.createCapture(-tok.getParenNumber(), next);
				next = compile(tok.getChild(0), next, reverse);
				ret = Op.createCapture(tok.getParenNumber(), next);
			}
			break;

		case Token.LOOKAHEAD:
			ret = Op.createLook(Op.LOOKAHEAD, next,
					compile(tok.getChild(0), null, false));
			break;
		case Token.NEGATIVELOOKAHEAD:
			ret = Op.createLook(Op.NEGATIVELOOKAHEAD, next,
					compile(tok.getChild(0), null, false));
			break;
		case Token.LOOKBEHIND:
			ret = Op.createLook(Op.LOOKBEHIND, next,
					compile(tok.getChild(0), null, true));
			break;
		case Token.NEGATIVELOOKBEHIND:
			ret = Op.createLook(Op.NEGATIVELOOKBEHIND, next,
					compile(tok.getChild(0), null, true));
			break;

		case Token.INDEPENDENT:
			ret = Op.createIndependent(next,
					compile(tok.getChild(0), null, reverse));
			break;

		case Token.MODIFIERGROUP:
			ret = Op.createModifier(next,
					compile(tok.getChild(0), null, reverse),
					((Token.ModifierToken) tok).getOptions(),
					((Token.ModifierToken) tok).getOptionsMask());
			break;

		case Token.CONDITION:
			Token.ConditionToken ctok = (Token.ConditionToken) tok;
			int ref = ctok.refNumber;
			Op condition = ctok.condition == null ? null : compile(
					ctok.condition, null, reverse);
			Op yes = compile(ctok.yes, next, reverse);
			Op no = ctok.no == null ? null : compile(ctok.no, next, reverse);
			ret = Op.createCondition(next, ref, condition, yes, no);
			break;

		default:
			throw new RuntimeException("Unknown token type: " + tok.type);
		} // switch (tok.type)
		return ret;
	}
1203497
private function _processSwitchDefault() {
		// If we already are in a "case", we remove it from the stack
		if ($this->statementStack->getCurrentStackItem()->type === StatementItem::TYPE_CASE || $this->statementStack->getCurrentStackItem()->type === StatementItem::TYPE_DEFAULT) {

			// Test if the previous case had a break
			$this->_checkSwitchCaseNeedBreak();

			$this->statementStack->pop();
		}

		// We flag the "SWITCH" stack item as having a default
		$this->statementStack->getCurrentStackItem()->switchHasDefault = true;

		// We store the control statement in the stack
		$stackitem = new StatementItem();
		$stackitem->line = $this->lineNumber;
		$stackitem->type = "DEFAULT";
		$stackitem->name = "default";
		$this->statementStack->push($stackitem);
	}
1358636
def boolean_or_list(config_name, args, configs, alternative_names=[]):
    """"""

    # when argument flag present, set to wildcard regex
    for key in alternative_names + [config_name]:
        if hasattr(args, key) and getattr(args, key):
            setattr(args, config_name, ['.*'])
            return

    setattr(args, config_name, [])

    option = None
    alternative_names.insert(0, config_name)
    for key in alternative_names:
        if configs.has_option('settings', key):
            option = configs.get('settings', key)
            break

    if option is not None:
        if option.strip().lower() == 'true':
            setattr(args, config_name, ['.*'])
        elif option.strip().lower() != 'false':
            for pattern in option.split("\n"):
                if pattern.strip() != '':
                    getattr(args, config_name).append(pattern)
598568
def p_switch_statement(self, p):
        """"""
        # this uses a completely different type that corrects a
        # subtly wrong interpretation of this construct.
        # see: https://github.com/rspivak/slimit/issues/94
        p[0] = self.asttypes.Switch(expr=p[3], case_block=p[5])
        p[0].setpos(p)
        return