 multident = (code, tab) ->
   code = code.replace /\n/g, '$&' + tab
   code.replace /\s+$/, ''
+
+# Parse a number (+- decimal/hexadecimal)
+# Examples: 0, -1, 1, 2e3, 2e-3, -0xfe, 0xfe
+parseNum = (x) ->
+  if not x?
+    0
+  else if x.match HEXNUM
+    parseInt x, 16
+  else
+    parseFloat x

    kvarAssign = if kvar isnt ivar then "#{kvar} = " else ""
    if @step and not @range
      [step, stepVar] = @cacheToCodeFragments @step.cache o, LEVEL_LIST
      stepNum = stepVar.match SIMPLENUM
    name      = ivar if @pattern
    varPart   = ''
    guardPart = ''

        namePart   = "#{name} = #{svar}[#{kvar}]"
      if not @object
        defPart += "#{@tab}#{step};\n" if step isnt stepVar
        lvar = scope.freeVariable 'len' unless @step and stepNum and down = (parseNum(stepNum[0]) < 0)
        declare = "#{kvarAssign}#{ivar} = 0, #{lvar} = #{svar}.length"
        declareDown = "#{kvarAssign}#{ivar} = #{svar}.length - 1"
        compare = "#{ivar} < #{lvar}"
