Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
Improved some regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Pes committed Jun 19, 2018
1 parent 3619502 commit 5ffc6d7
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions gendoxy.el
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
;;; gendoxy.el --- Generate doxygen documentation from C declarations

;; Copyright (C) 2018 Michele Pes

;; Author: Michele Pes <[email protected]>
;; Created: 21 May 2018
;; Created: 23 June 2018
;; Keywords: gendoxy, docs, doxygen
;; Version: 1.0
;; Version: 1.0.2
;; Homepage: https://github.com/mp81ss/gendoxy

;; This file is not part of GNU Emacs.

;; Copyright (c) <2018> <Michele Pes>

;; All rights reserved.
Expand Down Expand Up @@ -46,7 +46,7 @@


;;; Commentary:

;; This package provides some commands to generate doxygen documentation.
;; The main command is: 'gendoxy-tag'. It generates the documentation for
;; a C declaration (typedef, variable, struct, enum or function). Moreover, it
Expand All @@ -70,6 +70,10 @@

;;; Change log:
;;
;; 1.0.2
;; Critical bugfix on invalid C code invocation (due to regex backtracking)
;; Improved other regex
;;
;; 1.0.1
;; Fixed bug on structures
;; Optimized custom parameter documentation generation
Expand All @@ -80,6 +84,7 @@

;;; Code:


(defvar gendoxy-backslash nil
"If not nil, backslash will be used instead of asperand")

Expand All @@ -99,16 +104,16 @@
(if gendoxy-backslash (string (?\\)) (string ?@))
"The doxygen tag char, backslash or asperand (default)")

(defconst gendoxy-space-regex "[ \f\t\n\r\v]" "All blanks")
(defconst gendoxy-space-regex "[ \t\v\r\f\n]" "All blanks")

(defconst gendoxy-space-ptr-regex "[ \f\t\n\r\v\\*]" "All blanks plus pointer")
(defconst gendoxy-space-ptr-regex "[ \t\v\r\f\n\\*]" "All blanks plus pointer")

(defconst gendoxy-c-id-regex "_*[[:alpha:]]+[A-Z0-9a-z_]*"
(defconst gendoxy-c-id-regex "[[:alpha:]_][[:alnum:]_]\\{0,30\\}"
"C identifier regex")

(defconst gendoxy-macro-regexp
(concat "^[[:space:]]*#[[:space:]]*define[[:space:]]+"
"\\(" gendoxy-c-id-regex "\\([[:space:]]*(.*)\\)?\\)")
"\\(" gendoxy-c-id-regex "\\([[:space:]]*(.+)\\)?\\)")
"Regular expression for #define ... macros returning new defined symbol")

(defconst gendoxy-function-pointer-name-regex
Expand Down Expand Up @@ -449,7 +454,7 @@
(gendoxy-dump-parameters (seq-drop parameters 3)))))

(defun gendoxy-find-last (str pattern &optional index)
"Find last occurrence of pattern in str"
"Find last occurrence of pattern in str. Pattern must be one character"
(let ( (found (string-match pattern str (if index (1+ index) 0))) )
(if found (gendoxy-find-last str pattern found) index)))

Expand Down

0 comments on commit 5ffc6d7

Please sign in to comment.