parseFunction method
Parses an entire function, including its base and all of its arguments.
Implementation
GreenNode? parseFunction(
String? breakOnTokenText, String? name, int? greediness) {
final token = this.fetch();
final func = token.text;
final funcData = functions[func];
if (funcData == null) {
return null;
}
this.consume();
if (greediness != null &&
// funcData.greediness != null &&
funcData.greediness <= greediness) {
throw ParseException(
'''Got function '$func' with no arguments ${name != null ? ' as $name' : ''}''',
token);
} else if (this.mode == Mode.text && !funcData.allowedInText) {
throw ParseException(
'''Can't use function '$func' in text mode''', token);
} else if (this.mode == Mode.math && funcData.allowedInMath == false) {
throw ParseException(
'''Can't use function '$func' in math mode''', token);
}
// final funcArgs = parseArgument(func, funcData);
final context = FunctionContext(
funcName: func,
token: token,
breakOnTokenText: breakOnTokenText,
);
// if (funcData.handler != null) {
_enterArgumentParsingMode(func, funcData);
try {
return funcData.handler(this, context);
} finally {
_leaveArgumentParsingMode(func);
}
// } else {
// throw ParseException('''No function handler for $name''');
// }
// return this.callFunction(func, token, breakOnTokenText);
}