MCPcopy Index your code
hub / github.com/256dpi/gcode / ParseFile

Function ParseFile

parse.go:13–37  ·  view source on GitHub ↗

ParseFile will parse a whole G-Code file from the passed reader.

(r io.Reader)

Source from the content-addressed store, hash-verified

11
12// ParseFile will parse a whole G-Code file from the passed reader.
13func ParseFile(r io.Reader) (*File, error) {
14 s := bufio.NewScanner(r)
15
16 // prepare file
17 file := &File{}
18
19 // read line by line
20 for s.Scan() {
21 // parse lin
22 line, err := ParseLine(s.Text())
23 if err != nil {
24 return file, err
25 }
26
27 // add line
28 file.Lines = append(file.Lines, line)
29 }
30
31 // check error
32 if err := s.Err(); err != nil {
33 return file, err
34 }
35
36 return file, nil
37}
38
39// ParseLine will parse the specified string as a line of G-Codes.
40func ParseLine(s string) (Line, error) {

Callers 4

loadFileFunction · 0.92
TestParseFunction · 0.85
TestParseInvalidFunction · 0.85
TestWriteFileFunction · 0.85

Calls 1

ParseLineFunction · 0.85

Tested by 3

TestParseFunction · 0.68
TestParseInvalidFunction · 0.68
TestWriteFileFunction · 0.68