You are on page 1of 26
Sprint atrine® vel output! ‘print out* CHAPTER 5 CONTROLLING INPUT AND GUTPUT (PS, RS) NESTED PRIMITIVES AND FHOTSCTIVE: PARENT THE PRINT STRING PRIMITIVE (38) Printing at the reactive typewriter doss not occur merely bacaune there 16 text in the processor, ALL printing ts actually under the control of a special primitive, the "print string’ primitive whose mnemonic 1s PS. A typical example of thin primitive ts: #(PS CAT)" Tha precessor acting upon this primitive will firet determine the arguments, which ares FS cat ‘The first argunent PS indicates that a printing action te to take place. The second argument CAT is tha actual string to be printed out on the reactive typewriter, If we type this example at the keyboard, the following will appear on the pager #(PS,CAT) "Ca Since we are still considering only simple cases, the second arcument is restricted to one Line, and it munt not contain any commas or parentheses, ‘These restrictions will be removed later, In TRAC language, all output of strings at the reactive typeurtter is controlled hy the print string primitive, ‘The action ts called ‘output’ or tprint out', what is printed j= also ealled outint, Copyright ©) 1977 Rockford Research, Inc. ALL rights Feserved, ‘read string" “input! v “type int ‘THe READ STRING PRIMITIVE (RS) Putting strings into the TRAC processor is done mainly by use of the tvead string" primitive with the mnemonic RS, Its action is degerLbed vy the terns ‘input or ‘type in‘. The read string primitive has only one argunent RS , and it looks likes a(Rs)* When the action of this primitive ts carried out by the TRAC processor, character after character is received from the reactive typewriter Keyboard until the neta character, which is usually the apostroph received, At this point, the input action of RS terminates. If you try this primitive at your typewriter keyboard by typing: #(ns)" you will netice that something new has happened, The usual typexriter signal CRLF does net appear, After the meta character is typed, the typewriter stays motionless." The reason is that the processor is now trying to axecute or to carry out the action of the read string primitive, Tt 1s waiting for you to type something! The processor needs an input string. If you do type something, such as: apc! you will supply the input string, The meta character which follows causes completion of the RS action. Your page will look Like this: #(RS}"ABC'ABC This looks strange, since the second ABC is an echo, Hvidentally, something is going on which has no explanation fram our discussion so far, * Computers requiring an enter character wil] behave slightly differently in this situation, They will go toa a new line and wait. a3 ‘nested’ To find out just what has happened, and why, we mist learn some more about TRAC language fundamentals, Be patient. Sefore long, all will be clear. NESTED PRIMITIVES To solve the puzzle about #(3S) , we need first to get a deeper look at things. Consider the following new kind of expression nade up of two Primitives, one ‘nested’ inside the other: # (DS, INPUT,#{RS))* You might expect that this expression would cause the string composed of the five characters #(RS) to be stored in the form named INFUT, Instead of this happening, something a great deal nore useful takes place, What happens is that the define string action 1s held up until all prinitives making up any of the argunents of the DS prinitive have first ‘been executed, In this case, the third argument contains the primitive #(RS) . This nested printtive is executed first, and it causes characters to be accepted as they are typed at the keyboard. Acceptance of input stops when the meta character, the apostrophe, is typed, ‘The question is, where do the: typed=-in characters go? For example, we start with: 4(DS , INPUT, #(RS) }* and then we type THE FISK IS GREEN What actually happens ie that the #(RS) string disappears and the new input string of characters takes its place inside the DS expression. Space is adjusted to make things fit, If the new string has more than five characters, as in this instance, more room is provided. If fewer vou ‘protective parentheses’ characters are typed in, the space 1s closed up automatically, Inside the Processor, the resulting DS prinitive expression now locks like: #(DS,INFUT,THE FISH IS GREEN) There arr no more primitives waiting to be executed in any of the arpunents. The define string action can take place. The result is that a form is created with the string THE FISH IS GREEN going inte storage with the name INPUT. On the page, the entire transaction will look like thiss #(DS,INPUT,#(RS))*THE FISH IS GREEN' After the second apostrophe, there is a typewriter signal CRLF to indicate that the entire action has beer completed. We can now prove that the define string action has taken place by calling out the new form, and we will sees #(CL,INFUT)"THE FISH IS GREEN So far, we have used DS to record only ordinary words or sentences as the text strings in the forns, Expressions containing primitives can alse te recorded, We use a new technique, This technique requires the use of ‘protective parentheses" around expressions containing the prinitives. For example, the expression: #(PS,HELLO THERE) 4s nothing tut a primitive, Consider what happens 1f we try to record this expression ty putting it into the third argument position of a define string primitive, If we try it, this is what will appear on the paret #(DS.A1,#(PS,HELIO THERS)) "HELLO THERE A call '< the form named Ai gives nothing. Svidently, nothing was recorded, ve-5 ‘protective parentheses! What happened was that, according te rule, all the argunents of the 05 primitive were exectited before the DS storage action tock place, The execution of #(FS,HELLO THERE) caused HSLLO THERE to be typed out on the page. After this action, nothing was left behind for the third arrument of the define string primitive, fen storage action was about te take place, this was all that was in the primitive: #(DS,A1,) A storage action still took place, though what happened nay sound peculiar. A string of no characters was stored, and it was given the name AL in the usual fashion, This and ether seemingly pecullar situations will be discussed later on. What is important to notice here is that the effect intended, the storage ofthe expression #(PS,HELLO THERE) , did not occur, The expected action did not occur because the FS expression was executed too soon, before 1t had a chance to be stored, We need sone vay to protect such a string from execution inside the define string primitive in order to store it, PROTECTIVE PARENTHESES Protection of an executable expression, like #(FS,HELLO THERE) , can be secured ty enclosing the expression in ‘protective parentheses", This is how it is done: #(D8,A1,(#{PS,HRLLO THERE)))* What happens now can be seen and understood if we display the manner in which the argurents are fotmed, Te display the action on the arguments, we will use two lines of type. In the upper line, we will put the marker character: such as the commas and the pair #( and ) which delimit the prinitive expression. v-6 In the lower line, we will place the character strings which are the actual arguments finally used in carrying out the action of the define string primitive. In our example, after the arguments are separated out, and the protective parentheses are treated, what the processor has is diagranmed by: ae DS ML #(PS,HELLO THERE) The protective parentheses are gone, and the unexecuted expression 4(7S,HELLG THERE) 16 shown as the third argument. This unexecuted expression 1s what will be stored, ‘The vay the TRAC processor deals with protective parentheses ia te remove then, At the sane tine, everything that was contained ineide the protective parentheses is placed on the lower line unchanged. The eharacter strings on the lower line show the arguments, The strings on ‘the Lower line are not treated again by the processor before the execution of the define string prinitive. The three arguments are: BS AL #(PS,HELLO THERE) The result of the execution is a storage operation, and the unexecuted string #(PS,HELLO THERE) 4s put into storage with the name Al, This is exactly the result that we desired, The reason for wanting to store things like #(PS,HBLLO THERE) and other primitives is to be able to defer their action until sone later tine when they are to be called out, The call #(CL,At)" will bring the expression out of steraes and will cause its execution, On the sare, this is the way it looks: #(CLAL) "HELLO THERE ve7 Since the farm in memory 16 not erased by copying it out with the call, we can call it as many tines as we want: #(CL,AL) "HELLO THERE #(CL,A1)"HELLO THERE wee etes It 4s useful to print output in this indirect fashion, by first storing and then calling, expecially when repeated copies of a long or complex string 1s wanted. It 1s useful because the call, such as #{CL,A1)' is often shorter and easier to use than a long print string expression containing the complete string, With a stored form, each tine the form is called, the output text is printed out in exactly the same way every tine, ‘The sharp-eyed reader will note that I have still not explained exactly what happens between the use of the call primitive conmand and the action of printing out the string HELLO THERE . Actually, severa: additicnal interesting and important steps eccur. These will be explained in the next chapter. Now ts @ good tine to lock again at the Index, Turn to it now. Look up sone terns you hava learned, lke “protective parentheses". Note the table of the 34 TRAC language primitives and their argunent types. 4 * v8 ‘EXPERIMENTS AT THE REACTIVE TYPEWRITER NOTE: These examples go slightly beyond the scope of the things that have been explained so far. They are presented mainly as experiments at the reactive typewriter == things for you te try out, If you don't have the use of a reactive typewriter, skip thes for new. 1, Can you guess what would be the effect of the following nested expression? #(PS,#(PS,HELLO) )* Try 1t out. Also try #(PS,(#(PS,HELLO)})* #(PS,((#(PS,HELLO))))* ae What is the effect oft #(DS ,BBB,#(RS) )'(#(PS, GOODBYE) }* What is the result fron a later call #(CL,BBB)* 3 What is the effect of: #(PS,#(PS.#(PS,#(PS,ENOUGH))))* 4. Call out the form named ABC after performing the cperatdons #(DS,ABC,#(RE)#(RS)) "APPLES AND 'ORANCES* 5 What action results frome #(PS,#(35)) "AAAAA" Where have we seen this action before? "parsing" vet "grammar" ‘syntax" CHAPTER 6 THE GRAMMAR OF TRAC LANGUAGE -= PARSING GRAMMAR AND PARSING Since TRAC language primitives can be strung together or concatenate 4in any combination, and can also be nested ‘inside one another in any conbination, it is possible to get very conplex expressions, Therefore we need an easy and accurate method of predicting exactly what will happen when the processor works on such a complicated expression, The ethods of explanation wa have used so far, although they are perfectly correct, ar not adequate for dealing with the more complex expressions. This chapter is devoted to describing and explaining a nore powerful method of analysis and notation. With this new method, we can predict exactly what the TRAG processor will @o when presented with any expression, no matter how complicated it is, We do this by analyzing the ‘TRAG expressions into their various parts, showing the relationships ‘between these parts, Such an analysis is called "parsing’. TRAC language has a simple and very precise ‘grammar’ or ‘syntax', As applied here, these two words mean about the same thing. The American College Dictionary (C. L. Barnhart, Bd., Random House, New York, 1959) defines "granmar" asi “1) the features of a language considered systematically as a whole"; and "syntax" as: “la) the pattern of formation of sentences and phrases from words in a particular language; 1b) the study and description therecf." Within the meanings of the: two terms, we are Sopyrignt (©) 1972 Rockford Research, Inc. All rights Feserved. *Adealized processor! VE -2 now going to study the grammar and syntax of TRAC language. We will learn how to parse the language, In TRAC language, the role of a word or phrase is played by the arguments, Corresponding to the spaces and punctuation of an English sentence, we have the delimiters, commas, and protective parentheses, A sentence in ordinary language corresponds roughly to a complete TRAC language primitive expression like #(DS,AA,CAT) , TRAC language ia nore complex (and in sone ways more interesting) than ordinary ethnic languages Like English, in that TRAC language expressions can be nested inside one another to any desired degree, With English, anything with more than a few levela of nesting beconas very confusing. In explaining the parsing of TRAC language, I don't want to start out by giving & lot of abstract rules, I think it is sasier to learn how a TRAC language processor works if we first see how it deals with e variety of @ifferent kinds of statements in the language. Fortunately, the action of a TRAC processor is very orderly and uniform, Aa we go through the discussion of the various examples, I will state various rules, and we will see how the rules work, Soon you will have an expert ability with the grammar or syntax of the language. THE IDEALIZED PROCESSOR In ny explanation of the grammar or syntax of the TRAC language, 1 will make use of what is called an "idealized processor’. This is a kind of imaginary processor which shows exactly how things work with the language, but does not get into the details of how any particular computing machine must be programmed to carry the actions out, In actuality, the different computers generally will employ a variety of different tricks and ‘workspace! WI=3 ‘sean pointer! ‘scennine" ‘ecanner* ‘evaluation* ‘execution’ techniques to perform the different parts of the processing action. However, the end effect, as s¢ ‘by the person at the reactive typewriter keyboard, will not vary. TRAC language 1s a standard language. In order for a processor to be a standard TRAC processor, it must execute the language exactly as specified in the standards for TRAC language as given An Appendix Ay ‘The action on TRAC language expressions of the idealized processor takes place on strings which are located in a ‘workspace’. In the workspace of the processor, we night have this miscellaneous string of characters: #(PS,$:ABCr1 = 410)"** ‘The TRAC language processor examines the characters in this workspace fron left to right, beginning at the left-most character, We will use the rarker {/ to synbolize the point of division between the characters which have ‘been examined and those which have not. This marker is called the ‘scan pointer’, At each stage, the character to be examined is the character just to the right of the scan pointer. The process of ‘examination and action upon the characters 1s called parsing or "scanning", ani is done by the ‘scanner’, When a primitive has been fully parsed ty division into its parts by the scanning action, the appropriate action fer the ‘primitive is ready to be carried out. Carrying out the action of the prinitive is called "evaluation’ or ‘execution’ of the prinitive, Tho scan pointer divides the workspace into two areas, The area to the right of the acan pointer, holding the string of characters which have "active string" “neutral strings" vE-4 "parsing diagram’ not yet been scanned, 1s called the ‘active atring'. The area to the left of the scan pointer contains the various "neutral strings’, Hach individual neutral string is, in fact, an argument, or a part of an argunent, for sone primitive yet to be evaluated, In the area to the left of the scan pointer, we will also represent the syntactic markers, These are the commas and the deliniters #( and ) « For example, at an internediary stage of seanning the expression #(PS,BANANA) , the syntactic markers and the scan pointer will be placed Like this in our parsing notation! Syntactic fe . Markers io “aa //MANA) ATV Neutral Strings \ Active String Scan Pointer In this notation, the syntactic markers are placad on the Line above the line holding the active and noutral strings. Note that the final parenthesis at the right 4s not placed on the upper line, since it has not yet teen scanned. It is still in the active string. In this notation, the nested expression: #(DS 22, (#(PS,HELLO FOLKS))} after being scanned would be represented by this "parsing diagram’: “yy ) DS 22 #(PS,HELLO FOLKS) // This expression is now ready for execution. In this representation, the ‘neutral strings" Vi- 5 ‘active string’ ‘three neutral argunents of the define string primitive are shown on the lower Line or “downstaita", ‘The syntactic markers are shown in their correct relative position “upstairs” in the upper line. Since the scanning of this expression is complete, the scan pointer is at the far right. All the strings shown are now "neutral strings’, ‘These strings are called "neutral" because for the moment ne further scanning action on ‘then will take place. The ‘active string" 4s called “active” because it is waiting to be scanned. In the expression just scanned, the three neutral strings are: Di 22 #(PS,HELLO FOLKS) ‘These strings aro separated and marked out by the corresponding syntactic markers: ‘The neutral strings specify a coxplete primitive expression, in this case for the define string prisitive, The primitive is now ready to be executed. Skecution results in the storage #(PS,HELLO FOLKS) with the mame 22. Ag we can sea from this example, many things happened during the scanning action, Some connas went upstairs, and some stayed down, Sone primitives were executed, and sone were not. The protective parentheses completely @isappeared., Zvidentally, we shall need a set of exact rules for predicting exactly what happens in each circumstance. We shall now Begin te learn such rules for the scanning and parsing operation. As we shall see, the rules all focus upon what is happening at the sean Fointer. "transformation rule" vI-6 ‘TRE RULE FOR SCANNING TEXT CHARACTERS The first rule 4s the rule for scanning ordinary text characters, such as the letter of the alphabet or the numerical digits. As the scan pointer comes to sach such character, the seanning action is to sinply nove the character from the active string te the right of the scan pointer to the neutral string to the left of the pointer, For example, we may have ‘this situation: wajpare One step of the scanning action changes it tot al/ry At each step, only one thing happens, Such a single step, which involves only A and // , can be summarized ty the ruler Rule ifn ‘becomes: al/ where A stands for any text character. After each application of this rule, we apply the rule again te the next character in line, Thus, through step-by-step actiont L/A8CD becomes «= ABCDL/ with four applications of the rule. A rule of this sort, which shows an initial configuration like //s and a resulting configuration like A// , 1s called a "transformation rule’, In the rest of this charter, wa will learn a number of other transformation rules for the various characters, ‘In each case, when the vE-7 ‘yegin parenthesis" group shown at the left of soma rule is found, the group ts replaced by the group shown at the right of the transformation rule. In the operation of the TRAC janguage processor, the scan pointer can only mova from left to right by the succassive applications ¢f one or another of the transfornation rules, THE RULSS POR FROTHOTIVE PARENTHESES We will bagin our study of the rule for protective parentheses by studying several exanples, The first example is provided by the string: d/aa(peccDD). After scanning, the parsing diggra= for the string is: AABBOCDDEE// With the scan pointer left at the right-hand end, The protective parentheses have disappeared, When there are additional nested parentheses, all the parentheses do not disappear. Consider this example: (LfoaC (BB(CC) JOD) BE The result of scanning this string is shown by the diagram: AACEB(CC) )DDES We need sone cood rules to tell which parentheses disappear, and which renain. (nly the outermont parentheses are removed. ‘The rest of the varentheses are not touched in the scanning, Another thing to notice is that each "beein parenthesis’ { is matched by a corresponding following ‘end parenthesis" vr-8 "balanced strings’ end parenthesis’ | . Parentheses are used in pairs, There are just as many begin and end parentheses, The strings are nested, with the parentheses acting like the layers of an onion. ‘The way that the parentheses are paired 1s shown by the arrows in the following diagrams AA(3B (CC )) DDB Fach arrow 1s drawn from a begin parenthesis to its natehing end parenthesis, ‘The string CO 1s bracketed by the inner pair of parentheses, while the string BB(CC) is tracketed ty the outer pair. in some other strings, there can be more than three layers of parentheses. Parentheses can ecour in other combinations, 1iker AA(B(CC )DD(BS)) tit it Strings which can be diagranmed with all the parentheses matching are called "talanced strings'. In order to draw the arrows showing the matching pairs, it is best to natch the inner pairs of parentheses first. The important thing to notice 1s that in such a diagram, the arrous for the pairs must never cross, The following diagram is wrong, because the lines for some arrows are crossed: Berens aa(B(CC)DD(EE)) vI-9 EXERCISES Copy the following strings with nested parentheses on another sheet of paper. Draw in arrows to diagran the matching pairs of parentheses, 1. aa(a(B(C)) DD) eR FF}CC 2. ex(ry)z(apc)D(123) 3. 222(Aa#(PS(WOW)XX) YT) ay wal (((BB)C)D)E)F As shown in the third exercise, parentheses marking a nested primitive expression are treated in exactly the same way as any other parentheses when determining the mtching parenthesis pairs. We are now ready for the rules for parsing expressions with protective parentheses, When the scan pointer first comes to a begin parenthesis which 4s not a syntactic marker for a primitive, such as #{ or ##( , the following actions take places Buk 1, The matching end parenthesis which is paired with the begin parenthesis is located. 2. The begin parenthesis is deleted entirely. 3. ‘The entire character string bracketed by the parenthesis pair is transferred without change to the neutral string. 4, ‘The matching end parenthesis is deleted entirely. 5. Tha scan pointer 41s placed in frent of the character which follows the deleted end parenthesis and scanning is resuned, VI - 10 ‘SKERCISES Go back to the four exercises just given and apply these five rules for scanning the string, Write down the results. In sone cases, when there are not enough end parentheses, it is then impossible to locate » matching end parenthesis. These are exceptional cases, which wa shall put aside just tow. In the next chapter, we will got a rule for handling such poorly formed strings, Jt ie usually handier to have only = single rule, instead of five rules, for handling protective parentheses. We can get a single rule in the following way, We will use a series of three colens 111 to indicate any balanced string. Note that a string without any parentheses at all is also a balanced string. Then a typical protected string, such ast (aa(#(CD,X)E)F) can be symbolized byt Can) because the inside part, AA(#(CD,X)E)F , ie a balanced string, Using this notation, a protected balanced string just before parsing 1s symbolized by the dingran: ou) After the application of the five rules just given, the resulting string 1s dingrammed by: milf Viet The scanning action changes or transforns the strings from the state represented ty the first diagram to the state of the second diagram, With thie new notation, we can now state @ single transformation rule for protected strings. Rule L/( tts) becones EKEROISES Go ‘tack to the previous exercises and test the application of thir new rule, ‘THE RULES FOR SHARP STONS ‘The existence of a primitive in TRAG language 1s signalled by one or ‘two sharp signs in front of a begin parenthesis, The next transformation rules concern the manner of dealing with the character combinations #( and ##(. As we have already seen, when these chatacter eroups are scanned, they ara put upstairs in the parsing diagram, Three transformation rules are needed to deal with these character groups. The rules are: we( Rule (41) Lat becones “ue ac Bule (44 Leal becones i Rule (134) lf becomes: “uy These rules sust be used in strict sequence: first Rule (4), then VI = 42 ule (44), and finally Rule (111), The first rule that works is used for the transformation, If one rule cannot be applied, the next one is tried. After the successful use of a rule, the scanner begins again with the first rule. Example 1. Lfewwe Rule (1) doesn't apply. Rule (11) doesn't apply. Rule (114) does. a Leet Now Rule (1) applies, and it is used, We get this Alagran: ae ( # Lf Fule (144) 4s now the only one that applies. The final result is: aH ( * # ##( Example 2. (LittevtteH( becomes fava Uf wet Example 3. LU#(#C econes Th RULH FOR THE COMMA The comm separates the arcuments of the primitive expressions, We have already seen how it works, The comma just goes upstairs when it is scanned, The rule is: ule Lf, wocomes "ff The upstairs comma is tha syntactic marker for separating the neutral strings of a prinitive expression, When a comma is downstairs in a VI- 13 neutral string, it hae no syntactic importance, It 4s treated just iike any other text character. THE RULS FOR PORMAT CHARACTERS TRAC language recognizes two format characters, the carriage return character GH , and the line feed character IF. the bar ~ at the top of the group means that the group is to be taken as & symbol to represent gome single character, It means that the letters C or R are not meant to be taken as individual characters. Because format characters do not leave printed marks by thenselves, it is useful te have @ symbol of this kind to show very clearly just where the format characters are located in a string, Although the format characters do not print, they do control the location where other characters will print, For reasons that we will learn in Chapter 9, it is desirable that the format characters disappear when they are not protected by protective parentheses. In other words, when the scanner cones to them, these characters should vanish. Gonsider the string: AAKTREPBOYORLFDOC Such a string really represents the following on the printed page: AAA BOY D0G Because ne fornat characters in this string are not protected, the seanner operating on this string will change it toi VI = tu ‘AAABOYDOG ‘The string will then print out exactly as shown above, with all the characters on one line of the page, The two rules for the format characters are: LR vecones ff UF becores Lf ‘EXHROTSES Use the parsing rules you have learned so far to diagram what happens to these strings: L/##A BG#(HELLO) ,X¥2) Lf (d0RBo1TF, (CREF) L/## (PS, (A,B, (0), (B) 2. Be exBCUTION OF PRIMITIVES Reecution of @ primitive occurs when the scanner pointer arrives at the closing parenthesis (the matching right-hand parenthesis) of a primitive expression, Thus in the expression: A as (L/# (05,2 ,RED) becomes DS xY Rep{/} and execution of the primitive 1s ready to take place, With execution of the prinitive, the string RED 4s stored with the name XY. VE - 15 “seope" execution has the transforration ruler Rule Lb vecones “execute prinitive'// By this rile, the right parenthesis disappears, the primitive is executed, ani scanning starts again. when tha prinitives are nested, we get situations likes At AC L/# (2S ,ONEA(PS, TWO) ) ‘becomes FS ONE PS TwO//)) Now the question 1s exactly what neutral strings are to be included in the execution of each of the primitives, What is the ‘scope’ of the primitive? Fron this exanple, we see that the primitive which should be executed first has the diagram: ae Ps Twos/) Execution prints out: ‘Two and this primitive vanishes. There renains the expression: wy FS ONE{/) which now prints out: ove Fron these examples, we can say that the scope of the prinitive extends fron the croup //) back to the first or nearest syntactic aarker 4#( which ts upstairs and to the left of the scanning pointer, VE - 16 We also conclude that when one primitive is neste? inside another, the inner prinitive will be executed first, Note that in the example above, the two etrings will be printed out on ‘the paper, one after the othert THOONS, In the next chapter, we will continue our study of the execution or evaluation of TRAC primitives. SUMMARY OF THE SCANNING RULES It ds helpful to have all the scanning rules for TRAC language in one list, in the proper quence for their application. Note that the following list contains sone of the rules in the table “Rules for Scanning Transformations and Execution" on page INDEX + tut it onlts the execution rules diecussed in Chapter VII and the rules for default situations discussed in Chapters VII and VII For each character, the scanner begins its action by first trying to apply Rule A, then Rule 5, and so on down the list. Rule As UC ie) becomes ats ff where itt stands for any ‘balanced string, #0( Ltt becomes a Rule Cy LR ‘pecones i Rule Le becones *l i decones “i VI - 17 ‘default rule’ Rule F, Ufa becones, u Rule Ge fe becomes i Rule H. i) becomes “exeoute prinitive" Rule Ze ifs ‘pecones alf where A stands for any character not treated ty the preceding rules. In this list, the rule for the ordinary text character is placed last. ‘The reason for placing it last 1s that this rule 4s to be used for any character which has not been dealt with by any of the cther parsing rules. Such a character night be $ ot +, 4s well as any ordinary alphabetic or numerical character, This type of rule is celled a ‘default rule", When everything else fails, you use a default mie. For sone of the rules in this list, such as Rules 3, @, and D, the sequence in which you try the rules is important, For sone other rules, ‘the sequence is not important. For example, Rules F ard ¢ can be interchanged without making any difference in the action of the parser. On the other hand, if Rule I ut put ahead of Rule A in the list, all characters would be put directly into the neutral string, and the rest of the rules would never be applied. Hule I would tehave this way at the top ef the list because there would then be no “preceding rules", and consequently any character would meet the requirenent of the left side of the transforration rule, VI -18 EXERCISES 1, How far up in the List can Rule 2 be moved without changes 4n what will happen? Can it be moved ahead of Rule A? 2. Since we have Rule I, 4s Rule D really necessary? 3+ How far up in the list can Rule H be moved without changing the action of the parser? 4, How far up can Rule F or G be moved without changing the action of the parser?