Hi, list! I've seen the following in Stack Exchange:

https://tex.stackexchange.com/questions/503208/define-macro-that-scans-ahead-for-super-and-or-subscript-absorbs-them-and-mo
The answer is:

\documentclass{article} \usepackage{amsmath} \usepackage{xparse} \NewDocumentCommand{\mymathsym}{e{^_}}{% x^{\mathrm{foo}\IfValueT{#1}{,#1}}_{\mathrm{bar}\IfValueT{#2}{,#2}}% } \begin{document} \begin{gather} \mymathsym \\ \mymathsym^{\mathrm{extrasup}} \\ \mymathsym_{\mathrm{extrasub}} \\ \mymathsym^{\mathrm{extrasup}}_{\mathrm{extrasub}} \\ \mymathsym_{\mathrm{extrasub}}^{\mathrm{extrasup}} \end{gather} \end{document}

Such a macro contextually defines a behavior for a subscript and a superscript even if they aren't displayed in a specific order, so

\mymacro_{a}^{b}
\mymacro^{b}_{a}

have the same output, even if the intended behavior is not the typical one (I could redefine it so subscripts change colors, for instance).
Although I could just port the macro using xparse-generic because it works in ConTeXt too, how to define a macro like that the ConTeXt way, i.e., using only ConTeXt macros?

Thank you in advance.

Jairo :)