home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / PROG / PASCAL / SPEED2 / DOC / LANGREF.DOC < prev    next >
Text File  |  1994-10-03  |  42KB  |  981 lines

  1.  
  2. ----------------------------------------------------------------------------
  3.   SPEED-Pascal/2 V1.0 for OS/2 Language reference
  4. ----------------------------------------------------------------------------
  5.  
  6. by: Rene Nürnberger (the author of SPEED-Pascal/2 itself !)
  7.  
  8.     Special thanks to Jörg Braun and Wolfhard Rinke from the
  9.     "toolbox" magazine for all their help.
  10.  
  11. **************************************
  12. NOTE: This file is only a "fragment" !
  13. **************************************
  14.  
  15. CONTENTS
  16.  
  17.  
  18.     Chapter 1. Introduction and Basic Elements of SPEED-Pascal/2 .......
  19.       Introduction .....................................................
  20.       Who should read this book ? ......................................
  21.       System requirements ..............................................
  22.       Character set ....................................................
  23.       Identifiers ......................................................
  24.       Reserved Words ...................................................
  25.       Comments .........................................................
  26.  
  27.     Chapter 2. Structure of SPEED-Pascal/2 Programs ....................
  28.       Overview .........................................................
  29.       Basic structure of a SPEED-Pascal/2 Program ......................
  30.       Using the syntax description .....................................
  31.       Description of the SPEED-Pascal/2 Grammar ........................
  32.  
  33.     Chapter 3. Declarations ............................................
  34.       Overview .........................................................
  35.       CONST Declaration ................................................
  36.       VAR Declaration ..................................................
  37.       TYPE Declaration .................................................
  38.       LABEL Declaration ................................................
  39.  
  40.     Chapter 4. Data types...............................................
  41.       Overview .........................................................
  42.       Predefined data types ............................................
  43.       Defining your own data types .....................................
  44.       Type compatibility ...............................................
  45.       ARRAY Data Type ..................................................
  46.       BOOLEAN Data Type ................................................
  47.       BYTE Data Type ...................................................
  48.       CHAR Data Type ...................................................
  49.       DOUBLE Data Type .................................................
  50.       Enumeration Data Type ............................................
  51.       EXTENDED Data Type ...............................................
  52.       FILE Data Type ...................................................
  53.       INTEGER Data Type ................................................
  54.       LONGINT Data Type ................................................
  55.       LONGWORD Data Type ...............................................
  56.       POINTER Data Type ................................................
  57.       REAL Data Type ...................................................
  58.       SET Data Type ....................................................
  59.       SHORTINT Data Type ...............................................
  60.       TEXT Data Type ...................................................
  61.       WORD Data Type ...................................................
  62.  
  63.     Chapter 5. Procedures and functions
  64.       Overview .........................................................
  65.       PROCEDURE Definition .............................................
  66.       FUNCTION Definition ..............................................
  67.       MACRO Definition .................................................
  68.       Parameterlists ...................................................
  69.       Pass by Value Parameters .........................................
  70.       Pass by Reference Parameters .....................................
  71.       Returning function results .......................................
  72.       Using libaries ...................................................
  73.       Using Dynamic link libraries (DLL's) .............................
  74.       Calling Procedures ...............................................
  75.       Calling Functions ................................................
  76.       Calling Macros ...................................................
  77.       Calling DLL Procedures and Functions .............................
  78.  
  79.     Chapter 6. Expressions .............................................
  80.       Overview .........................................................
  81.       Boolean Expressions ..............................................
  82.       Numeric expressions ..............................................
  83.       Set expressions ..................................................
  84.       String expressions ...............................................
  85.       Other expressions ................................................
  86.       AND Operators ....................................................
  87.       Addition Operators ...............................................
  88.       Multiplication Operators .........................................
  89.       NOT Operators ....................................................
  90.       Relational Operators .............................................
  91.       Function Calls ...................................................
  92.       SET operators ....................................................
  93.  
  94.     Chapter 7. Statements ..............................................
  95.      Overview ..........................................................
  96.      ASM Statement .....................................................
  97.      ASSEMBLER Statement ...............................................
  98.      Assignment Statement ..............................................
  99.      BEGIN (Compound) Statement ........................................
  100.      CASE Statement ....................................................
  101.      Empty Statement ...................................................
  102.      FOR Statement .....................................................
  103.      Function Call .....................................................
  104.      GOTO Statement ....................................................
  105.      IF Statement ......................................................
  106.      Procedure Call ....................................................
  107.      REPEAT Statement ..................................................
  108.      WHILE Statement ...................................................
  109.      WITH Statement ....................................................
  110.  
  111.     Chapter 8. OOP Extensions to SPEED-Pascal/2.........................
  112.      Overview ..........................................................
  113.      Understanding OOP .................................................
  114.      Objects Methods and Variables .....................................
  115.      OBJECT Definition .................................................
  116.      CONSTRUCTOR Definition ............................................
  117.      DESTRUCTOR Definition .............................................
  118.      Using Objects .....................................................
  119.      Using Virtual Methods .............................................
  120.  
  121.    Chapter 10. Using DLL's with SPEED-Pascal/2 .........................
  122.      Overview ..........................................................
  123.      IMPORTS statement .................................................
  124.      EXPORTS statement .................................................
  125.      Creating your own DLL's ...........................................
  126.      Parameterlist Conversion in C functions ...........................
  127.  
  128.    Chapter 11. Using libraries with SPEED-Pascal/2 .....................
  129.      Overview ..........................................................
  130.      INTERFACE section of a library ....................................
  131.      IMPLEMENTATION section of a library ...............................
  132.      USES keyword ......................................................
  133.      Using standard libraries ..........................................
  134.      Creating your own libraries........................................
  135.      Using your own libraries ..........................................
  136.      Libraries versus DLL's ............................................
  137.  
  138.    Chapter 12. Advanced topics .........................................
  139.      Using Inline Assembler ............................................
  140.      Calling DLL's from Assembler ......................................
  141.      Binding External Assembler Modules ................................
  142.      Using large Memory Pools...........................................
  143.  
  144.    Chapter 13 Internal details..........................................
  145.      VMT and DMT Table layout...........................................
  146.      Using the Compiler/Assembler/Resource Compiler as DLL's............
  147.  
  148.    Appendix ............................................................
  149.      SPEED-Pascal/2 Error Messages .....................................
  150.      SPEED-ASM Error Messages ..........................................
  151.      Compiler Directives ...............................................
  152.  
  153.  
  154. Chapter 1. Introduction and Basic Elements of SPEED-Pascal/2
  155. ============================================================
  156.  
  157. Introduction
  158. ------------
  159.  
  160. SPEED-Pascal/2 is a 32 Bit Pascal Compiler for OS/2. It produces real fast
  161. EXE's and uses most of the features of OS/2 since version 2.1 including
  162. Multihreading and 32 Bit Memory Management.
  163.  
  164. SPEED-Pascal/2 is up to 99 per cent Turbo-Pascal compatible. That means you
  165. can use your old Pascal Sources and simply recompile them under OS/2.
  166. For creating new programs you can use the newly developed Object-PM
  167. library and take advantage of the OS/2 Presentation Manager under the
  168. hood of an object-oriented library.
  169.  
  170. SPEED-Pascal/2 is a true 32 Bit Compiler. That means the generated code
  171. is optimized for at least a 386-Processor. There are no longer barriers
  172. of 64K segments in SPEED-Pascal because all Data Objects are referenced
  173. over 32 Bit Pointers. Since that SPEED-Pascal requires as a minimum a
  174. 80386SX Processor and OS/2 2.1 (See "System Requirements").
  175.  
  176. SPEED-Pascal/2 comes along with several Standard libraries that can be used
  177. to easily access all basic features of OS/2 including File Management
  178. and Screen output. The Object oriented library Object-PM provides an
  179. object oriented user interface to cummunicate with the OS/2 Presentation
  180. Manager.
  181.  
  182. The Programs generated with SPEED-Pascal need no external libraries to
  183. run except the DLL's you import in your Program (and of course you can build
  184. your own DLL's).
  185.  
  186. The compiler comes as Command-line version and as the Integrated Development
  187. Environment (IDE). It's strongly recommended that you use the IDE to
  188. develop your programs. Under the hood of the IDE several programs are
  189. integrated such as:
  190.  * The SPEED-Pascal/2 Compiler itself
  191.  * The SPEED-Asm Assembler
  192.  * The Speed-Resource Compiler
  193.  * The Speed-Resource Editor
  194.  * The Help Precompiler
  195.  * An Editor
  196.  * A Context sensitive help system
  197.  
  198. If you have ideas for further versions of SPEED-Pascal/2 or you may find bugs
  199. please send E-Mail via Compuserve to 72662,2052.
  200.  
  201.  
  202. Who should read this book ?
  203. ---------------------------
  204.  
  205. This book is NOT a learner's guide. It's to be used by people who are
  206. always familiar with the PASCAL language and programming in high level
  207. languages. Refer to "SPEED-Pascal/2 Programming reference" for more
  208. information about programming.
  209.  
  210. This book provides the full definition of the SPEED-Pascal/2 Programming
  211. language and its syntax. It can also be used as a quick reference since
  212. all elements of the SPEED-Pascal language are discussed.
  213.  
  214. System requirements
  215. -------------------
  216.  
  217. SPEED-Pascal/2 requires at least a 80386SX Processor with a minimum of 4 MB
  218. RAM and OS/2 2.1 (or higher) running on it. It's strongly recommended to have
  219. a minimum of 8 MB RAM for compiling large projects. The compiler would also
  220. run with 4 MB memory but compile speed can slow down rapidly.
  221.  
  222. SPEED-Pascal/2 requires for installation a minimum of about 10 MB Hard disk
  223. space. IF you disable installing several components of SPEED-Pascal this
  224. can be reduced down to 5 MB.
  225. It's recommended to have after the installation at least 5 MB of Hard disk
  226. space free for compiling your own projects.
  227.  
  228.  
  229. Character set
  230. -------------
  231.  
  232. The following characters are known to the compiler. Other characters cannot
  233. be used inside of your SPEED-Pascal programs except those used in character
  234. strings.
  235.  
  236. Character set:
  237.  
  238.  !&'()*+,-/0123456789:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnop
  239.  qrstuvwxyz{|}
  240.  
  241. Identifiers
  242. -----------
  243.  
  244. Identifiers in SPEED-Pascal/2 can be an expression that meets the following
  245. rules:
  246.  
  247.  * Identifiers can be at least 32 characters long
  248.  * An Identifier MUST start with a letter or an underscore ("_" char).
  249.    After the first letter the following chars CAN follow (also multiple
  250.    times) :
  251.      - a letter
  252.      - a digit
  253.      - an underscore
  254.    If the Identifier starts with an underscore ("_" char), a minimum of
  255.    one letter must follow.
  256.  * An Identifier must completely fit in one source code line
  257.  
  258. SPEED-Pascal/2 doesn't distingish between uppercase and lowercase. That means
  259. the identifiers "ident","Ident" and "IDENT" or even "IdeNt" are aquivalent.
  260.  
  261. In SPEED-Pascal/2 two types of identifiers are valid:
  262.   * Predefined Identifiers (cannot be redefined or used in other context)
  263.   * User defined Identifiers (are declared by you as the programmer)
  264.  
  265.  
  266. Examples for valid Identifiers:
  267.  
  268.       Ident
  269.       Ident1
  270.       _m
  271.       _M1
  272.       MyVar
  273.  
  274.  
  275. Reserved Words
  276. --------------
  277.  
  278. Reserved words are predefined identifiers that are used by SPEED-Pascal as
  279. tokens. Reserved words cannot be redeclared or used in another context
  280. than those described in the Grammar of SPEED-Pascal (see "Description of the
  281. SPEED-Pascal/2 Grammar").
  282.  
  283. SPEED-Pascal/2 doesn't distingish between uppercase and lowercase. That means
  284. the reserved words "begin","Begin" and "BEGIN" or even "BeGin" are
  285. aquivalent.
  286.  
  287. Reserved words in SPEED-Pascal are:
  288.  
  289.    ┌─────────────────────────────────────────────────────────────────────┐
  290.    │  ABS            ADDR         AND           ARCTAN         ARRAY     │
  291.    │  ASM            ASSEMBLER    BEGIN         CASE           CDECL     │
  292.    │  CHR            CONST        CONSTRUCTOR   COS            DEC       │
  293.    │  DESTRUCTOR     DIV          DO            DOWNTO         ELSE      │
  294.    │  END            EXIT         EXP           EXPORTS        FALSE     │
  295.    │  FILE           FOR          FORWARD       FRAC           FUNCTION  │
  296.    │  GOTO           HI           IF            IMPLEMENTATION IMPORTS   │
  297.    │  IN             INC          INDEX         INLINE         INT       │
  298.    │  INTERFACE      LABEL        LENGTH        LIBRARY        LN        │
  299.    │  LO             MACRO        MOD           NIL            NOT       │
  300.    │  OBJECT         OF           OR            ORD            PRED      │
  301.    │  PROCEDURE      PROGRAM      PTR           READ           READLN    │
  302.    │  RECORD         REPEAT       RESOURCE      ROUND          RUNERROR  │
  303.    │  SET            SHL          SHR           SIN            SIZEOF    │
  304.    │  SQR            SQRT         STRING        SUCC           TEXT      │
  305.    │  THEN           TO           TRUE          TRUNC          TYPE      │
  306.    │  UNIT           UNTIL        USES          VAR            VIRTUAL   │
  307.    │  WHILE          WITH         WRITE         WRITELN        XOR       │               │
  308.    └─────────────────────────────────────────────────────────────────────┘
  309.  
  310.  
  311. Comments
  312. --------
  313.  
  314. Comments are remarks by the programmer to describe source code. SPEED-Pascal
  315. bypasses comments so that comments don't have any effect on the code
  316. generation.
  317.  
  318. A Comment can be placed on every position in the source code.
  319.  
  320. Comments can start with one of the following character(s):
  321.   * {  character
  322.   * (* characters
  323.   * /* characters
  324.  
  325. Comments must end with one of the following character(s):
  326.   * }  character (if comment started with {)
  327.   * *) characters (if comment started with (*)
  328.   * */ characters (if comment started with /*)
  329.  
  330. That means: You must enclose comments with "{...}", "(*...*)" or "/*...*/".
  331.  
  332. Between the start and the end markers of a comment any text can be.
  333. SPEED-Pascal/2 doesn't allow nested comments (a comment within a comment).
  334.  
  335. Examples for vaild comments:
  336.  
  337.         {This is a comment}
  338.         /*Another Comment*/
  339.         (*Just another...*)
  340.  
  341.  
  342.  
  343. Chapter 2. Structure of SPEED-Pascal/2 Programs
  344. ===============================================
  345.  
  346.  
  347. Overview
  348. --------
  349.  
  350. All SPEED-Pascal/2 programs are separately compilable units. Usually a
  351. program consists of a main unit and several libraries that are linked
  352. together to one executable (the EXE file) which can directly be executed
  353. by OS/2.
  354.  
  355. This section describes the basic structure of a SPEED-Pascal/2 Program.
  356. You will also learn more about using Units (Libraries) with SPEED-Pascal/2.
  357.  
  358.  
  359. Basic structure of a SPEED-Pascal/2 Program
  360. -------------------------------------------
  361.  
  362. Any SPEED-Pascal/2 Program consists of the parts illustrated by the following
  363. graphic:
  364.  
  365.   ┌──────────────────────────────────────────────────────────────────┐
  366.   │ SPEED-Pascal/2 Program                                           │
  367.   │ ┌──────────────────────────────────────────────────────────────┐ │
  368.   │ │ PROGRAM Head;                                                │ │
  369.   │ └──────────────────────────────────────────────────────────────┘ │
  370.   │ ┌──────────────────────────────────────────────────────────────┐ │
  371.   │ │      Label Declarations;                                     │ │
  372.   │ │      Type Declarations;                                      │ │
  373.   │ │      Constant Definitions;                                   │ │
  374.   │ │      Variable Definitions;                                   │ │
  375.   │ │      Procedure Declarations;                                 │ │
  376.   │ │      Function Declarations;                                  │ │
  377.   │ │      Macro Declarations;                                     │ │
  378.   │ │                                                              │ │
  379.   │ └──────────────────────────────────────────────────────────────┘ │
  380.   │                                                                  │
  381.   │ BEGIN                                                            │
  382.   │      ┌─────────────────────────────────────────────────────────┐ │
  383.   │      │ Statement(s);                                           │ │
  384.   │      │     .                                                   │ │
  385.   │      │     .                                                   │ │
  386.   │      │     .                                                   │ │
  387.   │      │ Statement(s);                                           │ │
  388.   │      └─────────────────────────────────────────────────────────┘ │
  389.   │ END.                                                             │
  390.   │                                                                  │
  391.   └──────────────────────────────────────────────────────────────────┘
  392.  
  393. The various types of Delarations and Definitions are optional and can
  394. appear in any order.
  395.  
  396. A Program must start with the reserved word PROGRAM followed by the name
  397. of the Program (which is a user defined unique name) and a semicolon.
  398.  
  399. The Execution of the Program starts with that statement that follows the
  400. reserved word BEGIN.
  401.  
  402. Note that this structure is only valid for the Main Executable file.
  403. Units or DLL's must have another structure. This is discussed in the
  404. chapters "Using libraries with SPEED-Pascal" and "Using DLL's with SPEED-
  405. Pascal".
  406.  
  407. Example for a valid SPEED-Pascal/2 Program:
  408.  
  409. PROGRAM Test;
  410. BEGIN
  411.      WriteLn('My first program !');
  412. END.
  413.  
  414.  
  415. If this program is compiled and started it'll display the text "My first
  416. program !" on the screen.
  417.  
  418. Libraries are like Procedures and Functions a way to structurize your
  419. program and make it more readable to other users.
  420. A Library provides usually several Procedures and Functions that can be
  421. used by other units (Libraries) or programs.
  422.  
  423. With SPEED-Pascal/2 several Standard Libraries are delivered. IF you want to
  424. use functions frome these units you must tell the compiler where to
  425. find these functions. The compiler is such intelligent that it searches
  426. for a function in every library that you told him to use. Therefore you
  427. only have to import libaries which contain code you plan to use.
  428.  
  429. For importing functions from a library use the reserved word USES followed
  430. by the name of the library you plan to use. The standard unit SYSTEM is
  431. always imported so that you don't have to import SYSTEM.
  432.  
  433. For example you wish to use the function "DosVersion" from the unit PMDos.
  434. The resulting program would be the following:
  435.  
  436. PROGRAM UnitTest;
  437. USES Dos;  {This is here to import the Unit}
  438. VAR        {Declare a variable v that holds the OS/2 Version numbers}
  439.    v:WORD;
  440. BEGIN
  441.      v:=DosVersion;  {Get the OS/2 Version}
  442.      Writeln('OS/2 Version is:',v AND 255,'.',v SHR 8); {Put out version}
  443. END.
  444.  
  445.  
  446. For more information about libraries refer to chapter "Using libraries with
  447. SPEED-PASCAL/2".
  448.  
  449.  
  450.  
  451. Using the syntax description
  452. ----------------------------
  453.  
  454. In the following for the description of the Syntax of SPEED-Pascal/2 an
  455. Extended Backus Naur Form (EBNF) is used.
  456.  
  457. The following Meta Symbols are used in this description:
  458.  
  459.   CHARACTERSTRING    : Terminal-Symbols - use without change in your source
  460.                        code
  461.  
  462.   <Characterstring>  : Non-Terminal-Symbols - point to another Non Terminal
  463.                        Symbol. The construction has to be replaced by
  464.                        the resulting Terminal-Symbol(s).
  465.  
  466.   |                  : Alternative - One Element from the construction has to
  467.                        be choosen.
  468.  
  469.   []                 : The construction within these brackets is optional.
  470.  
  471.   {}                 : Repeat - The construction within those brackets
  472.                        can be repeated multiple times or can be deleted.
  473.  
  474.   ::=                : "Is defined as" - Assign a construction to a
  475.                        Non-Terminal-Symbol.
  476.  
  477.   <empty>            : Empty Symbol-Stream - The construction can also be
  478.                        empty.
  479.  
  480.   ..                 : Values covered by this range are valid.
  481.                        f.e.: A..Z,a..z,_ --> all letters and the charater
  482.                        "_".
  483.  
  484.   "c"                : Single character. This character must be used
  485.                        unchanged in your source code.
  486.  
  487.  
  488. Description of the SPEED-Pascal/2 Grammar
  489. -----------------------------------------
  490.  
  491. In the following a complete description of the Grammar of SPEED-Pascal/2 is
  492. given in EBNF. (see "Using the syntax description")
  493.  
  494.   Syntax:
  495.   -------
  496.  
  497.   <Program>              ::=   <Program-Head> <Block> "."
  498.                              | <Unit-Head> <Block> "."
  499.  
  500.   <Program-Head>         ::=   PROGRAM <Identifier> ";"
  501.                              | PROGRAM <Identifier> "(" INPUT ","
  502.                                OUTPUT ")" ";"
  503.                              | LIBRARY <Identifier> ";"
  504.  
  505.   <Unit-Head>            ::=   UNIT <Identifier> ";"
  506.                                INTERFACE <Interface-Block>
  507.                                IMPLEMENTATION
  508.  
  509.   <Interface-Block>      ::=   <Import-Declaration>
  510.                                <Label-Declaration>
  511.                                <Constant-Declaration>
  512.                                <Type-Definition>
  513.                                <Variable-Definition>
  514.                                <Export-Procedure>
  515.                                <Export-Function>
  516.                                <DLL-Importdefinition>
  517.                              | <empty>
  518.  
  519.   <Export-Procedure>     ::=   PROCEDURE <Identifier> <Paramterlist> ";"
  520.                              | <empty>
  521.  
  522.   <Export-Function>      ::=   FUNCTION <Identifier> <Paramterlist> ";"
  523.                              | <empty>
  524.  
  525.   <Block>                ::=   <Import-Declaration>
  526.                                <Label-Declaration>
  527.                                <Constant-Declaration>
  528.                                <Type-Definition>
  529.                                <Variable-Definition>
  530.                                <Procedure-Declaration>
  531.                                <Function-Declaration>
  532.                                <Macro-Declaration>
  533.                                <Assignment-Block>
  534.                                <DLL-Importdefinition>
  535.                                <DLL-Exportdefinition>
  536.  
  537.   <Import-Declaration>   ::=   USES <identifier> { "," <Identifier> } ";"
  538.                              | <empty>
  539.  
  540.   <DLL-Importdefinition> ::=   IMPORTS <DLLImports> ";" { <DLLImports> ";" }
  541.                                END ";"
  542.  
  543.   <DLLImports>           ::=   <DLLProcHead>
  544.                              | <DLLFuncHead>
  545.  
  546.   <DLLProcHead>          ::=   PROCEDURE <Identifier> <Paramterlist> <DLLImp>
  547.                              | <empty>
  548.  
  549.   <DLLFuncHead>          ::=   FUNCTION <Identifier> <Paramterlist> <DLLImp>
  550.                              | <empty>
  551.  
  552.   <DLLImp>               ::=   ":" <Identifier> INDEX <Fixed-Number>
  553.                              | ";" <Identifier> INDEX <Fixed-Number>
  554.                              | ":" "'" <Identifier> "'" <Fixed-Number>
  555.                              | ";" "'" <Identifier> "'" <Fixed-Number>
  556.  
  557.   <DLL-Exportdefinition> ::=   EXPORTS <DLLExports> ";" { <DLLExports>
  558.                                ";" } END ";"
  559.  
  560.   <DLLExports>           ::=   <Identifier>
  561.  
  562.   <Label-Declaration>    ::=   LABEL <Identifier> { "," <Bezeichner> } ";"
  563.                              | <empty>
  564.  
  565.   <Constant-Declaration> ::=   CONST <Identifier> <Constantblock> ";"
  566.                              | <empty>
  567.  
  568.   <Constantblock>        ::=   "=" <Constant>
  569.                              | ":" <Type> "=" <Constant>
  570.  
  571.   <Type-Definition>      ::=   TYPE <Identifier> "=" <Type> ";"
  572.                              | <empty>
  573.  
  574.   <Type>                 ::=   <Identifier>
  575.                              | "^" <Identifier>
  576.                              | BYTE
  577.                              | CHAR
  578.                              | DOUBLE
  579.                              | EXTENDED
  580.                              | WORD
  581.                              | INTEGER
  582.                              | LONGINT
  583.                              | LONGWORD
  584.                              | REAL
  585.                              | FILE
  586.                              | TEXT
  587.                              | POINTER
  588.                              | RECORD <Recordlist> END
  589.                              | ARRAY <Arraylist> OF <Type>
  590.                              | SET OF <Type>
  591.                              | STRING
  592.                              | PSTRING
  593.                              | STRING [ <Fixed-Number> ]
  594.                              | OBJECT <Objectlist> END
  595.                              | PROCEDURE <Parameterlist>
  596.                              | FUNCTION <Parameterlist> ":" <Type>
  597.                              | "(" <Constant> { "," <Constant> } ")"
  598.  
  599.   <Recordlist>           ::=   <Identifierlist> ":" <Type>
  600.                              | { <Identifierlist> ":" <Type> }
  601.                                CASE <Identifier> OF <Variant>
  602.  
  603.   <Variant>              ::=   <Constant> : "( <Variantlist> )" ";"
  604.                                { <Constant> ":" "(" <Variantlist> ")" ";" }
  605.  
  606.   <Variantlist>          ::=   <identifierlist> ":" <Type>
  607.                                { ";" <Identifierlist> ":" <Type> }
  608.  
  609.   <Identifierlist>       ::=   <Identifier> { "," <Identifier> }
  610.  
  611.   <Arraylist>            ::=   "[" <Fixed-Number> ".." <Fixed-Number>
  612.                                { "," <Fixed-Number> ".."
  613.                                <Fixed-Number> } "]"
  614.  
  615.   <Objectlist>           ::=   { <Objectvariables> } { <Objectmethods> }
  616.  
  617.   <Objectvariables>      ::=   <Recordlist>
  618.  
  619.   <Objectmethods>        ::=   PROCEDURE <Identifier> <Parameterlist> ";"
  620.                              | PROCEDURE <Identifier> <Parameterlist> ":"
  621.                                          VIRTUAL ";"
  622.                              | FUNCTION <Identifier> <Parameterlist> ":"
  623.                                         <Type> ";"
  624.                              | FUNCTION <Identifier> <Parameterlist> ":"
  625.                                         <Type> ":" VIRTUAL ";"
  626.                              | CONSTRUCTOR <Identifier> <Parameterlist> ";"
  627.                              | DESTRUCTOR <Identifier> <Parameterlist> ";"
  628.                              | DESTRUCTOR <Identifier> <Parameterlist> ":"
  629.                                VIRTUAL ";"
  630.  
  631.   <Parameterlist>        ::=   "(" <PList> { ";" <PList> } ")"
  632.  
  633.   <PList>                ::=   <Identifierlist> ":" <Type>
  634.                              | VAR <Identifierlist> ":" <Type>
  635.  
  636.   <Variable-Definition>  ::=   <Variablelist> ";" { <Variablelist> ";" }
  637.                              | <empty>
  638.  
  639.   <Variablelist>         ::=   VAR <Identifierlist> ":" <Type>
  640.                                    { ";" <Identifierlist> ":" <Type> }
  641.  
  642.   <Procedure-Declaration>::=   PROCEDURE <Identifier> <Proclist>
  643.                              | PROCEDURE <Identifier> "." <Identifier>
  644.                                          <Proclist>
  645.                              | CONSTRUCTOR <Identifier> "." <Identifier>
  646.                                          <Proclist>
  647.                              | DESTRUCTOR <Identifier> "." <Identifier>
  648.                                          <Proclist>
  649.  
  650.   <Proclist>             ::=   <Proc-Head> ";" <Proc-Block> ";"
  651.  
  652.   <Proc-Head>            ::=   <Parameterlist> ";" <Proctyp>
  653.                              | ";" <Proctyp>
  654.  
  655.   <Proctyp>              ::=   ASM ";"
  656.                              | CDECL ";"
  657.                              | FORWARD ";"
  658.                              | <empty>
  659.  
  660.  
  661.   <Function-Declaration> ::=   FUNCTION <Identifier> <Functionlist>
  662.                              | PROCEDURE <Identifier> "." <Identifier>
  663.                                          <Functionlist>
  664.  
  665.   <Functionlist>         ::=   <Function-Head> <Proc-Block> ";"
  666.  
  667.   <Function-Head>        ::=   <Parameterlist> ":" <Type> ";" <Proctyp>
  668.                              | ":" <Type> ";" <Proctyp>
  669.  
  670.   <Macro-Declaration     ::=   MACRO <Identifier> <Macrolist>
  671.                              | MACRO <Identifier> ":" <Type> ";"
  672.                                <Macrolist>
  673.  
  674.   <Macrolist>            ::=   <Statement-Block> ";"
  675.  
  676.   <Proc-Block>           ::=   <Label-Declaration>
  677.                                <Constant-Declaration>
  678.                                <Type-Definition>
  679.                                <Variable-Definition>
  680.                                <Statement-Block>
  681.  
  682.   <Statement-Block>      ::=   BEGIN <Statements> END
  683.  
  684.   <Statements>           ::=   { <Statement> ";" }
  685.  
  686.   <Statement>            ::=   <Proc-Call>
  687.                              | <Assignment>
  688.                              | <Goto>
  689.                              | <Case>
  690.                              | <Repeat>
  691.                              | <If>
  692.                              | <With>
  693.                              | <While>
  694.                              | <For>
  695.  
  696.   <Proc-Call>            ::=   <Identifier>
  697.                              | <Identifier> "(" <Expressionlist> ")"
  698.                              | <Identifier> "." <Identifier>
  699.                              | <Identifier> "." <Identifier>
  700.                                "(" <Expressionlist> ")"
  701.  
  702.   <Expressionlist>       ::=   <Expression> { "," <Expression> }
  703.  
  704.   <Assignment>           ::=   <Variable> ":=" <Expression>
  705.  
  706.   <Goto>                 ::=   GOTO <Identifier>
  707.  
  708.   <Case>                 ::=   CASE <Variable> OF <Caselist> END
  709.  
  710.   <Caselist>             ::=   { <Constant> : <Statement-Block> ";" }
  711.                              | { <Constant> : <Statement-Block> }
  712.                                ELSE <Statement-Block> ";"
  713.  
  714.   <Repeat>               ::=   REPEAT <Anweisungen> UNTIL <Bedingung>
  715.  
  716.   <If>                   ::=   IF <Expression> <Comp> <Expression> DO
  717.                                   <ifexpression>
  718.  
  719.   <ifexpression>         ::=   <Statement>
  720.                              | <Statement> ELSE <elseexpression>
  721.                              | <Statement-Block>
  722.                              | <Statement-Block> ELSE <elseexpression>
  723.  
  724.   <elseexpression>       ::=   <Statement>
  725.                              | <Statement-Block>
  726.  
  727.   <With>                 ::=   WITH <Variable> DO <withexpression>
  728.  
  729.   <withexpression>       ::=   <Statement>
  730.                              | <Statement-Block>
  731.  
  732.   <While>                ::=   WHILE <Expression> <Comp> <Expression> DO
  733.                                      <whileexpression>
  734.  
  735.   <whileexpression>      ::=  <Statement>
  736.                              | <Statement-Block>
  737.  
  738.   <For>                   ::=  FOR <Variable> ":=" <Expression> <Direction>
  739.                                    <Expression> DO <forexpression>
  740.  
  741.   <forexpression>         ::=  <Statement>
  742.                              | <Statement-Block>
  743.  
  744.   <Direction>             ::=  TO
  745.                              | DOWNTO
  746.  
  747.   <Comp>                  ::=  ">"
  748.                              | "<"
  749.                              | "="
  750.                              | ">="
  751.                              | "<="
  752.                              | "<>"
  753.  
  754.   <Variable>             ::=   <Identifier>
  755.                              | <Variable> ^
  756.                              | <Variable> . <Variable>
  757.                              | <Variable> "[" <Expression> { ","
  758.                                <Expression> } "]"
  759.  
  760.    <Expression>          ::=   <Variable>
  761.                              | <Proc-Call>
  762.                              | <Consant>
  763.                              | <Expression> <Operator> <Expression>
  764.                                { <Operator> <Expression> }
  765.  
  766.    <Operator>            ::=   "+"
  767.                              | "-"
  768.                              | "*"
  769.                              | "/"
  770.                              | "!"
  771.                              | "|"
  772.                              | "&"
  773.                              | DIV
  774.                              | MOD
  775.                              | AND
  776.                              | OR
  777.                              | XOR
  778.                              | NOT
  779.                              | SHL
  780.                              | SHR
  781.  
  782.    <Constant>            ::=   <Identifier>
  783.                              | <Fixed-Number>
  784.                              | "$" A..F|a..f|0..9 {A..F|a..f|0..9}
  785.                              | <Fixed-Number> "." <Fixed-Number>
  786.                              | NIL
  787.                              | TRUE
  788.                              | FALSE
  789.  
  790.    <Identifier>          ::= A..Z|a..z|_ { A..Z|a..z|0..9|_ }
  791.  
  792.    <Fixed-Number>        ::= 0..9 { 0..9 }
  793.  
  794.  
  795.  
  796. Chapter 3. Declarations
  797. =======================
  798.  
  799.  
  800. Overview
  801. --------
  802.  
  803.  
  804. CONST Declaration
  805. -----------------
  806.  
  807. VAR Declaration
  808. ---------------
  809.  
  810. TYPE Declaration
  811. ----------------
  812.  
  813. LABEL Declaration
  814. -----------------
  815.  
  816.  
  817. Chapter 13 Internal details
  818. ===========================
  819.  
  820. VMT and DMT Table layout
  821. ------------------------
  822.  
  823. VMT and DMT can only be used within Objects.
  824.  
  825. Note: The Dynamic method table can only be used when you use the
  826.       Object-PM Libary or from assembler level. There is no other
  827.       way to get the adresses of DMT-procedures/functions.
  828.       Since that Dynamic methods have only one parameter.
  829.       Dynamic methodes MUST match the following form:
  830.  
  831.       PROCEDURE <Name>(VAR Msg:TMessage);VIRTUAL <XXX>;
  832.  
  833.       Where <Name> is the name of the method and <XXX> the
  834.       Message ID. The method is (when using Object-PM) called
  835.       if the message appears.
  836.       The Type TMessage is defined in the unit Objects. If you
  837.       want to create your own Object-PM library (WHY ?) this
  838.       type name MUST mach or the compiler will tell an error !
  839.  
  840.       The DMT is located in the Codesegment. Since that you
  841.       cannot write to the DMT until you've created an Alias
  842.       Descriptor !
  843.  
  844. VMT Offset        Description
  845.  
  846. 0 (POINTER)       Adress of virtual method list
  847. 4 (POINTER)       Adress of dynamic method table (DMT)
  848. 8 and further     Object variables
  849.  
  850.  
  851. The virtual method list is an array[1..MaxMethods] of POINTER and consists
  852. of procedure/function addresses that correspondent with
  853. the logical index of the method within the object. (The first procedure/
  854. constructor/destructor or function has index 1).
  855. MaxMethods is the overall count of methods you defined no matter
  856. if virtual or not.
  857. The Method names at assembler level are named as _!<Name>_<XXX> where
  858. <Name> is the name of the object and <XXX> is the logical index of the
  859. method in the object as described below.
  860.  
  861. The DMT exists for each object no matter if dynamic methods are defined.
  862.  
  863. DMT Offset        Description
  864.  
  865. 0 (LONGWORD)      Size of the DMT for this object (without this length)
  866. 4 (LONGWORD)      Message ID
  867. 8 (LONGWORD)      VMT Index of the procedure/function that belongs to the
  868.                   message above and should be called when the message
  869.                   appears.
  870. 12 (LONGWORD)      Message ID
  871. 16 (LONGWORD)     VMT Index of the procedure/function that belongs to the
  872.                   message above and should be called when the message
  873.                   appears.
  874. .
  875. .
  876. .
  877.  
  878.  
  879. Using the Compiler/Assembler/Resource Compiler as DLL's
  880. -------------------------------------------------------
  881.  
  882. The SPEED-PASCAL/2 Compiler, Assembler and Resource Compiler are distributed
  883. as DLL's and invoked from the IDE.
  884. IF you want to include PASCAL/2 in your own programs you can use these
  885. DLL's.
  886.  
  887. When doing so you MUST recognize the copyright terms. You are NOT
  888. allowed to distribute, sell or rent or give away the SPEED-PASCAL/2 Compiler,
  889. Assembler or Resource Compiler with any commercial or private programs
  890. without having contacted the author !
  891. You can free use this DLL functions for private purposes.
  892.  
  893. Note that all functions must be called with PASCAL calling convention
  894. since SPEED-PASCAL/2 itself was written in SPEED-PASCAL/2.
  895. Structure alignment must be 1 (BYTE).
  896.  
  897. The following structure must be filled before calling:
  898.  
  899. TYPE
  900.     TParams=Record
  901.                   Quell:STRING;  {File to Compile}
  902.                   Lib:STRING;    {Library directory}
  903.                   Out:STRING;    {Output directory}
  904.                   Libsrc:STRING; {Library sources (for Build)}
  905.                   Params:STRING; {Command line parameters}
  906.                   InMemory:PMemoryList;
  907.            End;
  908.  
  909. Where
  910.      * Quell is the full qualified name of the file to compile in upper
  911.        chars including path and extension.
  912.      * Lib is the search path to the libraries WITHOUT an '\' at the end
  913.      * Out is the search path to the output directory WITHOUT an '\' at
  914.        he end
  915.      * Libsrc is the search path to the library sources WITHOUT an '\' at
  916.        the end
  917.      * Params holds the parameters as it is from the command line
  918.        (only switches and options).
  919.      * InMemory allows you to compile files that are in memory and MUST
  920.        be set to NIL if this is no memory file !
  921.        Note that the file in memory must match a file that would be on disk.
  922.        The Type PMemoryList is declared as
  923.          TYPE
  924.              PMemoryList=^TMemoryList;
  925.              TMemoryList=RECORD
  926.                             Name:String;
  927.                             Adresse:LONGWORD;
  928.                             Len:LONGWORD;
  929.                             Next:PMemoryList;
  930.                          END;
  931.        Where:
  932.              * Name is the full qualified name of the file to compile in
  933.                upper chars including path and extension.
  934.              * Adresse is the virtual 32 Bit address where the text
  935.                starts.
  936.              * Len is the length of the file in memory
  937.              * With the Next parameter you can define multiple files that
  938.                are in memory. At the end of the list Next MUST have the
  939.                value ZERO.
  940.  
  941.     The following structure is returned after the call:
  942.  
  943. TYPE
  944.     TReturn=Record
  945.                  ErrorStr:STRING;
  946.                  ErrorLine:WORD;
  947.                  ErrorColumn:WORD;
  948.                  Error:BOOLEAN;
  949.                  ErrorFile:String;
  950.            End;
  951.  
  952.     Where:
  953.           * ErrorStr holds the error. This field is only set if error=TRUE.
  954.           * ErrorLine holds the line where the error was found.
  955.           * ErrorColumn holds the column where the error was found.
  956.           * Error is set to TRUE if an error occured.
  957.           * Errorfile contains the full qualified file where the error
  958.             was found.
  959.  
  960. Note that the length of a STRING is 257 in SPEED since SPEED appends a #0
  961. char at the end of the string. The first string index (0) must contain
  962. the length of the string. A STRING therefore is declared as an
  963. ARRAY[0..256] OF char.
  964.  
  965.  
  966. Invokation of the SPEED-PASCAL/2 Compiler:
  967.  
  968.   PROCEDURE InvokePas(VAR Params:TParams;
  969.                       VAR Return:TReturn):      PASDLL index 1;
  970.  
  971. Invokation of the Assembler:
  972.  
  973.   PROCEDURE InvokeAsm(VAR Params:TParams;
  974.                       VAR Return:TReturn):      ASMDLL index 1;
  975.  
  976. Invokation of the Resource Compiler:
  977.  
  978.   PROCEDURE InvokeRes(VAR Params:TParams;
  979.                       VAR Return:TReturn):      RESDLL index 1;
  980.  
  981.