code: func (p *Parser) parseRegex() (*RegexLiteral, error) {
  	nextRune := p.peekRune()
  	if isWhitespace(nextRune) {
  		p.consumeWhitespace()
  	}
  
  	// If the next character is not a '/', then return nils.
  	nextRune = p.peekRune()
  	if nextRune != '/' {
  		return nil, nil
  	}
  
  	tok, pos, lit := p.s.ScanRegex()
  
  	if tok == BADESCAPE {
  		msg := fmt.Sprintf("bad escape: %s", lit)
  		return nil, &ParseError{Message: msg, Pos: pos}
  	} else if tok == BADREGEX {
  		msg := fmt.Sprintf("bad regex: %s", lit)
  		return nil, &ParseError{Message: msg, Pos: pos}
  	} else if tok != REGEX {
  		return nil, newParseError(tokstr(tok, lit), []string{"regex"}, pos)
  	}
  
  	re, err := regexp.Compile(lit)
  	if err != nil {
  		return nil, &ParseError{Message: err.Error(), Pos: pos}
  	}
  
  	return &RegexLiteral{Val: re}, nil
  }
docs: // parseRegex parses a regular expression.