home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / a293_1 / !AForth_Docs_Semantics_!ReadMe1st < prev    next >
Encoding:
Text File  |  1999-04-27  |  7.2 KB  |  169 lines

  1.  
  2. Conventions and Format of Semantics files
  3.  
  4.  
  5. This file explains the format of word descriptions in the other files in this directory. A brief description of the functionality of each word set is also given.
  6.  
  7.  
  8. Contents ______________________________________________________________________
  9.  
  10. Files in This Directory
  11. Format of Word Semantic Descriptions
  12.   Stack Notation
  13.   Text Input Abbreviations
  14.   Data Type Compatability
  15.  
  16.  
  17. Files in This Directory _______________________________________________________
  18.  
  19. This directory contains the semantic description of all the words provided in the AForth kernel or supplied as include files to be included by the words 'INCLUDED' or 'INCLUDE-FILE'. The files are:
  20.  
  21.  
  22. !ReadMe1st
  23. This file is the one you are reading now. It explains the format of word descriptions used in the other files in this directory.
  24.  
  25. Words
  26. List of all words included in AForth and the ANS standard.
  27.  
  28.  
  29. Core
  30. Semantics for the Core and Core Extensions word sets. These word sets include the words most commonly used in applications.
  31.  
  32. Error
  33. Semantics for the Error handling word set. Description of structured error handling of AForth and explanation of error messages, their meaning and when to expect them.
  34.  
  35. File
  36. Semantics for the File Access and File Access Extensions word sets. These word sets handles all about sequential and random access files.
  37.  
  38. Memory
  39. Semantics for the Memory Allocation word set. This word set offers dynamic memory allocation and deallocation.
  40.  
  41. Search
  42. Semantics for the Search Order word set. This word set handles all about word lists and search orders. Only the more advanced user/programmer will ever need this.
  43.  
  44. String
  45. Semantics for the String handling word set. In this release of AForth, only a single word is present from this word set, namely 'COMPARE'.
  46.  
  47. Toolkit
  48. Semantics for the Programming Tools word set. This word set provides simple debugging facilities and programming aids.
  49.  
  50.  
  51. RISCOS
  52. Semantics for the non-standard words, which are supplied to ease the use of Forth with RISC-OS. This word set provides support for SWI calls, the CLI and control of ESCAPES in order to enable multi-tasking in the Wimp.
  53.  
  54. Graphics
  55. Semantics for the Graphics word set which is supplied as source file. The Graphics word set covers about the same graphics functionality as provided by ARM BBC BASIC.
  56.  
  57.  
  58. Format of Word Semantic Descriptions __________________________________________
  59.  
  60. A semantic description of a word means: what the word does when executed or compiled, ie. a description of a command.
  61.  
  62. Each word description starts with a header containing: the name in upper case letters, the name of the wordset the word belongs to, the word attributes and finally a stack diagram.
  63.  
  64. The word name is self-explanatory. The stack parameters are given as described below in the section 'Stack Notation'. The word set designator shows which word set the word belongs to. It can be one of the following:
  65.  
  66. Core    Core word set
  67. Double    Double number word set
  68. File    File Access word set
  69. Toolkit    Programmers Toolkit word set
  70. Search    Search order word set
  71. String    String handling word set
  72. Memory    Memory allocation word set
  73. Error    Error handling word set
  74. Float    Floating-point word set
  75.  
  76. If "Ext" is appended to the word set designator, it means that the word is from the corresponding Extension word set.
  77.  
  78. The word attributes signifies any special behaviour of the word. It can be either 'C', meaning that it's a compile only word and thus only can be used in a definition, or it can be 'D' meaning that the word is a defining word, and thus compiles a new definition when executed.
  79.  
  80. After the header comes a textual explanation of the word's behaviour. If the word has different behaviour in execute and compile mode, the explanation is split in two sections, each preceeded by 'Execution:' or 'Compilation:' respectively. Some few words have also a seperate entry for interpretation mode, ie. what the word does when input at the Forth prompt.
  81.  
  82.  
  83. --------------
  84. Stack Notation
  85. --------------
  86. Stack parameters are described via stack diagrams that look like this:
  87.  
  88. ( before -- after )
  89.  
  90. The "before" parameters are those the word expects on the stack when executed. The "after" corresponds to the values left on the stack after execution of the word. The right most value are the last number pushed on the stack, ie. we say it is the item on top of the stack or the value last pushed onto the stack. If no specific stack is mentioned, the data stack is implied. Sometimes the data stack is also called the parameter stack.
  91.  
  92. If the return stack is used, the stack diagram is amended to look like this:
  93.  
  94. ( R: before -- after )
  95.  
  96. If the Floating point stack is used in looks like this:
  97.  
  98. ( F: before -- after )
  99.  
  100. The following list shows the abbreviations used in stack parameter diagrams. It also gives the data type and its value range in the AForth implementation.
  101.  
  102. Abbr.    type            range
  103. -----------------------------------------------------------
  104. n    number            -2^31..2^31-1
  105. +n    non-negative n        0..2^31-1
  106. u    unsigned number        0..2^32-1
  107. n/u    n or u            -2^31..2^32-1
  108. w    unspecified cell    0..2^32-1
  109. d    double cell number    -2^63..2^63-1
  110. +d    non-negative d        0..2^63-1
  111. ud    unsigned d        0..2^64-1
  112. d/ud    d or ud            -2^63..2^64-1
  113. wd    unspecified cell pair    0..2^64-1
  114. char    character        0..127 (0..255)
  115. r    floating-point number    ?
  116. addr    address            0..2^26-1
  117. c-addr    char aligned address    addr
  118. a-addr    aligned address        addr, but in steps of four
  119. flag    flag            0=false, else=true
  120. true    flag            <>0
  121. false    flag            =0
  122. mask    bit-mask        0..2^32-1
  123. ior    I/O result        0 or non-zero
  124. sys    n/a            undefined
  125. orig    n/a            a-addr
  126. dest    n/a            a-addr
  127. fid    unspecified        unspecified
  128. i*w,j*w    unspecied cells        n/a
  129. -----------------------------------------------------------
  130.  
  131. In AForth c-addr and addr are synonyms for any address. a-addr means an aligned address.
  132.  
  133.  
  134. ------------------------
  135. Text Input Abbreviations
  136. ------------------------
  137. Some words require a text string to follow the word in the input stream. This action is represented by including the following notation in a stack diagram:
  138.  
  139. <char>    A delimiting character, marking the end of the stream being parsed.
  140.  
  141. <eol>    Delimiter, marking the end of line. In AForth the end of line
  142.     characters are any of the ASCII characters 0, 10 or 13.
  143.  
  144. <blank>    A space, or any control character in the ASCII range 0..31
  145.  
  146. <blanks> One or more <blank>s.
  147.  
  148. ccc    A sequence of arbitrary characters, parsed from the input stream.
  149.  
  150. name    A word name parsed from the input stream.
  151.  
  152.  
  153. -----------------------
  154. Data Type Compatability
  155. -----------------------
  156. Data type compatability is a new concept introduced by the ANS standard. It defines the level of portability expected from a program and should therefore possess no significance to the casual user.
  157.  
  158. The following table represents how the data types are related to each other in respect of subtypes, ie. which data types are a subset of other data types. A chain rule applies to data type compatability such that, if datatype x is a subtype of y and y is a subtype of z then x is also a subtype of z.
  159.  
  160. char -> +n -> w
  161. +n -> n -> w
  162. +n -> u -> w
  163. flag -> mask -> w
  164. a-addr -> c-addr -> addr -> u -> w
  165. +d -> d -> wd
  166. +d -> ud -> wd
  167.  
  168. It should be noted that the Forth compiler performs no data type checking whatsoever, so care should be taken. The table should be applied to any program meant to be portable.
  169.