SlideServe
Menu
Préférences
© SlideServe · v2026

Understanding Abstract Syntax Trees in MUPL: Evaluation and Semantics

marlee avatar
11 diapositives · 254 Views · Jul 23, 2014

This document explores Abstract Syntax Trees (ASTs) in the context of MUPL and Racket, covering key aspects such as correct and incorrect syntax and semantics. It emphasizes that while evaluating an AST, checking for bad semantics is crucial, even if syntax errors can lead to crashes during evaluation. The paper discusses the implementation of MUPL in Racket, the utility of quoting and quasiquoting, and how to handle expression evaluation. In essence, it outlines the necessary considerations for interpreters when dealing with expressions and ASTs in language implementation.

Understanding Abstract Syntax Trees in MUPL: Evaluation and Semantics - slide 1
01 / 11Understanding Abstract Syntax Trees in MUPL: Evaluation and Semantics
1 / 17

Télécharger la présentation

Understanding Abstract Syntax Trees in MUPL: Evaluation and Semantics
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Section 7 Patrick Larson CSE341 – Spring 2013

  2. Abstract Syntax Trees (add 2 2) (add (const 2) (const 2)) (add (const 2) (bool #t))

  3. Abstract Syntax Trees (add 2 2) Incorrect Syntax (add (const 2) (const 2)) Correct Syntax, Correct Semantics (add (const 2) (bool #t)) Correct Syntax, Incorrect Semantics

  4. Abstract Syntax Trees When evaluating an AST, we are not required to check for bad syntax But we ARE required to check for bad semantics

  5. Abstract Syntax Trees Evaluation can assume a legal syntax tree If the input is illegal the evaluation may crash (But this is okay!) We DO need to check that the return types of sub-expressions are correct

  6. Abstract Syntax Trees Interpreter should return expression, but only expressions that evaluate to themselves. Otherwise we haven’t interpreted far enough

  7. MUPL “macros” We are interpreting MUPL with Racket And MUPL is just Racket data So why not write a Racket function that returns a MUPL AST?

  8. Quote Racket statements can be thought of as lists of tokens We can use the built in quote operation to turn a racket program into a list of tokens We can use an apostrophe as syntactic sugar.

  9. Quasiquote Useful for inserting expressions into a quote Use unquote to escape a quote and evaluate it Quasiquote and quote are the same unless we have an unquote expression Can use the back tick for quasiquote and , for unquote

  10. Eval Treat the input data as a program and run it! This means we need a language implementation at runtime (This is useful, but there is typically a better way to do things)

  11. Eval