A {@link Parser} that returns both parsed object and matched string.
176940
public final Parser<WithSource<T>> withSource() {
    return new Parser<WithSource<T>>() {
      @Override boolean apply(ParseContext ctxt) {
        int begin = ctxt.getIndex();
        if (!Parser.this.apply(ctxt)) {
          return false;
        }
        String source = ctxt.source.subSequence(begin, ctxt.getIndex()).toString();
        @SuppressWarnings("unchecked")
        WithSource<T> withSource = new WithSource<T>((T) ctxt.result, source);
        ctxt.result = withSource;
        return true;
      }
      @Override public String toString() {
        return Parser.this.toString();
      }
    };
  }
1202288
public static Matcher findRegex(Object left, Object right) {
        String stringToCompare;
        if (left instanceof String) {
            stringToCompare = (String) left;
        } else {
            stringToCompare = toString(left);
        }
        String regexToCompareTo;
        if (right instanceof String) {
            regexToCompareTo = (String) right;
        } else if (right instanceof Pattern) {
            Pattern pattern = (Pattern) right;
            return pattern.matcher(stringToCompare);
        } else {
            regexToCompareTo = toString(right);
        }
        return Pattern.compile(regexToCompareTo).matcher(stringToCompare);
    }
230793
def parse(self, string, lexer=None):
        
        if not lexer:
            lexer = Lexer().lexer

        return self.parser.parse(string, lexer=lexer)
227646
def _matching_string(matched, string):
        
        if string is None:
            return string
        if IS_PY2:
            # pylint: disable=undefined-variable
            if isinstance(matched, text_type):
                return text_type(string)
        else:
            if isinstance(matched, bytes) and isinstance(string, str):
                return string.encode(locale.getpreferredencoding(False))
        return string
646124
public Map<String, Object> parseObject() throws IOException {
		Type t = lexer.readNextToken();
		if (t != Type.START_OBJECT) {
			throw new IOException("Unexpected token: " + t);
		}
		
		return parseObjectInternal();
	}
241397
static List<Object> parseList(AbstractContext context, JsonParser parser, List<Object> list, boolean skipRead) {
		try {
			if (!skipRead) {
				parser.nextToken();
			}

			if (parser.currentToken() != JsonToken.START_ARRAY) {
				throw (new KriptonRuntimeException("Invalid input format"));
			}

			skipRead = false;

			JsonToken token;
			do {
				if (skipRead) {
					token = parser.getCurrentToken();
				} else {
					token = parser.nextToken();
					skipRead = true;
				}
				switch (token) {
				case VALUE_FALSE:
				case VALUE_TRUE:
				case VALUE_NUMBER_FLOAT:
				case VALUE_NUMBER_INT:
				case VALUE_STRING:
					list.add(parser.getText());
					break;
				case VALUE_NULL:
					list.add(null);
					break;
				case VALUE_EMBEDDED_OBJECT:
					// parse submap
					list.add(parseMap(context, parser, new LinkedHashMap<String, Object>(), true));
					break;
				case START_ARRAY:
					list.add(parseList(context, parser, list, true));
					break;
				default:
					break;
				}
			} while (parser.nextToken() != JsonToken.END_ARRAY);
			return list;
		} catch (IOException e) {
			e.printStackTrace();
			throw (new KriptonRuntimeException(e));
		}
	}
528623
def _parse(cls, scope):
    
    if not scope:
      return ('default',)
    if isinstance(scope, string_types):
      scope = scope.split(' ')
    scope = {str(s).lower() for s in scope if s}
    return scope or ('default',)
1027411
public Object parse(String in) throws ParseException {
		return parse(in, JSONValue.defaultReader.DEFAULT);
	}
770902
static Class<? extends Matcher<? super ExpressionTree>> getValue(Matches matches) {
    String name;
    try {
      matches.value();
      throw new RuntimeException("unreachable");
    } catch (MirroredTypeException e) {
      DeclaredType type = (DeclaredType) e.getTypeMirror();
      name = ((TypeElement) type.asElement()).getQualifiedName().toString();
    }
    try {
      return asSubclass(Class.forName(name), new TypeToken<Matcher<? super ExpressionTree>>() {});
    } catch (ClassNotFoundException | ClassCastException e) {
      throw new RuntimeException(e);
    }
  }
1343069
@SuppressWarnings("unchecked")
    @NotNull
    public final Parser<Object> getParser() {
        if (parser != null) {
            return parser;
        }
        LOG.info("Creating parser: {}", className);
        if (className == null) {
            throw new IllegalStateException("Class name was not set: " + getName());
        }
        if (context == null) {
            throw new IllegalStateException("Context class loader was not set: " + getName() + " / " + className);
        }
        final Object obj = Utils4J.createInstance(className, context.getClassLoader());
        if (!(obj instanceof Parser<?>)) {
            throw new IllegalStateException("Expected class to be of type '" + Parser.class.getName() + "', but was: " + className);
        }
        parser = (Parser<Object>) obj;
        parser.initialize(context, this);
        return parser;
    }
810442
@Override
	public E parse(BinderContext context, ParserWrapper parserWrapper) throws Exception {
		E instance = null;

		switch (context.getSupportedFormat()) {
		case XML:
			instance = parseOnXml(((XmlWrapperParser) parserWrapper).xmlParser, 0);
			break;
		default:
			if (context.getSupportedFormat().onlyText)
				instance = parseOnJacksonAsString(((JacksonWrapperParser) parserWrapper).jacksonParser);
			else
				instance = parseOnJackson(((JacksonWrapperParser) parserWrapper).jacksonParser);

			break;
		}

		return instance;
	}
938955
@SuppressWarnings("unchecked")
    private <T> T parseElement(Element element, Class<T> cls) {
        T value;
        if (element == null) {
            value = null;
        } else if (MwsObject.class.isAssignableFrom(cls)) {
            value = MwsUtl.newInstance(cls);
            Element holdElement = currentElement;
            Node holdChild = currentChild;
            setCurrentElement(element);
            ((MwsObject) value).readFragmentFrom(this);
            currentElement = holdElement;
            currentChild = holdChild;
        } else if (cls == Object.class) {
            value = (T)element;
        } else {
            String v = getElementText(element);
            value = parseString(v, cls);
        }
        return value;
    }
836145
protected <T> T parse(JsonReaderI<T> mapper) throws ParseException {
		this.pos = -1;
		T result;
		try {
			read();
			result = readFirst(mapper);
			if (checkTaillingData) {
				if (!checkTaillingSpace)
					skipSpace();
				if (c != EOI)
					throw new ParseException(pos - 1, ERROR_UNEXPECTED_TOKEN, c);
			}
		} catch (IOException e) {
			throw new ParseException(pos, e);
		}
		xs = null;
		xo = null;
		return result;
	}
1328878
public static Object parse(String json, JSONVisitor handler)
            throws ParseException {
        StringReader reader = new StringReader(json);
        try {
            return parse(reader, handler);
        } catch (IOException e) {
            throw new ParseException(e.getMessage(), 0);
        } finally {
            reader.close();
        }
    }
370376
public <T> T parse(InputStream in, JsonReaderI<T> mapper) throws ParseException, UnsupportedEncodingException {
		InputStreamReader i2 = new InputStreamReader(in, "utf8");
		//
		return super.parse(i2, mapper);
	}
560386
function (str, parserOptions) {
  parserOptions = parserOptions || {};
  // Do a naive test whether this is a string or an object
  var mapFn = parserOptions.map ? str.trim().charAt(0) === '[' ? underscore.map : underscore.mapObject : identity;
  var jsonParser = JSON.parse;
  return mapFn(jsonParser(str, parserOptions.reviver, parserOptions.filename), parserOptions.map);
}
1046702
private boolean parseOne(ClassLoader classLoader, String resName) throws IOException {
        InputStream is = classLoader.getResourceAsStream(resName);
        if (is == null)     return false;

        BufferedReader in = new BufferedReader(new InputStreamReader(is,UTF8));
        String line;
        while((line=in.readLine())!=null) {
            Matcher m = INCLUDE.matcher(line);
            if(m.lookingAt())
                required.add(m.group(1));
        }
        in.close();
        return true;
    }