5 files changed,
16 insertions(+),
8 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-07-31 16:41:01 +0300
Authored at:
2026-07-31 13:17:13 +0300
Change ID:
noxrvyvkpruukrpwusrvvumqonlvrpls
Parent:
368f35a
M
internal/analyzer/testdata/directives.txtar
··· 34 34 usages: 0 35 35 36 36 payees (1): 37 - 37 + TestPayee 38 38 directives: 1 39 39 used: 0 40 - payee 40 + payee TestPayee 41 41 usages: 0 42 42 43 43 prefixes (1): ··· 51 51 directives (12): 52 52 account expenses:food 53 53 commodity $ 54 - payee 54 + payee TestPayee 55 55 tag mytag 56 56 alias expenses:food = expenses:food:old 57 57 year 2024
M
journal/parser/parser.go
··· 154 154 Span: token.Span{Start: cs.Start, End: rp.End}, 155 155 } 156 156 p.skipWhitespace() 157 + } else if p.got(token.TEXT) { 158 + // the lexer emits "(CODE)" as a single TEXT token; split it here 159 + if lit := p.cur.Literal; len(lit) >= 2 && lit[0] == '(' && lit[len(lit)-1] == ')' { 160 + tx.Code = &ast.Code{Value: lit[1 : len(lit)-1], Span: p.cur.Span} 161 + p.advance() 162 + p.skipWhitespace() 163 + } 157 164 } 158 165 159 166 // optional payee | note ··· 215 222 216 223 // keep spaces/tags between text tokens; stop before trailing whitespace 217 224 var name strings.Builder 218 - for p.got(token.TEXT) || p.got(token.INT) || p.got(token.DECIMAL) || (p.got(token.WHITESPACE) && (p.willGet(token.TEXT) || p.willGet(token.INT) || p.willGet(token.DECIMAL))) { 225 + for p.got(token.TEXT) || p.got(token.INT) || p.got(token.DECIMAL) || p.got(token.COMMODITYMARK) || (p.got(token.WHITESPACE) && (p.willGet(token.TEXT) || p.willGet(token.INT) || p.willGet(token.DECIMAL) || p.willGet(token.COMMODITYMARK))) { 219 226 _, _ = name.WriteString(p.cur.Literal) 220 227 p.advance() 221 228 } ··· 512 519 p.skipWhitespace() 513 520 514 521 name := "" 515 - if p.got(token.TEXT) || p.got(token.STRING) { 522 + if p.got(token.TEXT) || p.got(token.STRING) || p.got(token.COMMODITYMARK) { 516 523 name = p.parsePayee().Name 517 524 } 518 525
M
journal/parser/testdata/transaction_with_code.txtar
··· 6 6 Journal 7 7 Transaction j:1:1-4:1 8 8 Date: 2024-01-01 9 - Payee: "(123) groceries" j:1:12-2:0 9 + Code: "123" j:1:12-1:17 10 + Payee: "groceries" j:1:18-2:0 10 11 Posting j:2:1-3:1 11 12 Account j:2:5-2:18 12 13 SubAccount: "expenses" j:2:5-2:13