Folks,

I am writing a parser that will eventually take a string syntax object
to parse. I want to report errors where they are in the source file;
and with port-count-lines, and a bit of basic arithmetic, I should be
able to do this trivially. Except... for simple tests I will be using
quoted strings; but in anger, I will be using here strings.

;; ---------------------------------------------------------------------
#lang racket
(define-syntax (wheres-my-string stx)
  (syntax-case stx ()
    [(_ s)
     (eprintf "col: ~a span: ~a (string-length ~a) ~s~%"
              (syntax-column #'s)
              (syntax-span #'s)
              (string-length (syntax-e #'s))
              #'s)
     #'s]))


(wheres-my-string "abc")

(wheres-my-string #<<$
abc
$
                  )
;; ---------------------------------------------------------------------

My stderr output is:
col: 18 span: 5 (string-length 3) #<syntax:...>
col: 18 span: 10 (string-length 3) #<syntax:...>

The syntax objects, when printed in DrRacket don’t have anything more
to distinguish an ordinary string from an inline string.

Aside from (- span string-length) being 2 or >= 7, is there any better
way to identify the here string?

Thanks,

Tim

PS: Ow, I’ve just thought; I’ve got a similar problem with:

  (parse "'Hello\", said John")

and its #\\ quoting. Does anyone have any ideas about this

-- 
Tim Brown CEng MBCS <tim.br...@cityc.co.uk>
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                City Computing Limited · www.cityc.co.uk
      City House · Sutton Park Rd · Sutton · Surrey · SM1 2AE · GB
                T:+44 20 8770 2110 · F:+44 20 8770 2130
────────────────────────────────────────────────────────────────────────
City Computing Limited registered in London No:1767817.
Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE
VAT No: GB 918 4680 96

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to