1 files changed,
5 insertions(+),
12 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-08-19 14:11:06 +0300
Authored at:
2026-08-19 14:08:19 +0300
Change ID:
vtuxunmwpkvovqstqsxkrkqsznyqlnkp
Parent:
d41beb6
M
journal/parser/parser.go
··· 185 185 186 186 // keep spaces/tags between text tokens; stop before trailing whitespace 187 187 var name strings.Builder 188 - for payeeWord(p.cur.Type) || (payeeWord(p.peek.Type) && p.got(token.WHITESPACE)) { 188 + for isPayeeWord(p.cur.Type) || (isPayeeWord(p.peek.Type) && p.got(token.WHITESPACE)) { 189 189 _, _ = name.WriteString(p.cur.Literal) 190 190 p.advance() 191 191 } 192 192 return &ast.Payee{Name: unquote(name.String()), Span: p.span(s)} 193 193 } 194 194 195 -func payeeWord(t token.Type) bool { 195 +func isPayeeWord(t token.Type) bool { 196 196 switch t { 197 197 case token.TEXT, token.INT, token.DECIMAL, token.COMMODITYMARK: 198 198 return true ··· 354 354 switch { 355 355 case p.got(token.SEMICOLON): 356 356 // comment line: directive mode lexes only ';' as a comment marker 357 - s := p.cur.Span 358 - c := p.parseCommentRest(s) 357 + ns := p.cur.Span 358 + c := p.parseCommentRest(ns) 359 359 p.expectNewline() 360 - subs = append(subs, ast.AccountSubdirective{Kind: ast.SubdirectiveComment, NameSpan: s, Comment: c}) 360 + subs = append(subs, ast.AccountSubdirective{Kind: ast.SubdirectiveComment, NameSpan: ns, Comment: c}) 361 361 case p.got(token.TEXT) && isCommentMarker(p.cur.Literal): 362 362 // '#', '%' and '*' lex as TEXT in directive mode; treat them as comment lines 363 363 c := p.parseTextComment() ··· 1299 1299 p.expectNewline() 1300 1300 } 1301 1301 1302 -// parseSubdirectiveValue consumes the tokens after a subdirective keyword up 1303 -// to an inline comment or the end of the line, returning the raw text and its 1304 -// span (trimmed of surrounding whitespace). Single-token values return the 1305 -// lexer's literal, sharing the source backing without a copy. 1306 1302 func (p *Parser) parseSubdirectiveValue() (string, token.Span) { 1307 1303 var b strings.Builder 1308 1304 var first, last token.Span ··· 1342 1338 return strings.TrimSpace(b.String()), token.Span{Start: first.Start, End: last.End} 1343 1339 } 1344 1340 1345 -// parseTextComment consumes a comment line whose marker ('#', '%' or '*') 1346 -// lexed as TEXT inside a directive block, building the comment from token 1347 -// literals. Tags are not extracted; the comment is one line. 1348 1341 func (p *Parser) parseTextComment() *ast.Comment { 1349 1342 s := p.cur.Span 1350 1343 marker := p.cur.Literal[0]