> The next hurdle is the following unusual syntax:
> r'some string or regexp'
I don't know python at all and I am not sure I clearly understand the
problem. Does it concern handling of "raw-strings" of the form
Maybe could you provide some code snippets?
To handle raw-strings I (quickly ;-) wrote the following
`semantic-flex-extensions' that seems to work:
(defconst wisent-python-raw-string-re "\\<[r]\""
"Regexp matching python raw string prefix.")
(list (cons wisent-python-raw-string-re
"`semantic-flex-extensions' to recognize python raw strings.")
(defun wisent-python-flex-raw-string ()
"`semantic-flex' extension to handle python raw-strings.
Return a 'raw-string syntactic token."
(let* ((b (point))
(e (condition-case nil
(forward-char) ;; skip 'r'
;; This case makes flex
;; robust to broken strings.
(cons 'raw-string (cons b e))))
Then 'raw-string tokens can be easily handled by a specific
`wisent-flex' handler like this (untested):
;; %token <raw-string> RAW_STRING_LITERAL
;; %put raw-string handler 'wisent-python-raw-string-handler
(defun wisent-python-raw-string-handler ()
"`wisent-flex' handler of 'raw-string syntactic tokens."
(let* ((stok (car wisent-flex-istream))
(wisent-flex-istream (cdr wisent-flex-istream)))
;; Remove r" and " delimiters
(substring (semantic-flex-text stok) 2 -1)
I think it can be interesting to differentiate normal strings
(their value should be `read' to remove '\') and raw strings (their
value is the text between r" and the final ", and '\' aren't removed).
I hope I helped ;-)