infparse_nocomment.go 675 B

123456789101112131415161718192021222324
  1. // Start() commences the background infinite loop of parsing
  2. func (p *Parser) Start() {
  3. go func() {
  4. defer close(p.Done)
  5. expressions := make([]Sexp, 0, SliceDefaultCap)
  6. for {
  7. expr, err := p.parseExpression(0)
  8. if err != nil || expr == SexpEnd {
  9. if err == ParserHaltRequested {
  10. return
  11. }
  12. err = p.getMoreInput(expressions, err) // SexpEnd means we need more input
  13. if err == ParserHaltRequested {
  14. return
  15. }
  16. expressions = make([]Sexp, 0, SliceDefaultCap)
  17. } else {
  18. expressions = append(expressions, expr)
  19. }
  20. }
  21. }()
  22. }