chainParse method

void chainParse(
  1. Map<String, void Function()> handlerChain, [
  2. bool trimWhitespace = true
])

Call a series of functions based on the first matched symbol. If trimWhitespace is true, whitespace is skipped in between text.

Implementation

void chainParse(Map<String, void Function()> handlerChain, [bool trimWhitespace = true]) {
	// sort key list
	var keyList = handlerChain.keys.toList();
	keyList.sort((a, b) => b.length.compareTo(a.length));
	// leading whitespace
	if (trimWhitespace) skipWhitespace();
	// until eof
	while (inBounds) {
		// continue to find tokens!
		for (var match in keyList) {
			// if we find one
			if (matches(match)) {
				// execute handler
				handlerChain[match]!();
				// and stop checking
				break;
			}
		}
		// trailing whitespace
		if (trimWhitespace) skipWhitespace();
	}
}