;; operators
(cond ((char=? c #\+)
(define n (string->number p-tok)) ; partial token is completed
(if n
(return (cons n
(cons #'+
(parse-superscript-token-s0 nxt)))) ; continue the parsing of tokens
(error "Error parsing superscript : state2-number : bad format of string that can not be converted in number: " p-tok))
;; todo continue here
((char=? c #\-)
...
where i deal with basic arithmetic operators (+,-,*,/) and in each conditional branch the code is almost the same but i do not think there is a way in Scheme to factorize it, i mean i wanted to replace #'+ by something generic where i can construct the syntax object from the c character (of course this would not be exactly the same syntax object as syntax object take in account the line the character position in code but that does not matters) but i do not think it is possible.
I do not think i would have a solution at this problem, note i do not want a racket solution if it exists but a scheme compatible one. I'm facing this little problem in a recurrent way, so perheaps i missed something.....but that would surprise me a lot...
Regards,
update: i updated the code because there was error (unrelated with the question)
but i do not know what put in place of 'something' relative to the + operator (i can not put + because i would have to write it then for each operator, +,-,....)
Strange is that 'something' doesn not appear anymore in the syntax info box.
But i will try that, and see how it behave in real code....
No it does not seems to works , give (syntax #+) but not (syntax +)
Yes, you need to convert the character to a symbol. See
Identifiers stripped in this manner are converted to their symbolic names
just below syntax->datum in the same link.
This can be done like the code you wrote (datum->syntax #'here (string->symbol (string ch))) or (datum->syntax #'here (string->symbol (format "~a" ch))). This will create the equivalent of #'+ (modulo source locations).