INDAPlus21 / INDAPlus21/alholmbe-assembly

Pass

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

**Very well done Alexander!**

You are well set for DD1396! How sweet!

I like your solution! Thou I'm curious, why do you parse the code in string, and not use enum representations? Enum types are numerical, thus are a lot more efficient to compare etc. For example:
_Your code_:
```go
var registerType = []string{"add", "sub", "set", "jeq"}
var jumpType = []string{"j"}
var specialType = []string{"input", "print", "exit"}
```
_As enum types_:
```go
type RegisterInstr int
const (
Add RegisterInstr = iota + 1
Sub
Set
Jeq
)

type JumpInstr int
const J JumpInstr = 1

type SpecialInstr int
const (
Input SpecialInstr = iota + 1
Print
Exit
)
```

See enum types: https://gosamples.dev/enum/

Your `splitIntoLines` makes it difficult to acctually trace errors. `instructionsAreValid` handles the instructions as if there are no empty lines in the source code, which there are. I even found this beauty :)
_Your code_:
```go
var j int
for j = 1; j < 3; j++ {
//...
if /*...*/ {
fmt.Printf("Error on line %d: Missing '#'\n", j+1)
//...
}
}
```
I suggest that the trimmer function returns a sequence of tuples, whom hold an instruction and the instruction's origin line.

Thank you for your hard work :)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the splitIntoLines and instructionsAreValid functions mentioned in the issue. Preserve each instruction's original source line when trimming input, and review the instruction representation so validation and error reporting handle empty lines correctly; done means errors identify the actual source line.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.