added rudimentary line number parser
This commit is contained in:
parent
741dc336f7
commit
fd8a954100
3 changed files with 144383 additions and 1119 deletions
30
main.go
30
main.go
|
|
@ -1,6 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"bufio"
|
||||
"os"
|
||||
"fmt"
|
||||
|
|
@ -8,6 +10,7 @@ import (
|
|||
"fyne.io/fyne/v2/app"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
func readFileLBL(file_path string) {
|
||||
file, err := os.Open(file_path)
|
||||
if err != nil {
|
||||
|
|
@ -27,13 +30,34 @@ func readFileLBL(file_path string) {
|
|||
fmt.Println("Error reading file:", err)
|
||||
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() {
|
||||
//Create a new app instance
|
||||
a := app.New()
|
||||
|
|
|
|||
1117
test.gcode
1117
test.gcode
File diff suppressed because it is too large
Load diff
144355
test.gcode.orig
Normal file
144355
test.gcode.orig
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue