Running Code from Chapter 3

67 views
Skip to first unread message

sala limo

unread,
Oct 6, 2011, 1:50:23 AM10/6/11
to EOPL3
Hi all,

I am new to DrRacket and I would like to know how to run the tests for
the language Let in chapter 3.

I am basically asking how to run these files to evaluate one or more
Let expressions. So it is a setup issue and tool usage rather than a
conceptual issue.

Any guidance or documentation on how to do that would be greatly
appreciated.

Thanks in advance.


Marco Morazan

unread,
Oct 6, 2011, 11:55:56 AM10/6/11
to eo...@googlegroups.com
The first line in your file should be: #lang eopl

After the above, you can type in the program you wish to use for
evaluation in the definitions window. Hit run. To evaluate an
expression type it in the interactions window.

I use a wrapper function around value-of-program:

;; eval : String -> ExpVal
(define (eval string)
(value-of-program (scan&parse string)))

After hitting run:

Welcome to DrRacket, version 5.1.3 [3m].
Language: eopl; memory limit: 128 MB.
> (eval "let x = 2 in -(x, 2)")
#(struct:num-val 0)
>

I hope this helps.

Marco

> --
> You received this message because you are subscribed to the Google Groups "EOPL3" group.
> To post to this group, send email to eo...@googlegroups.com.
> To unsubscribe from this group, send email to eopl3+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/eopl3?hl=en.
>
>

--

Cheers,

Marco

sala limo

unread,
Oct 7, 2011, 2:58:11 AM10/7/11
to EOPL3
Thanks a lot. I went about it in a similar way. I basically type this:
(require "top.scm")
and then (run "...")

i think the same functions u mentioned above are in those files.

thanks

sala limo

unread,
Oct 7, 2011, 3:03:35 AM10/7/11
to EOPL3
If you are creating a grammar for a language and lets say you already
have a grammar defined. its an expression that adds two numbers like
+ (1,1)

now you want to create a grammar for another expression lets say
*(exp1, exp2...expn) where each expi is of this format: + (1,1).

how can that be done?

or the more general form of the question, how can you build a grammar
for a language based on existing defined expressions.

and how can you recursively nest such expressions.

Thanks again.
Reply all
Reply to author
Forward
0 new messages