[Improve spell components parser clinton@unknownlamer.org**20080416224907 * Now handles all cases * Arcane/Divine magic alternatives are indicated via list structure * Bard only components are indicated via list structure * :see-text is appended to list if the components suggests looking at the spell description ] { hunk ./src/srd-import.lisp 18 - '(:greedy-repetition 1 nil - (:register (:greedy-repetition 1 2 :word-char-class))))) + (let ((spell-component-pattern + '(:register (:greedy-repetition 1 2 :word-char-class)))) + `(:greedy-repetition 1 nil + (:sequence + (:alternation :word-boundary :start-anchor) + ,spell-component-pattern + (:alternation + (:sequence "/" ,spell-component-pattern) + :word-boundary) + (:alternation + (:register " (Brd only)") + "")))))) + +(defparameter *spell-see-text-scanner* + (cl-ppcre:create-scanner + '(:sequence "; see text" :end-anchor))) hunk ./src/srd-import.lisp 91 - (ppcre:do-register-groups (component) (*spell-components-scanner* - spell-components-string - (nreverse components)) - (push component components)))) + (ppcre:do-register-groups (component divine-alternative bard?) + (*spell-components-scanner* + spell-components-string + (nreverse components)) + (cond (divine-alternative + (push (list :divine-alternative + component divine-alternative) components)) + (bard? (push (list :bard-only component) components)) + (t (push component components)))))) hunk ./src/srd-import.lisp 106 - (mapcar (lambda (component) - (cdr (assoc component srd-abbreviations :test #'string=))) - spell-components))) + (append + (mapcar (lambda (component) + (flet ((component-name->symbol (name) + (cdr (assoc name srd-abbreviations :test #'string=)))) + (if (consp component) + (ecase (car component) + (:divine-alternative + (list :divine-alternative + (component-name->symbol (second component)) + (component-name->symbol (third component)))) + (:bard-only (list + :bard-only + (component-name->symbol (second component))))) + (component-name->symbol component)))) + spell-components) + (if (ppcre:scan *spell-see-text-scanner* spell-components-string) + (list :see-text))))) }