Parser fixes#20
Open
knivey wants to merge 5 commits into
Open
Conversation
chzchzchz
requested changes
Jan 3, 2025
| case '\n': | ||
| bold, underline, strikethrough, italic = false, false, false, false | ||
| cells = append(cells, row) | ||
| chompState, fg, bg = 0, -1, -1 |
Owner
There was a problem hiding this comment.
chompState, fg, bg, fgs, bgs := 0, -1, -1, 0, 0 so it matches the initialization at the beginning of the function
| if v == ',' { | ||
| chompState, bg = 2, -1 | ||
| continue | ||
| if len(dat) > i+1 && dat[i+1] >= '0' && dat[i+1] <= '9' { |
Owner
There was a problem hiding this comment.
peaking ahead like this breaks the fsm formulation; I think the handling should be in case 2 as like if v >= ... {} else if bgs == 0 { chompState = 0; break }
| s := "hello \x0315,01hello" | ||
| // 012345 6789 | ||
| a, _ := NewASCII(s) | ||
| if c := a.Get(2, 0); c == nil || c.Value != 'l' { |
Owner
There was a problem hiding this comment.
Too much repetition-- idiomatic go uses a table driven test pattern like https://github.com/chzchzchz/sitbot/blob/master/msl/grammar_test.go#L49
Struct would be like
struct {
input string
col []int
expected []Cell
}Driver would be like
for _, tt := range tests {
a, _ := NewAscii(tt.input);
for i := range tt.col {
c := a.Get(tt.col[i], 0)
if c == nil || c != tt.expected[i] {
t.Errorf("got %+v, want %+v at %d for %q", c, tt.expected[i], tt.col[i], tt.input)
}
}| } | ||
| case 1: | ||
| if v == '\x03' { | ||
| if fgs > 0 { |
Owner
There was a problem hiding this comment.
if fgs == 0 { bg = -1 }
fg, fgs = -1, 0
continue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.