added rudimentary line number parser

This commit is contained in:
specCon18 2025-03-25 05:54:06 -04:00
parent 741dc336f7
commit fd8a954100
3 changed files with 144383 additions and 1119 deletions

30
main.go
View file

@ -1,6 +1,8 @@
package main package main
import ( import (
"regexp"
"strings"
"bufio" "bufio"
"os" "os"
"fmt" "fmt"
@ -8,6 +10,7 @@ import (
"fyne.io/fyne/v2/app" "fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/widget"
) )
func readFileLBL(file_path string) { func readFileLBL(file_path string) {
file, err := os.Open(file_path) file, err := os.Open(file_path)
if err != nil { if err != nil {
@ -27,13 +30,34 @@ func readFileLBL(file_path string) {
fmt.Println("Error reading file:", err) fmt.Println("Error reading file:", err)
return return
} }
fmt.Print(line) // Output the line parseGcodeLine(line) // Output the line
} }
} }
func parseGcode(){ func removeLineNumber(input string) string {
// Define the regex pattern for the prefix 'N' followed by one or more digits and an optional space
re := regexp.MustCompile(`^N\d+\s?`)
// Replace the matched prefix with an empty string
return re.ReplaceAllString(input, "")
} }
func parseGcodeLine(line string){
//TODO: P:0 convert string to struct
if strings.HasPrefix(line,"N"){
fmt.Println("--------------------")
fmt.Println("Line has line number")
fmt.Println("--------------------")
//l := removeLineNumber(line)
//parseGcodeLine(l)
} else if strings.HasPrefix(line, "G") {
fmt.Println("is a gcode")
} else if strings.HasPrefix(line,"M"){
fmt.Println("is a mcode")
} else if strings.HasPrefix(line,";"){
fmt.Println("is a comment")
}
}
func main() { func main() {
//Create a new app instance //Create a new app instance
a := app.New() a := app.New()

1117
test.gcode

File diff suppressed because it is too large Load diff

144355
test.gcode.orig Normal file

File diff suppressed because it is too large Load diff