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);
}


On Fri, Oct 21, 2022 at 10:37 PM Kevet Duncombe <[email protected]>
wrote:

> I created a short test file reading:
>
> 1970-01-01 commodity T
>   name: "AT&T INC"
>   kind: "STOCK"
>   category: "LARGE"
>   cusip: "00206R102"
>
> 1970-01-01 open Assets:Schwab:Equities:T T
> 1970-01-01 open Assets:Schwab:Cash USD
>
> 2011-02-19 * "Buy 100 T"
>   Assets:Schwab:Equities:T 100 T {28.4575}
>   Assets:Schwab:Cash -2845.75 USD
>
> Running bean-check on it says:
>
> .../test.bean:1:       syntax error, unexpected FLAG, expecting CURRENCY
>
> .../test.bean:7:       syntax error, unexpected FLAG, expecting end of
> file or EOL
>
> .../test.bean:11:      syntax error, unexpected FLAG, expecting end of
> file or EOL or ATAT or AT
>
> Can someone tell me what I'm misunderstanding? Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/6c728cfd-71eb-46dd-b687-6db2f5cf682an%40googlegroups.com
> <https://groups.google.com/d/msgid/beancount/6c728cfd-71eb-46dd-b687-6db2f5cf682an%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAK21%2BhMAt6xs6Ud_W06UsGTrqCA3dxbsfXppbjqfX1XL%2B2wMEA%40mail.gmail.com.

Reply via email to