Skip to content

Commit

Permalink
Improve alignment token generation
Browse files Browse the repository at this point in the history
  • Loading branch information
peng committed Mar 17, 2024
1 parent 5bacf1a commit 017c5a2
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 62 deletions.
14 changes: 8 additions & 6 deletions nfp.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,18 +444,20 @@ func (ps *Parser) getTokens() Tokens {
}

if ps.currentChar() == Underscore {
if ps.nextChar() == ParenOpen || ps.nextChar() == ParenClose {
if ps.Token.TType != "" {
ps.Tokens.add(ps.Token.TValue, ps.Token.TType, ps.Token.Parts)
}
ps.Token.TValue = ps.nextChar()
ps.Token.TType = TokenTypeAlignment
if ps.Token.TType != "" {
ps.Tokens.add(ps.Token.TValue, ps.Token.TType, ps.Token.Parts)
}
ps.Token.TValue = Whitespace
ps.Token.TType = TokenTypeAlignment
ps.Offset += 2
continue
}

if ps.currentChar() == Asterisk {
if ps.Token.TValue != "" {
ps.Tokens.add(ps.Token.TValue, ps.Token.TType, ps.Token.Parts)
ps.Token = Token{}
}
ps.Tokens.add(ps.nextChar(), TokenTypeRepeatsChar, ps.Token.Parts)
ps.Token = Token{}
ps.Offset += 2
Expand Down
Loading

0 comments on commit 017c5a2

Please sign in to comment.