Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DQNEO committed Jul 10, 2023
1 parent 8814b98 commit b77d1ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ func TestEncodeStringAsText(t *testing.T) {

{"multi statements", "nop;ret;leave;", []byte{0x90, 0xc3, 0xc9}},

{"movq 64", "movq $1, %rax", []byte{0x48, 0xc7, 0xc0, 0x01, 0x00, 0x00, 0x00}},
{"movb", "movb %al, 0(%rsi)", []byte{0x88, 0x06}},
{"movw", "movw %ax,0(%rsi)", []byte{0x66, 0x89, 0x06}},
{"movl", "movl $3, %eax", []byte{0xb8, 0x03, 0, 0, 0}},
{"movq 64", "movq $3, %rax", []byte{0x48, 0xc7, 0xc0, 0x03, 0x00, 0x00, 0x00}},
{"callq myfunc", "callq myfunc", []byte{0xe8, 0, 0, 0, 0}},

{"andq", "andq %rax, %rcx", []byte{0x48, 0x21, 0xc1}},
Expand Down
6 changes: 6 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,16 @@ func (p *parser) assert(bol bool, errorMsg string) {
func (p *parser) consumeEOL() {
if p.source[p.idx] == '#' {
p.expect('#')
// In a comment, ';' has no role. Just skip till the first '\n'
for ; p.source[p.idx] != '\n'; p.idx++ {
}
} else if p.source[p.idx] == '/' {
// expect "//" comment
p.expect('/')
p.expect('/')
// In a comment, ';' has no role. Just skip till the first '\n'
for ; p.source[p.idx] != '\n'; p.idx++ {
}
}

for ; !isStatementTerminator(p.source[p.idx]); p.idx++ {
Expand Down

0 comments on commit b77d1ff

Please sign in to comment.