Fixed bug where comments were not properly ignored
This commit is contained in:
11
masm/main.go
11
masm/main.go
@@ -72,6 +72,10 @@ func main () {
|
||||
for lineNumber := 0; inputScanner.Scan(); lineNumber ++ {
|
||||
tokens := strings.Fields(inputScanner.Text())
|
||||
if len(tokens) == 0 { continue }
|
||||
if tokens[0][0] == '/' {
|
||||
// skip line if it is a comment
|
||||
continue
|
||||
}
|
||||
|
||||
statement, err := parseStatement(tokens)
|
||||
statement.lineNumber = lineNumber
|
||||
@@ -128,7 +132,7 @@ func main () {
|
||||
// for _, statement := range statements {
|
||||
// fmt.Println(statement)
|
||||
// }
|
||||
//
|
||||
|
||||
// for symbol, address := range symbolTable {
|
||||
// fmt.Println(symbol, address)
|
||||
// }
|
||||
@@ -195,11 +199,6 @@ func main () {
|
||||
}
|
||||
|
||||
func parseStatement (tokens []string) (statement Statement, err error) {
|
||||
if tokens[0][0] == '/' {
|
||||
// skip line if it is a comment
|
||||
return
|
||||
}
|
||||
|
||||
// get label if it exists
|
||||
possibleLabel := tokens[0]
|
||||
if possibleLabel[len(possibleLabel) - 1] == ',' {
|
||||
|
||||
Reference in New Issue
Block a user