Hello Good People<br><br>I have the task to make the translator from metalanguage A to the metalanguage B.<br>My app should open file &quot;a.ss&quot;, parse and translate to the file &quot;b.ss&quot;.<br>At the translation time the app should:<br>

<br>1) Expand all macro definitions of the file &quot;a.ss&quot; and evaluate all definitions witch are just a<br>scheme.<br>2) Generate the s-record structure witch represent the content of &quot;b.ss&quot;<br>3) In case if the &quot;a.ss&quot; have a syntax errors - printout error message with the line number <br>

at the file &quot;a.ss&quot; and the expression where  happen the error.<br><br>For example:<br>File: &lt;a.ss&gt; ---------------------------------------------------------------------<br><br>(define-syntax foo <br>   ;; This is macro definition in the &#39;a&#39; file<br>

)<br><br>(define (bar ...) <br>   ;; This is a function definition of the &#39;a&#39; file<br>)<br><br>;; meta language expression<br>(define-fsm <br>   :name &quot;trigger&quot;<br>   (define-state <br>      :name &quot;zero&quot;<br>

       (on-event &quot;switch&quot;<br>          (foo ...)   ;; use macro definition<br>          (go &quot;one&quot;)))<br>   (define-state<br>      :name &quot;one&quot; ;;; N.B. the scheme expression can be used anywhere there can be (string-append &quot;on&quot; &quot;e&quot;) <br>

       (on-event &quot;switch&quot;<br>
          (foo ...)   ;; call the function <br>          (go &quot;one&quot;)))))<br><br>Eof File &lt;a.ss&gt; ---------------------------------------------------------------------<br><br>In case if was used not valid keyword &quot;define-fsmZ&quot; the error message should be:<br>

<br>a.ss:L:C: unknown symbol &quot;define-fsmM&quot; in:   (define-fsmZ :name &quot;trigger&quot; (define-state ....<br><br>Where L and C are line and column numbers.<br><br>The easiest way to do this task can be: Just evaluate the file &quot;a.ss&quot; in the name space <br>

where are defined methods &quot;define-fsm&quot;, &quot;define-state&quot;, &quot;on-event&quot; and &quot;go&quot;<br><br>But this case each of those methods will not have the syntax object of the evaluated expression.<br>

And in case if it will find and error it could not message about error&#39;s location. <br><br>Alternative way is to use syntax-case instead methods for the &quot;define-fsm&quot;, &quot;define-state&quot;, &quot;on-event&quot; <br>

and &quot;go&quot; definitions. The body of macro will have the syntax object for an expression. <br><br>(define-syntax (define-fsm stx)<br>  (syntax-case stx ()<br>    [(_ params ...) <br>       (let ([name (get-name stx)])  ;;; the method &#39;get-name&#39; will return extracted name from the syntax<br>

         #&#39;(&#39;fsm name))]))  ;;; this is expression of language B<br><br>This code will not work because macro expansion could not have access to variable &#39;name&#39;<br>And I do not know how resolve this issue.<br>

<br>Another alternative is: to use the patterns like a:<br><br>(define-syntax (define-fsm stx)<br>  (syntax-case stx (:name)<br>    [(_ :name name 
params ...) <br>       #&#39;(&#39;fsm name)]))<br><br>But in case if there are will be bunch of parameters in random order:<br><br>:name ... :param1 ... :param2 ... etc<br>or <br>:param2 ... :name ... :param1 ... etc<br>

<br>As result the body of the macro can be awkward.<br><br>I spent already allot of time to make this task. And I have several variants of translator. None of them is good.<br>I am not a good scheme programmer and have no any friend who can help. That is why I address my question <br>

to the Racket community:<br><br>   &quot;What is the best way to make this task with scheme?&quot;<br><br clear="all">-- Valeriya<br>