[Question] How do you use function fragments
Closed this issue · 1 comments
I've been working on a terminal emulator using this library, and I'm a little confused as to how to actually use a FunctionFragment
once you've obtained it. Text fragments seem simple enough, but a function fragment doesn't appear to offer any methods that help you understand what it is. Am I not doing this right?
while ((fragment = parser.parse()) != null) {
if (fragment.getType() == FragmentType.FUNCTION) {
FunctionFragment funcFragment = (FunctionFragment) fragment;
// How to get function details?
} else {
writeText(fragment.getText());
}
}
Hello @sam54123. Having FunctionFragment
you can use methods defined in FunctionFragment and Fragment interfaces.
Mainly you use two methods - getFunction()
to the function that is parsed (all functions are enumerations, for details see this package) and getArguments()
to get function arguments.
So, you have everything what you need - function and its arguments. What you will do with them it is up to you and your application.