impl.txt 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298
  1. .pi \usr\bin\col
  2. .LP
  3. .ds RF Vadim Engelson, University of Latvia
  4. .DA
  5. .nr PS 9
  6. .nr VS 12
  7. .AI
  8. University of Latvia
  9. Institute of Mathematcs and Computer Science
  10. .TL
  11. RIGAL PROGRAMMING SYSTEM
  12. FOR SUN / UNIX
  13. PROGRAMMER'S GUIDE
  14. .AU
  15. by VADIM ENGELSON
  16. .SH
  17. TABLE OF CONTENTS
  18. .LP
  19. 1.1 Introduction
  20. 1.2 How to create a simple program
  21. 2. Additional features of the language
  22. 2.1 RIGAL lexical syntax
  23. 2.2 Including other files
  24. 2.3 Atom types
  25. 2.4 Lazy boolean evaluation
  26. 2.5 Opening text files
  27. 2.6 Text output
  28. 2.7 Length of the text file line
  29. 2.8 New line format
  30. 2.9 LOAD and SAVE statements
  31. 2.10 PRINT statement
  32. 2.11. Built-in rules
  33. 3 Scanners and special subroutines
  34. 3.1 Access to standard input and output
  35. 3.2 Lexical analyzers
  36. 3.3 Manipulations with the coordinates
  37. 3.4 String conversion
  38. 3.5 Real numbers
  39. 3.6 Other services
  40. 3.7 Low level memory control
  41. 4 The lexical analyzer
  42. 4.1 The simplest lexical analyser
  43. 4.2 Reading from file
  44. 4.3 Reading from list of atoms
  45. 4.5 Options
  46. 4.6 Common components of the lexical grammars
  47. 4.7 Using options
  48. 4.8 Coordinate calculation
  49. 4.9 Coordinate marks
  50. 4.10 Structure control characters
  51. 4.11 Lexical error messages
  52. 4.12 Error message code numbers
  53. APPENDIX A. Messages of the syntax checker
  54. APPENDIX B. Run time error messages
  55. APPENDIX C. Debugging messages
  56. APPENDIX D. Syntax of RIGAL
  57. APPENDIX E. Reference table on #CALL_PAS parameters
  58. .SH
  59. 1.1 Introduction
  60. .LP
  61. RIGAL is a high level programming language designed for
  62. syntax analysis, program optimization, code generation, converter
  63. writing and rapid design of language prototypes. RIGAL is
  64. designed in the Institute of Mathematics and Computer Science of
  65. the University of Latvia in 1987 - 1990. It was implemented in
  66. RSX-11M, VAX/VMS, MS-DOS, MS-Windows, UNIX/SUN operating
  67. systems.
  68. See the manual pages on how to install RIGAL in your system.
  69. .SH
  70. 1.2 How to create a simple program
  71. .LP
  72. After the installation try the example.
  73. Create file 'a.rig' with the following text:
  74. -- THIS IS PROGRAM
  75. #START
  76. $A:=(. ALPHA BETA GAMMA DELTA .);
  77. PRINT $A;
  78. $B:=#TAIL($A);
  79. PRINT $B;
  80. ##
  81. #TAIL
  82. (. $E (* $R!. := $K *) .)
  83. / RETURN $R /
  84. ##
  85. There are two rules in this program - #START and #TAIL. The
  86. first rule is the main one, it consists of four statements. There
  87. are two variables - $A and $B. The first statement assigns a list
  88. of four atoms to the variable $A, the third statement assigns to
  89. $B the result of rule #TAIL which works on the argument $A. The
  90. second and the fourth statements print out the values of the
  91. variable (to the standard output by default ).
  92. The second rule #TAIL consists of the list pattern (. .) ,
  93. the iteration pattern (* *) and the variable patterns $E and $K.
  94. Values of $K are appended to the list in the variable $R. The
  95. RETURN statement returns the result of this rule to the calling
  96. rule.
  97. Execute command to check the file:
  98. rc a
  99. If the program has no errors then continue, else correct the
  100. errors reported and check the program again.
  101. Now file 'a.rsc' appears in your directory.
  102. Execute command to interpret the program
  103. ic a
  104. You will see the result on the sceen:
  105. (. ALPHA BETA GAMMA DELTA .)
  106. (. BETA GAMMA DELTA .)
  107. Execute command to compile the program
  108. rc a -c
  109. Now file 'a' appears in your directory.
  110. Execute command to startup the compiled program
  111. a
  112. You see the same result:
  113. (. ALPHA BETA GAMMA DELTA .)
  114. (. BETA GAMMA DELTA .)
  115. Now you can try other examples or write them yourself.
  116. .SH
  117. 2. Additional features of the language
  118. .LP
  119. Some language limitations, extensions and special cases
  120. depending of the implementation are discussed.
  121. 2.1 RIGAL lexics
  122. Tokens in RIGAL programs are the following :
  123. -- rule names , e.g. #ABC
  124. -- variable names , e.g. $VAR
  125. -- RIGAL key words, e.g. FORALL, ELSIF
  126. -- RIGAL delimiters and special tokens, e.g. ## ! +
  127. -- atoms ( RIGAL data )
  128. The tokens differ in different cases (upper-case and
  129. lower-case). Type the key words in the upper-case only.
  130. In the following description LETTERS are A..Z,a..z,
  131. LETTERS_&_DIGITS are A..Z,a..z,0..9,_ (underscore).
  132. The restrictions to RIGAL token syntax follow.
  133. RULE NAMES begin with # followed by LETTER and zero or more
  134. LETTERS_&_DIGITS.
  135. VARIABLE names begin with $ followed by LETTER and zero or
  136. more LETTERS_&_DIGITS. If the first letter is N or I (upper-case
  137. only), such pattern variable matches the number or identifier
  138. respectively.
  139. Key words are :
  140. AND
  141. BREAK
  142. CLOSE
  143. DIV
  144. DO
  145. ELSIF
  146. END
  147. FAIL
  148. FI
  149. FORALL
  150. IF
  151. IN
  152. LAST
  153. LOAD
  154. LOOP
  155. MOD
  156. NOT
  157. NULL
  158. OD
  159. ONFAIL
  160. OPEN
  161. OR
  162. PRINT
  163. RETURN
  164. SAVE
  165. Note that all they are in uppercase.
  166. Delimiters and special tokens are :
  167. ## / ;; (* *) ! (+ +) <* *> : , ; := ++ !. !! + - * ( ) <> =<
  168. = >= < > :: <. .> (. .) [ ] . -> << <] @ S' V'
  169. Numerical atoms in RIGAL are decimal, from 0 to 2**31-1. The
  170. numbers may be written in octal mode, followed by the letter "B".
  171. Non-numerical atoms are quoted by apostrophes. An apostrophe
  172. inside the atom must be written twice. Atom maximal length
  173. is 80 characters.
  174. If the non-numerical atom is LETTER followed by
  175. zero or more
  176. LETTERS_&_DIGITS, and this atom is not a RIGAL keyword, then it
  177. is allowed to write it without apostrophes.
  178. 2.2 Including other files
  179. Use the %INCLUDE <filename>.rig directive to include other
  180. files into your program. The suffix (.rig) is necessary, path
  181. also may be specified. The file name is followed by spaces. Use
  182. %INCLUDE only between or after the rules. Don't use it between
  183. the statements or the patterns.
  184. 2.3 Atom types
  185. The atoms (excluding NULL) are implemented as Pascal records
  186. which consist of the type of the atom and the string (or
  187. numerical) value.
  188. There are the following atom types in RIGAL:
  189. 1. IDENTIFIER. Such atom value is LETTER followed by
  190. zero or more LETTERS_&_DIGITS.
  191. Such atoms match the built-in rule #IDENT and
  192. I-variables in the patterns. They may be used as the selectors in
  193. the trees.
  194. 2. NON-NUMERIC atoms which are not identifiers.
  195. 3. NUMBER. They match built-in rule #NUMBER and N-variables
  196. in the patterns.
  197. 4. PASCAL STRING CONSTANT. They are created by the PASCAL
  198. scanner and match built-in rule #TATOM.
  199. 5. PASCAL REAL CONSTANT. They are created by PASCAL scanner
  200. and match built-in rule #FATOM predicate. Arithmetical operations
  201. with them are allowed through rule #CALL_PAS(80) only.
  202. Other atom types (KEYWORD, SPECIAL, VARIABLE, RULENAME) are
  203. created by the RIGAL scanner and intended for internal use.
  204. 2.4 Lazy boolean evaluation
  205. AND and OR operations differ in the interpreter and in the
  206. compiled program. The interpreter evaluates all the arguments of
  207. boolean expressions, but the compiled program evaluates the
  208. necessary arguments only.
  209. 2.5 Opening text files
  210. The statement
  211. OPEN <internal-file-name> <expression>
  212. opens text file for output.
  213. The expression must have a value, which represents valid
  214. UNIX file name. If it is not an atom - ERROR 11 message is is-
  215. sued. If the file with such internal name is already open, then
  216. ERROR 16 is issued, and the new file is not being open. Only 5
  217. files can be open simultaneously, ERROR 13 appears if you try to
  218. open the 6-th file. ERROR 14 appears if you try to output to
  219. the closed file. ERROR 19 appears if the file name is not valid.
  220. File name which consists of one space symbol corresponds to
  221. the standard output.
  222. Examples :
  223. OPEN LST '~john/dd.rep';
  224. OPEN SCREEN ' ';
  225. OPEN PASCODE #IMPLODE ($Name '.pas');
  226. 2.6 Text output
  227. The <] and << statements write atoms to text file. NULL is
  228. written as empty string. The #TATOM atoms are written in
  229. apostrophes and inner apostrophes are duplicated. The list is
  230. written as sequence of the atoms in the list. The label of the
  231. list and the inner structure are not printed. The trees are
  232. not allowed to be written: the '<*!<*TREE*>!*>' mark will appear
  233. in the file.
  234. 2.7 Length of the text file line
  235. Default maximal length of the line is 80 bytes.
  236. Before every atom has written its length and length of
  237. the current line are added, and the sum is checked. If the atom
  238. does not fit in 80 bytes, then if insert-space mode is ON, (@
  239. switch) it causes switch to a new line, but, if OFF, then
  240. the atom is written to the current line (and length of this line
  241. will be more than the default maximal value).
  242. 2.8 New line format
  243. The << statement writes EOL byte and then writes the re-
  244. quired atoms. If the << statement is executed immediately
  245. after OPEN, the first line in the file remains empty.
  246. 2.9 LOAD and SAVE statements
  247. RIGAL data loading and saving require the following
  248. statements:
  249. LOAD $Variable <expression>;
  250. SAVE $Variable <expression>;
  251. The expression value must be an atom, its value must be a
  252. valid file name. If it is not an atom, ERROR 11 appears.
  253. Limitations and defaults for file name are the same as in OPEN
  254. statement. If the file name is invalid, LOAD statement causes
  255. ERROR 18, but SAVE causes ERROR 15. Piping and standard input and
  256. output are not allowed here.
  257. Screen file (' ') is not
  258. allowed. If the file does not exist, LOAD statement assigns
  259. NULL to the variable. If the variable value is NULL, SAVE
  260. statement does not create any file.
  261. 2.10 PRINT statement
  262. The PRINT statement writes the argument value to the special
  263. file, its name is received as the command line
  264. option. The statement writes to standard output by default.
  265. Atoms, lists and trees are written in structured form with
  266. the indentation. Identifiers, numbers and Pascal REAL
  267. CONSTANTS are written without the apostrophes, but Pascal STRING
  268. CONSTANTS and non-numerical atoms in apostrophes. The sequence of
  269. the tree selectors is not determined. The maximum depth of nesting can be
  270. changed by #CALL_PAS(78 level). The default level is 15.
  271. The trace information is written to the same file in the same
  272. format.
  273. 2.11. Built-in rules
  274. There are predicates such as #ATOM(E), #NUMBER(E), #IDENT(E),
  275. #LIST(E) and #TREE(E). They return their argument and end
  276. successfully or return NULL and end unsuccessfully.
  277. The built-in rule #LEN(E) returns the number of characters in
  278. the atom, the number of list elements or tree branches.
  279. #EXPLODE(E) returns E decomposed in separate characters.
  280. #IMPLODE(E1 E2 ... EN) concatenates atoms or lists
  281. E1, E2, ..., EN
  282. #CHR(N). The rule returns an atom, which consists of just one
  283. ASCII character with the code N ( 0 <= N <= 255).
  284. #ORD(A). Returns an integer, which is an internal code of the
  285. first character of the non-numerical atom A.
  286. #PARM(T) . Returns a list of the command line parameters.
  287. #DEBUG(E). If E equals the atom 'RULES', then debugging
  288. trace is turned ON , if NORULES, it is turned OFF. The list of
  289. debugging trace messages is given in Appendix C.
  290. #CALL_PAS(N ...) - special Pascal subroutines.
  291. .SH
  292. 3. Scanners and special subroutines (#CALL_PAS)
  293. .LP
  294. The scanners and special subroutines are called in the form
  295. #CALL_PAS ( <number> <parameters ...> )
  296. where <number> defines the option to be executed. The options are
  297. intended for interface between Rigal and Pascal data types, and
  298. they implement procedures which cannot be written in Rigal.
  299. Notions mentioned here are :
  300. - parameters of #CALL_PAS ( after number of option ) are
  301. Rigal objects, and the value returned from this rule is Rigal
  302. object.
  303. - non-numerical atoms, i.e. strings
  304. (including #FATOM , #TATOM and
  305. #IDENT), their
  306. values are used as values of Pascal type STRING
  307. (except #FATOM in #CALL_PAS(80) )
  308. - numerical atoms ( #NUMBER ), their values are used as
  309. values of Pascal integer type (32 bits).
  310. 3.1. ACCESS TO STANDARD INPUT AND OUTPUT
  311. 1. If the first parameter is given, the option writes it on
  312. the screen. The parameter must be non-numerical. The option reads
  313. one line from the standard input. The option returns
  314. the non-numerical atom
  315. containing the string. Zero length string is represented by NULL.
  316. LOOP
  317. $E:=#CALL_PAS(1 'Enter Y or N ');
  318. IF $E ->
  319. IF ($E=Y)OR($E=y)-> $REZ:=T;BREAK;FI;
  320. IF ($E=N)OR($E=n)-> $REZ:=NULL;BREAK;FI;
  321. FI;
  322. END;
  323. This program expects Y or N from the user.
  324. 31. The first parameter is numerical or non-numerical. The
  325. second parameter is numerical. The option converses the first
  326. parameter value to the string, and spaces are added to it (or
  327. some last characters are cut). The length of the string becomes
  328. equal to the second parameter value. The option calls Pascal
  329. WRITE procedure and writes the string on the screen.
  330. 3.2. LEXICAL ANALYZERS
  331. 35. The first parameter must be file name. The atoms are read
  332. from file. The optional second parameter is string of scanner
  333. options. See 4.2 for the detailed definition.
  334. 36. The first parameter must be list of atoms(strings). These
  335. atoms are parsed to smaller atoms. The optional second parameter
  336. is string of scanner options. See 4.3 for the detailed
  337. definition.
  338. 38. No parameters. Returns list of errors which was produced
  339. by last lexical analysis. See 4.11 for details.
  340. 14 and 15. Parameter must be existing file name, and the
  341. lexical scanner of Rigal is applied to this file. The option
  342. returns the list of tokens according to Rigal lexical rules. If
  343. the file does not exist, NULL is returned. Option 14 forces to
  344. include other files marked with %INCLUDE directive.
  345. 16. Parameter must be existing file name. All the lines of
  346. the file are read and appended to the list of atoms (one atom
  347. corresponds to one line).
  348. 3.3. MANIPULATIONS WITH THE COORDINATES
  349. 4. Parameter is any object, except list or tree. When the
  350. lexical scanner forms the output list, every numerical and
  351. non-numerical atom contains the coordinate of the corresponding
  352. token in the source file. See 4.8 on detailed
  353. definition of the coordinate. The option returns
  354. the value of the
  355. coordinate, or 0 if the object has no coordinate.
  356. #MAIN
  357. OPEN LST 'A.LST';
  358. $L:=#CALL_PAS(35 'A.PRG');
  359. #TEST($L)
  360. ##
  361. #TEST
  362. ( 'PROGRAM' !
  363. $E
  364. / LST << #CALL_PAS(4 $E) ' is coordinate of error ' /
  365. )
  366. ##
  367. This program prints the error message with the coordinate of
  368. the first token in file A.LST.
  369. 44. The first parameter is an atom. The second parameter (any
  370. number in 0..65535) is assigned to the coordinate of the atom
  371. (the first parameter) and modified first parameter is returned.
  372. This option is opposite to no. 4.
  373. 3.4. STRING CONVERSION
  374. 21. Parameter must be non-numerical. The option
  375. converts the string to number. If the
  376. conversion is impossible, NULL is returned.
  377. 85. Converts string to uppercase.
  378. 86. Converts string to lowercase.
  379. 87. Evaluates substring. First argument is string,
  380. second and optional third are numbers.
  381. The option takes number of characters specified by the third
  382. argument, starting from character specified by second argument.
  383. If third argument is absent, it takes substring until
  384. the end of string.
  385. #CALL_PAS(87 'AFRIKA' 3 2) returns 'RI'
  386. 88. Both arguments are strings. The option returns position
  387. of the first string in the second one. If position is
  388. not found 0 is returned.
  389. #CALL_PAS(88 'RI' 'AFRIKA') returns 3
  390. 3.5. REAL NUMBERS
  391. 80.You can access some operations with real numbers by #CALL_PAS(80)
  392. utility.
  393. Real numbers are represented as atoms (non identifiers)
  394. with length equal to the size of internal representation of 'real'
  395. type
  396. in your system.
  397. Following operations can be preformed; the second parameter
  398. of #CALL_PAS rule used as an operation sign.
  399. Operation "S" converts atom (or Fatom) to real atom:
  400. $REAL:=#CALL_PAS(80 S '444.22');
  401. $REAL:=#CALL_PAS(80 S '-44.22E05');
  402. #CALL_PAS(80 S '-4+') (invalid string) returns NULL
  403. Operation "I" converts integer to real atom:
  404. $REAL:=#CALL_PAS(80 I 55);
  405. #CALL_PAS(80 I '55') or
  406. #CALL_PAS(80 I $REAL_ATOM) returns NULL
  407. Operation "T" converts real atom to integer;
  408. The value is truncated (but not rounded).
  409. $NUM:=#CALL_PAS(80 T $REAL);
  410. #CALL_PAS(80 T $NOT_REAL) returns NULL
  411. Is possible overflow (run time error).
  412. Operation "Z" converts real atom to string in
  413. corresponding formats.
  414. The format is integer
  415. Format=100*Total_digits+Digits_after_point.
  416. The format value should present in parameters:
  417. If value of $REAL is 13.6254,
  418. #CALL_PAS(80 Z $REAL 702 ) returns ' 13.63'
  419. If argument is not real or format is not integer,
  420. NULL is returned.
  421. Operations '+','-','*','/' return the result:
  422. $REAL1 is 2.2
  423. $REAL2 is 1.5
  424. #CALL_PAS(80 '+' $REAL1 $REAL2) returns 3.7
  425. When '*' or '/' calculates run time error (overflow)
  426. can occur;
  427. If you divide to 0.0 , NULL is returned.
  428. If one of arguments is not real, NULL is returned.
  429. Operations '<','>','<=','>=','=','<>'
  430. return the first (real) argument if succeed and NULL
  431. if fail:
  432. $REAL1 is 2.2
  433. $REAL2 is 1.5
  434. #CALL_PAS(80 '>=' $REAL1 $REAL2) returns 2.2
  435. #CALL_PAS(80 '<=' $REAL1 $REAL2) returns NULL
  436. If one of arguments is not real, NULL is returned.
  437. If wrong operation is given, NULL is returned.
  438. 3.6. OTHER SERVICES
  439. 78. The first parameter is a number.
  440. The option sets maximal depth of nested elements, printed by
  441. statement PRINT. The default value is 15.
  442. 89. Returns list of two strings - system time and date:
  443. (.' 16:30:47 ' '18 Apr 92 ' .)
  444. 90. Closes all the files and halts the program.
  445. 3.7. LOW LEVEL MEMORY CONTROL
  446. NOTE: These control options are intended for advanced
  447. users only.
  448. 40. Parameter of any type. The option returns
  449. a number. Its value is equal to the S-address
  450. of the parameter (converted to number).
  451. 41. No parameters.
  452. The option returns
  453. a number. Its value is equal to the S-address
  454. of the returned atom (converted to number).
  455. 42. No parameters. The option returns a number.
  456. Its value is equal to the page number where the
  457. returned numerical atom was just allocated.
  458. This number is in -128..127.
  459. 43. No parameters. If the virtual memory manager uses the
  460. current (physical) disk drive as secondary disk, then the option
  461. returns the page number of the returned numerical atom (otherwise
  462. 0 is returned).
  463. 46. The first parameter is any Rigal object. The option tests
  464. the current environment. If the interpreter executes the program,
  465. the option returns the same value as the parameter. If the
  466. compiled program is working, the option returns NULL.
  467. 99. Parameter is an atom which is inserted into the generated
  468. Pascal code when the Rigal program is compiled.
  469. 4 The lexical analyzer
  470. .LP
  471. The analyzer reads unstructured data, e.g. strings of
  472. text or files and returns list of tokens or other structures.
  473. You can call the analyzer using #CALL_PAS built-in rule.
  474. The analyzer
  475. - supports Pascal, C and Modula-2 lexics;
  476. - produces labelled trees and lists;
  477. - takes input from Rigal atom or from disk file;
  478. - produces error message list;
  479. - supports different coordinate computation modes;
  480. 4.1 The simplest lexical analyzer
  481. This rule requires a file name and it returns the list of
  482. tokens.
  483. If you write
  484. $A:=#CALL_PAS(35 'A.PAS');
  485. and file A.PAS contains
  486. ABC+752 'TEXT'
  487. then value of variable $A becomes a list of 4 atoms:
  488. (. ABC '+' 752 'TEXT' .)
  489. The coordinates of these atoms are 1, 4, 5 and 9
  490. respectively. Use built-in rule #CALL_PAS(4 ..) to get the
  491. coordinates.
  492. Following questions are discussed here:
  493. How to read from text file ?
  494. How to analyze the atoms like 'ABC+D' ?
  495. How to set options for the analyzer ?
  496. How to change lexical grammar ?
  497. How to control computation of the coordinates ?
  498. How to get tree and list structures ?
  499. How to get error messages ?
  500. 4.2 Reading from file
  501. SYNTAX: $A:=#CALL_PAS (35 filename options)
  502. or
  503. $A:=#CALL_PAS (35 filename)
  504. FUNCTION: Reads tokens from the file
  505. REMARKS: Rigal tries to find the given file name and read from
  506. this file. If the file is absent, NULL is returned. File is set
  507. of zero or more lines, separated by the newline character.
  508. Each line is set of zero or more characters. The newline
  509. character isn't included into the line.
  510. Lines longer than 127 characters are truncated. Lexical grammar
  511. and the coordinates depend of the options specified.
  512. 4.3 Reading from list of atoms
  513. SYNTAX: $A:=#CALL_PAS (36 list_of_atoms options)
  514. or
  515. $A:=#CALL_PAS (36 list_of_atoms)
  516. FUNCTION: Forms tokens from the list of atoms
  517. REMARKS: Rigal reads data from the given list. It should be a
  518. Rigal expression; its value should be list of non-numerical
  519. atoms. This list is interpreted as a set of zero or more lines,
  520. each line is a set of characters. Numeric atoms, lists and trees
  521. are ignored (they are interpreted as empty lines). Lexical
  522. grammar and coordinates depend of the options given.
  523. EXAMPLE:
  524. #CALL_PAS(36 (. ' ABC+D' (. to ignore .) 'EF' .))
  525. returns value
  526. (. 'ABC' '+' 'D' 'EF' .)
  527. 4.5 Options
  528. Options are presented as string of characters followed
  529. by + (on) or - (off) immediately after them.
  530. Default value of options is 'D-C-P+p+m-U+S+O+s-t-L-A+R+Y-B-N-'.
  531. Options supplied by the user overwrite default ones. Note
  532. that some options require other ones, some of them are
  533. incompatible. All such cases are noted below in NOTE sections.
  534. 4.6 Common components of lexical grammars
  535. SPACES. One or more spaces, tabs, newline characters are
  536. ignored during lexical analysis.
  537. COMMENTS. They are ignored during lexical analysis.
  538. The options allow to choose among different comment start and comment
  539. end symbols.
  540. If a comment is not ended at the end of file, error code 12
  541. is produced.
  542. STRING CONSTANTS. They are converted into TATOM atoms.
  543. The options allow to choose among different string constant start and
  544. end symbols and conversion modes. If the end of line appears
  545. within string constant, error code 11 is produced and string con-
  546. stant is truncated.
  547. NUMBERS. They are converted to NUMBER or FATOM atoms.
  548. Integer numbers with less than 10 digits are converted to
  549. NUMBER atoms. Integer numbers with 10 or more digits, floating
  550. point numbers and fixed point numbers are converted to FATOM
  551. atoms. The following grammar rule defines all the acceptable
  552. numbers:
  553. Number ::= Digits [ . [ Digits ] ] [ ( e | E ) [ ( + | - ) ] [ Digits ] ]
  554. Digits ::= Digit*
  555. Digit ::= (0|1|...|9)
  556. IDENTIFIERS. They are converted to IDATOM atoms.
  557. The following grammar rule defines all the ac-
  558. ceptable identifiers:
  559. Identifier ::= Letter Letter_or_digit*
  560. Letter_or_digit ::= ( Letter | Digit | _ )
  561. The options allow to change the set of letters and to
  562. convert all the letters to the uppercase.
  563. SPECIAL SYMBOLS. They are converted to ATOMs.
  564. These symbols consist of 2 or more characters. Set of
  565. special symbols should be specified by options.
  566. SINGLE CHARACTERS. They are converted to ATOMs.
  567. NOTE: All the atoms have length up to 80 bytes. All the
  568. atoms longer are truncated and error code 10 is produced.
  569. 4.7 Using options
  570. The specific properties of different lexical grammars are
  571. set by the following option groups:
  572. Special symbols:
  573. A - Pascal-oriented symbols
  574. L - C-oriented symbols
  575. Identifier conversion: U - convert to uppercase
  576. Comment modes:
  577. P - Pascal-like comments ( (* *) { } )
  578. C - C-like comments ( /* */ )
  579. String constants:
  580. p - Pascal-like ( '..' )
  581. m - Modula-2-like ( '..' and ".." )
  582. For Pascal input you can use the default options.
  583. For C input use
  584. use Pascal or C options and switch some of them on(off) if
  585. necessary. Option 'C+P-m+p-U-L+A-' is recommended for C-like
  586. lexics.
  587. For other languages you should modify some assignments
  588. in the source file SCAN.PAS available in Rigal sources
  589. library.
  590. SYNTAX: A+ A- (default A+)
  591. FUNCTION: Sets Pascal-oriented special symbols and letter set
  592. REMARKS: This option sets the following special symbols:
  593. := <= >= ** .. <>
  594. #Digits_and_letters $Digits_and_letters %Digits_and_letters
  595. {$Any_characters}
  596. SYNTAX: L+ L- (default L-)
  597. FUNCTION: Sets C-oriented special symbols and letter set
  598. REMARKS: This option sets the following special symbols:
  599. -> ++ -- >> << == +=
  600. *= -= /= %= &= ^= |= !=
  601. 0Digits_and_letters
  602. NOTE: L+A+ is not allowed
  603. SYNTAX: P+ P- (default P+)
  604. FUNCTION: Sets Pascal-like comments
  605. REMARKS: This option sets comments start symbol { and (* ,
  606. comment end symbol } and *) . Nested comments are not allowed.
  607. {$...} is not comment. NOTE: Requires A+.
  608. SYNTAX: C+ C- (default C-)
  609. FUNCTION: Sets C-like comments
  610. REMARKS: This option sets comments start symbol /* , comment end
  611. symbol */ . Nested comments are not allowed.
  612. SYNTAX: p+ p- (default p+)
  613. FUNCTION: Sets Pascal-oriented string constants
  614. REMARKS: String constants start and end with one apostrophe (').
  615. An apostrophe within string constant should be written twice, but
  616. only one apostrophe is included into the atom value.
  617. NOTE:Requires P+.
  618. SYNTAX: m+ m- (default m-)
  619. FUNCTION: Sets C- or Modula-oriented string constants
  620. REMARKS: String constants start and end with one apostrophe (')
  621. and is converted to TATOM , or double quotes (") and is converted
  622. to KEYWORD. If back slash appears within string constant, this
  623. and the
  624. next character are included into the atom value. atom value.
  625. NOTE: Requires C+.
  626. 4.8 Coordinate calculation
  627. The lexical analyzer assigns a number (coordinate) to every
  628. atom produced. This number should be in 0..32767. You can access
  629. this number using built-in rule #CALL_PAS(4 ..). Following
  630. options give different modes to calculate this number.
  631. NOTE: Coordinate function does not check for coordinate
  632. value overflow. The function works correctly within given bounds
  633. only.
  634. SYNTAX: R+ (default R+)
  635. FUNCTION: Sets coordinate mode to Line*80+Column
  636. REMARKS: This option sets the coordinate function to
  637. line_number*80+column_number, where line_number in 1..410,
  638. column_number in 1..127.
  639. SYNTAX: s+R- (default R+)
  640. FUNCTION: Sets coordinate mode to Line
  641. REMARKS: This option sets the coordinate function to the line
  642. number (in 1..32767).
  643. SYNTAX: t+R- (default R+)
  644. FUNCTION: Sets coordinate mode to token number
  645. REMARKS: This option sets the coordinate function to the token
  646. number (in 1..32767).
  647. SYNTAX: Y+R- (default R+)
  648. FUNCTION: Sets coordinate mode to the byte number
  649. REMARKS: This option sets the coordinate function to byte number
  650. of the first character of token in source (in 1..32767). Newline
  651. and carriage-return characters are not included in this number.
  652. Coordinate marks (see below) and structure control characters are
  653. included.
  654. SYNTAX: B+R- (default R+)
  655. FUNCTION: Sets coordinate mode to mark_value+bytes_number
  656. REMARKS: This option sets the coordinate function to the last
  657. coordinate mark value plus byte number of the first character of
  658. token starting from the mark (in 1..32767). Newline and carriage-
  659. return characters are not included in this number. Coordinate
  660. marks (see below) and structure control characters are included.
  661. SYNTAX: N+R- (default R+)
  662. FUNCTION: Sets coordinate mode to mark_value
  663. REMARKS: This option sets the coordinate function to the last
  664. coordinate mark value (in 1..32767).
  665. 4.9 Coordinate marks
  666. You can insert a coordinate mark Chr(17) in source and any
  667. number immediately after the mark. The coordinate mark is used
  668. for calculation of coordinates of all the atoms produced between
  669. this mark and next one. The coordinate marks are not converted to
  670. atoms.
  671. EXAMPLE:
  672. #CALL_PAS(36 #IMPLODE ( #CHR(17) 100 ' a') 'N+R-')
  673. returns (.A.) and the coordinate of atom A is 100.
  674. 4.10 Structure control characters
  675. You can insert the structure control characters in source
  676. for lexical analyzer. It allows to have an arbitrary complex
  677. structure of trees and lists rather than simple list of atoms.
  678. Chr(21) - start list
  679. Chr(22) - end list
  680. Chr(23) - start tree
  681. Chr(24) - end tree
  682. Chr(25) - assign name to object
  683. The entire source for lexical analyzer should be accepted by
  684. the following grammar. If the source does not matches grammar,
  685. error codes are produced.
  686. Entire_source ::= (* Item *)
  687. Item ::= ( start_list (* Item *) end_list |
  688. start_tree (* Selector Item *) end_tree |
  689. name_character Item1 Item2 |
  690. token )
  691. Item1 ::= Item
  692. Item2 ::= Item
  693. Selector ::= Non-numeric_token
  694. The corresponding Rigal structure is
  695. #Entire_result (. #Object .) ##
  696. #Object ( (. (* #Object *) .) !
  697. <* #Selector : #Object *> !
  698. #Object1 :: #Object2 !
  699. #Atom ) ##
  700. #Object1 #Object ##
  701. #Object2 #Object ##
  702. EXAMPLE:
  703. #CALL_PAS(36 #IMPLODE(#CHR(21) ' A B ' #CHR(22) ' C ' ))
  704. returns
  705. (. (. A B .) C .)
  706. 4.11 Lexical error messages
  707. The following options allow to control error messages:
  708. SYNTAX: S+ S- (default S+)
  709. FUNCTION: Send error messages to the screen
  710. REMARKS: This option sends the error code number, line and
  711. column number to the screen. This option is intended for
  712. debugging purposes.
  713. SYNTAX: O+ O- (default S+)
  714. FUNCTION: Append error messages to the list
  715. REMARKS: This option collects the error code numbers in the
  716. special list of messages. You can have this list using
  717. $LIST:=#CALL_PAS(38)
  718. $LIST is Rigal list of numeric atoms. Each number is error
  719. code number, but the coordinate of the numeric atom is erroneous
  720. place coordinate. $LIST is NULL if there was no errors during
  721. last lexical analysis. This option is intended for smart
  722. diagnostic purposes. Text of the lexical error messages
  723. (corresponding to the given message code number and the
  724. coordinates) should be constructed by the programmer.
  725. 4.12 Error message code numbers
  726. 1 - unexpected end of file before end of tree
  727. 2 - unexpected end of file within tree branch
  728. 3 - unexpected end of file within tree
  729. 4 - unexpected end of file before end of list
  730. 5 - unexpected end of tree
  731. 6 - unexpected end of list or another control character
  732. 7 - unexpected end of file in name
  733. 8 - unexpected end of file in named object
  734. 9 - unexpected control character
  735. 10 - too long atom ( more than 80 bytes )
  736. 11 - end of string constant not found in the current line
  737. 12 - end of file before end of comment
  738. 13 - control character within comment
  739. 14 - control character within string constant
  740. .SH
  741. APPENDIX A. Messages of the syntax checker
  742. .LP
  743. 2- symbol '##' not found after the main rule
  744. 3- rule name '#...' not found in the beginning of the rule
  745. 5- symbol '##' not found after the rule
  746. 21- rule name '#...' not found in the beginning of the
  747. main rule
  748. 22- symbol '##' not found after the main rule
  749. 23- main rule name is built-in rule name
  750. 30- ending '/' not found after list of statements
  751. 31- symbol '.)' matching '(.' was not found
  752. 37- unexpected element in pattern
  753. 38- unexpected keyword or symbol in pattern
  754. 40- unexpected branch found in tree pattern after vari-
  755. able $a:...
  756. 41- variables not allowed in tree pattern <. $a : ...
  757. 42- variables not allowed in tree pattern <. ... [ $a : ..]
  758. 43- only variables and atoms allowed as branch name in
  759. tree pattern
  760. 44- symbol ':' not found in tree pattern
  761. 45- only one pattern as branch value in tree pattern allowed
  762. 46- symbol ']' matching ']' not found in tree pattern
  763. 47- symbol '.>', '*>' or ',' must be after branch pattern
  764. 48- pattern <* ... .> not allowed
  765. 49- pattern <. ... *> not allowed
  766. 50- a variable not find in the last branch of <* ... *>
  767. 51- no more than 5 branches in <* ... *> allowed
  768. 52- symbol '::' not allowed before rule name
  769. 53- symbol '::' not allowed before '('
  770. 54- must be at least one pattern or action within (* *)
  771. 55- must be at least one pattern or action within (+ +)
  772. 56- must be at least one pattern or action within [ ]
  773. 57- empty tree pattern is not allowed
  774. 58- symbol '::' is not allowed in this position
  775. 59- empty alternative in (..!..) or empty () are not allowed
  776. 61- symbol ';;' or '##' expected
  777. 63- rule name #... not found in the beginning of the rule
  778. 64- symbol ';;' or '##' expected
  779. 65- this rule name is built-in rule name
  780. 66- symbol ';;' or '##' expected
  781. 71- wrong delimiter in (*...* .. ) pattern
  782. 72- symbol ')' expected in (*...* .. ) pattern
  783. 73- symbol '*)' matching '(*' not found
  784. 74- wrong delimiter in (+...+ .. )
  785. 75- symbol ')' expucted in (+...+ .. ) pattern
  786. 76- symbol '+)' matching '(+' not found
  787. 77- symbol ']' matching '[' not found
  788. 81- only one element might be in every part of (..!..!..!..)
  789. 82- only one element might be in the last part of (..!..!..!..)
  790. 83- unexpected symbol in pattern (..!..!..!..)
  791. 84- unexpected '!' found in pattern (..!..!..!..)
  792. 86- symbol '(' expected after s' or v'
  793. 87- symbol ')' expected after s'(... or v'(...
  794. 91- assignment symbol ':=' expected after '!!', '!.', '++' or
  795. 101- - internal error :mainadr<>listmain
  796. 102- - internal error : push for trees
  797. 201- -ins- symbol 'fi','od', '/', '##' or ';' expected
  798. 202- symbol '->' after 'if' expected
  799. 203- symbol 'fi' after 'if...->' expected
  800. 205- symbol '->' after 'elsif' expected
  801. 206- symbol 'fi' after 'elsif...->' expected
  802. 207- statement expected after 'elsif..->'
  803. 208- symbol 'end' matching 'loop' no found
  804. 209- statement expected after 'if..->';
  805. 210- variable name after 'forall' expected
  806. 211- symbol 'in' after 'forall' expected
  807. 212- symbol 'do' after 'forall...in' expected
  808. 213- symbol 'od' or '' expected after forall..do...
  809. 215- symbol ':=' expected after this object
  810. 216- assignment symbol ':=' expected after '!!','!.','+' or
  811. '++'
  812. 217- variable expected after "selectors"
  813. 218- variable expected after "branches"
  814. 220- variable expected after 'load'
  815. 221- variable expected after 'save'
  816. 222- file identifier expected after 'open'
  817. 223- file identifier expected after 'close'
  818. 224- wrong beginning of the statement
  819. 225- unexpected symbol after rule call #..(..)
  820. 301- symbol ')' expected
  821. 302- rule name #... expected after 'last'
  822. 303- vaiable name $... expected after 'last #...'
  823. 304- built-in rule not allowed in 'last'
  824. 307- symbol '$$' allowed only inside s' pattern
  825. 313- symbol '(' expected after 'copy'
  826. 314- symbol ')' expected after 'copy (...'
  827. 321- symbol ']' matching '[' not found in expression
  828. 323- unexpected symbol (end of '<<'-statement not found)
  829. 324- null or a'... not allowed in the left side of
  830. the assignment
  831. 325- symbol '(' expected after rule call in expression
  832. 327- wrong object or symbol in expression
  833. 329- symbol ':' expected in <. ... .> constructor
  834. 330- symbol ',' or '.>' expected in <. ... .> constructor
  835. 331- symbol '','' is unexpected
  836. 405- rule was defined two times (this is the second)
  837. 406- rule was not defined in program
  838. 407- call of the main rule not allowed
  839. 408- variable $ not allowed in the main rule
  840. 409- variable $$ not allowed in the main rule
  841. 501- internal error : 1st parm - not rule name
  842. 503- internal error : 2nd parm - not variable
  843. 504- more than 255 variables in rule
  844. 505- more than 400 rules in program
  845. 521- internal error : no rulename in v-list
  846. 522- internal error : no listmain in r-list variable list
  847. 523- internal error : this rule not found
  848. 524- internal error : no num in v-list 1-st parm
  849. 525- internal error : no num in v-list 2-nd parm
  850. 526- rule #### was not defined in program
  851. 527- rule #### was defined two times
  852. 528- internal error : wrong type in bltin rule table
  853. 699- - unexpected end of program
  854. APPENDIX B. Run time error messages
  855. 1 - Interpreter stack size overflow (stack size = #### );
  856. (Usually looping in the sequence of calls)
  857. 2 - Assignment left side is not list or tree
  858. 3 - List index is not number
  859. 4 - Using [..] not for list
  860. 5 - Index value exceeds list bounds
  861. 6 - Not list or tree after "::"
  862. 7 - Not atomic name before "::"
  863. 8 - NULL in left side of assignment
  864. 9 - Not numerical value in left side of "+:=" statement
  865. 10 - Not numerical value in right side of "+:=" statement
  866. 11 - File specification is not atom
  867. 12 - Too long file specification
  868. 13 - Too much open text files
  869. 14 - File not open for output
  870. 15 - Unable to open file in SAVE
  871. 16 - File was not closed before new opening
  872. 17 - Atom length exceeds file record length
  873. 18 - Unable to open file in LOAD
  874. 19 - Unable to open file in OPEN
  875. 21 - Selector after "." is not identifier
  876. 22 - Selector in tree constructor is not identifier
  877. 23 - Not tree before "." operation
  878. 24 - Not tree or list as base of FORALL-IN statement
  879. 25 - Atom length more than 80 bytes in #IMPLODE
  880. 26 - "BRANCHES" option cannot be used for lists
  881. APPENDIX C. Debugging messages
  882. =>>>CALLS RULE #... IN STATEMENT
  883. 1-ST ARGUMENT($):
  884. =>>>CALLS RULE #... IN PATTERN
  885. 1-ST ARGUMENT($):
  886. >> (BRANCH NO 2)
  887. =>>>CALLS BUILT-IN RULE #... IN STATEMENT: SUCCESS
  888. RESULT:
  889. =>>>CALLS BUILT-IN RULE #... IN PATTERN: SUCCESS
  890. RESULT:
  891. <<<=EXITS FROM RULE #... : SUCCESS
  892. RESULT:
  893. APPENDIX D. Syntax grammar of Rigal
  894. Singature:
  895. NNNN - nonterminal
  896. 'TTTT' - terminal (inner quotes are duplicated)
  897. S1.S2 - concatenation without the delimiters
  898. [ S ] - optional
  899. S1 ! S2 - alternative
  900. (* S *) - iteration 0 or more times
  901. (+ S +) - iteration 1 or more times
  902. (* S * ) - delimiter A
  903. (+ S + ) - delimiter A
  904. ( ) - metaparentheses
  905. Lexical rules:
  906. Letter ::= A..Z,..z
  907. Digit ::= 1!2!3!4!5!6!7!8!9!0
  908. Number ::= (+ digit +)
  909. Symbol ::= visible character
  910. String ::= (+ Symbol +)
  911. Base rules of the grammar
  912. 1) RIGAL_program ::= main_program (* rule *)
  913. 2) main_program ::= '#'.name statements '##'
  914. 3) rule ::= '#'.name (* simple_rule * ';;' ) '##'
  915. 4) simple_rule ::= (* ( sequence_of_patterns !
  916. ( '/' statements '/' ) ) *)
  917. [ 'ONFAIL' statements ]
  918. Patterns
  919. 5) sequence_of_patterns ::=
  920. (* element_of_sequence_of_patterns *)
  921. 6) element_of_sequence_of_patterns ::= pattern !
  922. ( '(*' sequence_of_patterns ( '*)' !
  923. ( '*' atom ')' ) !
  924. ('*' '#'.name ')' )
  925. )!
  926. ( '(+' sequence_of_patterns ( '+)' !
  927. ('+' atom ')') !
  928. ('+' '#'.name ')')
  929. )!
  930. ( '[' sequence_of_patterns ']' ) !
  931. ( '(' sequence_of_patterns ')' ) !
  932. ( '('
  933. (+ element_of_sequence_of_patterns +
  934. '!') ')' )
  935. 7) pattern ::= ( [ variable assignment_symbol ]
  936. ( atom !
  937. variable !
  938. '#'.name !
  939. pattern_of_list !
  940. pattern_of_tree !
  941. 'S''' '(' expression ')' !
  942. 'V''' '(' expression ')' !
  943. ( '(' (* pattern * '!' ) ')' )
  944. )
  945. ) !
  946. ( [ '/' statements '/']
  947. pattern ['/' statements '/'] )
  948. 8) variable ::= '$'.name
  949. 9) assignment_symbol ::= [ '+' ! '++' ! '!!' ! '!.' ] ':='
  950. 10) atom ::= name ! number ! number.'B' ! 'NULL' !
  951. ( ''''. String .'''' )
  952. 11) name ::= letter [. (* ( letter ! digit ! '_' ) *) ]
  953. 12) pattern_of_list ::=
  954. [ ( atom ! variable ) '::' ]
  955. '(.' sequence_of_patterns '.)'
  956. 13) pattern_of_tree ::=
  957. [ ( atom ! variable ) '::' ]
  958. (( '<.' (* element_of_pattern_of_tree * ',') '.>' ) !
  959. ( '<*' (* element_of_pattern_of_tree ',' *)
  960. variable ':' pattern '*>' ) )
  961. 14) element_of_pattern _of_tree ::=
  962. ( atom ':' pattern ) ! ( '[' atom ':' pattern ']' )
  963. Statements
  964. 15) statements ::= (* statement * ';' ) [ ';' ]
  965. 16) statement ::= assignment ! condition! input_output !
  966. return ! fail ! loop ! call ! break
  967. 17) assignment ::= object assignment_symbol expression
  968. 18) condition ::=
  969. 'IF' expression '->' statements
  970. (* 'ELSIF' expression '->' statements ')
  971. 'FI'
  972. 19) input_output ::=
  973. ('LOAD' variable filename )!
  974. ('SAVE' variable filename )!
  975. ('OPEN' name filename )!
  976. ( name '<<' (* ( expression ! '@' ) *) )!
  977. ( name '<]' (* ( expression ! '@' ) *) )!
  978. ( 'CLOSE' name ) !
  979. ( 'PRINT' expression )
  980. 20) filename ::= expression
  981. 21) return ::= 'RETURN' expression
  982. 22) fail ::= 'FAIL'
  983. 23) loop ::= ( 'FORALL'
  984. [ ['SELECTORS'] variable ]
  985. [ 'BRANCHES' variable ]
  986. 'IN' expression
  987. 'DO' statements 'OD' ) !
  988. ( 'LOOP' statements 'END' )
  989. 24) break ::= 'BREAK'
  990. Expressions
  991. 25) object ::=
  992. [ prefix ] ( variable ! '$' ) (* index ! selector *)
  993. 26) expression ::= atom !
  994. ( [ prefix ] ( variable ! '$' ! '$$' ) ) !
  995. constructor !
  996. ( un_operation expression ) !
  997. ( expression bin_operation expression ) !
  998. call !
  999. ( expression (+ index ! selector +) ) !
  1000. ( '(' expression ')' )
  1001. 27) prefix ::= 'LAST' '#'.name
  1002. 28) index ::= '[' expression ']'
  1003. 29) selector ::= '.' expression
  1004. 30) constructor ::= constructor_of_list ! constructor_of_tree
  1005. 31) constructor_of_list ::= '(.' (* expression *) '.)'
  1006. 32) constructor_of_tree ::=
  1007. '<.' (* expression ':' expression * ',')
  1008. '.>'
  1009. 33) bin_operation ::= '!!' ! '!.' ! '++' ! '=' ! '<>' !
  1010. 'AND' ! 'OR' ! '+' ! '-' ! '*' ! 'DIV'! 'MOD'!
  1011. '>' ! '<' ! '>=' ! '<=' ! '::'
  1012. 34) un_operation ::= 'NOT' ! '-'
  1013. 35) call ::= '#'.name '(' (* expression *) ')'
  1014. APPENDIX E. FAST REFERENCE TABLE ON #CALL_PAS PARAMETERS
  1015. ATOM_OR_NULL:=#CALL_PAS(1 ATOM) WRITE and READLN from screen
  1016. NUM:=#CALL_PAS(4 ATOM_OR_NUM) Takes coordinate
  1017. LIST_OR_NULL:=#CALL_PAS(14 FILENAME) Rigal scanner with
  1018. %INCLUDE
  1019. LIST_OR_NULL:=#CALL_PAS(15 FILENAME)
  1020. Rigal scanner without %INCLUDE
  1021. LIST_OR_NULL:=#CALL_PAS(16 FILENAME) Reads file by lines
  1022. NUM_OR_NULL:=#CALL_PAS(21 ATOM) Numerical value from string.
  1023. #CALL_PAS(30 NUM_OR_ATOM) WRITE
  1024. #CALL_PAS(31 NUM_OR_ATOM SIZE) WRITE(X:SIZE)
  1025. $LIST:=#CALL_PAS(35 FILE [OPTIONS]) LEXICAL ANALYSER OF FILE
  1026. $LIST:=#CALL_PAS(36 LIST_OF_STRINGS [OPTIONS])
  1027. LEXICAL ANALYSER OF STRINGS
  1028. $LIST_OF_NUM:=#CALL_PAS(38) LEXICAL ERROR LIST
  1029. NUM:=#CALL_PAS(40 ANY) S-ADDRESS
  1030. NUM:=#CALL_PAS(41) S-ADDRESS of itself
  1031. NUM:=#CALL_PAS(42) Page number
  1032. NUM:=#CALL_PAS(43) Page number on disk (or 0)
  1033. NUM_OR_ATOM:=#CALL_PAS(44 NUM_OR_ATOM NUM)
  1034. Assign new coordinate to atom.
  1035. ANY_OR_NULL:=#CALL_PAS(46 ANY) NULL if this program is com-
  1036. piled
  1037. #CALL_PAS(78 DEPTH) maximal depth for PRINTs
  1038. #CALL_PAS(80 OP ???) Float processor:
  1039. #FATOM or NULL:=#CALL_PAS(80 S String) -- convertion
  1040. #FATOM:=#CALL_PAS(80 I #NUMBER) -- ---"---
  1041. #NUMBER:=#CALL_PAS(80 T #FATOM) -- Truncation
  1042. String:=#CALL_PAS(80 Z #FATOM X*100+Y) -- Formatter
  1043. ( X digits, Y after point )
  1044. #FATOM OR NULL:=#CALL_PAS(80 op #FATOM #FATOM) "op" is +
  1045. - * / < > = <= >= <>
  1046. TEXT:=#CALL_PAS(85 TEXT) UPPERCASE
  1047. TEXT:=#CALL_PAS(86 TEXT) LOWERCASE
  1048. TEXT:=#CALL_PAS(87 TEXT N1 [HOW_MANY])
  1049. SUBSTR(TEXT,N1,HOW_MANY) (default - until till the end)
  1050. NUM:=#CALL_PAS(88 TEXT1 TEXT2) POSITION OF TEXT1 IN TEXT2,
  1051. (0 if not found)
  1052. LIST:=#CALL_PAS(89) Returns data and time:
  1053. #CALL_PAS(90 [errorlevel]) Halts program, closes files.
  1054. #CALL_PAS(99 'a Pascal statement') insert to the compiled
  1055. text.