{"id":23608,"date":"2023-05-05T02:32:04","date_gmt":"2023-05-05T02:32:04","guid":{"rendered":"https:\/\/www.booksofall.com\/?post_type=product&#038;p=23608"},"modified":"2023-05-05T02:32:05","modified_gmt":"2023-05-05T02:32:05","slug":"programming-languages-application-and-interpretation","status":"publish","type":"product","link":"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/","title":{"rendered":"Programming Languages: Application and Interpretation"},"content":{"rendered":"<div id=\"reading-mode-page-div-10\" class=\"reading-mode-page-div\">\n<h2>2 Everything (We Will Say) About Parsing<\/h2>\n<p>Parsing is the act of turning an input character stream into a more structured, internal representation. A common internal representation is as a tree, which programs can<a href=\"https:\/\/en.wikipedia.org\/wiki\/Recursion_(computer_science)\"> recursively process<\/a>. For instance, given the stream.<\/p>\n<p>23 + 5 &#8211; 6<\/p>\n<p>we might want a tree representing addition whose left node represents the number 23 and whose right node represents subtraction of 6 from 5. A <a href=\"https:\/\/www.techtarget.com\/searchapparchitecture\/definition\/parser\">parser<\/a> is responsible for performing this transformation.<\/p>\n<p>Parsing is a large, complex problem that is far from solved due to the difficulties of ambiguity. For instance, an alternate parse tree for the above input expression might put subtraction at the top and addition below it. We might also want to consider whether this addition operation is commutative and hence whether the order of arguments can be switched. Everything only gets much, much worse when we get to full-fledged <a href=\"https:\/\/www.simplilearn.com\/best-programming-languages-start-learning-today-article\">programming languages<\/a> (to say nothing of natural languages).<\/p>\n<h3>2.1 A Lightweight, Built-In First Half of a Parser<\/h3>\n<p>These problems make parsing a worthy topic in its own right, and entire books, tools, and courses are devoted to it. However, from our perspective parsing is mostly a distraction, because we want to study the parts of programming languages that are not parsing. We will therefore exploit a handy feature of Racket to manage the transformation of input streams into trees: read. read is tied to the parenthetical form of the language, in that it parses fully (and hence unambiguously) parenthesized terms into a built-in tree form. For instance, running (read) on the parenthesized form of the above input\u2014<\/p>\n<p>(+ 23 (- 5 6))<\/p>\n<p>\u2014will produce a list, whose first element is the symbol \u2019+, second element is the number 23, and third element is a list; this list\u2019s first element is the symbol \u2019-, second element is the number 5, and third element is the number 6.<\/p>\n<h3>2.2 A Convenient Shortcut<\/h3>\n<p>As you know you need to test your programs extensively, which is hard to do when you must manually type terms in over and over again. Fortunately, as you might expect, the parenthetical syntax is integrated deeply into Racket through the mechanism of quotation. That is, \u2019&lt;expr&gt;\u2014which you saw a moment ago in the above example\u2014acts as if you had run (read) and typed &lt;expr&gt; at the prompt (and, of course, evaluates to the value the (read) would have).<\/p>\n<h3>2.3 Types for Parsing<\/h3>\n<p><span style=\"font-size: 1rem;\">Actually, I\u2019ve lied a little. I said that (read)\u2014or equivalently, using quotation\u2014will produce a list, etc. That\u2019s true in regular Racket, but in Typed PLAI, the type it returns a distinct type called an s-expression, written in Typed PLAI as s-expression:<\/span><\/p>\n<p><span style=\"font-size: 1rem;\"> &gt; (read)<br \/>\n&#8211; s-expression<br \/>\n[type in (+ 23 (- 5 6))]<br \/>\n&#8216;(+ 23 (- 5 6)) <\/span><\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Racket_(programming_language)\"><span style=\"font-size: 1rem;\">R<\/span><\/a><span style=\"font-size: 1rem;\"><a href=\"https:\/\/en.wikipedia.org\/wiki\/Racket_(programming_language)\">acket<\/a> has a very rich language of<a href=\"https:\/\/en.wikipedia.org\/wiki\/S-expression\"> s-expressions<\/a> (it even has notation to represent cyclic structures), but we will use only the simple fragment of it.<\/span><\/p>\n<\/div>\n<div id=\"reading-mode-page-div-11\" class=\"reading-mode-page-div\">\n<p>In the typed language, an s-expression is treated distinctly from the other types, such as numbers and lists. Underneath, an s-expression is a large recursive datatype that consists of all the base printable values\u2014numbers, strings, symbols, and so on\u2014and printable collections (lists, vectors, etc.) of s-expressions. As a result, base types like numbers, symbols, and strings are both their own type and an instance of s-expression. Typing such data can be fairly problematic, as we will discuss later [REF].<\/p>\n<p><a href=\"https:\/\/docs.racket-lang.org\/plai-typed\/index.html\">Typed PLAI<\/a> takes a simple approach. When written on their own, values like numbers are of those respective types. But when written inside a complex s-expression\u2014in particular, as created by read or quotation\u2014they have type s-expression. You have to then cast them to their native types. For instance:<\/p>\n<p id=\"cvcxvyn\"><img loading=\"lazy\" decoding=\"async\" width=\"428\" height=\"303\" class=\"alignnone size-full wp-image-23611 \" src=\"https:\/\/www.booksofall.com\/wp-content\/uploads\/2023\/05\/img_6454660b034d7.png\" alt=\"\" \/><\/p>\n<blockquote><p>This is similar to the casting that a <a href=\"https:\/\/www.java.com\/en\/\">Java<\/a> programmer would have to insert. We will study casting itself later [REF].<\/p><\/blockquote>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p><iframe style=\"width: 100%; height: 750px; border: none;\" src=\"https:\/\/online.visual-paradigm.com\/share\/book\/programming-languages-application-and-interpretation-1bw2rjp1cc?p=1\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"featured_media":23613,"template":"","meta":{"_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"Programming languages are used to give instructions to computers and other machines, which is a very large topic. Learn more about it here!"},"product_brand":[],"product_cat":[378],"product_tag":[],"class_list":{"0":"post-23608","1":"product","2":"type-product","3":"status-publish","4":"has-post-thumbnail","6":"product_cat-programming","8":"first","9":"instock","10":"shipping-taxable","11":"product-type-simple"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Programming Languages: Application and Interpretation - BooksOfAll French<\/title>\n<meta name=\"description\" content=\"Programming languages are used to give instructions to computers and other machines, which is a very large topic. Learn more about it here!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Programming Languages: Application and Interpretation - BooksOfAll French\" \/>\n<meta property=\"og:description\" content=\"Programming languages are used to give instructions to computers and other machines, which is a very large topic. Learn more about it here!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/\" \/>\n<meta property=\"og:site_name\" content=\"BooksOfAll French\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-05T02:32:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/05\/Programming-Languages-Application-and-Interpretation.jpg\" \/><meta property=\"og:image\" content=\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/05\/Programming-Languages-Application-and-Interpretation.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"827\" \/>\n\t<meta property=\"og:image:height\" content=\"1169\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/05\/Programming-Languages-Application-and-Interpretation.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/\",\"url\":\"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/\",\"name\":\"Programming Languages: Application and Interpretation - BooksOfAll French\",\"isPartOf\":{\"@id\":\"https:\/\/www.booksofall.com\/fr\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/05\/Programming-Languages-Application-and-Interpretation.jpg\",\"datePublished\":\"2023-05-05T02:32:04+00:00\",\"dateModified\":\"2023-05-05T02:32:05+00:00\",\"description\":\"Programming languages are used to give instructions to computers and other machines, which is a very large topic. Learn more about it here!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/#primaryimage\",\"url\":\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/05\/Programming-Languages-Application-and-Interpretation.jpg\",\"contentUrl\":\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/05\/Programming-Languages-Application-and-Interpretation.jpg\",\"width\":\"827\",\"height\":\"1169\",\"caption\":\"Programming Languages: Application and Interpretation\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.booksofall.com\/fr\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Categories\",\"item\":\"https:\/\/www.booksofall.com\/fr\/categories\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Programming Languages: Application and Interpretation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.booksofall.com\/fr\/#website\",\"url\":\"https:\/\/www.booksofall.com\/fr\/\",\"name\":\"BooksOfAll French\",\"description\":\"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.\",\"publisher\":{\"@id\":\"https:\/\/www.booksofall.com\/fr\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.booksofall.com\/fr\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.booksofall.com\/fr\/#organization\",\"name\":\"BooksOfAll French\",\"url\":\"https:\/\/www.booksofall.com\/fr\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/www.booksofall.com\/fr\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2022\/06\/booksofall-logo-2.png\",\"contentUrl\":\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2022\/06\/booksofall-logo-2.png\",\"width\":166,\"height\":30,\"caption\":\"BooksOfAll French\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/fr\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Programming Languages: Application and Interpretation - BooksOfAll French","description":"Programming languages are used to give instructions to computers and other machines, which is a very large topic. Learn more about it here!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/","og_locale":"fr_FR","og_type":"article","og_title":"Programming Languages: Application and Interpretation - BooksOfAll French","og_description":"Programming languages are used to give instructions to computers and other machines, which is a very large topic. Learn more about it here!","og_url":"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/","og_site_name":"BooksOfAll French","article_modified_time":"2023-05-05T02:32:05+00:00","og_image":[{"url":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/05\/Programming-Languages-Application-and-Interpretation.jpg","type":"","width":"","height":""},{"width":827,"height":1169,"url":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/05\/Programming-Languages-Application-and-Interpretation.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_image":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/05\/Programming-Languages-Application-and-Interpretation.jpg","twitter_misc":{"Dur\u00e9e de lecture estim\u00e9e":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/","url":"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/","name":"Programming Languages: Application and Interpretation - BooksOfAll French","isPartOf":{"@id":"https:\/\/www.booksofall.com\/fr\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/#primaryimage"},"image":{"@id":"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/#primaryimage"},"thumbnailUrl":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/05\/Programming-Languages-Application-and-Interpretation.jpg","datePublished":"2023-05-05T02:32:04+00:00","dateModified":"2023-05-05T02:32:05+00:00","description":"Programming languages are used to give instructions to computers and other machines, which is a very large topic. Learn more about it here!","breadcrumb":{"@id":"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/#primaryimage","url":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/05\/Programming-Languages-Application-and-Interpretation.jpg","contentUrl":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/05\/Programming-Languages-Application-and-Interpretation.jpg","width":"827","height":"1169","caption":"Programming Languages: Application and Interpretation"},{"@type":"BreadcrumbList","@id":"https:\/\/www.booksofall.com\/fr\/programming-languages-application-and-interpretation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.booksofall.com\/fr\/"},{"@type":"ListItem","position":2,"name":"Categories","item":"https:\/\/www.booksofall.com\/fr\/categories\/"},{"@type":"ListItem","position":3,"name":"Programming Languages: Application and Interpretation"}]},{"@type":"WebSite","@id":"https:\/\/www.booksofall.com\/fr\/#website","url":"https:\/\/www.booksofall.com\/fr\/","name":"BooksOfAll French","description":"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.","publisher":{"@id":"https:\/\/www.booksofall.com\/fr\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.booksofall.com\/fr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/www.booksofall.com\/fr\/#organization","name":"BooksOfAll French","url":"https:\/\/www.booksofall.com\/fr\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.booksofall.com\/fr\/#\/schema\/logo\/image\/","url":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2022\/06\/booksofall-logo-2.png","contentUrl":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2022\/06\/booksofall-logo-2.png","width":166,"height":30,"caption":"BooksOfAll French"},"image":{"@id":"https:\/\/www.booksofall.com\/fr\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/product\/23608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/product"}],"about":[{"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/types\/product"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/media\/23613"}],"wp:attachment":[{"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/media?parent=23608"}],"wp:term":[{"taxonomy":"product_brand","embeddable":true,"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/product_brand?post=23608"},{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/product_cat?post=23608"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/product_tag?post=23608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}