USERGUID.TXT 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771
  1. University of Latvia
  2. Institute of Mathematcs and Computer Science
  3. RIGAL PROGRAMMING SYSTEM
  4. ========================
  5. FOR IBM/PC/XT/AT IN MS-DOS
  6. PROGRAMMER'S GUIDE
  7. TABLE OF CONTENTS
  8. ABSTRACT
  9. 1. General information
  10. 1.1 Introduction
  11. 1.2 Notions of the integrated environment
  12. 1.3 Files and file extensions
  13. 1.4 About this guide
  14. 1.5 How to contact the authors
  15. 1.6 What is on your disks
  16. 1.7 Configuration requirements
  17. 1.8 Differences between version A and B
  18. 1.9 How to install Rigal on your computer
  19. 1.10 How to start up Rigal
  20. 1.11 Editor menu and the hot keys
  21. 1.12 How to create a simple program
  22. 2. Additional features of the language
  23. 2.1 Rigal lexical syntax
  24. 2.2 Including other files
  25. 2.3 Atom types
  26. 2.4 Lazy boolean evaluation
  27. 2.5 Opening text files
  28. 2.6 Text output
  29. 2.7 Length of the text file line
  30. 2.8 New line format
  31. 2.9 LOAD and SAVE statements
  32. 2.10 PRINT statement
  33. 2.11. Built-in rules
  34. 2.12 Passing parameters to the program
  35. 3. Features of the Integrated Environment
  36. 3.1 Text editor
  37. 3.1.1 Menu bar
  38. 3.1.2 Hot keys
  39. 3.1.3 Editor keys
  40. 3.2 File manipulations
  41. 3.3 Syntax checker
  42. 3.4 The interpreter
  43. 3.4.1 The interpreter in the integrated environment.
  44. 3.4.2 The interpreter in the command line mode.
  45. 3.4.3 Program execution by the interpreter
  46. 3.5 Compiler
  47. 3.5.1 Compilation phases
  48. 3.5.2 How to start up a compiled program
  49. 3.5.3 Execution of the compiled program
  50. 3.6 Cross reference table
  51. 3.7 Show saved Rigal object
  52. 3.8 Type compatibility checker
  53. 3.9 Status of the integrated environment
  54. 4 The new lexical analyzer
  55. 4.1 The simplest lexical utility
  56. 4.2 Reading from file
  57. 4.3 Reading from list of atoms
  58. 4.4 Reading from random access memory
  59. 4.5 Options
  60. 4.6 Common components of the lexical grammars
  61. 4.7 Using options
  62. 4.8 Coordinate calculation
  63. 4.9 Coordinate marks
  64. 4.10 Structure control characters
  65. 4.11 Lexical error messages
  66. 4.12 Error message code numbers
  67. 5 Scanners and special subroutines
  68. 6 Virtual memory
  69. APPENDIX A. Messages of the syntax checker
  70. APPENDIX B. Run time error messages
  71. APPENDIX C. Debugging messages
  72. APPENDIX D. Syntax grammar of Rigal
  73. APPENDIX E. Reference table on #CALL_PAS parameters
  74. ABSTRACT
  75. The Programming system for Rigal programm developement
  76. consists of Rigal integrated environment and several service
  77. programs. This document gives you comprehensive guidelines about
  78. interaction with the programming system.
  79. 1. General information
  80. 1.1 Introduction
  81. Rigal is a high level programming language designed for
  82. syntax analysis, program optimization, code generation, converter
  83. writing and rapid design of language prototypes. RIGAL is
  84. designed in the Institute of Mathematics and Computer Science of
  85. the University of Latvia in 1987 - 1990. It was implemented in
  86. RSX-11M, VAX/VMS and MS-DOS operating systems. Current
  87. implementation runs on IBM/PC/XT&AT and compatible computers.
  88. Implementation uses Borland's Turbo Pascal and Rigal itself.
  89. 1.2 Notions of the integrated environment
  90. Rigal is implemented as a set of united components. We shall
  91. call this union Rigal integrated environment. It includes text
  92. editor, interpreter and compiler. Menus, windows, on line help
  93. and utilities are supported.
  94. The implementation has two versions :
  95. Version A is simple and small. It is intended the beginners;
  96. Version B is more complicated. It is intended for more
  97. advanced users.
  98. The editor is assigned to create, view and modify source
  99. program files. Besides, it allows any ASCII file editing. Other
  100. components are called through pull down menus or functional keys
  101. from the editor window.
  102. These components are the following:
  103. The syntax checker (Check) checks correctness of your Rigal
  104. program and creates an intermediate code for interpretation.
  105. The interpreter (Run) starts up the program. It uses the
  106. intermediate code. The interpreter is intended for program
  107. debugging.
  108. The compiler (Compile) makes executable file of your program.
  109. The result program runs fast. In both cases (interpretation and
  110. running compiled program) results are the same.
  111. Utilities allow to browse or print out contents of saved (by
  112. SAVE statement) Rigal objects. The cross reference table and the
  113. type compatibility checking utility are supported.
  114. 1.3 Files and file extensions
  115. File names consist of no more than 8 symbols. Extensions
  116. consist of no more than 3 symbols. We use the following
  117. extensions :
  118. .EXE - executable file. The Rigal implementation consists of
  119. such files. Rigal compiler makes such files from source program
  120. text.
  121. .RIG - source text in Rigal. Other extensions are not allowed.
  122. .RSC - intermediate code for Rigal program. It is created by
  123. the syntax checker and used by the interpreter.
  124. X*.PAS, X*.TPU, *.RS2, *.RS4 - used by the compiler as
  125. intermediate files. By default they are deleted when compilation
  126. is completed.
  127. .TPL - run time library. It consists of compiled Turbo Pascal
  128. units necessary for the compiler.
  129. .PCK and .CFG - files RIGAL.PCK and RIGAL.CFG contain some
  130. information about the current state of the environment.
  131. Files with extensions RSC, RS2, RS4, PCK, CFG, EXE, TPL, TPU
  132. and all saved Rigal objects are not ASCII text files. They cannot
  133. be processed by the text editor.
  134. 1.4 About this guide
  135. This user's guide will help you to type, debug, compile and
  136. save your program. The diskettes contain simple examples. You can
  137. investigate, execute and modify them.
  138. Before starting the work with Rigal you should know about
  139. MS-DOS operating system, running programs and manipulations with
  140. files and directories.
  141. Pay attention to the version number. There are version
  142. compatibility discussion and last minute notes in README.1ST
  143. file.
  144. 1.5 How to contact the authors
  145. If you want to get some additional information or to inform
  146. us about any problems with Rigal - please contact
  147. Mikhail Auguston, Institute of Mathematics and Computer
  148. Science, Latvia University, Rainis blvd. 29, Riga, Latvia,
  149. SU-226250. Phone (013-2)224363, telex 161172 TEMA SU, e-mail
  150. auguston@lumii.lat.su.
  151. 1.6 What is on your disks
  152. Rigal implementation takes one or some disks. There are both
  153. (A and B) versions on the disks.
  154. File names are the following :
  155. README - text file which contains list of supplied files,
  156. discussion on compatibility with previous versions and last
  157. minute notes.
  158. RIG.EXE - Rigal integrated environment, version A.
  159. RIG1.EXE - Rigal integrated environment, version B.
  160. RIGCHECK.EXE - Independent checker.
  161. INT.EXE - Independent interpreter.
  162. RIGCOMP.EXE - Independent compiler.
  163. RIG_*.EXE - some components of Rigal Integrated environment.
  164. Do not run them. They are called from the integrated environment.
  165. They are :
  166. RIG_CHE.EXE - syntax checker.
  167. RIG_INT.EXE - interpreter.
  168. RIG_CRF.EXE - cross reference utility.
  169. RIG_LINT.EXE - type compatibility utility.
  170. RIG_PNT.EXE - Rigal saved object viewer.
  171. ANRIG.EXE - compiler, analysis part.
  172. GENRIG.EXE - compiler, generation part.
  173. TPC.EXE - Turbo Pascal compiler.
  174. TURBO.TPL - compiled Turbo Pascal units.
  175. *.RIG - examples.
  176. *.TXT - descriptions, guides and manuals.
  177. List of examples and TXT files are given in README.
  178. 1.7 Configuration requirements
  179. Rigal is implemented for IBM/PC XT , IBM/PC AT, IBM PS/2 and
  180. compatible computers. It requires no less than 512 Kbytes of RAM
  181. memory. Operation system must be MS-DOS V.3.0 or higher.
  182. Environment works depending on date and time of file
  183. creation. You must see to it that inner computer clock works
  184. correctly.
  185. Version B requires hard disk, version A does not. The very
  186. huge Rigal programs require up to 3 MBytes on hard disk during
  187. their compilation. If virtual disk driver is turned on, speed
  188. increases and hard disk is used less frequently.
  189. 1.8 Differences between version A and B
  190. Version A is one executable file which includes the editor,
  191. the checker and the interpreter. The compiler and utilities are
  192. not included. You can use the version A without the hard disk.
  193. Version B is a system of some executable files. They are the
  194. editor, the checker, the interpreter, the compiler and the
  195. utilities. The virtual disk driver may be used for the
  196. effectiveness.
  197. There are no differences in text editor, language syntax and
  198. semantics.
  199. 1.9 How to install Rigal on your computer
  200. Make a new directory in your hard disk. Take all the disks
  201. and copy all the files to one directory of the hard disk. If the
  202. files are in the archive, you must extract them. File READ.ME
  203. contains information about it. If you want to obtain only floppy
  204. disk version, copy RIG.EXE to the floppy disk.
  205. 1.10 How to start up Rigal
  206. You can call the Rigal Integrated environment from any
  207. directory, e.g.
  208. \RIGAL\RIG1
  209. Your Rigal source files must be in the current directory.
  210. There are no configuration files. Setting DOS "path" variable is
  211. not required.
  212. You can give a parameter - file name, e.g.
  213. \RIGAL\RIG1 AAA.RIG
  214. Entering such command you start work with file AAA.RIG. The
  215. current disk and directory and extension ".RIG" are default. If
  216. the parameter is not specified at all, then WORK.RIG is default.
  217. If file does not exist, an error message appears on the screen;
  218. press ESC to start work with this new file.
  219. 1.11 Editor menu and the hot keys
  220. There is pull down menu at the top of the editor window and
  221. functional keys list at the bottom.
  222. In the text editor you can use all the letters, digits and
  223. special characters, space bar, arrows (up, down, left, right,
  224. page up, page down, home, end), switch of insert/overwrite mode,
  225. "delete", "backspace" and new line insertion ("Enter" in insert
  226. mode).
  227. In menu window you can use arrows to walk through it,
  228. "Enter" to choose an item, "Esc" to exit menu.
  229. Additional hot keys are available:
  230. Ctrl/Y - delete current line;
  231. Ctrl/B - mark block starting from current line; editor
  232. requires the number of lines which will be included in the block.
  233. Ctrl/P - paste block at the current line;
  234. Ctrl/F - find by pattern starting at the current line;
  235. Ctrl/S - substitute by patterns beginning from the current
  236. line.
  237. Functional keys are :
  238. F1 - help;
  239. F2 - save current file;
  240. F3 - load another file;
  241. F4 - show list of some latest loaded files and choose one of
  242. them;
  243. F5 - show directory (by pattern) and choose one file;
  244. F6 - check program syntax;
  245. F7 - run the program using the interpreter;
  246. F8 - compile the program;
  247. F9 - set command line parameters;
  248. F10 - go to the pull down menu.
  249. ALT/X - exit Rigal integrated environment;
  250. ALT/C - enter Checker and compiler sub menu;
  251. ALT/F - enter File sub menu;
  252. ALT/R - enter Run sub menu;
  253. ALT/S - enter Utility (Services) submenu.
  254. 1.12 How to create a simple program
  255. You can call Rigal integrated environment from any
  256. directory:
  257. \RIGAL\RIG1
  258. Text editor window appears on the screen. If message "File
  259. WORK.RIG is not found" appears, then press "ESC" key.
  260. Now, press ALT/F. Submenu of file manipulations appears.
  261. Select "Create" line using up and down arrows. A new window
  262. appears. Type file name you want to create, e.g. MY.RIG. The new
  263. text editor window appears. It is empty, but on the bottom line
  264. current file name appears: MY.RIG.
  265. Type the following program ( letters must be in the
  266. uppercase) :
  267. -- THIS IS PROGRAM
  268. #START
  269. $A:=(. ALPHA BETA GAMMA DELTA .);
  270. PRINT $A;
  271. $B:=#TAIL($A);
  272. PRINT $B;
  273. ##
  274. #TAIL
  275. (. $E (* $R!. := $K *) .)
  276. / RETURN $R /
  277. ##
  278. There are two rules in this program - #START and #TAIL. The
  279. first rule is the main one, it consists of four statements. There
  280. are two variables - $A and $B. The first statement assigns a list
  281. of four atoms to the variable $A, the third statement assigns to
  282. $B the result of rule #TAIL which works on the argument $A. The
  283. second and the fourth statements print out the values of the
  284. variable (to the screen by default ).
  285. The second rule #TAIL consists of the list pattern (. .) ,
  286. the iteration pattern (* *) and the variable patterns $E and $K.
  287. Values of $K are appended to the list in the variable $R. The
  288. RETURN statement returns the result of this rule to the calling
  289. rule.
  290. Press F2 (Save) key to save the program.
  291. Press F6 (Check) key to check the program. Checked rule names
  292. appear on the screen. If the program has no errors, press "Enter"
  293. to return to the text editor window. If the program has an error,
  294. then the text editor window with an error message appears. The
  295. cursor shows the erroneous place. Correct the error on the screen
  296. and check the program again.
  297. The checker creates special code in file MYPROG.RSC if the
  298. program is correct.
  299. Press F7 (Run) to execute the program. You will see on the
  300. screen :
  301. (. ALPHA BETA GAMMA DELTA
  302. .)
  303. (. BETA GAMMA DELTA
  304. .)
  305. That is the output. The RIGAL interpreter has executed your
  306. program.
  307. If you are working with B version, try one more way to
  308. execute your program. Press F8 to compile it.
  309. The list of the analyzed and coded rules and additional
  310. information appears on the screen. The compiler creates file
  311. MYPROG.EXE and exits the Rigal environment. Type simply MYPROG
  312. after DOS command prompt. The results of the execution will be
  313. the same :
  314. (. ALPHA BETA GAMMA DELTA
  315. .)
  316. (. BETA GAMMA DELTA
  317. .)
  318. Now you can execute other examples or write them by yourself.
  319. 2. Additional features of the language
  320. Some language limitations, extensions and special cases
  321. depending of the implementation are discussed.
  322. 2.1 Rigal lexical syntax
  323. Tokens in Rigal programs are the following :
  324. -- rule names , e.g. #ABC
  325. -- variable names , e.g. $VAR
  326. -- RIGAL key words, e.g. FORALL, ELSIF
  327. -- RIGAL delimiters and special tokens, e.g. ## ! +
  328. -- atoms ( RIGAL data )
  329. The tokens in different cases (upper-case and lower-case)
  330. are different. Type the key words in the upper-case only.
  331. In the following description the LETTERS are A..Z,a..z, the
  332. LETTERS_&_DIGITS are A..Z,a..z.0..9,_ (underscore).
  333. The limitations to Rigal token syntax follow.
  334. RULE NAMES begin with # followed by LETTER and zero or more
  335. LETTERS_&_DIGITS.
  336. VARIABLE names begin with $ followed by LETTER and zero or
  337. more LETTERS_&_DIGITS. If the first letter is N or I (upper-case
  338. only), such pattern variable matches the number or identifier
  339. respectively.
  340. Key words are :
  341. NULL OR AND MOD DIV NOT IF ELSIF FI FORALL IN DO OD LOOP END
  342. BREAK OPEN SAVE LOAD CLOSE PRINT LAST ONFAIL FAIL RETURN
  343. Delimiters and special tokens are :
  344. ## / ;; (* *) ! (+ +) <* *> : , ; := ++ !. !! + - * ( ) <> =<
  345. = >= < > :: <. .> (. .) [ ] . -> << <] @ S' V'
  346. Numerical atoms in Rigal are decimal, from 0 to 2**31-1. The
  347. numbers may be written in octal mode, followed by the letter "B".
  348. Non-numerical atoms are quoted by apostrophes. An apostrophe
  349. inside the atom must be written twice.
  350. If the non-numerical atom is LETTER and zero or more
  351. LETTERS_&_DIGITS, and this atom is not a RIGAL keyword, then it
  352. is allowed to write it without apostrophes.
  353. 2.2 Including other files
  354. Use the %INCLUDE <FILENAME>.RIG directive to include other
  355. files into your program. The extension (.RIG) is necessary, disk
  356. and directory name may be specified (otherwise they are default).
  357. The file name is followed by spaces. Use %INCLUDE only between or
  358. after the rules, rather than between the statements or the
  359. patterns. If the included file does not exist an error message is
  360. produced.
  361. 2.3 Atom types
  362. The atoms (excluding NULL) are implemented as Pascal records
  363. which consist of the type of the atom and the string (or
  364. numerical) value.
  365. There are the following atom types in Rigal:
  366. 1. IDENTIFIER. Such atom value is LETTER and zero or more
  367. LETTERS_&_DIGITS. Such atoms match the built-in rule #IDENT and
  368. I-variables in the patterns. They may be used as the selectors in
  369. the trees.
  370. 2. NON-NUMERIC atoms which are not identifiers.
  371. 3. NUMBER. They match built-in rule #NUMBER and N-variables
  372. in the patterns.
  373. 4. PASCAL STRING CONSTANT. They are created by the PASCAL
  374. scanner and match built-in rule #TATOM.
  375. 5. PASCAL REAL CONSTANT. They are created by PASCAL scanner
  376. and match built-in rule #FATOM predicate. Value is represented as
  377. string.
  378. Other atom types (KEYWORD, SPECIAL, VARIABLE, RULENAME) are
  379. created by the Rigal scanner and intended for internal use.
  380. 2.4 Lazy boolean evaluation
  381. The AND and OR operations are executed in the different modes
  382. in the interpreter and in the compiled program. The interpreter
  383. supports the full evaluation of boolean expressions, but the
  384. compiled program evaluates the necessary arguments only.
  385. 2.5 Opening text files
  386. The statement
  387. OPEN internal-file-name expression
  388. opens text file for output.
  389. The expression must have a value, which represents valid
  390. MS-DOS file name. You can specify the disk and directory, but the
  391. current disk and current directory are default. If it is not an
  392. atom - ERROR 11 message is issued. If the file with such internal
  393. name is already open, then ERROR 16 is issued, and the new file
  394. is not being open. Only 5 files can be open simultaneously, ERROR
  395. 13 appears if you try to open the 6-th file. ERROR 14 appears if
  396. you try to output to the closed file. ERROR 19 appears if the
  397. file name is not valid.
  398. File name which consists of one space symbol corresponds to
  399. the standard output (screen).
  400. Examples :
  401. OPEN LST 'C:\DD\ABC.TXT';
  402. OPEN SCREEN ' ';
  403. OPEN PASCODE #IMPLODE ($Name '.PAS');
  404. 2.6 Text output
  405. The <] and << statements writes the atoms to text file. NULL
  406. is written as empty string. The #TATOM atoms are written in
  407. apostrophes and inner apostrophes are duplicated. The list is
  408. written as sequence of the atoms in the list. The name of the
  409. list and the inner structure is not printed. The trees are not
  410. allowed to be write: the '<*!<*TREE*>!*>' mark will appear in the
  411. text file.
  412. 2.7 Length of the text file line
  413. Default length of the line is 80 bytes.
  414. Before every atom is written its length and length of the
  415. current line are added, and the sum is checked. If the atom does
  416. not fit in 80 bytes, then if insert-space mode is ON, (@ switch)
  417. it causes switch to a new line, but if OFF then the atom is
  418. written to the current line (and length of this line will be more
  419. than the default value).
  420. 2.8 New line format
  421. The << statement writes EOL byte (Chr(13)) and CR byte
  422. (Chr(10)) and then writes the required atoms. If the << statement
  423. is executed immediately after OPEN, the first line in the file
  424. will be empty.
  425. 2.9 LOAD and SAVE statements
  426. RIGAL data loading and saving requires the following
  427. statements:
  428. LOAD $Variable <EXPRESSION>;
  429. SAVE $Variable <EXPRESSION>;
  430. The expression value must be atom, its value must be valid
  431. DOS file name. If it is not atom, ERROR 11 appears. Limitations
  432. and defaults for DOS file name are the same as in OPEN statement.
  433. If file name is invalid, LOAD statement causes ERROR 18, but SAVE
  434. causes ERROR 15. Screen file (' ') is not allowed. If the file
  435. does not exist, LOAD statement assigns NULL to the variable. If
  436. the variable value is NULL, the SAVE statement does not create
  437. any file.
  438. 2.10 PRINT statement
  439. The PRINT statement writes the argument value to the special
  440. PRINT-file, defined in the menu or received as the command line
  441. parameter. The output appears on the screen by default.
  442. Atoms, lists and trees are written in structured form with
  443. the indentation. The identifiers, numbers and Pascal REAL
  444. CONSTANTS are written without the apostrophes, but Pascal STRING
  445. CONSTANTS and non-numerical atoms in apostrophes. The sequence of
  446. the tree selectors is not fixed. The maximum nesting of levels is
  447. 15. It can be changed by #CALL_PAS(78 level).
  448. The trace information is written to the same file in the same
  449. format.
  450. 2.11. Built-in rules
  451. There are predicates such as #ATOM(E), #NUMBER(E), #IDENT(E),
  452. #LIST(E) and #TREE(E). They return their argument and end
  453. successfully or return NULL and end unsuccessfully.
  454. The built-in rule #LEN(E) returns the number of characters in
  455. the atom, the number of list elements or tree branches.
  456. #EXPLODE(E) returns E decomposed in separate characters.
  457. #IMPLODE(E1 E2 ... EN) concatenates atoms or lists E1, E2,
  458. ..., EN in a new atom.
  459. #CHR(N). The rule returns an atom, which consists of just one
  460. ASCII character with the code N ( 0 <= N <= 255).
  461. #ORD(A). Returns an integer, which is an internal code of the
  462. first character of the non-numerical atom A.
  463. #PARM(T) . Returns list of the parameters which was assigned
  464. when the whole program was called for execution.
  465. #DEBUG(E). If E equals the atom 'RULES' then debugging trace
  466. is turned ON , if NORULES, it is turned OFF. List of debugging
  467. trace messages is given in Appendix C.
  468. #CALL_PAS(N ...) - special Pascal subroutines.
  469. 2.12 Passing parameters to the program
  470. If the RIGAL program is run under Rigal Integrated
  471. Environment, you can pass the string of parameters through menu.
  472. If it is executed independently, you can pass the parameters in
  473. the command line.
  474. The string of parameters is a sequence of characters
  475. separated by one or more spaces. They are passed to the program
  476. by #PARM rule . You can call it from any place in program, and in
  477. all the cases it returns the list of parameters.
  478. If the parameters are absent, NULL is returned.
  479. If the parameters are present, then the string of parameters
  480. is parsed to identifiers, non-numerical atoms and numbers.
  481. 3. Features of the Integrated Environment
  482. Rigal Program Development System consists of Rigal
  483. integrated environment and several additional tools. You can
  484. start these tools from the DOS prompt. Some of these tools are
  485. parts of the integrated environment. This chapter covers all the
  486. features of Rigal Program Development System including all the
  487. features of the integrated environment and the additional tools.
  488. 3.1 Text editor
  489. You can use the text editor to enter and modify Rigal programs
  490. and other text files. You can also use any text editor which
  491. operates with ASCII files.
  492. You can start other components of the integrated environment
  493. from text editor window only. You must press corresponding hot
  494. key or select corresponding menu command. Hot key list is at the
  495. bottom of the screen (see 3.1.2) , the menu bar is at the top
  496. (see 3.1.1).
  497. The text of current (active) file is in the edit window. At
  498. every moment the text editor processes only one file, this file
  499. is called "current" file. You can see its full name and cursor
  500. position (row and column number) at the bottom of the screen. The
  501. current editor mode is also shown: INS means "insert" mode,
  502. spaces correspond to "overwrite" mode.
  503. Pay attention to the version number at the upper right corner
  504. of the screen.
  505. 3.1.1 Menu bar
  506. You can see following six menu names in the top of the screen:
  507. Exit, Files, Edit, Check/Compile, Run and Special. Press
  508. ALT+(X,F,E,C,R,S) respectively to enter the menu.
  509. Another way to enter the menu is to press F10 key and to
  510. choose the menu you need by "left" and "right" arrows.
  511. Exit (Alt-X) exits the integrated environment. If the current
  512. file was changed but was not saved, you get warning. If you want
  513. to save the file - press "Y", if you don't want to save it -
  514. press "N", if you cancel exit the integrated environment - press
  515. "ESC" key.
  516. Files menu (Alt-F) manages files and directories (see 3.2).
  517. Edit (Alt-E) returns you to the edit window.
  518. Run menu (Alt-R) starts the interpreter and controls the
  519. parameters and debug mode (see 3.4).
  520. Check/Compile menu (Alt-C) starts the syntax checker and the
  521. compiler.
  522. Special menu (Alt-S) starts some service utilities. These
  523. utilities are cross reference table (see 3.6), saved object
  524. print-out in different modes (see 3.7), the type compatibility
  525. checker (see 3.8) and status show (see 3.9).
  526. 3.1.2 Hot keys
  527. Look at hot key list in the bottom of the screen :
  528. F1 - Show the help screen containing the hot key list and
  529. copyright information.
  530. F2 - Save the current file to the disk (see 3.2).
  531. F3 - Load other file (see 3.2).
  532. F4 - Pick; select one of several latest loaded files (see 3.2).
  533. F5 - Select a file from the directory (see 3.2).
  534. F6 - Start the syntax checker (see 3.3).
  535. F7 - Start the interpreter (see 3.4).
  536. F8 - Start the compiler (see 3.5).
  537. F9 - Set up the parameters (see 3.4.1).
  538. F10 - go to the menu bar.
  539. 3.1.3 Editor keys
  540. You can use all the keys - letters, digits, special
  541. characters, spaces. Use the arrows (up, down, left, right, pgdn,
  542. pgup, home, end) to change the cursor position.
  543. Key INS turns on/off the insert mode. The mode is set to "on"
  544. when you begin. If the insert mode is on, a new character is
  545. inserted before the cursor position. If the insert mode is off, a
  546. character will be written at the current cursor position.
  547. Key DEL deletes the character in the current position,
  548. BACKSPACE deletes one character left to the current position. If
  549. you press BACKSPACE at the start of the line, the current line
  550. will be moved and appended to the previous one.
  551. Key CTRL-Y deletes the current line.
  552. Use buffer to move or copy a part of your file. You can move
  553. or copy only some lines, rather than parts of the line. Press
  554. CTRL-B and enter number of lines to move them to the buffer. You
  555. can see scale of the line relative numbers at the first column of
  556. the window. These lines (starting from the current one) disappear
  557. from the current file and they are placed in the buffer. Press
  558. CTRL-P to insert an exact copy of the lines from the buffer to
  559. the current file before the current line. Use CTRL-P twice if you
  560. want to insert one more copy of the buffer.
  561. Press CTRL-F to search for text in the current file. Type the
  562. text you want to search in the input box and press ENTER. The
  563. cursor will be placed to the position where text is found. The
  564. search direction and scope is forward from the current position.
  565. Press CTRL-S to substitute some text. Type the text you want
  566. to search for in the first input box and the text you want to
  567. replace it with in the second input box. All the substrings in
  568. the file equal to the search text will be replaced. The search
  569. direction and scope is forward from the current position.
  570. The editor operates with text files only. You cannot enter any
  571. special character from the keyboard, but if such characters are
  572. in file, they will be seen.
  573. The width of the editor window is 77 characters, but moving
  574. the cursor to the right you can access the 128-th character. The
  575. characters to the right (129-th and so forth) are ignored when
  576. you load your file from the disk. If there are characters to the
  577. right from 77-th character then a rectangle-like symbol appears
  578. in the last column of the screen.
  579. The maximum size of the file depends on the size of RAM
  580. available. Every line of the file occupies up to 150 bytes. When
  581. you exit the editor this memory is disposed.
  582. 3.2 File manipulations
  583. These options are available through "Files" menu. Some of
  584. them are available through the hot keys too.
  585. In all the options described later, file name may be
  586. specified with drive and directory name. The current drive and
  587. directory are default, extension ".RIG" is default.
  588. Load (F3) - loads new file from the disk. Type file name you
  589. want in the input box. Press ESC to cancel the operation. If the
  590. file does not exist, you get an error. If the file exist, but
  591. previous (current) file was changed and was not saved, you get
  592. question about the problem. Press ESC to cancel the operation,
  593. "Y" to save the current file, "N" not to save.
  594. Save(F2) saves the current file to the disk.
  595. Pick(F4) - loads one of the latest used files. Select one of
  596. (up to) eight latest loaded files. Choose "--load--" line if you
  597. need different file.
  598. Rules of load operation are described above. The list of
  599. eight latest used files is hold in file RIGAL.PCK in the current
  600. directory. You can erase this file, but the editor will restore
  601. it every time when you exit the editor.
  602. Dir (F5) - loads file from the directory list. Type in a file
  603. name with wildcards, which filters the file list of the current
  604. directory to match your specifications. The default file name,
  605. "*.*" displays all files in the current directory. File name "*"
  606. displays all files with extension ".RIG" in the current
  607. directory. File names appear in the alphabetical order followed
  608. by size and creation date and time. Select file you need in the
  609. menu. You can go to the next page of the list of files pressing
  610. ENTER on the upper row of the menu.
  611. WRITE TO - allows to save the current file with different
  612. name. The current file name does not change. New file name must
  613. be valid, otherwise you get an error message. Press ESC to cancel
  614. the operation.
  615. CREATE - allows to create new empty file. New file name must
  616. be valid, otherwise you get an error. Press ESC to cancel the
  617. operation.
  618. OS SHELL - temporal exit to the DOS command interpreter.
  619. Press "EXIT" to return to the integrated environment. This
  620. operation is available in "B" version only.
  621. QUIT - exit the integrated environment (same as ALT-X). If
  622. the current file was changed and was not saved, then question
  623. appears. Press ESC to cancel the operation, "Y" to save the
  624. current file, "N" not to save.
  625. 3.3 Syntax checker
  626. To start the syntax analyzer press F6 key or choose Check
  627. command in Check/Compile menu. You can use command line version
  628. too. The syntax checker analyses the current file (and previously
  629. saves it to the disk). File extension must be ".RIG".
  630. The syntax analyzer checks if the given program matches
  631. Rigal language syntax definition. If other files are included by
  632. %INCLUDE directive, they also are checked. You cannot check an
  633. included file separately, because the first rule in the file must
  634. be "main program" and its syntax differs from other rules.
  635. During the operation rule names and numbers appear on the
  636. screen.
  637. The syntax analysis continues until the first error occurs.
  638. If an error is found, the edit window appears with the source
  639. file where an error is found. Cursor is placed to the erroneous
  640. place. ( NOTE: For implementation technical reasons if there are
  641. an erroneous variable, the cursor is placed to the next token
  642. after it).
  643. The error message appears at the bottom of the screen. It
  644. will clear automatically. Every message has a number, list of
  645. messages is given in Appendix A.
  646. You can make the correction, switch the editor to the main
  647. file of the program (if necessary) and check the program again.
  648. If there are no errors in the program, intermediate code is
  649. produced and it is saved to the disk in file with extension
  650. ".RSC". Message "..saving code..." appears. The intermediate code
  651. is necessary for the interpreter.
  652. You can start the checker RIGCHECK.EXE in the command line
  653. mode. Source program name (without extension) is the first and
  654. the only parameter. A message appears on the screen and can be
  655. redirected by the DOS redirection symbol (">") if necessary. The
  656. message contains the error message text, the file name and the
  657. line number in the parentheses. The column is marked by "^"
  658. character.
  659. 3.4 The interpreter
  660. The interpreter runs the program using the intermediate
  661. code created by the syntax checker.
  662. You can start the interpreter from the integrated
  663. environment (see 3.4.1) or from the DOS prompt (see 3.4.2). The
  664. parameters and the debug mode passing is different in these
  665. cases. Common items are described in 3.4.3.
  666. 3.4.1 The interpreter in the integrated environment.
  667. To start the interpreter press F7 key or choose Run command in
  668. Run menu. The interpreter runs the current program, i.e. the main
  669. source file of the program must be in the edit window. The
  670. extension of the file must be ".RIG", it must be previously
  671. checked and the source must not be updated after the check.
  672. Otherwise you get an error message.
  673. When the interpretation is terminated, press ENTER to exit
  674. the interpreter and return to the editor window.
  675. The operation of the interpreter can be terminated by
  676. CTRL-BREAK or by DOS errors. In version "A" the operation of the
  677. integrated environment terminates, but in version "B" only the
  678. interpretation terminates and the editor window appears.
  679. Set up the parameters using F9 key or Parameters command in
  680. Run menu. Type the parameters in the input box. The parameters
  681. must be separated by one or more spaces, before the first and
  682. after the last parameter spaces are allowed too. Press ENTER when
  683. parameters are entered. Press ESC to set up an empty parameters
  684. string. Once entered the parameters retain until you exit the
  685. integrated environment. The parameters are passed to the
  686. interpreter and the program can receive them via built-in rule
  687. #PARM.
  688. Set up the debugging mode and PRINT-file name via
  689. corresponding commands in Run menu. One of three possible modes
  690. appears in the Print/Debug line of the menu. Press ENTER to
  691. switch the mode. Default mode is when PRINT is turned on, the
  692. debugging mode is turned off. The second mode is when both PRINT
  693. and debugger are turned off. The third mode is when both PRINT
  694. and the debugger are turned on. The PRINT-file name appears in
  695. the fourth line of the menu. The PRINT statements write to this
  696. file and debugger messages are written to this file too. By
  697. default the PRINT-file is assigned to the screen. If you want to
  698. assign PRINT-file to the disk, press ENTER and type file name in
  699. the input box. Press ENTER when file name is entered. Press ESC
  700. or leave the line empty if you want to assign the PRINT file to
  701. the screen. The debugging and PRINT mode and file name retain
  702. until you exit the integrated environment.
  703. 3.4.2 The interpreter in the command line mode.
  704. The command line version of the interpreter is INT.EXE. You
  705. can start it from any directory, and you can supply the
  706. intermediate code for the interpreter form any directory.
  707. If you start the command line version of the interpreter
  708. without the parameters, information about the parameters appears.
  709. The first parameter specifies the name of the intermediate
  710. code. It is file with extension ".RSC". Do not specify the
  711. extension here. If the code does not exist you get an error.
  712. The second parameter specifies the PRINT file name and
  713. debugging mode. It is necessary to specify PRINT file name. Use
  714. letter "s" to assign PRINT file to the screen. Use standard
  715. fictive file name "NUL" to turn the PRINT statements off. Add
  716. symbol "+" immediately after the PRINT file name to turn on the
  717. debug mode.
  718. The program parameters are placed after the second
  719. parameter. The parameters must be separated by one or more
  720. spaces. The parameters are passed to the interpreter and the
  721. Rigal program receives them via built-in #PARM rule (see 2.12).
  722. Example:
  723. If you enter command line
  724. \RIGAL\INT \USER\CC s+ AAA 11
  725. The program \USER\CC.RIG will start (if its intermediate
  726. code \USER\CC.RSC exist). PRINT statements will write to the
  727. screen, debugger is turned on. Statement $X:=#PARM(T) will assign
  728. (.AAA 11.) to the variable $X.
  729. The operation of the interpreter can be terminated by
  730. CTRL-BREAK or by DOS errors.
  731. 3.4.3 Program execution by the interpreter
  732. The interpreter always writes standard messages ("Beginning
  733. of execution" and "End of execution"). If virtual memory manager
  734. uses the physical disk, paging statistics is also reported.
  735. The interpreter loads the intermediate code and then
  736. traverses the code and interprets the encoded operations. The
  737. interpreter reports the debug information (if debug mode is
  738. turned on) and the run-time errors. Run-time error means
  739. incorrect output operations (see 2.5, 2.9) or wrong operand types
  740. in some operations. In most cases the result of erroneous
  741. operation is NULL, the erroneous statement has no effect.
  742. Run-time error messages are written to the screen and to the
  743. PRINT-file. If the PRINT-file is assigned to the screen, then
  744. every run-time error message will appear twice. The message
  745. consist of the number and text, list of error messages is given
  746. in the Appendix B.
  747. 3.5 Compiler
  748. To start the compiler press F8 key or choose Compile command
  749. in Check/Compile menu. You can use the command line version too.
  750. The command line version of the compiler is RIGCOMP.BAT. Two
  751. parameters are necessary for the compilation. First paramter is
  752. source file name without extension. The second paramter is full
  753. path of the directory of the integrated environment.
  754. EXAMPLE:
  755. F:\RIGAL\RIGCOMP C:\SOURCE\ABC F:\RIGAL
  756. This program compiles ABC.RIG to ABC.EXE.
  757. The compiler operates with the current program, i.e. the main
  758. source file of the program must be on the screen. The extension
  759. of the file must be ".RIG". At the beginning of the compilation
  760. the syntax of the program text is analyzed. The syntax error
  761. messages are reported exactly like in the syntax checker (see
  762. 3.3). The intermediate code of the program is not produced. If
  763. there was no errors, command file XCR.BAT and additional file
  764. RIGCOMP.TMP are produced. The command file starts automatically.
  765. During the operation the command file XCR.BAT creates some
  766. intermediate files (their names start with XCR) and compiles them
  767. to the executable file with the same name as source Rigal file,
  768. but with extension ".EXE". See start of the executable file in
  769. 3.5.1 and execution - in 3.5.2.
  770. 3.5.1 Compilation phases
  771. The compiler operates with whole program which consist of
  772. several files included by "%INCLUDE" directive. The separated
  773. compilation of files is not supported. There are four phases of
  774. the compilation - syntax check, syntax analysis, code generation
  775. and code compilation.
  776. The syntax check phase executes searches for syntax errors
  777. and produced command file XCR.BAT and additional list of included
  778. files RIGCOMP.TMP. Other phases are called from XCR.BAT command
  779. file. Here is sample of generated file XCR.BAT for program
  780. C:\SOURCE\A.RIG
  781. @echo off
  782. call f:\rigal\cmplbeg.bat f:\rigal\
  783. f:\rigal\anrig.exe NUL
  784. f:\rigal\genrig.exe NUL
  785. if exist xcrg.exe del xcrg.exe
  786. if exist C:\SOURCE\A.exe del C:\SOURCE\A.exe
  787. del *.rc2
  788. f:\rigal\tpc.exe xcrg /m/l/Tf:\rigal\
  789. copy xcrg.exe C:\SOURCE\A.exe
  790. call f:\rigal\cmplend.bat C:\SOURCE\A
  791. The command file CMPLBEG.BAT copies two files ("USEPAS.PAS" and
  792. "SCAN.PAS") from the integrated environment directory to the
  793. current directory (if they do not exist already).
  794. Program ANRIG.EXE reads list of files RIGCOMP.TMP and reads the
  795. source Rigal files. These files are analyzed and their syntax
  796. code is saved to some intermediate files with extensions ".RC2"
  797. and ".RC4".
  798. Program GENRIG.EXE reads list of files RIGCOMP.TMP and reads
  799. syntax codes. It generates some Pascal files with names XCR*.PAS.
  800. You can MODIFY this line if you want to turn off speed
  801. optimization and eliminate the code size. In this case you should
  802. write parameter "N":
  803. f:\rigal\genrig.exe NUL N
  804. This phase generates files XCRG_0.PAS, XCRG_N.PAS, XCRG_C.PAS,
  805. XCRG.PAS and some others, depending of the number of the files
  806. included.
  807. Old executable files are erased from the current directory.
  808. The intermediate files are also erased.
  809. Program TPC.EXE is Turbo Pascal Compiler. It compiles all the
  810. intermediate Pascal files into the file XCRG.EXE. The result
  811. files are XCRG_0.TPU, XCRG_N.TPU, XCRG_C.TPU, XCRG.EXE and some
  812. others, depending of the number of the files included. The Turbo
  813. Pascal Compiler uses run-time library routines collected in file
  814. TURBO.TPL in the directory of the integrated environment. File
  815. TURBO.TPL is collection of archived Turbo Pascal Units and its
  816. compatibility depends of Turbo Pascal version used.
  817. You can MODIFY this line if you want to use some additional
  818. Turbo Pascal options. Currently the following parameters and
  819. switches are supplied :
  820. /T means directory where TURBO.TPL is in;
  821. /M means compilation of all the necessary (new) files only;
  822. /L means that link buffer is placed in the current disk,
  823. rather than in memory.
  824. Program XCRG.EXE is renamed to file with name equal to the
  825. source program name and extension ".EXE". At the end of the
  826. compilation all the intermediate files are erased from the
  827. current directory.
  828. The retained files are
  829. XCR.BAT - you can start it once again
  830. RIGCOMP.TMP - is necessary for some phases of the compiler
  831. SCAN.PAS - Lexical analyzer, you can modify it.
  832. USEPAS.PAS - Rigal-Pascal interface programs you can modify
  833. it.
  834. You can add some corresponding DEL commands in the
  835. CMPLEND.BAT file if you want to delete these files too.
  836. 3.5.2 How to start up a compiled program
  837. You can copy an executable file to any directory, you can start
  838. it from any directory and it can read and write files to any
  839. directory.
  840. The first parameter should be PRINT-file name. It is
  841. necessary to specify PRINT file name. Use letter "s" to assign
  842. PRINT-file to the screen. Use standard fictive file name "NUL" to
  843. turn the PRINT statements off.
  844. You can specify virtual disk drive name after the slash
  845. symbol ("/"). It is recommended for huge programs or processing
  846. huge data.
  847. The program parameters are placed after the first parameter.
  848. The parameters must be separated by one or more spaces. The
  849. parameters are passed to the interpreter and the Rigal program
  850. receives them via built-in #PARM rule (see 2.12).
  851. Example:
  852. If you enter command line
  853. \USER\CC s/E AAA 11
  854. The program \USER\CC.RIG will start (if it was compiles to
  855. \USER\CC.EXE). PRINT statements will write to the screen. Drive
  856. "E" must be specified as the virtual disk drive. The statement
  857. $X:=#PARM(T) will assign (. AAA 11 .) to variable $X.
  858. 3.5.3 Execution of the compiled program
  859. If the parameters was not specified, help information about the
  860. parameters is reported. At the end of the execution the program
  861. reports virtual memory statistic information (if physical disk
  862. was in use during the execution). The operation can be terminated
  863. by CTRL-BREAK or by DOS errors. The debug information is never
  864. reported and #DEBUG built-in rule has no any effect in compiled
  865. program. Boolean expression evaluation order sometimes differs
  866. from one in the interpreter (see 2.4).
  867. Run-time error means incorrect output operation (see 2.5, 2.9)
  868. or wrong operand types in some operations. In most cases the
  869. result of an erroneous operation is NULL, an erroneous statement
  870. has no effect. The run-time error messages are written to the
  871. PRINT-file only. The message consist of the number and text; list
  872. of error messages is given in the Appendix B.
  873. 3.6 Cross reference table
  874. You should construct a cross reference table for
  875. investigating and debugging large programs. It helps you to see
  876. connections between rules and variables. Following information is
  877. supplied for every rule in your program:
  878. - number and rule name,
  879. - list of rules calling this one,
  880. - list of rules called by this one,
  881. - list of the variables of the rule,
  882. - list of global variables and list of rules which use them.
  883. To construct the Cross-reference table choose "Cross
  884. Reference" in "Special" menu. The table is built for the current
  885. program together with all the included files. The result file has
  886. the same file name as the source program, but extension is
  887. ".CRF".
  888. 3.7 Show saved Rigal object
  889. If you saved a Rigal object to the disk it is useful to look
  890. at the contents and the structure of the object.
  891. Menu "Special" allows you to choose one of four modes:
  892. - to the screen, in pseudo graphical mode; this mode is also
  893. implemented in command line version.
  894. - to text file, in pseudo graphical mode
  895. - to the screen, in PRINT mode
  896. - to text file, in PRINT mode.
  897. After you select the mode in "Special" menu you should specify
  898. file name (with extension) in the input box. The results are
  899. undefined the file has wrong format.
  900. If you choose text file modes, the result file name is
  901. RIGSHOW.LST and this file appears in the edit window.
  902. The command line version is program RPNT.BAT. The parameter
  903. list is similar to the integrated evironment version.
  904. You can also request a component of the object rather than
  905. whole object. A component is branch of tree or element of list.
  906. You should specify additional parameters after the file name.
  907. These parameters must be separated by spaces. Following
  908. parameters are allowed:
  909. IDENTIFIER is accepted as a branch label of Rigal tree and
  910. specify that you need the corresponding branch rather than whole
  911. tree.
  912. NUMBER is accepted as index of Rigal list and specify that
  913. you need the corresponding list element rather than whole list.
  914. ? - specifies that the component should not be printed, only
  915. header information is reported. "?" can be only last parameter of
  916. the parameter list. Only screen mode is supported for "?".
  917. EXAMPLE
  918. You have an object saved in file A.KKK :
  919. <. NN :(. FF GG <. TT : YY , LL : PP .> JJ .), OO :II .>
  920. and you type in the input box
  921. A.KKK NN 3 LL
  922. as the result you will see only single atom PP.
  923. If you have specified parameters
  924. A.KKK NN 3 ?
  925. the following will be reported:
  926. tree without name TT : ID-ATOM
  927. LL : ID-ATOM
  928. The following messages can be reported:
  929. No such file - specified file does not exist
  930. Use "?" only if output to screen - reports with "?" parameter
  931. cannot be written to the file.
  932. object is not list - number was specified for the object
  933. which is not list.
  934. object's length-only NNN - specified number is greater than
  935. list length.
  936. object is not tree - identifier (branch label) was specified
  937. for the object which is not tree.
  938. object has no such selector - identifier (branch label) does
  939. not exist in the tree.
  940. wrong element in parameters - a parameter is not identifier
  941. or number.
  942. In the report about header information following messages
  943. appear:
  944. For list and trees:
  945. NULL; tree; tree without name; tree with name; list ; list
  946. without name; list with name; list length = NNN; list is XXX.
  947. For atoms:
  948. F-ATOM #FATOM
  949. NUMBER-ATOM #NUMBER
  950. ID-ATOM #IDATOM
  951. ATOM #ATOM
  952. RULE-DESK VAR-DESK KEYW-DESK - Atoms constructed by RIGAL
  953. scanner.
  954. 3.8 Type compatibility checker
  955. There is no type and variable declarations in Rigal language.
  956. Nevertheless the values of different types can be assigned to the
  957. variables. There are following data types: lists, trees, atoms,
  958. numbers and other data. Using incompatible types in some
  959. operations is evidence of error in many cases. For example, using
  960. not-lists in "!!" operation, trees in "<<"-statements,
  961. non-numeric data in the argument of the built-in rule #CHR.
  962. Type compatibility checker (Rigal Lint) in many cases allow
  963. to prevent such errors. Values of different type can be assigned
  964. to one variable in different statements or pattern elements of
  965. the rule. Nevertheless it is place of possible error. Type
  966. compatibility checker issues warnings, rather than error
  967. messages. These warnings should help the programmer to be more
  968. disciplined in programming. You can call "Rigal Lint" via menu
  969. "Special". The current program is analyzed (with "%INCLUDE"-ed
  970. files). The messages appear in file with the same name as the
  971. source program, but with extension ".LNT".
  972. 3.9 Status of the integrated environment
  973. You can see the current status of the integrated environment
  974. via menu "Special". The status items retain unchanged when the
  975. integrated environment components are called. These items can be
  976. changed via corresponding windows only 4. Lexical analyser
  977. Some built-in utilities for the lexical analysis are
  978. described here.
  979. 4 The new lexical analyzer
  980. ------------------------------
  981. - supports Pascal, C and Modula-2 lexical grammar rather
  982. than Pascal grammar only;
  983. - produces named trees and lists rather than lists only;
  984. - takes input from Rigal atom, from disk file and from RAM
  985. memory rather than from disk file only;
  986. - produces error message list rather than fixed format error
  987. files;
  988. - supports different coordinate computation modes;
  989. - source Pascal code is open to the user, and can be easy
  990. modified.
  991. 4.1 The simplest lexical utility
  992. The lexical analysis utilities input unstructured data, e.g.
  993. strings of text, files or data from memory and output list of
  994. tokens or other structures. You can call them using #CALL_PAS
  995. built-in rule.
  996. The simplest utility requires a file name and it returns the
  997. list of tokens.
  998. If you write
  999. $A:=#CALL_PAS(35 'A.PAS'); and file A.PAS
  1000. contains
  1001. ABC+752 'TEXT' then $A will contain list
  1002. of 4 atoms :
  1003. (. ABC '+' 752 'TEXT' .)
  1004. The coordinates of these atoms are 1, 4, 5 and 9
  1005. respectively. Use built-in rule #CALL_PAS(4 ..) to get the
  1006. coordinates.
  1007. Following questions are discussed here:
  1008. How to read from text file ?
  1009. How to analyze the atoms like 'ABC+D' ?
  1010. How to get data from random access memory ?
  1011. How to set options for the analyzer ?
  1012. How to change lexical grammar ?
  1013. How to control computation of the coordinates ?
  1014. How to get tree and list structures ?
  1015. How to get error messages ?
  1016. 4.2 Reading from file
  1017. SYNTAX: $A:=#CALL_PAS (35 filename options)
  1018. or
  1019. $A:=#CALL_PAS (35 filename)
  1020. FUNCTION: Reads tokens from disk file
  1021. REMARKS: Rigal tries to find given file name and read from this
  1022. file. If file is absent, NULL is returned. File is set of zero or
  1023. more lines, separated by the newline and carriage-return
  1024. characters. Each line is set of zero or more characters. The
  1025. newline and carriage-return character aren't included into the
  1026. line. Lines longer than 127 characters are truncated. The lexical
  1027. grammar and the coordinates depend of options given.
  1028. 4.3 Reading from list of atoms
  1029. SYNTAX: $A:=#CALL_PAS (36 list_of_atoms options)
  1030. or
  1031. $A:=#CALL_PAS (36 list_of_atoms)
  1032. FUNCTION: Forms tokens from list of atoms
  1033. REMARKS: Rigal reads data from given list. It should be Rigal
  1034. expression; its value should be list of the non-numerical atoms.
  1035. This list is interpreted as set of zero or more lines, each line
  1036. is set of characters. Numeric atoms, lists and trees are ignored
  1037. (they are interpreted as empty lines). Lexical grammar and
  1038. coordinates depend of options given.
  1039. EXAMPLE: #CALL_PAS(36 (. ' ABC+D' (. TO IGNORE .) 'EF' .))
  1040. returns value
  1041. (. 'ABC' '+' 'D' 'EF' .)
  1042. 4.4 Reading from random access memory
  1043. SYNTAX: $A:=#CALL_PAS (37 segment offset options)
  1044. or
  1045. $A:=#CALL_PAS (37 segment offset)
  1046. FUNCTION: Reads tokens from memory
  1047. REMARKS: Rigal tries to read data from the random access
  1048. memory address. The segment and the offset should be numbers.
  1049. This utility is used when Rigal program (or the Rigal
  1050. interpreter) is called from resident non-Rigal user's program.
  1051. Symbol Chr(13) (newline character) should be placed in byte
  1052. corresponding to given memory address. Otherwise NULL is
  1053. returned. This guarantees that we read from correct place.
  1054. Rigal reads the bytes forward, one by one, until Chr(13)
  1055. Chr(26) Chr(13) is encountered.
  1056. Data should be separated to parts. Symbol Chr(13) should be
  1057. used as delimiter. Every part is interpreted as one line, each
  1058. line is set of characters. The newline character isn't included
  1059. into the line.
  1060. Lexical grammar and coordinates depend of options given.
  1061. EXAMPLE:
  1062. A resident program:
  1063. Program E;
  1064. {$M $4000,0,0 } uses Dos;
  1065. const NL=Chr(13); EF=Chr(26);
  1066. var
  1067. datas:string;
  1068. CmdLine,s1,s2: string;j:integer;
  1069. begin
  1070. datas:='A B C ' + NL + ' X D ' + NL+EF+NL;
  1071. write('Source data=');
  1072. for j:=1 to length(datas) do write(' ',ord(datas[j]));
  1073. writeln;
  1074. datas[0]:=NL; { mark about start of data }
  1075. Str(Seg(datas),s1);
  1076. Str(Ofs(datas),s2);
  1077. CmdLine:='RIGPROG '+s1+' '+s2;
  1078. WriteLn('Exec ', CmdLine);
  1079. SwapVectors;
  1080. Exec(GETENV('COMSPEC'),'/C '+ CmdLine);
  1081. SwapVectors;
  1082. WriteLn('...back from Exec');
  1083. if DosError <> 0 then WriteLn('Dos error #', DosError)
  1084. else
  1085. WriteLn('Exit code = ',DosExitCode);
  1086. end.
  1087. Program RIGPROG.RIG :
  1088. #W
  1089. OPEN S ' ';
  1090. $B:=#PARM(T);
  1091. $A:=#CALL_PAS(37 $B[1] $B[2] );
  1092. PRINT $A=(. A B C X D .);
  1093. ##
  1094. This Rigal program should print out character T ;
  1095. 4.5 Options
  1096. Options value should be non-numeric string containing option
  1097. characters and + (on) or - (off) immediately after them. Default
  1098. value of options is 'D-C-P+p+m-U+S+O+s-t-L-A+R+Y-B-N-'. Options
  1099. supplied by the user overwrite default ones. Note that some
  1100. options require other ones, some of them are incompatible. All
  1101. such cases are noted below.
  1102. 4.6 Common components of the lexical grammars
  1103. Spaces. One or more spaces, tabs, newline characters are
  1104. ignored during lexical analysis.
  1105. Comments. They are ignored during lexical analysis.
  1106. The options allow to choose some comment start and comment
  1107. end symbols.
  1108. If comment is not ended at the end of file, error code 12 is
  1109. produced.
  1110. String constants. They are converted to TATOM atoms.
  1111. The options allow to choose some string constant start and
  1112. end symbols and conversion modes. If end of line appears within
  1113. string constant, error code 11 is produced and string constant is
  1114. truncated.
  1115. Numbers. They are converted to NUMBER or FATOM atoms.
  1116. Integer numbers with less than 10 digits are converted to
  1117. NUMBER atoms. Integer numbers with 10 or more digits, floating
  1118. point numbers and fixed point numbers are converted to FATOM
  1119. atoms. Following grammar rule defines all the acceptable numbers:
  1120. Number ::= Digits[.[Digits]][(e|E)[(+|-)][Digits]]
  1121. Digits ::= (*Digit*)
  1122. Digit ::= (0|1|...|9)
  1123. Identifiers. They are converted to IDATOM atoms.
  1124. Following grammar rule defines all the acceptable
  1125. identifiers:
  1126. Identifier ::= Letter (Letter|Digit|_)
  1127. The options allow to change the set of letters and to
  1128. convert all the letter to the uppercase.
  1129. Special symbols. They are converted to ATOMs.
  1130. These symbols consist of 2 or more characters. Set of
  1131. special symbols should be specified by options.
  1132. Single characters. They are converted to ATOMs.
  1133. NOTE: All the atoms have length up to 80 bytes. All the
  1134. atoms longer are truncated and error code 10 is produced.
  1135. 4.7 Using options
  1136. The specific properties of different lexical grammars are
  1137. set by the following option groups:
  1138. Special symbols:
  1139. L - Pascal-oriented symbols
  1140. A - C-oriented symbols
  1141. Identifier conversion: U - convert to uppercase
  1142. Comment modes:
  1143. D - Ada-like comments (--...)
  1144. P - Pascal-like comments ( (* *) { } )
  1145. C - C-like comments ( /* */ )
  1146. String constants:
  1147. p - Pascal-like ( '..' )
  1148. m - Modula-2-like ( '..' and ".." )
  1149. For Pascal input use default options. For C input use
  1150. 'L-A+U-P-C+p-m+' options. For other Pascal- or C-like languages
  1151. use Pascal or C options and switch some of them on(off) if
  1152. necessary. For other languages you should modify some assignments
  1153. in source file SCAN.PAS available in Integrated environment
  1154. directory.
  1155. SYNTAX: A+ A- (default A+)
  1156. FUNCTION: Sets Pascal-oriented special symbols and letter set
  1157. REMARKS: This option sets the following special symbols:
  1158. := <= >= ** .. <>
  1159. #Digits_and_letters
  1160. $Digits_and_letters
  1161. %Digits_and_letters
  1162. {$Any_characters}
  1163. Letters are A..Z,a..z,Chr(128)..Chr(255)
  1164. SYNTAX: D+ D- (default D-)
  1165. FUNCTION: Sets C-oriented special symbols and letter set
  1166. REMARKS: This option sets the following special symbols:
  1167. -> ++ -- >> << == += *= -= /= %= &= ^= |= !=
  1168. 0Digits_and_letters
  1169. Letters are A..Z,a..z,_,$,Chr(128)..Chr(255)
  1170. NOTE: D+A+ is not allowed
  1171. SYNTAX: P+ P- (default P+)
  1172. FUNCTION: Sets Pascal-like comments
  1173. REMARKS: This option sets comments start symbol { and (* ,
  1174. comment end symbol } and *) . Nested comments are not allowed.
  1175. {$...} is not comment. NOTE: Requires A+.
  1176. SYNTAX: C+ C- (default C-)
  1177. FUNCTION: Sets C-like comments
  1178. REMARKS: This option sets comments start symbol /* , comment end
  1179. symbol */ . Nested comments are not allowed.
  1180. NOTE: Requires P+.
  1181. SYNTAX: p+ p- (default p+)
  1182. FUNCTION: Sets Pascal-oriented string constants
  1183. REMARKS: String constants start and end with one apostrophe (').
  1184. An apostrophe within string constant should be written twice, but
  1185. only one apostrophe is included into the atom value. NOTE:
  1186. Requires P+.
  1187. SYNTAX: m+ m- (default m-)
  1188. FUNCTION: Sets C- or Modula-oriented string constants
  1189. REMARKS: String constants start and end with one apostrophe (')
  1190. and is converted to TATOM , or double quotes (") and is converted
  1191. to KEYWORD. If \ appears within string constant, this and the
  1192. next character are included into the atom value. atom value.
  1193. NOTE: Requires C+.
  1194. 4.8 Coordinate calculation
  1195. The lexical analyzer assigns a number (coordinate) to every
  1196. atom produced. This number should be in 0..65535. You can access
  1197. this number using built-in rule #CALL_PAS(4 ..). Following
  1198. options give different modes to calculate this number.
  1199. NOTE: Coordinate function does not check for coordinate
  1200. value overflow. The function works correctly within given bounds
  1201. only.
  1202. SYNTAX: R+ (default R+)
  1203. FUNCTION: Sets coordinate mode to Line*80+Column
  1204. REMARKS: This option sets the coordinate function to
  1205. line_number*80+column_number, where line_number in 1..820,
  1206. column_number in 1..127.
  1207. SYNTAX: s+R- (default R+)
  1208. FUNCTION: Sets coordinate mode to Line
  1209. REMARKS: This option sets the coordinate function to the line
  1210. number (in 1..65535).
  1211. SYNTAX: t+R- (default R+)
  1212. FUNCTION: Sets coordinate mode to token number
  1213. REMARKS: This option sets the coordinate function to the token
  1214. number (in 1..65535).
  1215. SYNTAX: Y+R- (default R+)
  1216. FUNCTION: Sets coordinate mode to the byte number
  1217. REMARKS: This option sets the coordinate function to byte number
  1218. of the first character of token in source (in 1..65535). Newline
  1219. and carriage-return characters are not included in this number.
  1220. Coordinate marks (see below) and structure control characters are
  1221. included.
  1222. SYNTAX: B+R- (default R+)
  1223. FUNCTION: Sets coordinate mode to mark_value+bytes_number
  1224. REMARKS: This option sets the coordinate function to the last
  1225. coordinate mark value plus byte number of the first character of
  1226. token starting from the mark (in 1..65535). Newline and carriage-
  1227. return characters are not included in this number. Coordinate
  1228. marks (see below) and structure control characters are included.
  1229. SYNTAX: N+R- (default R+)
  1230. FUNCTION: Sets coordinate mode to mark_value
  1231. REMARKS: This option sets the coordinate function to the last
  1232. coordinate mark value (in 1..65535).
  1233. 4.9 Coordinate marks
  1234. You can insert a coordinate mark Chr(17) in source and any
  1235. number immediately after the mark. The coordinate mark is used
  1236. for calculation of coordinates of all the atoms produced between
  1237. this mark and next one. The coordinate marks are not converted to
  1238. atoms.
  1239. EXAMPLE:
  1240. #CALL_PAS(36 #IMPLODE ( #CHR(17) 100 ' a') 'N+R-')
  1241. returns (.A.) and the coordinate of atom A is 100.
  1242. 4.10 Structure control characters
  1243. You can insert the structure control characters in source
  1244. for lexical analyzer. It allows to have an arbitrary complex
  1245. structure of trees and lists rather than simple list of atoms.
  1246. Chr(21) - start list
  1247. Chr(22) - end list
  1248. Chr(23) - start tree
  1249. Chr(24) - end tree
  1250. Chr(25) - assign name to object
  1251. The entire source for lexical analyzer should be accepted by
  1252. the following grammar. If the source does not matches grammar,
  1253. error codes are produced.
  1254. Entire_source ::= (* Item *)
  1255. Item ::= ( start_list (* Item *) end_list |
  1256. start_tree (* Selector Item *) end_tree |
  1257. name_character Item1 Item2 |
  1258. token )
  1259. Item1 ::= Item
  1260. Item2 ::= Item
  1261. Selector ::= Non-numeric_token
  1262. The corresponding Rigal structure is
  1263. #Entire_result (. #Object .) ##
  1264. #Object ( (. (* #Object *) .) !
  1265. <* #Selector : #Object *> !
  1266. #Object1 :: #Object2 !
  1267. #Atom ) ##
  1268. #Object1 #Object ##
  1269. #Object2 #Object ##
  1270. EXAMPLE:
  1271. #CALL_PAS(36 #IMPLODE(#CHR(21) ' A B ' #CHR(22) ' C ' ))
  1272. returns
  1273. (. (. A B .) C .)
  1274. 4.11 Lexical error messages
  1275. The following options allow to control error messages:
  1276. SYNTAX: S+ S- (default S+)
  1277. FUNCTION: Send error messages to the screen
  1278. REMARKS: This option sends the error code number, line and
  1279. column number to the screen. This option is intended for
  1280. debugging purposes.
  1281. SYNTAX: O+ O- (default S+)
  1282. FUNCTION: Append error messages to the list
  1283. REMARKS: This option collects the error code numbers in the
  1284. special list of messages. You can have this list using
  1285. $LIST:=#CALL_PAS(38)
  1286. $LIST is Rigal list of numeric atoms. Each number is error
  1287. code number, but the coordinate of the numeric atom is erroneous
  1288. place coordinate. $LIST is NULL if there was no errors during
  1289. last lexical analysis. This option is intended for smart
  1290. diagnostic purposes. Text of the lexical error messages
  1291. (corresponding to the given message code number and the
  1292. coordinates) should be constructed by the programmer.
  1293. 4.12 Error message code numbers
  1294. 1 - unexpected end of file before end of tree
  1295. 2 - unexpected end of file within tree branch
  1296. 3 - unexpected end of file within tree
  1297. 4 - unexpected end of file before end of list
  1298. 5 - unexpected end of tree
  1299. 6 - unexpected end of list or another control character
  1300. 7 - unexpected end of file in name
  1301. 8 - unexpected end of file in named object
  1302. 9 - unexpected control character
  1303. 10 - too long atom ( more than 80 bytes )
  1304. 11 - end of string constant not found in the current line
  1305. 12 - end of file before end of comment
  1306. 13 - control character within comment
  1307. 14 - control character within string constan
  1308. 5 Scanners and special subroutines
  1309. (#CALL_PAS)
  1310. The scanners and special subroutines are called in the form
  1311. #CALL_PAS ( <number> <parameters ...> )
  1312. where <number> defines the option to be executed. The options are
  1313. intended for interface between Rigal and Pascal data types, and
  1314. they implement procedures which cannot be written in Rigal.
  1315. Notions mentioned here are :
  1316. - parameters of #CALL_PAS ( after number of option ) are
  1317. Rigal objects, and the value returned from this rule is Rigal
  1318. object.
  1319. - non-numerical atoms ( including #FATOM , #TATOM and
  1320. #IDENT), their values are used as values of Pascal type STRING.
  1321. - numerical atoms ( #NUMBER ), their values are used as
  1322. values of Pascal type LONGINT.
  1323. Options are described in ascending order.
  1324. 1. If the first parameter is given, the option writes it on
  1325. the screen. The parameter must be non-numerical. The option waits
  1326. for the user's answer (Pascal READLN(STRING) executes). When the
  1327. user presses ENTER key, the option returns the non-numerical atom
  1328. containing the string. Zero length string is represented by NULL.
  1329. EXAMPLE
  1330. LOOP
  1331. $E:=#CALL_PAS(1 'Enter Y or N ');
  1332. IF $E ->
  1333. IF ($E=Y)OR($E=y)-> $REZ:=T;BREAK;FI;
  1334. IF ($E=N)OR($E=n)-> $REZ:=NULL;BREAK;FI;
  1335. FI;
  1336. END;
  1337. This program expects Y or N from the user.
  1338. 2 and 3 .
  1339. NOT recommended to use. See Chapter 4 (Lexical analyser).
  1340. The first parameter must be file name, and the lexical
  1341. scanner of Pascal is applied to this file. The option returns
  1342. list of tokens according to Pascal lexical rules. If the file
  1343. does not exist, NULL is returned. The messages about the lexical
  1344. errors are written to the file with extension '.LER'.
  1345. 4. Parameter is any object, except list or tree. When the
  1346. lexical scanner forms the output list, every numerical and
  1347. non-numerical atom contains the coordinate of the corresponding
  1348. token in the source file. The coordinate is in 0..65535 and it
  1349. equals COLUMN+ROW*80. The option returns the value of the
  1350. coordinate, or 0 if the object has no coordinate.
  1351. EXAMPLE
  1352. #MAIN
  1353. OPEN LST 'A.LST';
  1354. $L:=#CALL_PAS( 3 'A.PRG');
  1355. #TEST($L)
  1356. ##
  1357. #TEST
  1358. ( 'PROGRAM' !
  1359. $E
  1360. / LST << #CALL_PAS(4 $E) ' is coordinate of error ' /
  1361. )
  1362. ##
  1363. This program prints the error message with the coordinate of
  1364. the first token in file A.LST.
  1365. 5. The parameter is identifier. The string containing
  1366. extended ASCII characters (e.g. russian) is transformed to the
  1367. canonical form with standard character set ( for INTERNAL use
  1368. only ).
  1369. 6. Parameter is identifier. Controls the character set (for
  1370. INTERNAL use only ).
  1371. 7. Two parameters are file names, the first is renamed to the
  1372. second one by Pascal RENAME procedure. The numerical value of
  1373. Pascal IORESULT system variable is returned. Zero value
  1374. corresponds to success.
  1375. 8. Parameter is file name, file is deleted by Pascal DELETE
  1376. procedure. The numerical value of Pascal IORESULT system variable
  1377. is returned. Zero value corresponds to success.
  1378. 10. Parameter is any object. The option puts to the screen
  1379. the DUMP of this object. It shows the S-address, physical address
  1380. and contents of its implementation (Pascal record, 40 bytes). The
  1381. option offers the user to enter another S-address in decimal
  1382. format and then shows the next dump. The loop continues until the
  1383. user enters 0.
  1384. 12. Parameter is any object. Object is printed out to the
  1385. PRINT file using pseudo graphic characters of extended ASCII
  1386. code.
  1387. Tree List
  1388. ÄÄÄÂÄname:: ÄÄÄÄÒÄname::
  1389. ÃÄarc1-el1 ÇÄel1
  1390. ÀÄarc2-el2 ÓÄel2
  1391. 13. Parameter is any object. Object is printed out to the
  1392. screen using pseudo graphic characters of extended ASCII code.
  1393. 14 and 15. Parameter must be existing file name, and the
  1394. lexical scanner of Rigal is applied to this file. The option
  1395. returns the list of tokens according to Rigal lexical rules. If
  1396. the file does not exist, NULL is returned. Option 14 forces to
  1397. include other files marked with %INCLUDE directive.
  1398. ACCESS TO SOME PASCAL UTILITIES
  1399. 16. Parameter must be existing file name. All the lines of
  1400. the file are read and appended to the list of atoms (one atom
  1401. corresponds to one line).
  1402. 18. No parameters. The option returns one numerical atom,
  1403. result of Pascal READKEY function. If READKEY returns 0, then
  1404. secondary READKEY result added to 256 is returned by the option.
  1405. EXAMPLE
  1406. Pressing key F2 returns 256+60=316 because the scan-code of
  1407. this key is (0,60).
  1408. 19. No parameters. The option calls Pascal RANDOMIZE
  1409. procedure.
  1410. 20. The parameter must be numerical. The option calls Pascal
  1411. RANDOM function and returns the result (numerical atom).
  1412. Random(N) is in 0..N-1.
  1413. 21. Parameter must be non-numerical. The option calls Pascal
  1414. VAL procedure which converts the string to number. If the
  1415. conversion is impossible, -1 is returned. The option always
  1416. returns a numerical atom.
  1417. SCREEN AND SOUND UTILITIES
  1418. 22. Parameter must be numerical. The option calls Pascal
  1419. DELAY procedure; execution is suspended for N/1000 seconds.
  1420. 23. Parameter must be numerical. The option calls Pascal
  1421. SOUND procedure ; it turns on sound with N Hz frequency.
  1422. 24. No parameters. The option calls Pascal NOSOUND procedure;
  1423. it turns sound off.
  1424. 25. Two parameters must be numerical. The option calls Pascal
  1425. GOTOXY procedure. It sets the cursor to the corresponding place
  1426. in the last opened window ( in the relative coordinates).
  1427. 26. Two parameters must be numerical. The option calls Pascal
  1428. WINDOW procedure. It sets the window to the corresponding
  1429. rectangle (in the absolute coordinates ). The first parameter is
  1430. X1+Y1*80, the second X2+Y2*80.
  1431. 27. Parameter must be numerical. The option sets value of
  1432. Pascal system variable TEXTATTR. Value is equal to Background
  1433. color * 16 + Text color, where the background color in 0..7, the
  1434. text color in 0..15.
  1435. 28. No parameters. The option calls Pascal CLREOL procedure.
  1436. 29. No parameters. The option calls Pascal CLRSCR procedure.
  1437. 30. Parameter is numerical or non-numerical. The option calls
  1438. Pascal WRITE procedure and writes the value on the screen.
  1439. 31. The first parameter is numerical or non-numerical. The
  1440. second parameter is numerical. The option converses the first
  1441. parameter value to the string, and spaces are added to it (or
  1442. some last characters are cut). The length of the string becomes
  1443. equal to the second parameter value. The option calls Pascal
  1444. WRITE procedure and writes the string on the screen.
  1445. 32. No parameters. The option returns numerical value 1 if
  1446. any key of the keyboard is pressed. The option calls Pascal
  1447. KEYPRESSED function.
  1448. 33. No parameters. The option returns X coordinate of the
  1449. cursor (in 1..80) . It uses Pascal WHEREX function.
  1450. 34. No parameters. The option returns Y coordinate of the
  1451. cursor (in 1..25) . It uses Pascal WHEREY function.
  1452. LEXICAL ANALYSER
  1453. 35. The first parameter must be file name. The atoms are read
  1454. from file. The optional second parameter is string of scanner
  1455. options. See 4.2 for the detailed definition.
  1456. 36. The first parameter must be list of atoms(strings). These
  1457. atoms are parsed to smaller atoms. The optional second parameter
  1458. is string of scanner options. See 4.3 for the detailed
  1459. definition.
  1460. 37. The first parameter is segment value, the second is
  1461. offset. The option reads the atoms from the random access memory
  1462. starting from the given address. The optional second parameter is
  1463. string of scanner options. See 4.4 for the detailed definition.
  1464. 38. No parameters. The option returns the list of error
  1465. message numbers. See 4.11 for the detailed definition.
  1466. LOW LEVEL MEMORY CONTROL
  1467. 40. Parameter of any type. The option returns the S-address
  1468. of the parameter (as number).
  1469. 41. No parameters. The option returns the S-address of the
  1470. returned numerical atom.
  1471. 42. No parameters. The option returns the page number of the
  1472. returned numerical atom. This number is in 0..255.
  1473. 43. No parameters. If the virtual memory manager uses the
  1474. current (physical) disk drive as secondary disk, then the option
  1475. returns the page number of the returned numerical atom (otherwise
  1476. 0 is returned).
  1477. 44. The first parameter is an atom. The second parameter (any
  1478. number in 0..65535) is assigned to the coordinate of the atom
  1479. (the first parameter) and modified first parameter is returned.
  1480. This option is opposite to no. 4.
  1481. 45. The first parameter is any Rigal object. The option
  1482. clears all the memory of the structured objects (S-memory),
  1483. excluding this parameter value, and opens the memory once more
  1484. (REOPENs). The option returns the parameter value. All other
  1485. variable values will be unpredictable. The option is useful only
  1486. for big iterative programs in loop in the main rule. In the Rigal
  1487. interpreter the option has no effect (it returns the same value
  1488. as parameter). Use #CALL_PAS(99 'ACON;'); immediately after the
  1489. call.
  1490. 46. The first parameter is any Rigal object. The option tests
  1491. the current environment. If the interpreter executes the program,
  1492. the option returns the same value as the parameter, otherwise it
  1493. returns NULL.
  1494. 47. The first parameter is an atom (file name). The option
  1495. returns full file specification if the file exists (otherwise
  1496. NULL). The option uses Pascal FSEARCH ( FEXPAND(X) ,'') function.
  1497. FAST NUMERIC AND ATOMIC TABLES
  1498. The terms and the notions mentioned here are Common memory,
  1499. Elements of common memory, Numerical and Atomic tables, Table
  1500. elements, Keys. The numerical tables with numerical keys
  1501. (integers) represent the lists of Rigal, the atomic tables with
  1502. atomic keys (identifiers) represent the trees. Elements of table
  1503. may be any Rigal objects. Every element has its own unique key.
  1504. The table utilities work much faster than traditional Rigal
  1505. operations with big lists or trees. Tables are allocated in so
  1506. called Common memory by special user request The user must
  1507. require the total size of the common memory before the execution
  1508. in the command line (after the PRINT-file name, like
  1509. A.LST/M4000). The default size of the common table is 1000
  1510. elements, the physical limit is 160000; every element takes 4
  1511. bytes. Up to 20 numerical or atomic tables can be allocated.
  1512. Every table has its own overflow area and is logically infinite.
  1513. The operation becomes much slower when table overflows.
  1514. The negative error codes can be returned from the table
  1515. functions. Rigal outputs all the error messages only to the PRINT
  1516. file.
  1517. The error codes follow :
  1518. -1 : Numerical parameter required
  1519. -2 : Parameter required
  1520. -3 : Table is not created
  1521. -4 : Wrong table number
  1522. -5 : Too much tables
  1523. -6 : No free common memory at all
  1524. -7 : No more common memory
  1525. -8 : Positive number required
  1526. -9 : Warning: overflow area is used
  1527. -10 : Rigal list required
  1528. -11 : Rigal tree required
  1529. -12 : Identifier required
  1530. -13 : Table length must be positive.
  1531. 59. Used for INTERNAL purposes only.
  1532. 60. The parameter is numerical. The option ALLOCATES a
  1533. numerical table of the length required. All the element values
  1534. are empty. Every numerical table element occupies one element of
  1535. the common memory. The table manager registers the numerical
  1536. table. It is not possible to delete a table. The table number or
  1537. negative error code is returned.
  1538. 61. The parameter is numerical. The option ALLOCATES an
  1539. atomic table of the length required. All the element values are
  1540. empty. Every atomic table element occupies approximately 2.2
  1541. elements of the common memory. The table manager registers the
  1542. numerical table. It is not possible to delete a table. The table
  1543. number or negative error code is returned.
  1544. The optional second parameter is overflow area fragmentation
  1545. size; default value is 10, and the best value may be found during
  1546. experiments with different PUT/GET intensity.
  1547. 62. The parameters are :
  1548. 1 - table number
  1549. 2 - numerical or atomic key (number or identifier)
  1550. 3 - any object
  1551. This option PUTs the object (may be NULL) into the table
  1552. corresponding to the table number and key. The option returns
  1553. NULL if the object was put or negative error code otherwise.
  1554. 63. The parameters are :
  1555. 1 - table number
  1556. 2 - numerical or atomic key ( number or identifier )
  1557. This option GETS an object from the table corresponding to
  1558. table number and key. It returns an object, or NULL if the object
  1559. is absent or an error has occurred.
  1560. 64. The parameter is a table number. The option returns CARD
  1561. of the table (the number of the not-NULL objects in the table) or
  1562. negative error code.
  1563. 65. The parameter is table number.
  1564. The option UNPACKs the table and converses it to Rigal
  1565. object.
  1566. For NUMERIC tables it returns list of the table elements. The
  1567. Nth element value is equal to the Nth element in the list, absent
  1568. elements are conversed to NULL. The tail of NULL elements is cut
  1569. off, therefore the last element of the list is not NULL. If the
  1570. table is empty, then NULL is returned.
  1571. For ATOMIC tables The option returns the tree; the keys are
  1572. tree selectors and elements are the values under the selectors.
  1573. If the table is empty, then NULL is returned. The order of
  1574. branches is arbitrary, and it is not predictable.
  1575. 66. The parameters are
  1576. 1 - table number
  1577. 2 - Rigal object.
  1578. This option PACKs the object into the table. For the NUMERIC
  1579. table the object must be Rigal list, for the ATOMIC table - tree.
  1580. The table is cleared and the Rigal object is transformed to the
  1581. table. The option returns NULL or negative error code.
  1582. 67. The parameters are
  1583. 1 - atomic table number
  1584. 2 - any number.
  1585. This option for every number from 1 to CARD (CARD is returned
  1586. by #CALL_PAS(64) ) returns the identifier. It is a key from this
  1587. table. The option is useful for organizing loop through atomic
  1588. table.
  1589. 78. The parameter is any number.
  1590. This option sets maximum of nested levels for PRINT
  1591. statements. The default value is 15.
  1592. 99. Parameter is an atom which is inserted into the generated
  1593. Pascal code when the Rigal program is compiled.
  1594. For reloading the virtual memory you can use such call:
  1595. #CALL_PAS(99 'Closes;Opens(vdname);Acon;');
  1596. but #CALL_PAS(45) does it in a more effective way.
  1597. 6 Virtual memory
  1598. The Rigal programs can use large amount of data. At the
  1599. beginning the Rigal data are placed in the Random Access Memory
  1600. (in 640 KB limit) given for the program. There are different
  1601. methods of including other memory types and place some data
  1602. there. If the RAM memory is not enough, the disk memory is used.
  1603. When the user works in MS-DOS mode at first a virtual disk driver
  1604. is used. If it overflows, physical disk is used. If the virtual
  1605. disk is too small or it is not specified at all, only the
  1606. physical disk is used.
  1607. The RAM memory plus memory on the disk form Rigal virtual
  1608. memory. The virtual memory manager controls the paging
  1609. algorithms. The memory manager writes the temporal files with
  1610. extension ".TMP" to the physical disk. The temporal files are
  1611. erased when the program ends.
  1612. There are two kinds of virtual memory - A-memory and
  1613. S-memory. A-memory contains texts of Rigal atoms. S-memory
  1614. contains the linked structures forming Rigal data objects (trees,
  1615. lists, integers, atoms). The S-memory is divided to 8 KB pages
  1616. and the memory manager holds them in the RAM or in the temporal
  1617. file on the disk. At the beginning of the execution the virtual
  1618. memory is empty. When the program works it fills the pages and
  1619. changes them, then allocates pages on the disk, reads and writes
  1620. them if necessary. If the program reads and writes to the
  1621. physical disk, the speed decreases 4-8 times. You shold try never
  1622. use physical disk.
  1623. Some advices about using the memory follow:
  1624. 1. Try to set free RAM from resident programs you currently
  1625. do not use.
  1626. 2. Use version B, rather than version A.
  1627. 3. Don't load and particularly don't save to disk Rigal data
  1628. grater than 200 KB becouse normally this data are duplicated in
  1629. the virtual memory during SAVE operation.
  1630. 4. You should know that scanner results take approximately
  1631. 13*N bytes, where N is number of tokens.
  1632. When a program ends, paging manager reports information about
  1633. the number of pages used, the number of page writes and reads.
  1634. This information is reported if the physical disk is used only.
  1635. You can specify virtual disk driver in CONFIG.SYS file:
  1636. DEVICE=RAMDRIVE.SYS 1024 512 64 /e
  1637. Where 1024 is size of the virtual disk in KBytes. Name of the
  1638. virtual drive follow name of the previous drive specified in
  1639. CONFIG.SYS.
  1640. You must specify this name in parameters of the compiled
  1641. Rigal programs. See 3.5.2 for details.
  1642. APPENDIX A. Messages of the syntax checker
  1643. 2- SYMBOL '##' NOT FOUND AFTER THE MAIN RULE
  1644. 3- RULE NAME '#...' NOT FOUND IN THE BEGINNING OF THE RULE
  1645. 5- SYMBOL '##' NOT FOUND AFTER THE RULE
  1646. 21- RULE NAME '#...' NOT FOUND IN THE BEGINNING OF THE MAIN
  1647. RULE
  1648. 22- SYMBOL '##' NOT FOUND AFTER THE MAIN RULE
  1649. 23- MAIN RULE NAME IS BUILT-IN RULE NAME
  1650. 30- ENDING '/' NOT FOUND AFTER LIST OF STATEMENTS
  1651. 31- SYMBOL '.)' MATCHING '(.' WAS NOT FOUND
  1652. 37- UNEXPECTED ELEMENT IN PATTERN
  1653. 38- UNEXPECTED KEYWORD OR SYMBOL IN PATTERN
  1654. 40- UNEXPECTED BRANCH FOUND IN TREE PATTERN AFTER VARIABLE
  1655. $A:...
  1656. 41- VARIABLES NOT ALLOWED IN TREE PATTERN <. $A : ...
  1657. 42- VARIABLES NOT ALLOWED IN TREE PATTERN <. ... [ $A : ..]
  1658. 43- ONLY VARIABLES AND ATOMS ALLOWED AS BRANCH NAME IN TREE
  1659. PATTERN
  1660. 44- SYMBOL ':' NOT FOUND IN TREE PATTERN
  1661. 45- ONLY ONE PATTERN AS BRANCH VALUE IN TREE PATTERN ALLOWED
  1662. 46- SYMBOL ']' MATCHING ']' NOT FOUND IN TREE PATTERN
  1663. 47- SYMBOL '.>', '*>' OR ',' MUST BE AFTER BRANCH PATTERN
  1664. 48- PATTERN <* ... .> NOT ALLOWED
  1665. 49- PATTERN <. ... *> NOT ALLOWED
  1666. 50- A VARIABLE NOT FIND IN THE LAST BRANCH OF <* ... *>
  1667. 51- NO MORE THAN 5 BRANCHES IN <* ... *> ALLOWED
  1668. 52- SYMBOL '::' NOT ALLOWED BEFORE RULE NAME
  1669. 53- SYMBOL '::' NOT ALLOWED BEFORE '('
  1670. 54- MUST BE AT LEAST ONE PATTERN OR ACTION WITHIN (* *)
  1671. 55- MUST BE AT LEAST ONE PATTERN OR ACTION WITHIN (+ +)
  1672. 56- MUST BE AT LEAST ONE PATTERN OR ACTION WITHIN [ ]
  1673. 57- EMPTY TREE PATTERN IS NOT ALLOWED
  1674. 58- SYMBOL '::' IS NOT ALLOWED IN THIS POSITION
  1675. 59- EMPTY ALTERNATIVE IN (..!..) OR EMPTY () ARE NOT ALLOWED
  1676. 61- SYMBOL ';;' OR '##' EXPECTED
  1677. 63- RULE NAME #... NOT FOUND IN THE BEGINNING OF THE RULE
  1678. 64- SYMBOL ';;' OR '##' EXPECTED
  1679. 65- THIS RULE NAME IS BUILT-IN RULE NAME
  1680. 66- SYMBOL ';;' OR '##' EXPECTED
  1681. 71- WRONG DELIMITER IN (*...* .. ) PATTERN
  1682. 72- SYMBOL ')' EXPECTED IN (*...* .. ) PATTERN
  1683. 73- SYMBOL '*)' MATCHING '(*' NOT FOUND
  1684. 74- WRONG DELIMITER IN (+...+ .. )
  1685. 75- SYMBOL ')' EXPUCTED IN (+...+ .. ) PATTERN
  1686. 76- SYMBOL '+)' MATCHING '(+' NOT FOUND
  1687. 77- SYMBOL ']' MATCHING '[' NOT FOUND
  1688. 81- ONLY ONE ELEMENT MIGHT BE IN EVERY PART OF (..!..!..!..)
  1689. 82- ONLY ONE ELEMENT MIGHT BE IN THE LAST PART OF (..!..!..!..)
  1690. 83- UNEXPECTED SYMBOL IN PATTERN (..!..!..!..)
  1691. 84- UNEXPECTED '!' FOUND IN PATTERN (..!..!..!..)
  1692. 86- SYMBOL '(' EXPECTED AFTER S' OR V'
  1693. 87- SYMBOL ')' EXPECTED AFTER S'(... OR V'(...
  1694. 91- ASSIGNMENT SYMBOL ':=' EXPECTED AFTER '!!', '!.', '++' OR
  1695. '+'
  1696. 101- - INTERNAL ERROR :MAINADR<>LISTMAIN
  1697. 102- - INTERNAL ERROR : PUSH FOR TREES
  1698. 201- -INS- SYMBOL 'FI','OD', '/', '##' OR ';' EXPECTED
  1699. 202- SYMBOL '->' AFTER 'IF' EXPECTED
  1700. 203- SYMBOL 'FI' AFTER 'IF...->' EXPECTED
  1701. 205- SYMBOL '->' AFTER 'ELSIF' EXPECTED
  1702. 206- SYMBOL 'FI' AFTER 'ELSIF...->' EXPECTED
  1703. 207- STATEMENT EXPECTED AFTER 'ELSIF..->'
  1704. 208- SYMBOL 'END' MATCHING 'LOOP' NO FOUND
  1705. 209- STATEMENT EXPECTED AFTER 'IF..->';
  1706. 210- VARIABLE NAME AFTER 'FORALL' EXPECTED
  1707. 211- SYMBOL 'IN' AFTER 'FORALL' EXPECTED
  1708. 212- SYMBOL 'DO' AFTER 'FORALL...IN' EXPECTED
  1709. 213- SYMBOL 'OD' OR '' EXPECTED AFTER FORALL..DO...
  1710. 215- SYMBOL ':=' EXPECTED AFTER THIS OBJECT
  1711. 216- ASSIGNMENT SYMBOL ':=' EXPECTED AFTER '!!','!.','+' OR '++'
  1712. 217- VARIABLE EXPECTED AFTER "SELECTORS"
  1713. 218- VARIABLE EXPECTED AFTER "BRANCHES"
  1714. 220- VARIABLE EXPECTED AFTER 'LOAD'
  1715. 221- VARIABLE EXPECTED AFTER 'SAVE'
  1716. 222- FILE IDENTIFIER EXPECTED AFTER 'OPEN'
  1717. 223- FILE IDENTIFIER EXPECTED AFTER 'CLOSE'
  1718. 224- WRONG BEGINNING OF THE STATEMENT
  1719. 225- UNEXPECTED SYMBOL AFTER RULE CALL #..(..)
  1720. 301- SYMBOL ')' EXPECTED
  1721. 302- RULE NAME #... EXPECTED AFTER 'LAST'
  1722. 303- VAIABLE NAME $... EXPECTED AFTER 'LAST #...'
  1723. 304- BUILT-IN RULE NOT ALLOWED IN 'LAST'
  1724. 307- SYMBOL '$$' ALLOWED ONLY INSIDE S' PATTERN
  1725. 313- SYMBOL '(' EXPECTED AFTER 'COPY'
  1726. 314- SYMBOL ')' EXPECTED AFTER 'COPY (...'
  1727. 321- SYMBOL ']' MATCHING '[' NOT FOUND IN EXPRESSION
  1728. 323- UNEXPECTED SYMBOL (END OF '<<'-STATEMENT NOT FOUND)
  1729. 324- NULL OR A'... NOT ALLOWED IN THE LEFT SIDE OF THE
  1730. ASSIGNMENT
  1731. 325- SYMBOL '(' EXPECTED AFTER RULE CALL IN EXPRESSION
  1732. 327- WRONG OBJECT OR SYMBOL IN EXPRESSION
  1733. 329- SYMBOL ':' EXPECTED IN <. ... .> CONSTRUCTOR
  1734. 330- SYMBOL ',' OR '.>' EXPECTED IN <. ... .> CONSTRUCTOR
  1735. 331- SYMBOL '','' IS UNEXPECTED
  1736. 405- RULE WAS DEFINED TWO TIMES (THIS IS THE SECOND)
  1737. 406- RULE WAS NOT DEFINED IN PROGRAM
  1738. 407- CALL OF THE MAIN RULE NOT ALLOWED
  1739. 408- VARIABLE $ NOT ALLOWED IN THE MAIN RULE
  1740. 409- VARIABLE $$ NOT ALLOWED IN THE MAIN RULE
  1741. 501- INTERNAL ERROR : 1ST PARM - NOT RULE NAME
  1742. 503- INTERNAL ERROR : 2ND PARM - NOT VARIABLE
  1743. 504- MORE THAN 255 VARIABLES IN RULE
  1744. 505- MORE THAN 400 RULES IN PROGRAM
  1745. 521- INTERNAL ERROR : no RULENAME in V-list
  1746. 522- INTERNAL ERROR : no LISTMAIN in R-list variable list
  1747. 523- INTERNAL ERROR : THIS RULE NOT FOUND
  1748. 524- INTERNAL ERROR : no num in V-list 1-st parm
  1749. 525- INTERNAL ERROR : no num in V-list 2-nd parm
  1750. 526- RULE #### WAS NOT DEFINED IN PROGRAM
  1751. 527- RULE #### WAS DEFINED TWO TIMES
  1752. 528- INTERNAL ERROR : wrong type in BLTIN rule table
  1753. 699- - UNEXPECTED END OF PROGRAM
  1754. APPENDIX B. Run time error messages
  1755. 1 - Interpreter stack size overflow (stack size = #### );
  1756. (Usually looping in the sequence of calls)
  1757. 2 - Assignment left side is not list or tree
  1758. 3 - List index is not number
  1759. 4 - Using [..] not for list
  1760. 5 - Index value exceeds list bounds
  1761. 6 - Not list or tree after "::"
  1762. 7 - Not atomic name before "::"
  1763. 8 - NULL in left side of assignment
  1764. 9 - Not numerical value in left side of "+:=" statement
  1765. 10 - Not numerical value in right side of "+:=" statement
  1766. 11 - File specification is not atom
  1767. 12 - Too long file specification
  1768. 13 - Too much open text files
  1769. 14 - File not open for output
  1770. 15 - Unable to open file in SAVE
  1771. 16 - File was not closed before new opening
  1772. 17 - Atom length exceeds file record length
  1773. 18 - Unable to open file in LOAD
  1774. 19 - Unable to open file in OPEN
  1775. 21 - Selector after "." is not identifier
  1776. 22 - Selector in tree constructor is not identifier
  1777. 23 - Not tree before "." operation
  1778. 24 - Not tree or list as base of FORALL-IN statement
  1779. 25 - Atom length more than 80 bytes in #IMPLODE
  1780. 26 - "BRANCHES" option cannot be used for lists
  1781. APPENDIX C. Debugging messages
  1782. =>>>CALLS RULE #... IN STATEMENT
  1783. 1-ST ARGUMENT($):
  1784. =>>>CALLS RULE #... IN PATTERN
  1785. 1-ST ARGUMENT($):
  1786. >> (BRANCH NO 2)
  1787. =>>>CALLS BUILT-IN RULE #... IN STATEMENT: SUCCESS
  1788. RESULT:
  1789. =>>>CALLS BUILT-IN RULE #... IN PATTERN: SUCCESS
  1790. RESULT:
  1791. <<<=EXITS FROM RULE #... : SUCCESS
  1792. RESULT:
  1793. APPENDIX D. Syntax grammar of Rigal
  1794. Singature:
  1795. NNNN - nonterminal
  1796. 'TTTT' - terminal (inner quotes are duplicated)
  1797. S1.S2 - concatenation without the delimiters
  1798. [ S ] - optional
  1799. S1 ! S2 - alternative
  1800. (* S *) - iteration 0 or more times
  1801. (+ S +) - iteration 1 or more times
  1802. (* S * € ) - delimiter A
  1803. (+ S + € ) - delimiter A
  1804. ( ) - metaparentheses
  1805. Lexical rules:
  1806. Letter ::= A..Z,..z
  1807. Digit ::= 1!2!3!4!5!6!7!8!9!0
  1808. Number ::= (+ digit +)
  1809. Symbol ::= visible character
  1810. String ::= (+ Symbol +)
  1811. Base rules of the grammar
  1812. 1) RIGAL_program ::= main_program (* rule *)
  1813. 2) main_program ::= '#'.name statements '##'
  1814. 3) rule ::= '#'.name (* simple_rule * ';;' ) '##'
  1815. 4) simple_rule ::= (* ( sequence_of_patterns !
  1816. ( '/' statements '/' ) ) *)
  1817. [ 'ONFAIL' statements ]
  1818. Patterns
  1819. 5) sequence_of_patterns ::= (* element_of_sequence_of_patterns *)
  1820. 6) element_of_sequence_of_patterns ::= pattern !
  1821. ( '(*' sequence_of_patterns ( '*)' !
  1822. ( '*' atom ')' ) !
  1823. ('*' '#'.name ')' ) )!
  1824. ( '(+' sequence_of_patterns ( '+)' !
  1825. ('+' atom ')') !
  1826. ('+' '#'.name ')') )!
  1827. ( '[' sequence_of_patterns ']' ) !
  1828. ( '(' sequence_of_patterns ')' ) !
  1829. ( '(' (+ element_of_sequence_of_patterns + '!') ')' )
  1830. 7) pattern ::= ( [ variable assignment_symbol ]
  1831. ( atom !
  1832. variable !
  1833. '#'.name !
  1834. pattern_of_list !
  1835. pattern_of_tree !
  1836. 'S''' '(' expression ')' !
  1837. 'V''' '(' expression ')' !
  1838. ( '(' (* pattern * '!' ) ')' )
  1839. )
  1840. ) !
  1841. ( [ '/' statements '/'] pattern ['/' statements '/'] )
  1842. 8) variable ::= '$'.name
  1843. 9) assignment_symbol ::= [ '+' ! '++' ! '!!' ! '!.' ] ':='
  1844. 10) atom ::= name ! number ! number.'B' ! 'NULL' !
  1845. ( ''''. String .'''' )
  1846. 11) name ::= letter [. (* ( letter ! digit ! '_' ) *) ]
  1847. 12) pattern_of_list ::=
  1848. [ ( atom ! variable ) '::' ] '(.' sequence_of_patterns '.)'
  1849. 13) pattern_of_tree ::=
  1850. [ ( atom ! variable ) '::' ]
  1851. (( '<.' (* element_of_pattern_of_tree * ',') '.>' ) !
  1852. ( '<*' (* element_of_pattern_of_tree ',' *)
  1853. variable ':' pattern '*>' ) )
  1854. 14) element_of_pattern _of_tree ::=
  1855. ( atom ':' pattern ) ! ( '[' atom ':' pattern ']' )
  1856. Statements
  1857. 15) statements ::= (* statement * ';' ) [ ';' ]
  1858. 16) statement ::= assignment ! condition! input_output !
  1859. return ! fail ! loop ! call ! break
  1860. 17) assignment ::= object assignment_symbol expression
  1861. 18) condition ::= 'IF' expression '->' statements
  1862. (* 'ELSIF' expression '->' statements ') 'FI'
  1863. 19) input_output ::=
  1864. ('LOAD' variable filename )!
  1865. ('SAVE' variable filename )!
  1866. ('OPEN' name filename )!
  1867. ( name '<<' (* ( expression ! '@' ) *) )!
  1868. ( name '<]' (* ( expression ! '@' ) *) )!
  1869. ( 'CLOSE' name ) ! ( 'PRIN’' expression )
  1870. 20) filename ::= expression
  1871. 21) return ::= 'RETURN' expression
  1872. 22) fail ::= 'FAIL'
  1873. 23) loop ::= ( 'FORALL'
  1874. [ ['SELECTORS'] variable ]
  1875. [ 'BRANCHES' variable ]
  1876. 'IN' expression
  1877. 'DO' statements 'OD' ) !
  1878. ( 'LOOP' statements 'END' )
  1879. 24) break ::= 'BREAK'
  1880. Expressions
  1881. 25) object ::=
  1882. [ prefix ] ( variable ! '$' ) (* index ! selector *)
  1883. 26) expression ::= atom !
  1884. ( [ prefix ] ( variable ! '$' ! '$$' ) ) !
  1885. constructor !
  1886. ( un_operation expression ) !
  1887. ( expression bin_operation expression ) !
  1888. call !
  1889. ( expression (+ index ! selector +) ) !
  1890. ( '(' expression ')' )
  1891. 27) prefix ::= 'LAST' '#'.name
  1892. 28) index ::= '[' expression ']'
  1893. 29) selector ::= '.' expression
  1894. 30) constructor ::= constructor_of_list ! constructor_of_tree
  1895. 31) constructor_of_list ::= '(.' (* expression *) '.)'
  1896. 32) constructor_of_tree ::=
  1897. '<.' (* expression ':' expression * ',') '.>'
  1898. 33) bin_operation ::= '!!' ! '!.' ! '++' ! '=' ! '<>' !
  1899. 'AND' ! 'OR' ! '+' ! '-' ! '*' ! 'DIV'! 'MOD'!
  1900. '>' ! '<' ! '>=' ! '<=' ! '::'
  1901. 34) un_operation ::= 'NOT' ! '-'
  1902. 35) call ::= '#'.name '(' (* expression *) ')'
  1903. APPENDIX E. FAST REFERENCE TABLE ON #CALL_PAS PARAMETERS
  1904. (*********************************************************)
  1905. (******** ********************)
  1906. (******** VERSION 2.28 ********************)
  1907. (******** ********************)
  1908. (*********************************************************)
  1909. ATOM_OR_NULL:=#CALL_PAS(1 ATOM) WRITE and READLN from screen
  1910. LIST_OR_NULL:=#CALL_PAS(2 FILENAME) Pascal scanner
  1911. LIST_OR_NULL:=#CALL_PAS(3 FILENAME) Pascal scanner
  1912. NUM:=#CALL_PAS(4 ATOM_OR_NUM) Takes coordinate
  1913. IDENT:=#CALL_PAS(5 IDENT) Recodes russian identifier
  1914. IDENT_OR_NULL:=#CALL_PAS(6 IDENT) Identifier is russian ?
  1915. NUM_IoResult:=#CALL_PAS(7 FILE1 FILE2) RENAME
  1916. NUM_IoResult:=#CALL_PAS(8 FILE) DELETE
  1917. #CALL_PAS(10 ANY) Prints hexadecimal dump
  1918. #CALL_PAS(12 ANY) Nice print to PRINT file
  1919. #CALL_PAS(13 ANY) Nice print to screen
  1920. LIST_OR_NULL:=#CALL_PAS(14 FILENAME) Rigal scanner with %INCLUDE
  1921. LIST_OR_NULL:=#CALL_PAS(15 FILENAME) Rigal scanner without
  1922. %INCLUDE
  1923. LIST_OR_NULL:=#CALL_PAS(16 FILENAME) Reads file by lines
  1924. NUM:=#CALL_PAS(18) READKEY (0..255, 256+0..256+255)
  1925. #CALL_PAS(19) RANDOMIZE
  1926. NUM:=#CALL_PAS(20 NUM) RANDOM ( NUM )
  1927. NUM:=#CALL_PAS(21 ATOM) Numerical VAL of string. (NULL if error)
  1928. 37L, 37l is also allowed.
  1929. #CALL_PAS(22 NUM) DELAY
  1930. #CALL_PAS(23 NUM) SOUND
  1931. #CALL_PAS(24) NOSOUND
  1932. #CALL_PAS(25 X Y) GOTOXY(X,Y)
  1933. #CALL_PAS(26 X1+Y1*80 X2+Y2*80) WINDOW(X1,Y1,X2,Y2)
  1934. #CALL_PAS(27 B_COL*16+TEXT_COL) TEXTATTR:=...
  1935. #CALL_PAS(28) CLREOL
  1936. #CALL_PAS(29) CLRSCR
  1937. #CALL_PAS(30 NUM_OR_ATOM) WRITE
  1938. #CALL_PAS(31 NUM_OR_ATOM SIZE) WRITE(X:SIZE)
  1939. NULL_OR_1:=#CALL_PAS(32) KEYPRESSED (yes=1)
  1940. X:=#CALL_PAS(33) WHEREX (where cursor)
  1941. Y:=#CALL_PAS(34) WHEREY
  1942. $LIST:=#CALL_PAS(35 FILE [OPTIONS]) LEXICAL ANALYSER OF FILE
  1943. $LIST:=#CALL_PAS(36 LIST_OF_STRINGS [OPTIONS])
  1944. LEXICAL ANALYSER OF STRINGS
  1945. $LIST:=#CALL_PAS(37 SEGM OFS [OPTIONS])
  1946. LEXICAL ANALYSER OF RAM ADDRESS
  1947. $LIST_OF_NUM:=#CALL_PAS(38) LEXICAL ERROR LIST
  1948. NUM:=#CALL_PAS(40 ANY) S-ADDRESS
  1949. NUM:=#CALL_PAS(41) S-ADDRESS of itself
  1950. NUM:=#CALL_PAS(42) Page number
  1951. NUM:=#CALL_PAS(43) Page number on disk (or 0)
  1952. NUM_OR_ATOM:=#CALL_PAS(44 NUM_OR_ATOM NUM) Assign new coordinate
  1953. to atom.
  1954. ANY:=#CALL_PAS(45 ANY) Reopens memory
  1955. ANY_OR_NULL:=#CALL_PAS(46 ANY) NULL if this program is compiled
  1956. Argument if it is run by the interpreter.
  1957. EXPANDED_FILENAME_OR_NULL:=#CALL_PAS(47 [ FILENAME ])
  1958. Expands file name by adding full path.
  1959. If FILENAME is not given, CURRENT directory path is returned
  1960. with ending '\'.
  1961. FILENAME_OR_NULL:=#CALL_PAS(48 FILENAME) Returns FILENAME is
  1962. such file exists ?
  1963. =============== WORK with tables ====================
  1964. TABNUM:=#CALL_PAS(60 SIZE) Allocate numerical
  1965. TABNUM:=#CALL_PAS(61 SIZE [ FRAGMSIZE ] ) Allocate atomic
  1966. NULL_or_ERNUM:=#CALL_PAS(62 TABNUM KEY ANY) PUT
  1967. ANY:=#CALL_PAS(63 TABNUM KEY) GET
  1968. SIZE:=#CALL_PAS(64 TABNUM) CARD
  1969. LIST_OR_TREE:=#CALL_PAS(65 TABNUM) UNPACK
  1970. NULL_OR_ERNUM:=#CALL_PAS(66 TABNUM LIST_OR_TREE) PACK
  1971. KEY:=#CALL_PAS(67 TABNUM NUM) KEY by order
  1972. 68,69,70,71,72 - Reserved for tables
  1973. ============== DDE of Protocol 1 =====================
  1974. #CALL_PAS(73 APPL_NAME TOPIC_NAME) waits for the answer
  1975. from WINDOWS DDE Client
  1976. STRING:=#CALL_PAS(74) waits and gets WINDOWS DDE message
  1977. #CALL_PAS(75 STRING) sends WINDOWS DDE message
  1978. T:=#CALL_PAS(76 T) allocates buffers for WINDOWS DLL
  1979. Returns NULL if unsuccess
  1980. LIST_of_rez:=#CALL_PAS(77 (.Parm1 Parm2 ... .) ) calls a WINDOWS
  1981. SFDLL.DLL screen management service
  1982. The parameters can be ATOMS, NUMBERS or one-level list of atoms,
  1983. which represents splitted string. (. 'AB' 'C' .) is the same as 'ABC'.
  1984. LIST_of_rez is the same types of parameters. Error is reported
  1985. in 1st or 2nd element.
  1986. NULL is reported if there are errors in parameter list.
  1987. #CALL_PAS(78 DEPTH) maximal depth for PRINTs
  1988. $ATOM:=#CALL_PAS(79 TREE BRANCH_VALUE)
  1989. Returns selector; BRANCH_VALUE must be Numeric or non-numeric atom
  1990. $NUMBER:=#CALL_PAS(79 LIST ELEMENT_VALUE)
  1991. Returns index. ELEMENT_VALUE must be Numeric or non-numeric atom
  1992. If unsuccess, returns NULL.
  1993. =============== Float processor =====================
  1994. #CALL_PAS(80 OP ???) Float processor:
  1995. #FATOM or NULL:=#CALL_PAS(80 S String) -- convertion
  1996. #FATOM:=#CALL_PAS(80 I #NUMBER) -- ---"---
  1997. #NUMBER:=#CALL_PAS(80 T #FATOM) -- Truncation
  1998. (.0 0.) or (.bef aft):=#CALL_PAS(80 D #FATOM) - Digit number before and after
  1999. -- point in decimal real numbers.
  2000. String:=#CALL_PAS(80 Z #FATOM X*100+Y) -- Formatter
  2001. ( X digits, Y after point )
  2002. #FATOM OR NULL:=#CALL_PAS(80 op #FATOM #FATOM) "op" is +
  2003. - * / < > = <= >= <>
  2004. (!) SEE MORE DETAILS IN "80.TXT"
  2005. #CALL_PAS(81 APPL_NAME TOPIC_NAME) initializes a WINDOWS
  2006. window of the application
  2007. $REZ:=#CALL_PAS(82 TITLE STRING_WITH_nl [MODE] )
  2008. shows a WINDOWS Message box, returns button
  2009. pressed.
  2010. Default mode is mb_iconInformation+mb_ok.
  2011. If MODE is 36 then "Yes" is 6, "No" is 7
  2012. -- the same is available with R_MESSA functiuon of GRAD.DLL
  2013. $REZ:=#CALL_PAS(83 TITLE TEXT) shows a WINDOWS input
  2014. box, returns modified text.
  2015. #CALL_PAS(84 N VALUE) modifies a WINDOWS WinCrt window of
  2016. the application BEFORE the very first output.
  2017. N=1,2 WindowORG N=3,4 WindowSIZE N=5,6 ScreenSIZE
  2018. TEXT:=#CALL_PAS(85 TEXT) UPPERCASE
  2019. TEXT:=#CALL_PAS(86 TEXT) LOWERCASE
  2020. TEXT:=#CALL_PAS(87 TEXT N1 [HOW_MANY]) SUBSTR(TEXT,N1,HOW_MANY)
  2021. (default - to the end)
  2022. NUM:=#CALL_PAS(88 TEXT1 TEXT2) POSITION OF TEXT1 IN TEXT2,
  2023. (0 if not found)
  2024. LIST:=#CALL_PAS(89) Returns data and time:
  2025. (. YEAR MONTH DAY WEEKDAY HOUR MIN SEC MICROSEC .)
  2026. #CALL_PAS(90 [Parm1])
  2027. closes files,
  2028. in MS-Windows- sends Message with code WM_USER+Parm1
  2029. (here by default and
  2030. when every application terminates,
  2031. WM_USER+105 is sent )
  2032. Halts program with halt code Parm1.
  2033. $LIST_OR_NULL:=#CALL_PAS(91 LIST)
  2034. Removes (at place) last elements of the list.
  2035. If list length is 1 or 0 then NULL is returned and argument is
  2036. not modified.
  2037. $ANY:=#CALL_PAS(92 ADDRESSING_LIST ANY_STRUCTUTRE)
  2038. ADDRSSING is list of numbers and identifier. If number, then indexing
  2039. is applied to the 2nd argument, if identifier, then selection is
  2040. applied.
  2041. #CALL_PAS(92 (. A (-2) .) $S is the same as $S.A[-2]
  2042. SIZE:=#CALL_PAS(93)
  2043. Returns stack size
  2044. #CALL_PAS(99 'a Pascal statement') insert to the code
  2045. $RET_CODE_OR_HANDLE:=#CALL_PAS(101 LIBARY_FILE)
  2046. Loads DLL library. Currently only GRAD.DLL is valid library for
  2047. call with this option.
  2048. You MUST analyze the return code.
  2049. You MUST call #CALL_PAS(103) before termination of your application
  2050. -1 - no enough memory
  2051. -2 - wrong parameters
  2052. 0..32 - WinExec return codes
  2053. 33 - Library handle. You MUST use it in #CALL_PAS(102 $handle ...)
  2054. $RET_CODE_OR_RESULT:=
  2055. #CALL_PAS(102 $handle FUNCTION_NAME (. Parm1 Parm2 ... ParmN .) )
  2056. Calls DLL function.
  2057. You MUST have successful call of #CALL_PAS(76) and
  2058. #CALL_PAS(101..) before this call
  2059. You MUST analyze the return code.
  2060. The parameters can be ATOMS, NUMBERS or one-level list of atoms,
  2061. which represents splitted string. (. 'AB' 'C' .) is the same as 'ABC'.
  2062. 1000 #CALL_PAS(76) was not called
  2063. 1001 1st paramter is not number
  2064. 1002 2nd paramter is not atom
  2065. 1003 3 handle is less than 32, Library was not opened for access
  2066. 1004 no memory 80 bytes
  2067. 1005 parameters are not formed in list,
  2068. possible atom instead of list
  2069. 1006 function not found in library
  2070. (function must be declared as FAR and EXPORT)
  2071. 1008 descriptor too small (see P_max_size in RIF.PAS )
  2072. 1009 too many parameters (see P_max_cnt in RIF.PAS )
  2073. 1010 wrong atoms in list of atoms which must represent
  2074. super long string (only non numeric atoms allowed)
  2075. 1011 wrong element (tree) in parameters
  2076. (. ResParm1 ResParm2 ... .)
  2077. Result parameters are of the same 3 types as input parameters
  2078. SEE GRAD.TXT for description of the functions.
  2079. #CALL_PAS(103 $handle) Frees library. Invalidates the handle.
  2080. $RET_CODE:=#CALL_PAS(104 EXEFILE_WITH_PARAMETERS [ MESS_NUM ] )
  2081. Calls EXE-FILE as Windows application; Waits until the application
  2082. returns message with code WM_USER+MESS_NUM. Default MESS_NUM=105
  2083. RET_CODE is one of WinExec return codes.
  2084. If you call a Rigal application from Rigal application then don't
  2085. use this #CALL_PAS with default value.
  2086. $DIRNAME:=#CALL_PAS(105) Home directory (where EXE or RSC file
  2087. located) ( with '\' symbol)
  2088. $RET_CODE:=#CALL_PAS(106 EXEFILE_WITH_PARAMETERS [ MESS_NUM ] )
  2089. Calls EXE-FILE as Windows application; Waits until the application
  2090. returns message with code WM_USER+MESS_NUM. Default MESS_NUM=104
  2091. RET_CODE is one of WinExec return codes
  2092. $RET_CODE:=#CALL_PAS(107 COMMAND_LINE_WITH_PARAMETERS )
  2093. Calls BAT-FILE or any MS-DOS or Windows application;
  2094. Windows application starts to work parallelly with the
  2095. calling application.
  2096. RET_CODE is one of WinExec return codes
  2097. ATOM_OR_NUMBER_OR_NULL:=#CALL_PAS(108 ENV_VAR)
  2098. Returns value of environment variable (possible,numeric),
  2099. or NULL if not found.
  2100. #CALL_PAS(109 FROM_FILE TO_FILE) Cuts all part of every
  2101. read line after symbol ';' (including it)
  2102. NUM:=#CALL_PAS(110 NUM1 ) Returns SQRT(NUM1)
  2103. NUM:=#CALL_PAS(111 NUM1 NUM2) Returns SQRT(NUM1*NUM1+NUM2*NUM2)
  2104. HANDLE:=#CALL_PAS(112 CODE)
  2105. Saves S-code into memory stream.
  2106. HANDLE is global Windows memory handle
  2107. CODE:=#CALL_PAS(113 HANDLE)
  2108. Loads S-code from memory stream.
  2109. HANDLE is global Windows memory handle
  2110. list_of_tokens:=#CALL_PAS(114 HANDLE [ SCANER_OPTIONS ] )
  2111. Calls scaner for analyse memory stream in global memory.
  2112. HANDLE is Windows global memory handle
  2113. SCANER_OPTIONS are the same as in #CALL_PAS(35 ...)
  2114. STRING:=#CALL_PAS(116 STRING)
  2115. String conversion for writing C string constants:
  2116. A\B"C will be "A\\B\"C"
  2117. LIST_of_rez:=#CALL_PAS(117 (.Parm1 Parm2 ... .) ) calls a WINDOWS
  2118. RFDLL.DLL screen management service
  2119. The parameters can be ATOMS, NUMBERS or one-level list of atoms,
  2120. which represents splitted string. (. 'AB' 'C' .) is the same as 'ABC'.
  2121. LIST_of_rez is the same types of parameters. Error is reported
  2122. in 1st or 2nd element.
  2123. NULL is reported if there are errors in parameter list.
  2124. LIST_of_rez:=#CALL_PAS(118 (.Parm1 Parm2 ... .) ) calls a WINDOWS
  2125. RFDLL.DLL screen management service
  2126. (. AVAIL COMPACTED .):=#CALL_PAS(119)
  2127. size of available and size of compact memory (in Windows only)
  2128. NULL or
  2129. (. Shortname Size Time Attr.):=#CALL_PAS(120 [ Path [ Attr ] ] )
  2130. First time Path must be given. Next times Path must not be
  2131. given. Default Attr=32 (normal file). Searches files that
  2132. match "Path" string. NULL if no files. Shortname is up to 13
  2133. bytes long name of file.