Currency needs two characters in v2.
/* Currencies.
*
* A currency (or sometimes called "commodities") is a string which
* - Begins with either a letter or a slash (/) character.
* - Contains at least one letter.
* - Ends with either a letter or a number.
* - May contain the following special characters within: period (.),
* underscore (_), dash (-), or quote (').
* The pattern has to be kept in sync with beancount.core.amount.CURRENCY_RE.
*
* In Beancount v3 (C++ version), a single character (e.g. "V" for Visa) is a
* valid currency. v2 uses the GNU flex scanner which does not have the
* lookahead capability required to make this possible but the v3 C++ scanner
* uses Genivia's RE-Flex which supports a lookahead and it will.
*
* Example currencies:
* "AAPL" (stock)
* "V" (single-character stock)
* "
NT.TO" (stock on another market)
* "TLT_040921C144" (equity option)
* "/6J" (currency futures)
* "/NQH21" (commodity futures)
* "/NQH21_QNEG21C13100" (futures option)
*
* Counter-examples:
* - "/6.3": If a currency begins with a slash, the following pattern has to
* include at least one letter. "/6J" is a valid currency, but "/6.3" is not.
* - "CAC_": A currency cannot end with a special character; it has to end with
* either an uppercase letter or a number ("C345" is a valid currency, but
* "C_" is not).
*
* Note: In this scanner we locate the rule above that matching SLASH on
* purpose so that a name starting with '/' for a futures contract will match
* with higher priority than that matching a divide '/' character.
*
* Keep in sync with {edefe3fbe907}.
*/
[A-Z][A-Z0-9\'\.\_\-]*[A-Z0-9] {
return TOKEN(CURRENCY, yytext, yyleng);
}
\/[A-Z0-9\'\.\_\-]*[A-Z]([A-Z0-9\'\.\_\-]*[A-Z0-9])? {
return TOKEN(CURRENCY, yytext, yyleng);
}