<div><br><div class="im"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div>
> name space<br>
> where are defined methods "define-fsm", "define-state", "on-event"
and "go"<br>
><br>
> But this case each of those methods will not have the syntax object
of the<br>
> evaluated expression.<br>
> And in case if it will find and error it could not message about
error's<br>
> location. The easiest way to do this task can be: Just evaluate the file
"a.ss" in the<br></div></blockquote><div> <br>Noel Welsh <span dir="ltr"></span>wrote:
<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Have you tried eval-syntax, instead of eval? I think that will
keep<br>
location information.<br></blockquote></div></div><br><br>How? <br><br>(eval-syntax
(file->syntax "a.ss"))<br><br>lets imagine the function 'define-fsm'
was called. And "some-condition?" informs that there are syntax error
in the source expression. How i can printout the line and column number
of the source expression?<br>
<br>(define (define-fsm params)<br> (if (some-condition? params) <br>
(display "error message" ????? )<br> )<br>)<br><br>Noel Welsh <span dir="ltr"></span>
wrote:<br>> Look up read-syntax.<br>
<div class="im"><br>
Yes, In my example file->syntax was somthing like<br>
<br>
(define
(file->syntax file-name)<br>
;; read the file and convert it to the
syntax object<br>
(let* ([in (open-input-file file-name)])<br>
(port-count-lines! in)<br>
(begin0<br>
(let loop ([rs '()] <br>
[r
(read-syntax file-name in)])<br>
(if (eof-object? r)<br>
(reverse rs)<br>
(loop (cons r rs) (read-syntax file-name
in))))<br>
(close-input-port in)<br>
)))<br>
<br>Noel Welsh <span dir="ltr"><<a href="mailto:noelwelsh@gmail.com" target="_blank">noelwelsh@gmail.com</a>></span>
wrote:<br>> lets imagine the function 'define-fsm' was called. And
"some-condition?"<br>
> informs that there are syntax error in the source expression. How i
can<br>
> printout the line and column number of the source expression?<br>
<br>
</div><a href="http://docs.racket-lang.org/unstable/Source_Locations.html" target="_blank">> http://docs.racket-lang.org/unstable/Source_Locations.html</a><br>
<font color="#888888"><br><br></font>The question is: when in
the eval-synax process there will be called some function how that
function can to reffer to the current syntax-object?<br><br>Noel Welsh <span dir="ltr"></span>wrote:
<br>
> foo.ss:<br>
<br>
> (foo 1 2)<br>
<br>> Code:<br>
<br>
> (with-input-from-file "foo.ss"<br>
> (lambda ()<br>
> (parameterize ([error-display-handler (lambda (name . stuff)<br>
> (printf "Got ~a ~a\n" name stuff))])<br>
> (eval-syntax (read-syntax 'foo.ss)))))<br>
<br>
> Output:<br>
<br>> Got foo.ss::0: compile: unbound identifier (and no #%app syntax<br>
> transformer is bound) at: foo in: (foo 1 2) (#(struct:exn:fail:syntax<br>
> foo.ss::0: compile: unbound identifier (and no #%app syntax<br>
> transformer is bound) at: foo in: (foo 1 2)
#<continuation-mark-set><br>
> (#<syntax::2 foo>)))<br>
<br>
> So the exception structure has the syntax object you want.<br>
<font color="#888888"><br></font><font color="#888888"><span style="color: rgb(0, 0, 0);">There are two issues. <br><br>First</span>:<br><br><span style="color: rgb(0, 0, 0);">what if the file foo.ss will have defined function foo.</span><br style="color: rgb(0, 0, 0);">
<br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);">(define (foo a b) (+ a b)))</span><br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);">(foo 1 2)</span><br style="color: rgb(0, 0, 0);"><br style="color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0);">It makes error:</span><br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);"> Got compile: unbound identifier (and no #%app syntax transformer is bound) (#(struct:exn:fail:syntax compile: unbound identifier (and no #%app syntax transformer is bound) #<continuation-mark-set> </span><br style="color: rgb(0, 0, 0);">
<br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);">Second:</span><br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);">When function foo is defined correctly and called from the eval process and errors occurs in foo, how can we find the caller's location in order to format an error message?</span><br style="color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0);"></span><br><br clear="all"></font>-- Valeriya<br>