I'm writing a Bison/Flex program to convert LaTeX into MathML. At the moment, dealing with functions (i.e. \sqrt, \frac, etc) works like this, with a token for every function
\\frac {return FUNC_FRAC;}
and passes the token FUNC_FRAC back to bison, which plays its part in the description of this subtree:
function: FUNC_FRAC LBRACE atom RBRACE LBRACE atom RBRACE {$$ = "<mfrac>" + $3 + $6 + "</mfrac>";}
But this means that I need to define and juggle a potentially unlimited number of tokens. What I would like to do is something like this, which doesn't work as written. In flex:
\\[A-Za-z]+[0-9]* {return the-matched-string;}
and in bison:
function: "\frac" LBRACE atom RBRACE LBRACE atom RBRACE {$$ = "<mfrac>" + $3 + $6 + "</mfrac>";}