<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>I don’t think it has to map  the elements of the expanded code to anything, it just has to use the source location information already stored in the syntax objects.</div><div><br></div><div>For example this draws an arrow from <font face="Courier New">from-loc-stx</font> to <font face="Courier New">to-loc-stx</font>:</div><div><br></div><div><div><font face="Courier New">#lang racket</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(begin-for-syntax</font></div><div><font face="Courier New">  (define (orig stx)</font></div><div><font face="Courier New">    (syntax-property stx 'original-for-check-syntax #t))</font></div><div><font face="Courier New">  )</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define-syntax (draw-arrow stx)</font></div><div><font face="Courier New">  (let ([sym 'sym]</font></div><div><font face="Courier New">        [from-loc #'from-loc-stx]</font></div><div><font face="Courier New">        [to-loc #'to-loc-stx])</font></div><div><font face="Courier New">    (with-syntax ([from (orig (datum->syntax stx sym from-loc))]</font></div><div><font face="Courier New">                  [to (orig (datum->syntax stx sym to-loc))])</font></div><div><font face="Courier New">    #'(let ([from 0])</font></div><div><font face="Courier New">        to</font></div><div><font face="Courier New">        (void)))))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(draw-arrow)</font></div></div><div><br></div><div>Or you can even do something like this, where it can point to any source location:</div><div>(this one happens to point to the syntax in begin-for-syntax, but you could potentially get it to point to anything)</div><div><br></div><div><div><font face="Courier New">#lang racket</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(begin-for-syntax</font></div><div><font face="Courier New">  (define (orig stx)</font></div><div><font face="Courier New">    (syntax-property stx 'original-for-check-syntax #t))</font></div><div><font face="Courier New">  )</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define-syntax (draw-arrow stx)</font></div><div><font face="Courier New">  (let ([sym 'sym]</font></div><div><font face="Courier New">        [from-loc (list (syntax-source #'this) 3 11 26 6)] ;line: 3, column: 11, position: 26, span: 6</font></div><div><font face="Courier New">        [to-loc #'to-loc])</font></div><div><font face="Courier New">    (with-syntax ([from (orig (datum->syntax stx sym from-loc))]</font></div><div><font face="Courier New">                  [to (orig (datum->syntax stx sym to-loc))])</font></div><div><font face="Courier New">    #'(let ([from 0])</font></div><div><font face="Courier New">        to</font></div><div><font face="Courier New">        (void)))))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(draw-arrow)</font></div></div><br><div><div>On Jun 20, 2014, at 5:07 PM, Jonker, Todd <<a href="mailto:jonker@amazon.com">jonker@amazon.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">

<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">

<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;">
<div>Greetings,</div>
<div><br>
</div>
<div>I’m interested in learning how DrRacket’s “Check Syntax” feature works.</div>
<div><br>
</div>
<div>As I understand it, the process is (1) perform full macro-expansion on the source code; (2) map elements of the expanded code back to the source code; (3) use that mapping to apply annotations/markup to the source code. The documentation at
<a href="http://docs.racket-lang.org/tools/Check_Syntax.html">http://docs.racket-lang.org/tools/Check_Syntax.html</a> seems to cover step (3), but I’m struggling to understand how (2) works.</div>
<div><br>
</div>
<div>In other words, I’m trying to learn how the lexical information in the expanded syntax objects is mapped back to the appropriate parts of the original syntax objects. I’m reading the code to try to figure out the algorithm but hoping that there’s a paper
 that describes it more directly.</div>
<div><br>
</div>
<div>Thanks in advance for any pointers,</div>
<div><br>
</div>
<div>--Todd</div>
<br>
</div>

____________________<br>  Racket Users list:<br>  <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br></body></html>