Semantics.html 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <html lang="en">
  2. <head>
  3. <title>Semantics - avram - a virtual machine code interpreter</title>
  4. <meta http-equiv="Content-Type" content="text/html">
  5. <meta name="description" content="avram - a virtual machine code interpreter">
  6. <meta name="generator" content="makeinfo 4.13">
  7. <link title="Top" rel="start" href="index.html#Top">
  8. <link rel="up" href="A-Simple-Lisp-Like-Language.html#A-Simple-Lisp-Like-Language" title="A Simple Lisp Like Language">
  9. <link rel="prev" href="Syntax.html#Syntax" title="Syntax">
  10. <link rel="next" href="Standard-Library.html#Standard-Library" title="Standard Library">
  11. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  12. <meta http-equiv="Content-Style-Type" content="text/css">
  13. <style type="text/css"><!--
  14. pre.display { font-family:inherit }
  15. pre.format { font-family:inherit }
  16. pre.smalldisplay { font-family:inherit; font-size:smaller }
  17. pre.smallformat { font-family:inherit; font-size:smaller }
  18. pre.smallexample { font-size:smaller }
  19. pre.smalllisp { font-size:smaller }
  20. span.sc { font-variant:small-caps }
  21. span.roman { font-family:serif; font-weight:normal; }
  22. span.sansserif { font-family:sans-serif; font-weight:normal; }
  23. --></style>
  24. </head>
  25. <body>
  26. <div class="node">
  27. <a name="Semantics"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Standard-Library.html#Standard-Library">Standard Library</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="Syntax.html#Syntax">Syntax</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="A-Simple-Lisp-Like-Language.html#A-Simple-Lisp-Like-Language">A Simple Lisp Like Language</a>
  32. <hr>
  33. </div>
  34. <h5 class="subsubsection">2.7.4.2 Semantics</h5>
  35. <p>Declarations in <code>silly</code> should be understood in the obvious way as
  36. preprocessor directives to perform parenthetic textual substitutions (similar to
  37. <code>#define id (exp)</code> in C). All identifiers in expressions are thereby
  38. eliminated during the preprocessing phase.
  39. <p><a name="index-semantic-function-257"></a>The overall meaning of the program is the meaning of the expression in
  40. the last declaration. A denotational semantics for expressions is given
  41. by the following equations, where [[<var>x</var>]] should be read as
  42. &ldquo;the meaning of <var>x</var>&rdquo;, and <var>x</var>, <var>y</var> and <var>z</var>
  43. are metavariables. (That is, they stand for any source code fragment
  44. that could fit there subject to the constraint, informally speaking,
  45. that it has to correspond to a connected subtree of the parse tree as enforced
  46. by the unambiguous grammar in the context of the rest of the program.)
  47. <pre class="display">
  48. [[<code>()</code>]] = <code>nil</code>
  49. [[<code>(</code><var>x</var><code>)</code>]] = [[<var>x</var>]]
  50. [[<code>(</code><var>x</var><code>,</code><var>y</var><code>)</code>]] = <code>cons(</code>[[<var>x</var>]]<code>,</code>[[<var>y</var>]]<code>)</code>
  51. [[<var>x</var> <var>y</var>]] = [[<var>x</var><code>(</code><var>y</var><code>)</code>]] = [[<var>x</var>]] [[<var>y</var>]]
  52. [[<var>x</var><code> (</code><var>y</var><code>,</code><var>z</var><code>)</code>]] = [[<var>x</var><code>(</code><var>y</var><code>,</code><var>z</var><code>)</code>]] = [[<var>x</var>]] [[<code>(</code><var>y</var><code>,</code><var>z</var><code>)</code>]]
  53. </pre>
  54. <p class="noindent">Toy languages like this are among the few situations a
  55. <a name="index-denotational-semantics-258"></a>denotational semantics stands a chance of clarifying more than it
  56. obfuscates, so the reader is invited to take a moment to savor it.
  57. </body></html>