1(defun remove-double-string-from-delphi-mode()
2 (defconst delphi-strings
4 "Tokens that represent string literals.")
6 (defun delphi-literal-start-pattern (literal-kind)
7 ;; Returns the start pattern of the literal kind.
8 (cdr (assoc literal-kind
9 '((comment-single-line . "//")
10 (comment-multi-line-1 . "{")
11 (comment-multi-line-2 . "(*")
14 (defun delphi-literal-end-pattern (literal-kind)
15 ;; Returns the end pattern of the literal kind.
16 (cdr (assoc literal-kind
17 '((comment-single-line . "\n")
18 (comment-multi-line-1 . "}")
19 (comment-multi-line-2 . "*)")
22 (defun delphi-literal-stop-pattern (literal-kind)
23 ;; Returns the pattern that delimits end of the search for the literal kind.
24 ;; These are regular expressions.
25 (cdr (assoc literal-kind
26 '((comment-single-line . "\n")
27 (comment-multi-line-1 . "}")
28 (comment-multi-line-2 . "\\*)")
29 ;; Strings cannot span lines.
30 (string . "['\n]")))))
32 (defun delphi-parse-next-literal (limit)
33 ;; Searches for the next literal region (i.e. comment or string) and sets the
34 ;; the point to its end (or the limit, if not found). The literal region is
35 ;; marked as such with a text property, to speed up tokenizing during face
36 ;; coloring and indentation scanning.
37 (let ((search-start (point)))
38 (cond ((not (delphi-is-literal-end search-start))
39 ;; We are completing an incomplete literal.
40 (let ((kind (delphi-literal-kind (1- search-start))))
41 (delphi-complete-literal kind limit)
42 (delphi-set-text-properties
43 search-start (point) (delphi-literal-text-properties kind))))
46 "\\(//\\)\\|\\({\\)\\|\\((\\*\\)\\|\\('\\)"
47 limit 'goto-limit-on-fail)
48 ;; We found the start of a new literal. Find its end and mark it.
49 (let ((kind (cond ((match-beginning 1) 'comment-single-line)
50 ((match-beginning 2) 'comment-multi-line-1)
51 ((match-beginning 3) 'comment-multi-line-2)
52 ((match-beginning 4) 'string)))
53 (start (match-beginning 0)))
54 (delphi-set-text-properties search-start start nil)
55 (delphi-complete-literal kind limit)
56 (delphi-set-text-properties
57 start (point) (delphi-literal-text-properties kind))))
59 ;; Nothing found. Mark it as a non-literal.
60 ((delphi-set-text-properties search-start limit nil)))
61 (delphi-step-progress (point) "Parsing" delphi-parsing-progress-step)))