100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Samenvatting hoofdstuk 7: Evaluator met Expliciete Controle

Rating
-
Sold
-
Pages
11
Uploaded on
27-07-2022
Written in
2019/2020

Dit is de samenvatting van het zevende hoofdstuk van het vak Interpretatie van Computerprogramma's I. In deze samenvatting werd zowel alle informatie uit de slides als bijkomende informatie uit eigen notities opgenomen. Aan het einde van de samenvatting werden ook de herhalingsvragen opgelost EINDRESULTAAT: 16/20

Show more Read less
Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Connected book

Written for

Institution
Study
Course

Document information

Summarized whole book?
No
Which chapters are summarized?
Hoofdstuk 5.4
Uploaded on
July 27, 2022
Number of pages
11
Written in
2019/2020
Type
Summary

Subjects

Content preview

Hoofdstuk 7: Evaluator met expliciete
controle
1 Motivatie
• In de evaluatoren tot nu toe: volgorde waarin de operands van een functie-applicatie worden
geëvalueerd hangt af van de implementatie van cons
o Cons is primitief dus we zijn afhankelijk van iemand anders zijn implementatie van
cons
• Met deze evaluator wordt de volgorde waarin operands geëvalueerd worden veel explicieter.
o Verder ook duidelijk hoe staartrecursie-optimalisatie werkt
• Geïmplementeerd als registermachine
o Evaluator voor Scheme in registermachinetaal, bovenop simulator voor
registermachinetaal geschreven in Scheme, bovenop DrRacket

2 Definitie van registermachine voor ec-eval
(define eceval
(make-machine
'(exp env val proc argl continue unev)
Lijst van benodigde registers
eceval-operations
Hulpprocedures van de meta-circulaire evaluator zijn beschikbaar als
primitieven
'(
read-eval-print-loop

registermachinecode
)))

• exp bevat de te evalueren uitdrukking
• env bevat de omgeving waarbinnen de evaluatie gebeurt
o pointer naar de omgeving
• val bevat de uit evaluatie resulterende waarde
• continue ondersteunt verschillende sprongen naar zelfde subroutine
o enorm belangrijk voor implementatie
• proc bevat het procedure-object waarnaartoe een operator evalueert
• unev bevat een lijst van nog te evalueren expressies (bv. operanden)
• argl bevat de waarden waarnaartoe een lijst van operanden evalueert




1

, 3 Implementatie van read-eval-print lus
(define (get-global-environment)
the-global-environment)

read-eval-print-loop
(perform (op initialize-stack))
Nieuwe aanroep v/d REPL --> stack opnieuw initialiseren waardoor
brol van vorige uitvoeringen weg is.
(perform (op prompt-for-input) (const ";;; EC-Eval input:"))
Vragen naar invoer gebruiker
(assign exp (op read))
Exp = wat de gebruiker ingeeft
(assign env (op get-global-environment))
Env terug op globale omgeving zetten
(assign continue (label print-result))
Cont begint op subroutine print-result
(goto (label eval-dispatch))
Sprong naar subroutine eval-dispatch
print-result
(perform (op announce-output) (const ";;; EC-Eval value:"))
(perform (op user-print) (reg val))
Uitprinten van resultaat = printen inhoud val register
(goto (label read-eval-print-loop))
Nieuwe oproep van REPl nadat resultaat geprint werd
unknown-expression-type
(assign val (const unknown-expression-type-error))
(goto (label signal-error))
unknown-procedure-type
(restore continue)
Zie sprong vanuit apply-dispatch
(assign val (const unknown-procedure-type-error))
(goto (label signal-error))
signal-error
algemene subroutine om fout mee te melden
(perform (op user-print) (reg val))
Print het soort fout --> staat in register val
(goto (label read-eval-print-loop))
Nieuwe oproep REPL



4 Syntactische analyse
eval-dispatch
subroutine die aan de hand van het soort expressie doorverwijst naar
gespecialiseerde subroutines.
(test (op self-evaluating?) (reg exp))
(branch (label ev-self-eval))
(test (op variable?) (reg exp))
(branch (label ev-variable))
(test (op quoted?) (reg exp))

2
R70,43
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached


Document also available in package deal

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
lennyS Vrije Universiteit Brussel
Follow You need to be logged in order to follow users or courses
Sold
163
Member since
5 year
Number of followers
62
Documents
34
Last sold
2 weeks ago

4,5

6 reviews

5
4
4
1
3
1
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions