ifdef : ifdefelsea ifdefelseb ENDIF
498703
def p_ifdef_else(p):
    
    global ENABLED

    p[0] = p[1] + p[2]
    p[0] += ['#line %i "%s"' % (p.lineno(3) + 1, CURRENT_FILE[-1])]
    ENABLED = IFDEFS[-1][0]
    IFDEFS.pop()
1054429
private String getDsDefStr(DsDef def) {
		return "DS:" + def.getDsName() + ":" + def.getDsType() + ":" + def.getHeartbeat() + ":" + formatDouble(def.getMinValue()) + ":"
				+ formatDouble(def.getMaxValue());
	}
992940
def fsliceafter(astr, sub):
    """"""
    findex = astr.find(sub)
    return astr[findex + len(sub):]
148991
private static Stream<IConditional> conditionals( FunctionInputDef function)
    {
    return toStream( function.getVarDefs()).flatMap( var -> conditionals( var));
    }
1000842
def ifdef(parser, token):
    
    block_tokens = ('elifdef', 'else', 'endifdef')
    # {% ifdef ... %}
    bits = token.split_contents()[1:]
    if len(bits) > 1:
        raise TemplateSyntaxError('%r is not an identifier.' % token)
    condition = IfDefParser(bits).parse()
    nodelist = parser.parse(block_tokens)
    conditions_nodelists = [(condition, nodelist)]
    token = parser.next_token()

    # {% elifdef ... %} (repeatable)
    while token.contents.startswith('elifdef'):
        bits = token.split_contents()[1:]
        if len(bits) > 1:
            raise TemplateSyntaxError('%r is not an identifier.' % token)
        condition = IfDefParser(bits).parse()
        nodelist = parser.parse(block_tokens)
        conditions_nodelists.append((condition, nodelist))
        token = parser.next_token()

    # {% else %} (optional)
    if token.contents == 'else':
        nodelist = parser.parse(block_tokens[-1:])
        conditions_nodelists.append((None, nodelist))
        token = parser.next_token()

    # {% endifdef %}
    assert token.contents == 'endifdef'

    return IfNode(conditions_nodelists)
775357
def _pastoref(ins):
    ''' 
    '''
    output = _paddr(ins.quad[1])

    value = ins.quad[2]
    if value[0] == '*':
        value = value[1:]
        indirect = True
    else:
        indirect = False

    try:
        if indirect:
            value = int(value) & 0xFFFF  # Inmediate?
            output.append('push hl')
            output.append('ld hl, %i' % value)
            output.append('call __ILOADF')
            output.append('ld a, c')
            output.append('ld b, h')
            output.append('ld c, l')  # BC = Lower 16 bits, A = Exp
            output.append('pop hl')     # Recovers pointer
            REQUIRES.add('iloadf.asm')
        else:
            value = float(value)  # Inmediate?
            C, DE, HL = fp.immediate_float(value)  # noqa TODO: it will fail
            output.append('ld a, %s' % C)
            output.append('ld de, %s' % DE)
            output.append('ld bc, %s' % HL)
    except ValueError:
        output.append('pop bc')
        output.append('pop de')
        output.append('ex (sp), hl')  # Preserve HL for STOREF
        output.append('ld a, l')
        output.append('pop hl')

    output.append('call __STOREF')
    REQUIRES.add('storef.asm')

    return output
72550
function dec2frac(d) {

  var df = 1;
  var top = 1;
  var bot = 1;

  while (df != d) {
    if (df < d) {
      top += 1;
    }
    else {
      bot += 1;
      top = parseInt(d * bot);
    }
    df = top / bot;
  }
  return top + '/' + bot;
}
589908
def _handle_if_block(tokens, tokens_len, body_index, function_call):
    
    # First handle the if statement and body
    next_index, if_statement = _IF_BLOCK_IF_HANDLER(tokens,
                                                    tokens_len,
                                                    body_index,
                                                    function_call)
    elseif_statements = []
    else_statement = None
    footer = None

    # Keep going until we hit endif
    while True:

        # Back up a bit until we found out what terminated the if statement
        # body
        assert _RE_END_IF_BODY.match(tokens[next_index].content)

        terminator = tokens[next_index].content.lower()
        if terminator == "endif":
            next_index, footer = _handle_function_call(tokens,
                                                       tokens_len,
                                                       next_index)
            break

        next_index, header = _handle_function_call(tokens,
                                                   tokens_len,
                                                   next_index)

        if terminator == "elseif":
            next_index, elseif_stmnt = _ELSEIF_BLOCK_HANDLER(tokens,
                                                             tokens_len,
                                                             next_index + 1,
                                                             header)
            elseif_statements.append(elseif_stmnt)
        elif terminator == "else":
            next_index, else_statement = _ELSE_BLOCK_HANDLER(tokens,
                                                             tokens_len,
                                                             next_index + 1,
                                                             header)

    assert footer is not None

    return next_index, IfBlock(if_statement=if_statement,
                               elseif_statements=elseif_statements,
                               else_statement=else_statement,
                               footer=footer,
                               line=if_statement.line,
                               col=if_statement.col,
                               index=body_index)
1181272
function offsetLeft (elem) {
    let left = 0

    do {
      if (!isNaN(elem.offsetLeft)) left += elem.offsetLeft
    } while (elem = elem.offsetParent )

    return left
  }
493227
def end(self):
        

        # Note: Vend is just a macro; use 'Vfinish' instead
        # Note also the the same C function is used to end
        # the VS interface
        _checkErr('vend', _C.Vfinish(self._hdf_inst._id),
                  "cannot terminate V interface")
        self._hdf_inst = None
285216
def p_ifdef_else_b(p):
    
    global ENABLED

    if ENABLED:
        p[0] = ['#line %i "%s"%s' % (p.lineno(1) + 1, CURRENT_FILE[-1], p[2])]
        p[0] += p[3]
    else:
        p[0] = []
926314
private void validateIfdBL(IFD ifd, int p) {
    IfdTags metadata = ifd.getMetadata();

    if (p == 1) {
      checkRequiredTag(metadata, "NewSubfileType", 1, new long[]{0});
    }
    checkRequiredTag(metadata, "ImageLength", 1);
    checkRequiredTag(metadata, "ImageWidth", 1);
    checkRequiredTag(metadata, "BitsPerSample", 1, new long[]{1});
    checkRequiredTag(metadata, "Compression", 1, new long[]{32898});
    if (p == 0) {
      checkRequiredTag(metadata, "PhotometricInterpretation", 1, new long[] {0, 1});
    } else {
      checkRequiredTag(metadata, "PhotometricInterpretation", 1, new long[] {0});
    }
    checkRequiredTag(metadata, "StripOffsets", 1);
    if (p == 0) {
      checkRequiredTag(metadata, "Orientation", 1, new long[]{1,4,5,8});
    } else {
      checkRequiredTag(metadata, "Orientation", 1, new long[]{1});
    }
    checkRequiredTag(metadata, "SamplesPerPixel", 1, new long[]{1});
    checkRequiredTag(metadata, "StripBYTECount", 1);
    checkRequiredTag(metadata, "XResolution", 1);
    checkRequiredTag(metadata, "YResolution", 1);
    if (p == 1) {
      checkRequiredTag(metadata, "ResolutionUnit", 1, new long[]{2, 3});
      checkRequiredTag(metadata, "DotRange", 2, new long[]{0, 255});
    }
    checkRequiredTag(metadata, "ImageColorIndicator", 1, new long[]{0, 1, 2});
    checkRequiredTag(metadata, "BackgroundColorIndicator", 1, new long[]{0, 1, 2});
  }
240652
private IfdReader readIFD(int offset, boolean isImage, int n) {
    IFD ifd = new IFD(isImage);
    ifd.setOffset(offset);
    IfdReader ir = new IfdReader();
    ir.setIfd(ifd);
    int nextIfdOffset = 0;
    try {
      if (offset % 2 != 0) {
        validation.addErrorLoc("Bad word alignment in the offset of the IFD", "IFD" + n);
      }
      int index = offset;
      int directoryEntries = data.readShort(offset).toInt();
      if (directoryEntries < 1) {
        validation.addError("Incorrect number of IFD entries", "IFD" + n,
            directoryEntries);
        validation.setFatalError(true, "Incorrect number of IFD entries");
      } else if (directoryEntries > 500) {
        if (n < 0) {
          validation.addError("Incorrect number of IFD entries", "SubIFD" + (-n), directoryEntries);
          validation.setFatalError(true, "Incorrect number of IFD entries");
        } else {
          validation.addError("Incorrect number of IFD entries", "IFD" + n, directoryEntries);
          validation.setFatalError(true, "Incorrect number of IFD entries");
        }
      } else {
        index += 2;

        // Reads the tags
        for (int i = 0; i < directoryEntries; i++) {
          int tagid = 0;
          int tagType = -1;
          int tagN = -1;
          try {
            tagid = data.readShort(index).toInt();
            tagType = data.readShort(index + 2).toInt();
            tagN = data.readLong(index + 4).toInt();
            boolean ok = checkType(tagid, tagType, n);
            if (!ok && tagN > 1000) tagN = 1000;
            TagValue tv = getValue(tagType, tagN, tagid, index + 8, ifd, n);
            if (ifd.containsTagId(tagid)) {
              if (duplicateTagTolerance > 0)
                validation.addWarning("Duplicate tag", "" + tagid, "IFD" + n);
              else
                validation.addError("Duplicate tag", "IFD" + n, tagid);
            }
            ifd.addTag(tv);
          } catch (Exception ex) {
            validation.addErrorLoc("Parse error in tag #" + i + " (" + tagid + ")", "IFD" + n);
            TagValue tv = new TagValue(tagid, tagType);
            tv.setReadOffset(index + 8);
            tv.setReadLength(tagN);
            ifd.addTag(tv);
          }

          index += 12;
        }

        // Reads the position of the next IFD
        nextIfdOffset = 0;
        try {
          nextIfdOffset = data.readLong(index).toInt();
        } catch (Exception ex) {
          nextIfdOffset = 0;
          if (nextIFDTolerance > 0)
            validation.addWarning("Unreadable next IFD offset", "", "IFD" + n);
          else
            validation.addErrorLoc("Unreadable next IFD offset", "IFD" + n);
        }
        if (nextIfdOffset > 0 && nextIfdOffset < 7) {
          validation.addError("Invalid next IFD offset", "IFD" + n, nextIfdOffset);
          nextIfdOffset = 0;
        }
        ir.setNextIfdOffset(nextIfdOffset);

        ir.readImage();
        if (isImage && !ifd.hasStrips() && !ifd.hasTiles()) {
          validation.setFatalError(true, "Incorrect image");
        }
      }
    } catch (Exception ex) {
      validation.addErrorLoc("IO Exception", "IFD" + n);
      return null;
    }
    return ir;
  }
115591
def get_if(iff, cmd):
    """"""

    sck = socket.socket()
    ifreq = ioctl(sck, cmd, struct.pack("16s16x", iff.encode("utf8")))
    sck.close()
    return ifreq
548882
private void readIFDs() {
    int offset0 = 0;
    try {
      // The pointer to the first IFD is located in bytes 4-7
      offset0 = data.readLong(4).toInt();
      tiffModel.setFirstIFDOffset(offset0);
      if (offset0 == 0)
        validation.addErrorLoc("There is no first IFD", "Header");
      else if (offset0 > data.size())
        validation.addErrorLoc("Incorrect offset", "Header");
    } catch (Exception ex) {
      validation.addErrorLoc("IO exception", "Header");
    }
      
    if (validation.isCorrect()) {
      int nifd = 1;
      try {
        IfdReader ifd0 = readIFD(offset0, true, 0);
        HashSet<Integer> usedOffsets = new HashSet<Integer>();
        usedOffsets.add(offset0);
        if (ifd0.getIfd() == null) {
          validation.addErrorLoc("Parsing error in first IFD", "IFD" + 0);
        } else {
          IFD iifd = ifd0.getIfd();
          iifd.setNextOffset(ifd0.getNextIfdOffset());
          tiffModel.addIfd0(iifd);

          IfdReader current_ifd = ifd0;

          // Read next IFDs
          boolean stop = false;
          while (current_ifd.getNextIfdOffset() > 0 && !stop) {
            if (usedOffsets.contains(current_ifd.getNextIfdOffset())) {
              // Circular reference
              validation.addErrorLoc("IFD offset already used", "IFD" + nifd);
              stop = true;
            } else if (current_ifd.getNextIfdOffset() > data.size()) {
              validation.addErrorLoc("Incorrect offset", "IFD" + nifd);
              stop = true;
            } else {
              usedOffsets.add(current_ifd.getNextIfdOffset());
              IfdReader next_ifd = readIFD(current_ifd.getNextIfdOffset(), true, nifd);
              if (next_ifd == null) {
                validation.addErrorLoc("Parsing error in IFD " + nifd, "IFD" + nifd);
                stop = true;
              } else {
                iifd = next_ifd.getIfd();
                iifd.setNextOffset(next_ifd.getNextIfdOffset());
                current_ifd.getIfd().setNextIFD(iifd);
                current_ifd = next_ifd;
              }
              nifd++;
            }
          }
        }
      } catch (Exception ex) {
        validation.addErrorLoc("IFD parsing error", "IFD" + nifd);
      }

      try {
        tiffModel.createMetadataDictionary();
      } catch (Exception ex) {
      }
    }
  }
630151
def p_IfBlock(p):
    '''
    
    '''
    if isinstance(p[1], str):
        p[0] = IfBlock(None, p[2], p[4], p[5])
    else:
        p[0] = IfBlock(p[1], p[3], p[5], p[6])
82793
function _nthchild($f, $c)
	{
		// $f is formula e.g. 2N+1 split into a preg_match array
		// $c is the comparator value e.g row or column number
		$c += 1;
		$select = false;

		$f_count = count($f);
		if ($f[0] === 'ODD') {
			$a = 2;
			$b = 1;
		} elseif ($f[0] === 'EVEN') {
			$a = 2;
			$b = 0;
		} elseif ($f_count === 2) {
			$a = 0;
			$b = $f[1] + 0;
		} // e.g. (+6)
		elseif ($f_count === 3) {  // e.g. (2N)
			if ($f[2] == '') {
				$a = 1;
			} elseif ($f[2] == '-') {
				$a = -1;
			} else {
				$a = $f[2] + 0;
			}
			$b = 0;
		} elseif ($f_count === 4) {  // e.g. (2N+6)
			if ($f[2] == '') {
				$a = 1;
			} elseif ($f[2] == '-') {
				$a = -1;
			} else {
				$a = $f[2] + 0;
			}
			$b = $f[3] + 0;
		} else {
			return false;
		}
		if ($a > 0) {
			if (((($c % $a) - $b) % $a) === 0 && $c >= $b) {
				$select = true;
			}
		} elseif ($a == 0) {
			if ($c == $b) {
				$select = true;
			}
		} else {  // if ($a<0)
			if (((($c % $a) - $b) % $a) === 0 && $c <= $b) {
				$select = true;
			}
		}
		return $select;
	}