MCPcopy Index your code
hub / github.com/gopherdata/gophernotes / checkComplete

Function checkComplete

kernel.go:385–415  ·  view source on GitHub ↗

checkComplete checks whether the `code` is complete or not.

(code string, ir *interp.Interp)

Source from the content-addressed store, hash-verified

383
384// checkComplete checks whether the `code` is complete or not.
385func checkComplete(code string, ir *interp.Interp) (status, indent string) {
386 status, indent = "unknown", ""
387
388 if len(code) == 0 {
389 return status, indent
390 }
391 readline := base.MakeBufReadline(bufio.NewReader(strings.NewReader(code)))
392 for {
393 _, _, err := base.ReadMultiline(readline, base.ReadOptions(0), "")
394 if err == io.EOF {
395 return "complete", indent
396 } else if err == io.ErrUnexpectedEOF {
397 return "incomplete", indent
398 } else if err != nil {
399 return "invalid", indent
400 }
401 }
402
403 var parser mp.Parser
404 g := ir.Comp
405 parser.Configure(g.ParserMode, g.MacroChar)
406 parser.Init(g.Fileset, g.Filepath, g.Line, []byte(code))
407
408 _, err := parser.Parse()
409 if err != nil {
410 status = "invalid"
411 } else {
412 status = "complete"
413 }
414 return status, indent
415}
416
417// handleIsCompleteRequest sends a is_complete_reply message.
418func (kernel *Kernel) handleIsCompleteRequest(receipt msgReceipt) error {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected