Lines Matching refs:idx
85 scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_t *next_idx_ptr);
87 _build_rval_index_tuple(PyObject *rval, Py_ssize_t idx);
344 raise_stop_iteration(Py_ssize_t idx)
346 PyObject *value = PyLong_FromSsize_t(idx);
354 _build_rval_index_tuple(PyObject *rval, Py_ssize_t idx) {
355 /* return (rval, idx) tuple, stealing reference to rval */
359 steal a reference to rval, returns (rval, idx)
364 pyidx = PyLong_FromSsize_t(idx);
678 _parse_object_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_t *next_idx_ptr)
681 idx is the index of the first character after the opening curly brace.
711 while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind,str, idx))) idx++;
714 if (idx > end_idx || PyUnicode_READ(kind, str, idx) != '}') {
719 if (idx > end_idx || PyUnicode_READ(kind, str, idx) != '"') {
720 raise_errmsg("Expecting property name enclosed in double quotes", pystr, idx);
723 key = scanstring_unicode(pystr, idx + 1, s->strict, &next_idx);
733 idx = next_idx;
736 while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind, str, idx))) idx++;
737 if (idx > end_idx || PyUnicode_READ(kind, str, idx) != ':') {
738 raise_errmsg("Expecting ':' delimiter", pystr, idx);
741 idx++;
742 while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind, str, idx))) idx++;
745 val = scan_once_unicode(s, pystr, idx, &next_idx);
767 idx = next_idx;
770 while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind, str, idx))) idx++;
773 if (idx <= end_idx && PyUnicode_READ(kind, str, idx) == '}')
775 if (idx > end_idx || PyUnicode_READ(kind, str, idx) != ',') {
776 raise_errmsg("Expecting ',' delimiter", pystr, idx);
779 idx++;
782 while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind, str, idx))) idx++;
786 *next_idx_ptr = idx + 1;
809 _parse_array_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_t *next_idx_ptr) {
811 idx is the index of the first character after the opening brace.
836 while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind, str, idx))) idx++;
839 if (idx > end_idx || PyUnicode_READ(kind, str, idx) != ']') {
843 val = scan_once_unicode(s, pystr, idx, &next_idx);
851 idx = next_idx;
854 while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind, str, idx))) idx++;
857 if (idx <= end_idx && PyUnicode_READ(kind, str, idx) == ']')
859 if (idx > end_idx || PyUnicode_READ(kind, str, idx) != ',') {
860 raise_errmsg("Expecting ',' delimiter", pystr, idx);
863 idx++;
866 while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind, str, idx))) idx++;
870 /* verify that idx < end_idx, PyUnicode_READ(kind, str, idx) should be ']' */
871 if (idx > end_idx || PyUnicode_READ(kind, str, idx) != ']') {
875 *next_idx_ptr = idx + 1;
884 _parse_constant(PyScannerObject *s, const char *constant, Py_ssize_t idx, Py_ssize_t *next_idx_ptr) {
888 idx is the index of the first character of the constant
903 idx += PyUnicode_GET_LENGTH(cstr);
905 *next_idx_ptr = idx;
912 idx is the index of the first character of the number
923 Py_ssize_t idx = start;
937 if (PyUnicode_READ(kind, str, idx) == '-') {
938 idx++;
939 if (idx > end_idx) {
946 if (PyUnicode_READ(kind, str, idx) >= '1' && PyUnicode_READ(kind, str, idx) <= '9') {
947 idx++;
948 while (idx <= end_idx && PyUnicode_READ(kind, str, idx) >= '0' && PyUnicode_READ(kind, str, idx) <= '9') idx++;
951 else if (PyUnicode_READ(kind, str, idx) == '0') {
952 idx++;
961 if (idx < end_idx && PyUnicode_READ(kind, str, idx) == '.' && PyUnicode_READ(kind, str, idx + 1) >= '0' && PyUnicode_READ(kind, str, idx + 1) <= '9') {
963 idx += 2;
964 while (idx <= end_idx && PyUnicode_READ(kind, str, idx) >= '0' && PyUnicode_READ(kind, str, idx) <= '9') idx++;
968 if (idx < end_idx && (PyUnicode_READ(kind, str, idx) == 'e' || PyUnicode_READ(kind, str, idx) == 'E')) {
969 Py_ssize_t e_start = idx;
970 idx++;
973 if (idx < end_idx && (PyUnicode_READ(kind, str, idx) == '-' || PyUnicode_READ(kind, str, idx) == '+')) idx++;
976 while (idx <= end_idx && PyUnicode_READ(kind, str, idx) >= '0' && PyUnicode_READ(kind, str, idx) <= '9') idx++;
979 if (PyUnicode_READ(kind, str, idx - 1) >= '0' && PyUnicode_READ(kind, str, idx - 1) <= '9') {
983 idx = e_start;
998 idx - start);
1008 n = idx - start;
1022 *next_idx_ptr = idx;
1027 scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_t *next_idx_ptr)
1030 idx is the index of the first character of the term
1048 if (idx < 0) {
1049 PyErr_SetString(PyExc_ValueError, "idx cannot be negative");
1052 if (idx >= length) {
1053 raise_stop_iteration(idx);
1057 switch (PyUnicode_READ(kind, str, idx)) {
1060 return scanstring_unicode(pystr, idx + 1, s->strict, next_idx_ptr);
1066 res = _parse_object_unicode(s, pystr, idx + 1, next_idx_ptr);
1074 res = _parse_array_unicode(s, pystr, idx + 1, next_idx_ptr);
1079 if ((idx + 3 < length) && PyUnicode_READ(kind, str, idx + 1) == 'u' && PyUnicode_READ(kind, str, idx + 2) == 'l' && PyUnicode_READ(kind, str, idx + 3) == 'l') {
1080 *next_idx_ptr = idx + 4;
1086 if ((idx + 3 < length) && PyUnicode_READ(kind, str, idx + 1) == 'r' && PyUnicode_READ(kind, str, idx + 2) == 'u' && PyUnicode_READ(kind, str, idx + 3) == 'e') {
1087 *next_idx_ptr = idx + 4;
1093 if ((idx + 4 < length) && PyUnicode_READ(kind, str, idx + 1) == 'a' &&
1094 PyUnicode_READ(kind, str, idx + 2) == 'l' &&
1095 PyUnicode_READ(kind, str, idx + 3) == 's' &&
1096 PyUnicode_READ(kind, str, idx + 4) == 'e') {
1097 *next_idx_ptr = idx + 5;
1103 if ((idx + 2 < length) && PyUnicode_READ(kind, str, idx + 1) == 'a' &&
1104 PyUnicode_READ(kind, str, idx + 2) == 'N') {
1105 return _parse_constant(s, "NaN", idx, next_idx_ptr);
1110 if ((idx + 7 < length) && PyUnicode_READ(kind, str, idx + 1) == 'n' &&
1111 PyUnicode_READ(kind, str, idx + 2) == 'f' &&
1112 PyUnicode_READ(kind, str, idx + 3) == 'i' &&
1113 PyUnicode_READ(kind, str, idx + 4) == 'n' &&
1114 PyUnicode_READ(kind, str, idx + 5) == 'i' &&
1115 PyUnicode_READ(kind, str, idx + 6) == 't' &&
1116 PyUnicode_READ(kind, str, idx + 7) == 'y') {
1117 return _parse_constant(s, "Infinity", idx, next_idx_ptr);
1122 if ((idx + 8 < length) && PyUnicode_READ(kind, str, idx + 1) == 'I' &&
1123 PyUnicode_READ(kind, str, idx + 2) == 'n' &&
1124 PyUnicode_READ(kind, str, idx + 3) == 'f' &&
1125 PyUnicode_READ(kind, str, idx + 4) == 'i' &&
1126 PyUnicode_READ(kind, str, idx + 5) == 'n' &&
1127 PyUnicode_READ(kind, str, idx + 6) == 'i' &&
1128 PyUnicode_READ(kind, str, idx + 7) == 't' &&
1129 PyUnicode_READ(kind, str, idx + 8) == 'y') {
1130 return _parse_constant(s, "-Infinity", idx, next_idx_ptr);
1135 return _match_number_unicode(s, pystr, idx, next_idx_ptr);
1144 Py_ssize_t idx;
1146 static char *kwlist[] = {"string", "idx", NULL};
1147 if (!PyArg_ParseTupleAndKeywords(args, kwds, "On:scan_once", kwlist, &pystr, &idx))
1151 rval = scan_once_unicode(self, pystr, idx, &next_idx);
1512 Py_ssize_t idx;
1560 idx = 0;
1601 if (idx) {
1621 idx += 1;