Evaluate text passed by L{_partialParseDateStd()}
244
def _evalDateStd(self, datetimeString, sourceTime):
        
        s = datetimeString.strip()
        sourceTime = self._evalDT(datetimeString, sourceTime)

        # Given string is in the format 07/21/2006
        return self.parseDate(s, sourceTime)
91489
@VisibleForTesting
  static Context parse(String text) {
    Queue<String> parts = Lists.newLinkedList(Arrays.asList(text.split(" ")));
    Context.Builder builder = HTML_PCDATA.toBuilder();
    builder.withState(HtmlContext.valueOf(parts.remove()));
    if (!parts.isEmpty()) {
      try {
        builder.withElType(ElementType.valueOf(parts.element()));
        parts.remove();
      } catch (IllegalArgumentException ex) {
        // OK
      }
    }
    if (!parts.isEmpty()) {
      try {
        builder.withAttrType(AttributeType.valueOf(parts.element()));
        parts.remove();
      } catch (IllegalArgumentException ex) {
        // OK
      }
    }
    if (!parts.isEmpty()) {
      try {
        builder.withDelimType(AttributeEndDelimiter.valueOf(parts.element()));
        parts.remove();
      } catch (IllegalArgumentException ex) {
        // OK
      }
    }
    if (!parts.isEmpty()) {
      try {
        builder.withSlashType(JsFollowingSlash.valueOf(parts.element()));
        parts.remove();
      } catch (IllegalArgumentException ex) {
        // OK
      }
    }
    if (!parts.isEmpty()) {
      try {
        builder.withUriPart(UriPart.valueOf(parts.element()));
        parts.remove();
      } catch (IllegalArgumentException ex) {
        // OK
      }
    }
    if (!parts.isEmpty()) {
      try {
        builder.withUriType(UriType.valueOf(parts.element()));
        parts.remove();
      } catch (IllegalArgumentException ex) {
        // OK
      }
    }
    if (!parts.isEmpty()) {
      String part = parts.element();
      String prefix = "templateNestDepth=";
      if (part.startsWith(prefix)) {
        try {
          builder.withTemplateNestDepth(Integer.parseInt(part.substring(prefix.length())));
          parts.remove();
        } catch (NumberFormatException ex) {
          // OK
        }
      }
    }
    if (!parts.isEmpty()) {
      String part = parts.element();
      String prefix = "jsTemplateLiteralNestDepth=";
      if (part.startsWith(prefix)) {
        try {
          builder.withJsTemplateLiteralNestDepth(Integer.parseInt(part.substring(prefix.length())));
          parts.remove();
        } catch (NumberFormatException ex) {
          // OK
        }
      }
    }
    if (!parts.isEmpty()) {
      throw new IllegalArgumentException(
          "Unable to parse context \"" + text + "\". Unparsed portion: " + parts);
    }
    Context result = builder.build();
    return result;
  }
583992
def evaluate_postfix(tokens):
    
    stack = []

    for token in tokens:
        total = None

        if is_int(token) or is_float(token) or is_constant(token):
            stack.append(token)
        elif is_unary(token):
            a = stack.pop()
            total = mathwords.UNARY_FUNCTIONS[token](a)
        elif len(stack):
            b = stack.pop()
            a = stack.pop()
            if token == '+':
                total = a + b
            elif token == '-':
                total = a - b
            elif token == '*':
                total = a * b
            elif token == '^':
                total = a ** b
            elif token == '/':
                if Decimal(str(b)) == 0:
                    total = 'undefined'
                else:
                    total = Decimal(str(a)) / Decimal(str(b))
            else:
                raise PostfixTokenEvaluationException(
                    'Unknown token {}'.format(token)
                )

        if total is not None:
            stack.append(total)

    # If the stack is empty the tokens could not be evaluated
    if not stack:
        raise PostfixTokenEvaluationException(
            'The postfix expression resulted in an empty stack'
        )

    return stack.pop()
1157427
private String processText(String text) {
        String rslt = text; // default
        Expression x =
                portalSpELService.parseExpression(
                        text, PortalSpELServiceImpl.TemplateParserContext.INSTANCE);
        rslt = x.getValue(ctx, String.class);
        return rslt;
    }
979731
function _getLtbr (context, mergedStyle) {
  return ['left', 'top', 'bottom', 'right'].reduce((pre, key) => {
    const msv = mergedStyle && mergedStyle[key]
    // undefined, null, or '0px' -> o
    pre[key] = msv && parseFloat(msv) || 0
    return pre
  }, {})
}
341102
function getValueText(data) {
            let value = data[valueLabel];
            let valueText;

            if (data.missingValue) {
                valueText = '-';
            } else {
                valueText = getFormattedValue(value).toString();
            }

            return valueText;
        }
907358
def visit_FormattedValue(self, node: AST,
                             dfltChaining: bool = True) -> str:
        """"""
        format_spec = node.format_spec
        return f"{{{self.visit(node.value)}" \
               f"{self.CONV_MAP.get(node.conversion, '')}" \
               f"{':'+self._nested_str(format_spec) if format_spec else ''}}}"
51518
private static TextDirection  parseTextDirection(String val)
   {
      switch (val)
      {
         case "ltr": return Style.TextDirection.LTR;
         case "rtl": return Style.TextDirection.RTL;
         default:    return null;
      }
   }
1057712
function parseText(source, delimiters) {
    delimiters = delimiters || ['{{', '}}'];

    var regCacheKey = delimiters[0] + '>..<' + delimiters[1];
    var exprStartReg = delimRegCache[regCacheKey];
    if (!exprStartReg) {
        exprStartReg = new RegExp(
            regexpLiteral(delimiters[0])
                + '\\s*([\\s\\S]+?)\\s*'
                + regexpLiteral(delimiters[1]),
            'g'
        );
        delimRegCache[regCacheKey] = exprStartReg;
    }

    var exprMatch;

    var walker = new Walker(source);
    var beforeIndex = 0;

    var expr = {
        type: ExprType.TEXT,
        segs: []
    };

    function pushStringToSeg(text) {
        text && expr.segs.push({
            type: ExprType.STRING,
            literal: text,
            value: decodeHTMLEntity(text)
        });
    }

    var delimEndLen = delimiters[1].length;
    while ((exprMatch = walker.match(exprStartReg)) != null) {
        var interpSource = exprMatch[1];
        var interpLen = exprMatch[0].length;
        if (walker.cut(walker.index + 1 - delimEndLen, walker.index + 1) === delimiters[1]) {
            interpSource += walker.cut(walker.index, walker.index + 1);
            walker.go(1);
            interpLen++;
        }

        pushStringToSeg(walker.cut(
            beforeIndex,
            walker.index - interpLen
        ));

        var interp = parseInterp(interpSource);
        expr.original = expr.original || interp.original;
        expr.segs.push(interp);

        beforeIndex = walker.index;
    }

    pushStringToSeg(walker.cut(beforeIndex));



    if (expr.segs.length === 1 && expr.segs[0].type === ExprType.STRING) {
        expr.value = expr.segs[0].value;
    }

    return expr;
}
394583
def parse_id_literal(ast, _variables=None):
    """"""
    if isinstance(ast, (StringValueNode, IntValueNode)):
        return ast.value
    return INVALID
738308
def parse_text(self,text):
        """"""
        try:
            return self.rProgram.ignore(cStyleComment).parseString(text, parseAll=True)
        except SemanticException as err:
            print(err)
            exit(3)
        except ParseException as err:
            print(err)
            exit(3)
234068
function parseTextData(text) {
    var data = String(text).replace(/(\r\n|\r|\n)/g, '\n');
    var lines = data.split(/\n/), line;

    var output = '';
    for (var i = 0, l = lines.length; i < l; ++i) {
        line = lines[i];

        output += 'data: ' + line;
        output += (i + 1) === l ? '\n\n' : '\n';
    }

    return output;
}
300336
def get_partial_text(fulltext):
    
    def _get_index(x):
        return int(float(x) / 100 * len(fulltext))

    partial_text = [
        fulltext[_get_index(start):_get_index(end)]
        for start, end in current_app.config[
            "CLASSIFIER_PARTIAL_TEXT_PERCENTAGES"
        ]
    ]

    return "\n".join(partial_text)
229847
private void parseCharData() throws Exception {
        char c;
        int state = 0;
        boolean pureWhite = false;

        // assert (dataBufferPos == 0);

        // are we expecting pure whitespace? it might be dirty...
        if ((currentElementContent == CONTENT_ELEMENTS)
                && !isDirtyCurrentElement) {
            pureWhite = true;
        }

        // always report right out of readBuffer
        // to minimize (pointless) buffer copies
        while (true) {
            int i;

            loop: for (i = readBufferPos; i < readBufferLength; i++) {
                advanceLocation();
                switch (c = readBuffer[i]) {
                    case '\n':
                        nextCharOnNewLine = true;
                        // pureWhite unmodified
                        break;
                    case '\r': // should not happen!!
                    case '\t':
                    case ' ':
                        // pureWhite unmodified
                        break;
                    case '&':
                    case '<':
                        // pureWhite unmodified
                        // CLEAN end of text sequence
                        state = 1;
                        rollbackLocation();
                        break loop;
                    case ']':
                        // that's not a whitespace char, and
                        // can not terminate pure whitespace either
                        pureWhite = false;
                        // Refill buffer if needed -- 2008-03-06 hsivonen
                        if (readBufferOverflow == -1) {
                            if ((i + 2) >= readBufferLength) {
                                reportText(pureWhite, i);
                                readBufferOverflow = ']';
                                fillBuffer();
                                i = readBufferPos;
                            }
                            if ((readBuffer[i + 1] == ']')
                                    && (readBuffer[i + 2] == '>')) {
                                // ERROR end of text sequence
                                state = 2;
                                rollbackLocation();
                                break loop;
                            }
                        }
                        break;
                    default:
                        if (((c < 0x0020) || (c > 0xFFFD))
                                || ((c >= 0x007f) && (c <= 0x009f)
                                        && (c != 0x0085) && (xmlVersion == XML_11))) {
                            fatal("illegal XML character U+"
                                    + Integer.toHexString(c));
                        } else if ((c >= '\u007F') && (c <= '\u009F')) // 2006-04-25
                        // hsivonen
                        {
                            handler.warn("Saw a control character: U+00"
                                    + Integer.toHexString(c) + ".");
                        }
                        // that's not a whitespace char
                        pureWhite = false;
                }
            }
            // report characters/whitspace
            reportText(pureWhite, i);

            if (state != 0) {
                break;
            }

            // fill next buffer from this entity, or
            // pop stack and continue with previous entity
            unread(readCh());
        }
        if (!pureWhite) {
            isDirtyCurrentElement = true;
        }
        // finish, maybe with error
        if (state != 1) // finish, no error
        {
            fatal("character data may not contain ']]>'");
        }
    }
1330803
def parse_partial(self, data):
        
        try:
            # Python 3 requires all JSON data to be a text string
            lines = self._decoder1.decode(data, False).split("\n")

            # Add first input line to last buffer line, if applicable, to
            # handle cases where the JSON string has been chopped in half
            # at the network level due to streaming
            if len(self._buffer) > 0 and self._buffer[-1] is not None:
                self._buffer[-1] += lines[0]
                self._buffer.extend(lines[1:])
            else:
                self._buffer.extend(lines)
        except UnicodeDecodeError as error:
            raise exceptions.DecodingError('json', error)

        # Process data buffer
        index = 0
        try:
            # Process each line as separate buffer
            #PERF: This way the `.lstrip()` call becomes almost always a NOP
            #      even if it does return a different string it will only
            #      have to allocate a new buffer for the currently processed
            #      line.
            while index < len(self._buffer):
                while self._buffer[index]:
                    # Make sure buffer does not start with whitespace
                    #PERF: `.lstrip()` does not reallocate if the string does
                    #      not actually start with whitespace.
                    self._buffer[index] = self._buffer[index].lstrip()

                    # Handle case where the remainder of the line contained
                    # only whitespace
                    if not self._buffer[index]:
                        self._buffer[index] = None
                        continue

                    # Try decoding the partial data buffer and return results
                    # from this
                    data = self._buffer[index]
                    for index2 in range(index, len(self._buffer)):
                        # If decoding doesn't succeed with the currently
                        # selected buffer (very unlikely with our current
                        # class of input data) then retry with appending
                        # any other pending pieces of input data
                        # This will happen with JSON data that contains
                        # arbitrary new-lines: "{1:\n2,\n3:4}"
                        if index2 > index:
                            data += "\n" + self._buffer[index2]

                        try:
                            (obj, offset) = self._decoder2.raw_decode(data)
                        except ValueError:
                            # Treat error as fatal if we have already added
                            # the final buffer to the input
                            if (index2 + 1) == len(self._buffer):
                                raise
                        else:
                            index = index2
                            break

                    # Decoding succeeded – yield result and shorten buffer
                    yield obj
                    if offset < len(self._buffer[index]):
                        self._buffer[index] = self._buffer[index][offset:]
                    else:
                        self._buffer[index] = None
                index += 1
        except ValueError as error:
            # It is unfortunately not possible to reliably detect whether
            # parsing ended because of an error *within* the JSON string, or
            # an unexpected *end* of the JSON string.
            # We therefor have to assume that any error that occurs here
            # *might* be related to the JSON parser hitting EOF and therefor
            # have to postpone error reporting until `parse_finalize` is
            # called.
            self._lasterror = error
        finally:
            # Remove all processed buffers
            del self._buffer[0:index]
87024
def eval_string_type(self, text, is_string=False):
        """"""

        stype = set()
        wstype = set()

        for m in RE_ITER_STRING_TYPES.finditer(text):
            value = m.group(0)
            if value == '*':
                wstype.add('u')
                wstype.add('f')
                wstype.add('r')
                wstype.add('b')
            elif value.endswith('*'):
                wstype.add(value[0].lower())
            else:
                stype.add(value.lower())

        if is_string and 'b' not in stype and 'f' not in stype:
            stype.add('u')

        return stype, wstype
630450
function parseloopspec(p){
    var m = p.match( /^(\w+)\s*<-\s*(\S+)?$/ );
    if(m === null){
      error('bad loop spec: "' + p + '"');
    }
    if(m[1] === 'item'){
      error('"item<-..." is a reserved word for the current running iteration.\n\nPlease choose another name for your loop.');
    }
    if( !m[2] || (m[2] && (/context/i).test(m[2]))){ //undefined or space(IE)
      m[2] = function(ctxt){return ctxt.context;};
    }
    return {name: m[1], sel: m[2]};
  }