Function: cperl-is-here-doc-p

cperl-is-here-doc-p is a byte-compiled function defined in cperl-mode.el.gz.

Signature

(cperl-is-here-doc-p START)

Documentation

Find out whether a "<<" construct starting at START is a here-document.

The point is expected to be after the end of the delimiter. Quoted delimiters after "<<" are unambiguously starting here-documents and are not handled here. This function does not move point but does change match data.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cperl-mode.el.gz
(defun cperl-is-here-doc-p (start)
  "Find out whether a \"<<\" construct starting at START is a here-document.
The point is expected to be after the end of the delimiter.
Quoted delimiters after \"<<\" are unambiguously starting
here-documents and are not handled here.  This function does not
move point but does change match data."
  ;; not a here-doc | here-doc
  ;; $foo << b;     | $f .= <<B;
  ;; ($f+1) << b;   | a($f) . <<B;
  ;; foo 1, <<B;    | $x{a} <<b;
  ;; Limitations:
  ;; foo <<bar is statically undecidable.  It could be either
  ;; foo() << bar # left shifting the return value or
  ;; foo(<<bar)   # passing a here-doc to foo().
  ;; We treat it as here-document and kindly ask programmers to
  ;; disambiguate by adding parens.
  (null
   (or (looking-at "[ \t]*(") ; << function_call()
       (looking-at ">>")      ; <<>> operator
       (save-excursion ; 1 << func_name, or $foo << 10
	 (condition-case nil
	     (progn
	       (goto-char start)
	       (forward-sexp -1) ;; examine the part before "<<"
	       (save-match-data
		 (cond
		  ((looking-at "[0-9$({]")
		   (forward-sexp 1)
		   (and
		    (looking-at "[ \t]*<<")
		    (condition-case nil
			;; print $foo <<EOF
			(progn
			  (forward-sexp -2)
			  (not
			   (looking-at cperl-here-doc-functions)))
		      (error t)))))))
	   (error nil)))))) ; func(<<EOF)