Home
APPLAB User's Guide Version 1.2
Contents
1. Grammar PA aspect L ae PAESE windows m Revision window gt Add Abstract Concrete When adding a new grammar aspect window the meta grammar is bound using an explicit binding A Target grammar window may be bound to the current revision This is achieved by assigning the PBOId to lt SELF gt wqbrgeger Slthernetivel Reviecan gt gt Change meta grammars All relations are rebound using explicit binding m Grammar aspect window gt Binding Rule gt Set Binding Rule gt Dynamic Sets the binding type to dynamic rebinding and asks for the binding rule The command will not affect the current value of the relation gt Binding Rule gt Set Binding Rule gt Explicit Sets the binding type to explicit rebinding The command will not affect the current value of the relation gt Binding Rule gt Set Binding Rule gt Fixed Sets the binding type to fixed rebinding The command will not af fect the current value of the relation gt Binding Rule gt Show Binding Rule Shows the binding rule of the relation 7 9 Predefined Attributes This section introduces the predefined attributes on both the PBO and the revisions 50 of 56 APPLAB User s Guide version 1 2 The Version Handling System 7 9 1 PBO Attributes Currently there are only two predefined PBO attributes m Purge The attribute defines how many revisions should be left at the end of each alternative when the p
2. None of the commands will affect the binding rule of the relations The revision identifi cation will be changed to the bound revision When the last revision of an alternative is opened the key is removed from the al ternative Only a revision with a key is allowed to be appended at the end of the alterna tive When quit is done on a revision with a key the key is returned Restrictions If the key is removed when opening the last revision of an alternative or when opening a revision within the alternative the user will be notified In these cases the opened revi sion has to be saved in a new alternative rap hd Eeeletion Eragi 46 of 56 APPLAB User s Guide version 1 2 The Version Handling System 7 6 4 Delete Deletes a selected alternative or selected revisions gt Delete Restrictions If the evolution graph has only one alternative this alternative cannot be deleted It is not allowed to delete the source revision in the evolution graph the leftmost box m It is not allowed to delete a revision which forms a fork between two alternatives 7 6 5 Rename Renames a selected alternative or selected revisions gt Rename The rename operation will not affect the binding of relations since the RevisionId is not used for selecting revisions at binding time 7 6 6 Attribute Support An attribute is an attribute name with an associated attribute contents In the current im plementatio
3. amp 4 5 The productions state that an Expression is an alternation if ID Add Sub Mult and Div and that a Plus is a construction of two Expressions 6 Finally an ID dentifier has a textual contents filled in by the user This is stated in a lexeme pro duction LEXEME In the ABSTRACT window the abstract grammar is edited by means of the struc ture oriented editor It is edited according to the language of abstract grammars The structure of abstract grammars is defined by an abstract grammar for abstract grammars Below the structure of abstract grammars is shown The grammar is written in its own formalism 1 AbstractGrammar Production 2 Production Id amp Definition 3 Definition Alternation Construction List Lexeme 4 Alternation Id 5 Construction Id 6 7 8 List LEXEME Id LEXEME Lexeme _ 5 This is actually the grammar interpreted by the structure oriented editor while editing an ab stract grammar in the ABSTRACT window 28 of 56 APPLAB User s Guide version 1 2 The Grammar Formalisms 5 2 1 An abstract grammar consists of a number of productions 2 A production consists of an Id containing the production name at the left hand side and a definition at the right hand side 3 The definition states the production type which can be chosen from Al ternation Construction List and Lexeme 4 An alterna
4. 3 Configuration String Quote w 4 Comrent Ct 44 SE 5 3 The first is part of the unparsing scheme for concrete grammars while the second is a placeholder for an unexpanded lexeme APPLAB User s Guide version 1 2 9 of 56 Grammar Editing A Guided Tour 2 8 2 9 1 The production Greater and Less are non associative and have the same precedence which is lower than that for the productions Add 2 and Mult 3 which are left associ ative Left right nonassociative and no associativity can be defined for the productions of the abstract grammar The configuration part of the parse grammar is used to configure the text editing for programs based on the current grammar In the example 4 a string is specified as being enclosed by the quote character 5 a comment is specified as being recog nized by beginning with the token and ending with m Open the PARSE window by double clicking on it m Make the window large enough to show its entire contents Pin up the editor menu Changing the Precedence of Operators Any structure of the program in the TARGET window can be selected and edited as text The system translates the edited text into a structure which is then inserted into the se lected focus of the TARGET window When text editing expressions the precedence of the different productions determine which structure the edited text will be translated to
5. Construction WE uw 1 then gt gt gt lt nl gt 2 lt lt lt lt nl gt else gt gt gt lt nl gt 3 lt lt lt 3 Plus Construction el DESA 2 _ 4 ID Lexeme before _ after _ 1 The production in the abstract grammar describing a StatementList is a list produc tion In the concrete grammar the presentation is also specified in a list production with the same name A list production has three parts the before in and after part The be fore part specifies the text and formatting information before the first descendant It is expressed in a list of templates chosen from text indentation gt gt gt end indenta tion lt lt lt and newlines lt nl gt In this case the text begin is presented followed by increasing the indentation level gt gt gt and a new line lt nl gt The in part specifies the concrete syntax separating the descendants of the StatementList in the example a semi colon followed by a new line The after part specifies the concrete syntax after the last descendant In the example decreasing the indentation level a new line and the text end APPLAB User s Guide version 1 2 29 of 56 The Grammar Formalisms 2 An If statement is a construction production The concrete production consists of the concrete syntax before the first descendant if and a number of references to the presentation of the descendants fol
6. Expand after AB Expand before m Function keys Copy Paste Cut Find m The TAB key works as Edit as text Short cuts to the Expand Menu Instead of selecting syntactic constructs from the Expand menu with the mouse the key board can be used Type the keywords of an entry and press lt TAB gt The keyboard entry will be matched with the expand menu entries and the matching construct will be insert ed in the program Each word of the menu entry may be abbreviated For instance while lt TAB gt while do lt TAB gt wh d lt TAB gt and wh lt TAB gt will all result in that a while do template is inserted in the program Notice that the placeholder symbols and 2 in the menu entries should not be typed These short cuts are still at an experimental level in the system They are thus not yet fully supported The keyboard input is not echoed on the screen for instance and the input can not be edited using lt DELETE gt Editing In the Text Link Window Working in a text link window is basically the same as working in a target or grammar aspect window All the editing operations described in section 4 4 are also available in text link windows The only difference is that a text link window is of a more temporary nature Each text link window is edited according to a base grammar and its actual con tents is linked to a text file The menu of a text link window contains the additional op tion
7. 39 revision number 39 revision window 42 48 S save 19 24 save as alternative 49 save as revision 49 save as text 23 save as tree 23 save interface 23 saving 19 scrollbars 17 scrollbars on off 5 23 selection 20 set startprod 23 set title 23 short cuts 23 show attribute 23 show selection 45 son pos 37 source revision 43 strings 32 surface syntax 5 T TARGET 4 target window 4 19 text 17 text editing 21 text link window 19 24 textprompts 17 title 15 title menu 15 U unambiguant grammar 33 unlock 14 V visible 17 WwW window 15 window structure 42
8. AG 36 5 4 7 List Nodes in OOSL 37 5 5 Editing Metagrammars 37 6 0 Grammar Tools 38 6 1 The Pretty Printer 38 6 2 The OOSL Generator 38 ii of iv Contents 7 0 The Version Handling System 39 7 1 Introduction 39 7 2 Terminology 39 7 3 Relations 39 7 3 1 Look up of PBOId 40 7 3 2 Explicit Binding of Relations 41 7 3 3 Evaluation of Relations at Binding time 41 7 4 Window Structure 42 7 5 PBO Window 42 7 5 1 Commands 42 7 5 2 Undocumented Features 43 7 6 Evolution Graph Window 43 7 6 1 Interactive Selection of Alternatives and Revisions 44 7 6 2 Selection of Revisions by Rule 45 7 6 3 Open 46 7 6 4 Delete 47 7 6 5 Rename 47 7 6 6 Attribute Support 47 7 6 7 Other Commands 48 7 6 8 Undocumented Features 48 7 7 Revision window 48 7 7 1 Save 48 7 7 2 Quit 49 7 8 Grammar Document Characteristics 49 7 8 1 Revision Commands 49 7 8 2 Undocumented Features 49 7 8 3 Binding of Relations 50 7 9 Predefined Attributes 50 7 9 1 PBO Attributes 51 7 9 2 Revision Attributes 51 8 0 Unix Level 52 8 1 The applab Script 52 8 2 The ormmessage Script 52 8 3 Grammar Files 53 8 4 Environment Variable 53 8 5 Files in the Release 54 9 0 Trouble Shooting 55 9 1 Problems With Starting APPLAB 55 Contents iii of iv 9 2 9 3 9 4 9 5 9 1 1 APPLAB Prints Error Message on Standard Output 55 Problems With Saving a Revision 55 Dead Windows 55 Problems With Editing 55 9 4 1 Confusing Behaviour at Expand 5
9. command However a complication oc curs if the system crashes during opening or saving the grammar In this case the stored grammar may be left in an inconsistent state Such crashes may occur if you run out of disk quota heap space or swap space during these operations If the program is in an inconsistent state APPLAB will crash or give an error mes sage when you start it on the grammar again Usually the following error message is given in the Unix shell window Warning Wrong version of bytestring In this case press lt CTRL gt C or press lt RETURN gt a few times until APPLAB crashes To be able to open the grammar again consistency must be restored by removing the latest revision of the grammar To do this proceed as follows Save a backup copy of the grammar in case this cure does not work by ormcp lang gram lang backup gram If you are out of disk quota this might not be possible Open the grammar with revision handling by the following command in a unix shell window applab lang gram A revision handling window for the grammar appears The revision handling window contains an Evolution Graph window showing small boxes which represent all the ex isting revisions of the grammar 1 The revisions are organized in a tree structured graph of alternative lines with old er revisions to the left and newer to the right Often there is only one alternative line Each alternative has a key which i
10. have entered it correctly the corresponding structure should have been inserted into the OOSL window The resulting node class should look like this RepeatStmt node Stmt a_Stmt ref Stmt a_Exp ref Exp eq undeclaredEnv a_Stmt undeclaredEnv union a_Exp undeclaredEnv m Choose Compile OOSL The changed OOSL grammar is now compiled If any errors where detected they are marked in the OOSL window with a dotted marker and a message will appear stating the number of errors found If this happens press OK to acknowledge that there are compilation errors and look at the error messages by choosing Explain next error from the menu If you have entered the node class as described the only possible error should be that the new node class appears before the node classes Stmt and or Exp have been defined If this is the case then move the node class with Cut and Paste after to appear after the declarations of Stmt and Exp Redo Compile oosl Switch to the TARGET window 12 of 56 APPLAB User s Guide version 1 2 Grammar Editing A Guided Tour 2 10 2 11 m Select the expression of the while loop Do Show Attributes gt A list of all available attributes at that point in the program is shown m Choose Show Attributes gt env The value of the attribute is calculated and dis played in a window It should contain all the declared variables at this point in the program Remove the window
11. in the production name RepeatStmt using Expand gt Edit lexeme Be care ful to spell it in the same way as in the abstract grammar m Expand the right hand side of the production to representing a construction production A template is inserted in which the first placeholder automatically is se lected m Expand the placeholder to and then choose Expand gt Edit lexeme to fill in repeat The second line of the production is now complete m Select the 3placeholder and do Edit lexeme Fill in 1 Expand the follow ing placeholder to do Expand gt Edit lexeme and fill in until The third line of the production is now complete 8 of 56 APPLAB User s Guide version 1 2 Grammar Editing A Guided Tour 2 7 m Select the whole third line by repeatedly clicking at some part of it Do Expand af ter and a new line appears m Select the placeholder and Expand gt Edit lexeme to 2 Select the fol lowing placeholder and choose Cut from the menu m Save the grammar on file just to be on the safe side Select Savein the popup menu of the grammar document window The concrete production is now ready and should look like the production above We are now ready to use the new language construct in the target program Move to the TARGET window Select a statement in the program and do Expand after Check that the hierarchical
12. support the user in defining new grammars and editing programs System Requirements Machines Sun SPARC workstations Operating system Solaris version 2 3 or later or SunOS release 4 1 or later Window system OpenWindows 3 0 or later or X 11 release 4 or later It is recommended but not necessary to use mouse moved focus rather than click to type focus in the setup of OpenWindows The cut copy paste functionality will then work better Consult the installation guide for details Scope and Usage APPLAB is an evolving research system rather than a supported product Although it contains several bugs it is a working system and can be used for designing smaller lan guages We do not guarantee any correction of bugs or compatibility with future versions of APPLAB We are however very interested in comments on the system and bug re ports mail to lt Elizabeth Bjarnason dna lth se gt APPLAB User s Guide version 1 2 1 of 56 Introduction 1 3 1 4 1 5 How to Use This Guide Go through the guided tour of chapter 2 0 and then create a new grammar from scratch following the instructions in section 4 3 This guide also contains chapters of reference manual character Chapter 3 0 de scribes basic interaction techniques used i e how to interact with windows menus etc in the system Chapter 4 0 describes the grammar editor Chapter 5 0 describes the grammar formalisms Chapter 6 0 describes the avai
13. tribute construction expression has been added It has the following syntax AC S lt Id gt lt Start Exp gt lt Loop_Exp gt The AC expression iterates over all the sons of the list node evaluating lt Loop_Exp gt for each one of them The temporary variable lt Id gt is used to store the intermediate re sults and can be accessed in lt Loop_Exp gt lt Id gt is initiated by evaluating lt Start Exp gt Attributes of the current son are accessed through the predefined reference variable son which can only be used in a lt Loop_Exp gt of an AC expression The left to right posi tion of the current son can be accessed by son pos The result of evaluating the AC ex pression is the resulting value found in lt Id gt Editing Metagrammars All grammars in APPLAB are represented as abstract syntax trees They are edited by means of the structure oriented editor according to grammars describing grammars i e metagrammars All abstract grammars are defined by a grammar defining abstract gram mars containing one abstract and one concrete aspect specifying their structure and presentation respectively All concrete grammars are defined by a grammar defining concrete grammars containing an abstract and a concrete aspect This is also the case for the parse and oosl grammars The metagrammars i e the grammars specifying grammars are in turn defined in terms of themselves Since the metagrammars are ordinary grammars they ca
14. 2 1 2 2 The Application Language Laboratory APPLAB is a structure oriented environment used for editing grammars and programs based on those grammars It allows experi menting with grammars in an explorative fashion This guided tour will give an intro duction to APPLAB Please refer to chapter 4 0 for more information on the commands used For trou ble shooting see chapter 2 11 Enter the Application Language Lab and a Demo Grammar m Log on toa SUN sparc and start Open Windows or X windows m Copy the APPLAB demo grammar toy gram to a directory of your own using the ormcp script gt ormcp ApplabDir demo toy gram where ApplabDir is the location of the APPLAB installation directory m Start APPLAB on the grammar document toy gram gt applab toy gram latest A grammar window for the latest revision of toy gram appears on the screen m Resize the window to fill most of the screen by dragging the lower right window cor ner with the left or middle button on the mouse The different icons contain grammars describing different aspects of the target language ABSTRACT contains the abstract grammar defining the syntactic structure of the target language CONCRETE contains the concrete grammar which defines the syntactic sugar and screen layout of different constructs in the language PARSE con tains the parser grammar which defines the priorities of the different language con structs OOSL
15. 5 9 4 2 The System Hangs 55 Frequent brooms 56 iv of iv Contents Introduction 1 0 Introduction 1 1 1 2 APPLAB Application Language Laboratory is a system that supports language design in an integrated interactive way making it especially suitable for prototyping small domain specific languages application languages The system allows the language de signer to work on the language definitions and simultaneously experiment with the re sulting language Changes made to the grammars of the language are immediately effective in any program written in that language APPLAB includes the following func tionality m Hybrid grammar driven structure oriented editing The APPLAB editor is structure oriented and based on a technique for interpreting grammars Text editing of struc tures is supplied by a grammar interpreting parser component The interpreting of grammars gives great flexibility and allows the syntax for a language and a program in that language to be edited at the same time The effects of changing the language are immediately made visible in the program and new language constructs can be tried out immediately m Static semantics The support for static semantics is supplied by a demand attribute evaluator for Door Attribute Grammars The attributes defined for a language struc ture of a document can be listed and evaluated by a menu command m Grammar tools A set of grammar tools are available to
16. APPLAB User s Guide Version 1 2 Elizabeth Bjarnason LU CS IR 96 01 Department of Computer Science Lund Institute of Technology Lund University Box 118 S 221 00 Lund Sweden APPLAB User s Guide version 1 2 April 1996 The Software Development Environments Group Department of Computer Science Lund University Sweden The Software Development Environments Group Department of Computer Science Lund University Box118 S 221 00 Lund Sweden Email orm dna th se 1996 by Elizabeth Bjarnason APPLAB Application Language Laboratory is the result of continued work on the Orm system which was first developed as part of the Mj lner project Contents 1 0 Introduction 1 1 1 1 2 1 3 1 4 1 5 1 6 System Requirements 1 Scope and Usage 1 How to Use This Guide 2 More Literature 2 Important Notice on Copying Removing and Renaming Documents 2 Acknowledgments 3 2 0 Grammar Editing A Guided Tour 4 2 1 2 2 2 3 2 4 2 3 2 6 Zel 2 8 2 9 Enter the Application Language Lab and a Demo Grammar 4 The Target Window 4 The Abstract Grammar Window 5 The Concrete Grammar Window 5 Make a Small Modification of the Concrete Grammar 6 Extend the Grammar With a New Statement The Parse Grammar Window 9 Changing the Precedence of Operators 10 The OOSL Grammar Window 10 2 10 The Names menu 13 2 11 Things That May Go Wrong 13 2 12 Leave the Application Language Lab 14 3 0 Ba
17. CT window by double clicking Resize the window and add scrollbars as described in the previous section Pin up the editor menu Scroll down to the productions for statements IfStmt AssignStmt etc Scrolling a page is done by clicking at the small box at the bottom of the scroll elevator The Concrete Grammar Window The concrete grammar specifies the surface syntax of a language i e the keywords de limiters and formatting information It is edited in the concrete grammar window also by means of the structure oriented editor A concrete grammar consists of productions of different types one type for each production type in the abstract grammar constructions lists and lexemes An exception APPLAB User s Guide version 1 2 5 of 56 Grammar Editing A Guided Tour 2 5 is the alternation productions which are not specified in the concrete grammar A con crete grammar corresponding to the above abstract grammar may have the following ap pearance Stmts List before _ i Gea Sig ls after _ TfStmt Construction Na E AAI 1 then 2 else 3 IdUse Construction ID Lexeme Add Construction 1 2_ Block Construction begin gt gt gt lt nl gt 1 lt n1l gt 2 lt lt lt lt nl gt end A list production contains specification of the concrete syntax tokens before the first list element between the elements and after the last list e
18. Do the following in the TARGET window m Click at the expression i 4 x gt 0 of the assignment statement until the whole ex pression is chosen m Choose Edit as text from the editor menu A one line text editor appears contain ing the text of the current editor focus Press return The string is now translated to a structure and inserted into the program m Clicking at the and symbols of the expression reveals that the resulting structure is equivalent to i 4 x gt 0 Now do the following change in the PARSE window m Give Add higher precedence than Mult Select Add and do Cut Now select Mult and do Paste after Select Mult do Cut Select the empty marker on the line above Do Expand list and then Paste Return to the TARGET window m Repeat the text edit of the i 4 x gt 0 expression The text presented for editing is now i 4 x gt 0 representing the underlying structure of the expression Remove the parenthesis and press Return Investigate the resulting structure It is now equiva lent to i 4 x gt 0 since Add has been given higher priority than Mult The OOSL Grammar Window The static semantics of a language can be defined as an attribute grammar in the OOSL window It is edited in the OOSL grammar window by the means of the same structure oriented editor as the previously described grammar windows 10 of 56 APPLAB User s Guide version 1 2 Grammar Editing A Guided Tour A
19. Indent EndIndent Text 23 gt LEXEME NewLine Indent ndIndent E SonList Son Son SonNumber amp TemplateList SonNumber LEXEME List TemplateList amp TemplateList amp TemplateList Lexeme TemplateList amp TemplateList 1 A concrete grammar is a list of productions 2 A Production consists of an identifi er Id and a definition 3 An ID contains a production name and is thus a lexeme 4 A definition is either a construction a list or a lexeme 5 A construction definition con sists of a TemplateList describing the concrete syntax presented before the descendants The concrete syntax of the descendants is described in the SonList production 6 A TemplateList consists of a number of templates containing keywords and formatting in formation 7 A Template either is a text containing a keyword or delimiter or format ting information Newline Indent or Endindent NewLine means that a new line is to be inserted Indent that the indentation level is to be increased and EndIndent that the in dentation level is to be decreased 8 A Text contains the text to be presented in a lex eme 9 10 11 The Newline Indent and Endindent production do not have any descendants or text contents They are thus terminals in the grammar 12 The SonList in the construction definition specifies the concrete syntax for the des
20. RETURN key on the keyboard is a short cut for clicking on the OK button Some hints m If the text is too large to be completely visible in the prompt you need to resize the promptbox Scrolling in promptboxes is currently not implemented The textprompt can be resized by dragging one of its corners The textprompt can be moved by holding on to its frame and dragging it The broom The APPLAB implementation depends on garbage collection which sometimes takes a few seconds and slightly disturbs user interaction To give the user feedback on when this happens the mouse cursor changes shape to a broom each time the garbage APPLAB User s Guide version 1 2 17 of 56 Basic Interaction collector is started as shown below If the broom appears simply wait until it disap pears again In case the broom shows up very frequently you probably need to run AP PLAB with a larger heap This may be the case if you are working with larger grammars See section 8 1 on how to start APPLAB with a larger heap 18 of 56 APPLAB User s Guide version 1 2 The Grammar Editor 4 0 The Grammar Editor 4 1 Window Structure The window hierarchy in the grammar editor is the following PBO window Represents all the revisions of the grammar Evolution Graph window Contains the Evolution graph for the grammar document Grammar window Contains the parts of a revision of the grammar so called aspect Grammar a
21. The questionmark denotes a placeholder for a language construct e g a state ment or an expression E g while do Here the first questionmark is a placeholder for any expression The second ques tionmark is a placeholder for any statement The underscore denotes an empty list E g while do begin end Here the underscore denotes an empty list of statements The at sign denotes a placeholder for a Jexeme in the program A lexeme place holder must be replaced by a sequence of characters Selection Language constructs are selected by clicking with the left mouse button Repeated clicks at the same position extends the selection to the enclosing construct If the whole AST is selected a repeated click starts from the beginning and selects the smallest construct at the click position Unfortunately there is currently no mechanism for selecting a part of a list e g two statements out of three in a list Expansion A placeholder can be replaced or expanded by the menu command Expand gt 20 of 56 APPLAB User s Guide version 1 2 The Grammar Editor 4 4 4 4 4 5 4 4 6 What appears in the submenu depends on the current selection Non placeholder cannot be expanded placeholder the submenu contains syntactically correct language con structs _ placeholder Expand gt Expand list will insert an element into the list placeholder Expand gt Edit lexeme will produce a text pr
22. ally However the system is fairly tolerant to inconsistencies and does not crash for this reason in general Inconsistencies may also occur between abstract and concrete grammar aspects This may cause the system to crash E g if the abstract aspect contains a production WhileStmt Exp amp Stmt and the concrete aspect contains a production WhileStmt while 1 do 3 _ trying to edit a While statement will cause the unparser to crash If the display of any grammar window gets garbled do a Misc gt Reunparse in that window If the system should crash while you are working on a grammar revision that revi sion will be locked Unlock it by restarting APPLAB without the option latest and do Misc gt Restore all keys in the Evolution Graph Window If the system freezes for no apparent reason no working message or garbage collection it may be that the Caps Lock or Num Lock have been engaged Unengage them for APPLAB to correctly respond to mouse actions 2 12 Leave the Application Language Lab m Do Quit in the grammar window If any changes have been made since the grammar document was last changed a prompt box with the alternatives Save Quit and Cancel will appear asking you if you wish to save the changes Choosing Save will save the changes and then quit the program while Quit will quit without sav ing The Cancel option will neither save nor quit the current
23. ammars A parse grammar or the parse aspect of a grammar specifies additional information needed to correctly perform textual editing of a grammar aspect A Grammar Interpret ing Parser component is used to allow textual editing of any selected structure of a grammar aspect within the structure oriented editor The same abstract and concrete syntax as is used in the structure oriented editor is recognized by the parse Any ambi guities of the abstract grammar are resolved in a parse grammar by specifying the prec edence and associativity of ambiguant productions operators The parse grammar also partly specifies the lexical syntax of the defined language and configures certain aspects of the parsing component An example of a parse grammar is given below Priorities left Add Sub lt left Mult Div Configuration Comments 8 aie NE String Quote w Each line of the priority part contains a list of productions of the same precedence They are either right left or non associative or have no associativity The productions are listed from the lowest to the highest level of precedence I e in the given example Add and Sub which are left associative have lower precedence than Mult and Div The configuration part of the parse grammar is used to specify certain aspects of the lexical syntax i e comments and strings and to configure the parser component APPLAB has knowledge of the structure of the parse gramma
24. and a revision name Quit This command lets the user leave a revision without saving changes in the revision gt Quit If the user has received the key it is returned Grammar Document Characteristics This section describes some characteristics of the grammar documents from the version handling point of view Revision Commands The revision commands are located in the revision window menu as follows gt Revision gt Saveas revision This command behaves as the Save command except the user has to provide an explicit revision name for the revision to be saved gt Revision gt Save as alternative The current revision is saved in a new alternative and the user is prompted for names of the new alternative and revision gt Revision gt Insert Revision Window The PBO window and evolution graph window is created if it was not already present and the revision window is inserted as a son to the PBO window This enables the user to view and manipulate the revisions in the revision graph Undocumented Features gt Miscellaneous gt Create relation gt Miscellaneous gt Delete relation gt gt Miscellaneous gt Relation info APPLAB User s Guide version 1 2 49 of 56 The Version Handling System 7 8 3 Binding of Relations One relations is connected to each grammar aspect window in the grammar document The relation is bound to the meta grammar T iby bir APT teal Faroe i
25. ar The operations for entering exiting and saving grammar documents use the ver sion handling system for storing the information These operations use the version han dling system in a straightforward way similar to the traditional way in which programs are stored in a file system This chapter describes how the version handling system may be used in order to extend the function of the entering exiting and saving operations Terminology A grammar document including all its revisions is called a Program Base Object or PBO for short The PBO d is used for identification of a PBO The revisions of a PBO are organized in an evolution graph which describes the development order of the revi sions A series of consecutive revisions in this graph is called an alternative New alter natives may be created by making a branch from a revision in an existing alternative A Revisionld is used for identification of a revision and consists of three names the alter native name the revision name and the revision number Two PBO s can be connected by a relation which describes a dependency between the PBO s or between two revi sions of the PBO s A typical example is a program that depends on a grammar It is possible to store information in attributes connected to the revisions and to the PBO An attribute has an attribute name and an attribute content Automatic purge is an example of a facility controlled by an attribute Relations A relation is use
26. be changed 4 3 Creating a New Grammar A new grammar document is created by starting APPLAB with a new grammar docu ment name with the extension gram e g applab newlang gram A PBO win 4 See Section 7 0 for further details on the version control system APPLAB User s Guide version 1 2 19 of 56 The Grammar Editor 4 4 4 4 1 4 4 2 4 4 3 dow with an Evolution Graph containing one empty revision node appears Opening it reveals an empty grammar window Add an abstract a concrete and a target window as described in section 4 6 1 Do not forget to set the startproduction in the target window before editing in the target window see section 4 4 8 If no startproduction is set the first production of the abstract window is chosen Editing In the Target and Grammar Aspect Windows Grammars and programs edited in APPLAB are represented internally as abstract syn tax trees ASTs The basic editing technique used is structure editing where constructs are inserted into the grammar aspects by selecting them in a menu The program can contain placeholders which represent incomplete parts of the aspect The placeholders can be replaced by syntactically correct language constructs by choosing from a menu This means that it is impossible to construct documents which are syntactically incor rect APPLAB also supports text editing of structures Placeholders There are three kinds of placeholders
27. by doing Kill m Change the declaration of i to declare a variable x Re evaluate the env attribute of the expression as before Note that the variable x is now contained in the env at tribute instead of i The Names menu In the menu of the TARGET window there is a submenu called Names gt The contents of this submenu is defined by the OOSL aspect of the base grammar The OOSL at tribute names is used to define the contents of this submenu In the demo grammar the node class Exp has a names attribute that defines all semantically visible names at the current Exp node in the TARGET window m Select the expression of the while loop and choose Names gt from the menu A submenu containing all visible names will then be displayed If the OOSL grammar needs to be recompiled a menu option Recompile OOSL grammar is given If so perform the needed compilation by choosing the given menu option and then choose Names gt again Choosing one of the presented names e g OK inserts it into the current selection In a similar fashion variables that are used but not declared in the demo can be ac cessed in a declaration structure m Click twice on the OK in the declaration of OK Choose Names gt and a list of all used but undeclared variables is presented Note The demo only has support for limited static semantics For example the declared types of the variables are not taken into account This will be possible in future releas
28. cendants sons of a construction 13 A Son consists of a SonNumber and a TemplateList containing 6 This is the grammar used by the structure oriented editor when editing concrete grammars in the CONCRETE window 30 of 56 APPLAB User s Guide version 1 2 The Grammar Formalisms 5 3 the concrete syntax to be presented after the son 14 A SonNumber contains the number of the son that is part of a construction It is a lexeme and its contents should be 1 for the first son 2 for the second etc 15 A List definition has three parts One TemplateList that specifies the concrete syntax to be presented before the first element of the list one TemplateList that specifies the concrete syntax separating list elements and one TemplateList for the concrete syntax after the last list element 16 A lexeme definition contains a TemplateList containing the concrete syntax before the lexeme contents and one TemplateList for the concrete syntax after it The bread and butter of the concrete grammars are the Text Indent EndIndent and NewLine templates A Text template will cause the lexeme contents of the Text to be presented The Indent and Endindent will increase and decrease the indentation level respectively The Indent and Endindent will not come into effect until a NewLine is per formed A NewLine results in a new line in the presentation and an indentation to the current indentation level The Structure of Parse Gr
29. contains the semantic grammar which defines the static semantics of the language Finally TARGET is a target structure which can be edited in accord ance with the abstract concrete and parse grammars To leave APPLAB see section 2 12 The Target Window The target window is used for editing the program according to the abstract and concrete grammars in a structure oriented fashion For a more thorough presentation of the func tionality of the structure oriented editor please refer to Section 4 4 m Double click on the TARGET icon The target window is opened showing a pro gram fragment 1 Users acquainted with the grammar editor of the Mjglner Orm system can skip sections 2 2 2 6 2 A more technical description can be found in Min r S On Structure Oriented Editing Ph D thesis Dept of Computer Science Lund University 4 of 56 APPLAB User s Guide version 1 2 Grammar Editing A Guided Tour 2 3 2 4 m Make the window a little larger Pin up the editor menu by pressing the right mouse button inside the window and select the pin at the top of the menu Add scrollbars to the window by selecting the Scroll bars on off entry under the Misc entry in the menu m Make some minor modifications of the program A new statement for instance is created by selecting one statement by repeatedly clicking at it until the whole state ment is selected and then choosing the Expand after
30. ct window to be changed Allows a production to be chosen as the start production of the abstract syntax tree in the window This is typically used when a target window just has been created The root node of the tree is set to the desired start production of the abstract grammar Use the Edit alternative to enter an arbitrary production name Not documented Contains the available OOSL attributes at the current fo cus Choosing an attribute from the menu evaluates that at tribute and displays the result The same as Show attribute but the value of the attribute is displayed to a textfile You will be prompted for the filename Contains a few utilities It varies slightly depending on which aspect it appears in It basically has the following entries Undocumented Undocumented There are a number of short cuts when editing grammar aspect windows Mouse short cuts m Middle mouse button works as Edit as text Keyboard short cuts m The arrow keys move the selection APPLAB User s Guide version 1 2 23 of 56 The Grammar Editor 4 4 10 4 5 UP moves the selection one level up in the AST DOWN moves the selection to the first son node in the AST RIGHT moves the selection to the next node in a preorder traversal LEFT moves the selection to the previous node in a preorder traversal m Control keys hold down the CTRL key while typing another character AE Expand list or Expand lexeme M or RETURN
31. ctured to allow the parser to perform correctly Sometimes it may be desirable to limit the amount of restructuring done to the grammars but that means that the original grammar must be suitable for parsing without those grammar transformations The configuring options in clude No left factoring Common prefixes are not factored out the grammar should be LL 1 Do not use priorities The precedence and associativity of productions specified in the parse grammar should not be used the grammar must be unambiguous Extended focus When selecting a structure for textual editing match to the most general language construct with the same extent on the screen E g for the grammar Exp Add NUM NUM LEXEM Selecting the lexeme structure of a NUM production is equal to text editing an Exp structure The Structure of OOSL Grammars The OOSL grammar or the oosl aspect of a grammar is used to define static semantics defined as Door Attribute Grammars Each production in the abstract grammar has a node class in the OOSL grammar There are different types of node classes Alterna tion Construction List and Lexeme LEXEM They correspond to the al ternation sequence list and lexeme productions of the abstract grammar The node class name in the OOSL grammar production has to be the same as in the abstract grammar An example of an OOSL grammar is given below Expr node ANYNODE Alternation inh expectedType int
32. d in order to describe a relationship between two PBO s or even be tween specific revisions within the PBO s The information connected to a relation con sists of three parts the revision description which describes the current value of the relation the binding type which is used to describe how the relation should be rebound and the binding rule which describes how a revision should be selected in the evolution graph m Revision description The revision description consists of the PBOId and an Internal number which uniquely identifies a revision within the selected PBO APPLAB User s Guide version 1 2 39 of 56 The Version Handling System PBOId File name of the PBO or lt SELF gt lt SELF gt is used in order to refer to an open revision despite it not yet being inserted in the evolution graph Internal no Undocumented description m Binding type The binding type defines how the relation will be rebound Explicit Rebind the relation by letting the user interactively choose PBO and revision Fixed Do not rebind the relation Uses the revision identification in order to bind the rela tion If the revision can not be found the user is prompted to bind the relation interactively Dynamic Rebind the relation according to the binding rule If the rule can not point out exactly one revision the user is prompted to bind the relation interactively m Binding rule A binding rule is a wild card speci
33. e productions ID NUM INT REAL and ANYLEX described in Section 5 3 1 are implemented as predefined lexeme classes in OOSL through which the contents of the actual lexeme text can be accessed in the OOSL grammar The prede fined lexeme classes are defined as follows also found in the LIB aspect of oosl gram ID node syn val string syn lex string NUM node syn val real syn lex string REAL node syn val real syn lex string INT node syn val integer syn lex string APPLAB User s Guide version 1 2 35 of 56 The Grammar Formalisms ANYLEX node syn lex string 5 4 5 Predefined Abstract Data Types In order to more efficiently express static semantics of a language using the OOSL grammar a number of abstract data types have been predefined The only data type im plemented at the moment is a set of strings but in the future lists dictionaries and sym bol tables are to be predefined The set is defined as follows also found in the LIB aspect of oosl gram Set class Returns true if the set is empty empty func boolean Returns true if the set contains item contains func boolean item string Adds item to the set add func ref Set item string Returns the union of this set ands union fune ref Set s ref Set Returns true if this set contains exactly the same stri
34. e productions and used instead of user defined lexeme productions Internally the predefined lexeme productions comments strings and key words are implemented as follows NUM gt INT REAL INT gt Integer REAL gt RealNumber Exponent ID gt Letter Letter Digit _ ANYLEX gt Chars 1 2 3 4 5 32 of 56 APPLAB User s Guide version 1 2 The Grammar Formalisms 5 3 2 5 4 Comment gt CommentBeginToken ANYLEX CommentEndToken String gt QuoteChar ANYLEX QuoteChar Keyword gt Non blank RealNumber gt Integer Integer 6 7 8 9 Exponent gt E e Integer Integer gt Digit Digit gt 0 9 CommentBeginToken gt Specified in PARSE CommentEndToken gt Specified in PARSE QuoteChar gt Default specified in PARSE Chars gt All printable ASCII characters Non blank gt All printable non blank ASCII characters Letter gt A Z a z 1 Configure Text Editing The text editing facilities of APPLAB can be configured for each language described by a grammar in APPLAB The parser component that performs the text editing works on an internal representation of the current grammar In order to correctly parse as large a set of grammars as possible this internal grammar representation is restru
35. eat shima Copa Hery E Bitt e Set Tig EE E H Gane Babe id ff tren 7 gly 7 we EFi Do the following in the CONCRETE window m Find the while stmt production in the concrete grammar by scrolling the window or by selecting WhileStmt from the menu Find gt Find names gt Select the while token at the second line of the production by clicking at it Choose Expand gt E dit lexeme from the editor menu A one line text editor ap pears Change the text from while to when and press return Move to the TARGET window m Click anywhere in the TARGET window and the program display will change ac cording to the modified concrete grammar m Select a statement by clicking on it Choose Expand after to get a new placeholder for a statement Check that the hierarchical menu under Expand has changed to the new syntax and create a new when do statement by selecting it APPLAB User s Guide version 1 2 7 of 56 Grammar Editing A Guided Tour 2 6 Extend the Grammar With a New Statement In the previous section only the surface syntax of the language was modified We will now extend both the abstract and concrete grammars with a new statement Since there is a while statement but no repeat statement in the language let us make one It shall have the following abstract syntax RepeatStmt Stmt amp Exp Do the following in the ABSTRACT window m Select a whole production and choo
36. ected the list In these situations you can find out by re peated selections which construct you have actually selected Text Editing The expand command is usually rather tedious to use for constructing and changing e g expressions Therefore text editing facilities are also provided for expressions and all other language construct To edit a structure as text select it and choose Edit as text from the menu A promptbox appears in which you can edit the selected structure as text When you are ready press the RETURN key on the keyboard The text is then processed and if it is syntactically correct the corresponding AST will replace the cur APPLAB User s Guide version 1 2 21 of 56 The Grammar Editor 4 4 7 4 4 8 rent selection If any syntax errors where encountered an error window will appear con taining a report on the detected errors and the edited text is presented to the user for further text editing Sometimes a window containing grammar errors and warnings ap pears E g when text editing in the CONCRETE window such a window appears To avoid it popping up every time a text edit is performed iconize it and it will only appear again if any further grammar errors are detected There is a convenient short cut to text editing Click on the middle button of the mouse instead of choosing the Edit as text menu command See section 5 3 on how to configure the text editing facilities for a specific lan gua
37. eger loc myType integer loc sonError boolean 9 See Hedin G Incremental Semantic Analysis Ph D thesis Dept of Computer Science Lund University for a more detailed description of the grammar formalism APPLAB User s Guide version 1 2 33 of 56 The Grammar Formalisms 5 4 1 loc locTypeError boolean eq locTypeError if expectedType anyType or myType anyType then false else xpectedType myType eq error locTypeError or sonError WhileStmt node Stmt Construction a_Expr ref Expr a_Stmt ref Stmt eq error a_Expr error or a_Stmt error eq a_Expr expectedType boolType Less node Expr Construction a_Exprl ref Expr a_Expr2 ref Expr eq sonError a_Exprl error or a_Expr2 error eq son Expr expectedType numType eq myType boolType For each node class attributes and equations defining the value of those attribute can be specified APPLAB has knowledge of the structure of the OOSL grammar It can be ex pressed in an abstract grammar for the OOSL grammar Compiling an OOSL Grammar In order to benefit from the entered OOSL grammar it must be compiled This is done by choosing the menu alternative Compile oosl in the menu of the OOSL window or the menu alternative Recompile OOSL grammar which appears when the system discovers the need to recompile During compila
38. ented by a construction class with Exp as its superclass The OOSL aspect of the demo grammar defines that variables need to be declared in the local or in an outer block to be used The attribute env contains the names of the declared variables at the current node class while the attribute undeclaredEnv con tains the names of all the used but undeclared variables The OOSL attributes and equations need to be compiled to internal structures to be available in the TARGET window When they are the attributes are accessible through a submenu Do the following in the OOSL window m First we need to update the OOSL aspect with a node class for the Repeat Stmt we added to the grammar earlier Select a whole node class by repeatedly clicking at it and choose Expand after A placeholder for a OOSL declaration appears APPLAB User s Guide version 1 2 11 of 56 Grammar Editing A Guided Tour m Choose the node entry under Expand which inserts a placeholder for a node class The node class name placeholder is automatically selected m Choose Expand gt dit lexeme and enter the name of the node class i e Re peat Stmt followed by return The prefix placeholder is now automatically select ed Choose the entry under Expand and then Expand gt dit lexeme and fill in Stmt The Repeat Stmt appears on the right hand side of the St mt production in the abstract grammar m Now choose the i entry under Ex
39. ented in a window on the screen If something goes wrong during the evaluation e g an attribute does not have an equation defined for it or the target grammar is not complete then the attribute is said to have an erroneous value Before presenting the list of accessible attributes the system checks if the OOSL grammar needs recompiling If so the menu option Recompile OOSL grammar is given Defining the Names Menu If the current selection has an OOSL attribute with the name names the contents of this attribute is presented in the Names menu This facility is intended to be used to present a list of all names semantically visible at the current selection of the program It is up to the language designer to define the names attribute defining the current names to be presented in the Names menu Such an attribute can be defined for any node class of the grammar If no such attribute is defined for the current selection it is said to have no se mantics defined for it See sections 2 10 and 4 4 7 for a description of the Names menu facility When requesting the Names menu the system checks if any names attribute is defined in the OOSL aspect for the node class of the current selection and if so it is eval uated and its contents presented in a Names menu in the TARGET window The system also checks if the OOSL grammar needs to be recompiled If so the menu option Rec ompile OOSL grammar is given Predefined Lexeme Classes The predefined lexem
40. entry A new placeholder is inserted which may be expanded to a new statement chosen from the hierarchical menu under the Expand entry If an if statement is selected a template for that statement is inserted containing placeholders for the predicate and the statements of the then part and the else part respectively These placeholders may be further ex panded by choosing the desired entries in the menu under the Expand menu The Abstract Grammar Window The abstract grammar defines the structure of the language of the program in the target window The abstract grammar itself is also represented and edited as a structure It is edited by means of the same editor as in the target window just using different meta grammars An abstract grammar is similar to a conventional BNF grammar It contains four different production types construction list alternation and lexeme productions They have the following form Stmt Stmt List Stmt Block IfStmt WhileStmtAssignStmt Alternative TfStmt Exp amp Stmt amp Stmt Construction Exp IdUse Constant Add Mult Greater Alternative IdUse ID Construction ID LEXEM Lexeme Add Exp amp Exp Construction Block Decls amp Stmts Construction Notice that the productions do not contain any concrete syntax such as keywords and delimiters and that different types such as construction and list cannot be nested in one production Open the ABSTRA
41. es of APPLAB See sections 4 4 7 and 5 4 3 for further details on the Names menu facility Things That May Go Wrong One mistake resulting in the changes of a grammar not coming into effect in the target window is misspelling of the production name Be careful not to add extra blanks and to use the same upper lower case letters Use the All names facility to avoid this Grammar changes of the abstract concrete or parse grammars will not come into effect until an operation click Expand is performed in the TARGET window Changes of the OOSL grammar need to be compiled to come into effect When OOSL attributes are accessed Names Show attribute the system checks if the OOSL grammar needs to be recompiled If so a menu command for recompiling the OOSL is presented Recompilation of the current OOSL grammar is only performed if Recom pile OOSL grammar is chosen APPLAB User s Guide version 1 2 13 of 56 Grammar Editing A Guided Tour Unexpanded placeholders in the grammars can sometimes give unexpected re sults Check that all placeholders are expanded in the grammar Inconsistencies may occur between abstract grammars and programs If an ab stract production is modified and the program contains constructs generated from the old production the program is inconsistent with its grammar The system does not sup port program transformations from old to new abstract grammars You have to cut the inconsistent parts manu
42. fication for selecting revisions in an evolution graph The wild card specification is a pattern corresponding to the parts of the Revi sionId BindingRule AlternativeName RevisionName RevisionNo AlternativeName WildCardSpecification RevisionName WildCardSpecification RevisionNo WildCardSpecification NewestRevision Integer WildCardSpecification Chart Where is a wild card character matching any sequence of characters NewestRevision gt gt matches the newest revision among the revisions selected by the previ ous two parts of the binding rule Example Alternative name MyAlt Revision name SELECT Revision number gt This means select the latest created revision with an alternative name starting with MyAlt and containing SELECT in the Revision name 7 3 1 Look up of PBOld At binding time the PBOId is looked up in the file system in the following order 1 Current directory 2 According to the environment variable corresponding to the PBO type If no PBO is found an explicit binding is initiated 40 of 56 APPLAB User s Guide version 1 2 The Version Handling System 7 3 2 7 3 3 Explicit Binding of Relations When the relation is rebound explicitly the user is prompted for the PBOId fornia wuss flu ba gaa After selecting the PBOId the full file name of the PBO is looked up and a revi sion selection prompt i
43. g grammars and icon raster files APPLAB User s Guide version 1 2 53 of 56 Unix Level 8 5 Files in the Release This section lists the files included in the APPLAB release and their purpose bin applab ormmessage ormcp ormmv ormrm demo doc grammars abs gram con gram code gram doc gram oosl gram par gram rapid gram sem gram Images UILrasters Grey lib greyscales Sun sparc Solaris binary executable for APPLAB Sun sparc Solaris binary executable for socket communication with an open APPLAB session script for copying grammar files script for moving grammar files script for removing grammar files demonstration programs and grammars documentation metagrammar for abstract grammars metagrammar for concrete grammars metagrammar for code generation grammar metagrammar for documentation grammar metagrammar for oosl grammars metagrammar for parse grammars metagrammar for rapid grammars metagrammar for semantic checking grammar not OOSL raster files for icons raster files for background grey scales configuration file for the grey scales used in background windows 54 of 56 APPLAB User s Guide version 1 2 Trouble Shooting 9 0 Trouble Shooting 9 1 9 2 9 3 9 4 9 4 1 9 4 2 Problems With Starting APPLAB APPLAB Prints Error Message on Standard Output This may happen after a previous crash during a save operation which has lef
44. ge Semantic Editing As a complement to structure oriented editing and text editing it is also possible to do semantic editing Semantic editing can utilize static semantic information such as scope rules properties of declared identifiers and context of the current selection to support high level editing At the moment such semantic support is limited to the Names menu but in future releases of APPLAB will contain more support for configuring and per forming semantic editing of grammars and programs The Names menu is designed to give a submenu of all names semantically visi ble at the current selection cmp the Names menu in the Mjglner Orm system The ac tual contents of the Names menu is defined by the OOSL aspect of the base grammar and can be configured by the language designer If the contents of the Names menu has not been defined in the OOSL aspect the current selection it is said to have no semantics defined for it See section 5 4 3 for further details on how to define the contents of the Names menu When the user selects a name from the Names menu the system tries to insert it into the current selection If the text can not be correctly matched to a structure error messages are given and the user is presented with a text editing prompt with the chosen text The submenu All names works in the same way as Names except that it contains a list of all current lexemes in the grammar aspect window I e when a lexeme text is c
45. ge concerning the current heap size socket start APPLAB with open socket communication msgport initiate socket communication on port Only meaningful when starting APPLAB with the socket option text textFile grammar startProd starts APPLAB with a text link window see section 4 5 con taining the imported text from text File The file is assumed to contain a program written in the metagrammar grammar starting at production start Prod If no grammar name is given the current grammar is used If no start production is giv en the first production of the grammar is used filename Must have the extension gram If the file does not exist a new grammar is created 8 2 The ormmessage Script The ormmessage script sends a message to an active APPLAB session The synopsis for ormmessage is gt ormmessage ormclient lt orm machine gt msgport STOP READ EDIT lt FileName gt lt grammar gt lt startProd gt ormclient lt orm machine gt Send message to APPLAB running on orm machine 52 of 56 APPLAB User s Guide version 1 2 Unix Level 8 3 8 4 msgport Use port for socket communication STOP Close the current APPLAB session READ EDIT lt FileName gt lt grammar gt lt startProd gt Initiates a Text Link Window see section 4 5 with the con tents of the text file FileName interpreted according to the grammar grammar with start produc
46. grammar document 14 of 56 APPLAB User s Guide version 1 2 Basic Interaction 3 0 Basic Interaction This chapter explains how to interact with windows menus and promptboxes and how to use the mouse 3 1 Windows A window is either opened or closed An open window has the following parts an icon a title a frame and a contents part The icon and title parts are optional When the win dow is closed only the icon and title parts are shown f title icon frame contents 3 2 The Mouse The mouse has three buttons left LB middle MB and right RB General usage LB Moving windows and selecting items of the window contents MB Resizing windows initiating text editing RB Bringing up popup menu In addition to this general usage there may be specialized behaviour in different windows The mouse cursor changes shape depending on what it points to This helps when pointing to small or narrow things e g the window frame Note Do not try to click ahead If the response of the system is not immediate it is better to wait a little while Otherwise strange things may happen 3 3 Popup Menus Different parts of a window may be associated with different popup menus In particular there is icon menu on the icon of a closed window title menu on the title of a closed window frame menu on the icon and frame of an open window APPLAB User s Guide version 1 2 15 of 56 Basic Interaction 3 4 co
47. h the APPLAB system from the Unix shell window lt CTRL gt C and restart it Your changes since the last save are lost APPLAB User s Guide version 1 2 55 of 56 Trouble Shooting 9 5 Frequent brooms The broom is the mouse cursor shown during garbage collection see section 3 8 In case the broom shows up very frequently you probably need to run APPLAB with a larger heap This may be the case if you are working with larger grammars See section 8 1 for how to start APPLAB with a larger heap 56 of 56 APPLAB User s Guide version 1 2 Index A ABSTRACT 4 abstract data types 36 abstract grammar 4 28 abstract grammar window 5 AC expression 37 Add 25 alternation 5 alternative 39 alternative name 39 ANYLEX 32 35 applab script 52 associativity 31 attribute content 39 attribute name 39 attributes 34 B back 17 binding rule 23 40 binding type 40 broom 17 Cc cardinal 37 change meta grammars 25 check grammar 23 choose selected 41 close 16 comments 32 compile OOSL 34 CONCRETE 4 concrete grammar 4 29 concrete grammar window 5 construction 5 contents 15 contents menu 16 copy 21 cut 21 D debug 23 26 delete 47 delete fork 23 25 demand attribute evaluation 35 door attribute grammars 33 dynamic rebinding 46 E edit as text 21 Edit lexem 21 edit lexeme 7 21 enter selection criteria 45 entering 19 environment variable 53 equations 34 error recove
48. he Pretty Printer collects information about each production from the abstract con crete and parse aspect and produces a tree listing of the grammar Any undefined pro ductions are marked in the produced list Defined but unused productions are found at the root of a separate tree in the listing This helps to identify misspelled and or unde fined productions It also gives a better overview of the defined language since informa tion from the abstract concrete and parse aspect is compiled into one list The list is written to a text file specified by the user Invoke the pretty printer by the menu command Pretty Print in the pop up menu of the grammar window The OOSL Generator When entering a grammar for a language one usually begins by defining the abstract and concrete aspects Later on an OOSL aspect may be added The structure of the node classes has then already been defined in the abstract grammar aspect and entering the corresponding structures once again in OOSL syntax is both tedious and error prone In stead the OOSL Generator can be used to automatically generate and or update these structures from the current abstract aspect The OOSL Generator is invoked by the menu command Special gt Generate from ABSTRACT in the OOSL window The user is asked to give the name of a general prefix class i e an alternation node class that will be the superclass of all the node classes in the grammar It is often useful to declare a com mon n
49. he meta grammar Usually you can use the meta grammar name suggested in the prompt box by just pressing return The revision is selected in a revision graph To get the latest revision double click in the right most box of the graph The meta grammar lt SELF gt is suggested when a target window is opened It means that the target struc ture is edited using the abstract and concrete grammar aspects in the grammar of which the target window itself is part this is usually what you want A target or grammar aspect window is removed using Delete fork Delete a target or grammar aspect window The name of the window to be deleted is specified in a prompt box N B Be careful to spell the name exactly as it appears in the title of the window Other Commands The grammar window menu also contains the following entries We recommend not us ing the undocumented ones Change Meta Grammars Not documented Revision Not documented Miscellaneous Not documented Import text Imports a program from a textfile to a new grammar as pect APPLAB User s Guide version 1 2 25 of 56 The Grammar Editor Import text as Same as Import text but a new metagrammar can be specified Pretty Print Generates a pretty print list of the current grammar Debug Not documented 4 7 Restoring a Crashed Grammar If APPLAB crashes while you have an opened grammar you will normally have lost only the changes you made since the last Save
50. hosen from the All names list the system tries to insert it at the current selection Other Editor Commands in Grammar Aspect Windows Edit as text Edit the current focus as text Import text Import the contents of a text file into the current focus Find gt Tries to locate a lexeme matching a given search string Find Asks the user for a search string Find pastebuffer Uses the current contents of the pastebuffer Find next Continues a previous successful search 22 of 56 APPLAB User s Guide version 1 2 The Grammar Editor Find names gt Misc gt Scrollbars on off Redisplay Reunparse Rebuild menus Save As Text Save Interface Save As Tree Delete Fork Set Title gt Set Startprod gt Binding Rule gt Show attribute gt Print attribute gt Special gt Debug gt Check Grammar 4 4 9 Short cuts Presents a list of all lexeme texts of the current window Add or remove scrollbars to the window Redisplay the text in the window Reunparses the contents of the window according to the concrete grammar and displays it Used in the target win dow when the display has been garbled Recreates the contents of the expand menu Saves a grammar aspect or target structure on a text file You will be prompted for the filename Not documented Not documented Deletes this TARGET or grammars aspect window after confirmation Allows the title if a target or grammar aspe
51. ight corner shape You may also use the LB for resizing if you start dragging close to one of the corners Resizing an interior window will automatically resize outer win dows as well if this is needed to make all of the window visible Front Bring window to the front by clicking on title or frame LB The window is placed in front of sibling windows Instead of clicking the front command in the frame or icon menu can be used 16 of 56 APPLAB User s Guide version 1 2 Basic Interaction 3 5 3 6 3 6 1 3 6 2 3 6 3 3 7 3 8 Back Bring a window to the back of all its sibling windows by the back command in the frame or icon menu Additional Menu Commands on Windows Visible Resizes outer windows to make sure all of the items of the window contents are applicable Scrollbars Adds or removes scrollbars Only applicable to windows with text contents Refresh Redraws the window or icon Text Text based interaction is only possible in textprompts Positioning and Selection LB click position the text cursor MB click extend the selection Keyboard arrow keys up down left right change the position of the text cursor Cut Copy and Paste Use the cut copy and paste keys on the keyboard or the menu commands in the popup menu Scrolling Add scrollbars to the window by the command in the popup menu or the frame menu Textprompts Textprompts usually contain an OK and a CANCEL button Pressing the
52. itiated The binding rule is overruled 7 4 Window Structure The window corresponding to a grammar represents a single revision of the grammar and is here called the revision window It is labelled with the PBO name and the Revi sionId When starting APPLAB an outer window called the PBO window is created which represents all of the revisions of the grammar From the PBO window it is possi ble to open one or more revision windows of the document These revision windows are placed inside the PBO window Within the PBO window there is functionality available for viewing and affecting the revisions of the document The PBO window is labelled only with the PBOId With in the PBO window an evolution graph window is displayed This window shows the evolution graph of the PBO and is used for manipulating the graph and the revisions of the PBO Evolution PBO Graph Window Window DOO me Piim Revision Window 7 5 PBO Window In this section the functionality of the PBO window is described 7 5 1 Commands gt Quit This command removes the PBO window and terminates APPLAB Restriction It is not allowed to quit from the PBO window if any revision win dow currently is open 42 of 56 APPLAB User s Guide version 1 2 The Version Handling System Sahat linn irg D a H hiiri DSS os Anii fh CONCRETE 7 5 2 Undocumented Features gt Garbage Collect gt Memory Statistics gt Memory Statistics
53. lable grammar tools Chapter 7 0 describes the version handling system which applies to grammars Chapter 8 0 describes how grammar documents are stored as files on the Unix level and variations on how to start the APPLAB system Finally there is a chapter 9 0 on troubleshooting More Literature APPLAB is the result of further development of the Orm Programming Environment that was initially developed as part of the Nordic research project Mj lner The main re search results from the Mj lner project are summarized in a book Object Oriented Environments The Mj lner Approach Editors J rgen Lindskov Knudsen Mats L fgren Ole Lehrmann Madsen Boris Magnusson PRENTICE HALL the object oriented series 1994 ISBN 0 13 009291 6 More detailed account of the techniques used in developing the Orm system are available in Ph D theses and research reports from Dept of Computer Science Lund University Many of the reports are available electronically via anonymous ftp mjolner dna lth se or via world wide web http www dna lth se Research ProgEnv ProgEnv html Important Notice on Copying Removing and Renaming Documents APPLAB document filenames have the extension gram However for each grammar document basefile lang gram there are a number of additional revision files with names lang gram_n In copying removing or renaming grammar documents all these files must be treated consistently I
54. lement A construction production contains first the leading concrete syntax and then a reference to each sube lement n together with the concrete syntax after that subelement A lexeme produc tion contains the concrete syntax before and after the lexeme contents The concrete syntax is expressed using text a text indentation gt gt gt end in dentation lt lt lt and newline lt nl gt An empty sequence of concrete syntax is repre sented with an underscore _ m Open the CONCRETE window by double clicking on it m Make the window larger and add scrollbars Pin up the editor menu Scroll down to the productions for statements After this step the screen will look something like figure 1 Make a Small Modification of the Concrete Grammar The program in the target window is edited in accordance with the grammars A modifi cation of the grammars will affect the target program A simple modification is to change the keywords of a statement To start with let us change the keywords of a while statement from while do to for example when do 6 of 56 APPLAB User s Guide version 1 2 Grammar Editing A Guided Tour FIGURE 1 Ej Loy t Dero piri jin FI gt Bc arai LiL ee Acid LE T arietta biasa Katee idda reer fij pasar X r Bib ramen miz Epara giter EETU panne bef a Ii i IT ri Trae Falga pica atte barie Friri stir ibaie Cie L E E amia ey l
55. lowed by the concrete syntax after the de scendant In the example 1 results in presentation of descendant one the condition expression of the if statement followed by the text then increasing the indentation level and a new line The second descendant the then statement is presented followed by decreasing the indentation level a new line the text else increasing the indenta tion level and a new line 3 The Plus production is another example of a construction production It has no concrete syntax before the first descendant represented by an emp ty template list _ The first descendant is followed by the text and the presentation of the second descendant No concrete syntax follows the second descendant 4 Finally the ID is a lexeme production It has two parts before and after The before part specifies the concrete syntax presented before the lexeme contents The lexeme contents is then presented followed by the concrete syntax of the after part In the example no concrete syntax is preceding or following the identifier The structure oriented editor has knowledge of the structure of concrete gram mars It can be expressed in an abstract grammar for concrete grammars ConcreteGrammar Production Production Id amp Definition ID LEXEME Definition Construction List Lexeme Construction TemplateList amp SonList TemplateList Template Templa Text NewLine
56. menu under Expand is extended with the new state ment m Select it and a template is inserted in the program If you are not fully satisfied with it modify the concrete production click in the TARGET window and watch the re sult of the modification You can now use the new statement as any other statement The expression and statement in the repeat statement may be further expanded If you are not satisfied with a single statement inside the repeat statement which can be expanded to begin end to get a list of statements you can change that in the abstract grammar Do the fol lowing m Select the Stmt part of the RepeatStmt production in the abstract grammar Do Expand gt Edit lexeme to change it to Block m Cut the statement parts of the repeat statements in the program You can now insert several statements in the repeat statement using Expand after The Parse Grammar Window The parse grammar contains specifications needed to correctly perform text editing of the language It is edited in the parse grammar window using the same editor as the pre viously described grammar windows A parse grammar contains a list of productions of the abstract grammar An asso ciativity and precedence is defined for each line of productions A parse grammar for the above abstract and concrete grammars may have the following appearance Priorities nonassoc Greater Less 1 lt left Add 2 lt left Mult
57. n OOSL grammar consists of node classes of different types one type for each production type in the abstract grammar constructions alternation lists and lexemes An OOSL grammar corresponding to the abstract grammar above may have the follow ing appearance ANYNODE node Alternation inh env ref Set syn undeclaredEnv ref Set eq son ANYNODE env env eq undeclaredEnv new Set eq son Exp names env hi Exp node ANYNODE Alternation inh names ref Set Mult node Exp Construction a_Expl ref Exp a_Exp2 ref Exp eq undeclaredEnv a_Expl undeclaredEnv union a_Exp2 undeclaredEnv Stmts node ANYNODE Stmt List eq undeclaredEnv AC SX new Set SX union son undeclaredEnv ID node val string Lexeme Attributes and equations for those attributes can be defined in the different node class es OOSL is an object oriented specification language so each node class may inherited attributes and equations from an alternation class This corresponds to the alternative productions in the abstract grammar E g the Exp production of the abstract grammar above is an alternative production listing all the different kinds of expressions for the language In the OOSL aspect this corresponds to an alternation class containing all the common attributes and equations for Exp and each specific expression Add Mult etc is repres
58. n be edited using AP PLAB The concrete aspects of the metagrammars can be edited freely changing the presentation of grammars e g the way an abstract grammar is presented with amp amp The abstract aspects of the metagrammars may not be changed since they define the structure of the grammars which is the language APPLAB interprets while editing Changing the abstract aspects of the metagrammars will cause unpredictable re sults The metagrammars are named abs gram con gram par gram and oosl gram They are located in the grammars directory The grammars may be inspected using APPLAB but we strongly recommend you to not edit them APPLAB User s Guide version 1 2 37 of 56 Grammar Tools 6 0 Grammar Tools 6 1 6 2 When defining new languages in APPLAB it is useful to have a few tools that help the language designer in editing and debugging the grammar specifications Two such sim ple rudimentary tools are included in this release of APPLAB a Pretty Printer and an OOSL generator The Pretty Printer compiles the abstract concrete and parse aspects of a grammar into one list The OOSL generator is used to generate the outlines of an OOSL grammar aspect corresponding to the abstract aspect The Pretty Printer The grammar for a language is entered production by production and information con cerning each production is spread over a number of different aspects of the grammar T
59. n both the name and the contents are text strings The attribute can be at tached to the PBO or to any revision Attributes can be used for example to describe the state of a revision in the development process gt Attached Info gt Attributes gt Object attributes gt These commands apply to the PBO attributes eee gt Show Show the attributes of the PBO iets gt Set Define a new attribute or change the contents of an attribute in the PBO ass gt Delete Delete a PBO attribute Restriction m See Predefined Attributes section 7 9 for a summary of all attributes with an al ready defined meaning gt Attached Info gt Attributes gt Revision attributes gt These are the commands applicable to the revision attributes fens gt Show all Show all attributes for each revision in the PBO Pere gt Show Show all attributes of the selected revisions APPLAB User s Guide version 1 2 47 of 56 The Version Handling System 7 6 7 7 6 8 7 7 7 7 1 sinks gt Set Define a new attribute or change the contents of an attribute for eve ry selected revision eck gt Delete Delete an attribute for every selected revision Other Commands gt Show Revision Names The selected revisions will have their names printed above its sym bol gt Misc gt Restore all keys If anyone takes the key from an alternative and the execution of the program is unintentionally interrup
60. ngs as s equal func boolean s ref Set 5 4 6 The Implemented Subset of Door AG The OOSL compiler and demand attribute evaluator of APPLAB are presently limited to handling only a subset of Door AG constructs This subset includes alt and cons classes with single inheritance list classes extended with the predefined attributes cardinal and son pos and an at tribute construction expression See List Nodes in OOSL on page 37 for a descrip tion of the added features local inherited and synthesized attributes virtual functions with parameters classes without parameters types integer real boolean string object references logical operations not or and lt gt if then else arithmetic operations function calls string operations concat blanks attribute equations collective equations 36 of 56 APPLAB User s Guide version 1 2 The Grammar Formalisms 5 4 7 5 5 Doors and semantic objects have been left out as well as iterators collections condi tions and fix attributes List Nodes in OOSL The list node construct of OOSL has been extended with the predefined attributes car dinal and son pos and an attribute construction expression The predefined attribute cardinal can be described as follows cardinal attribute of list nodes denoting the current number of sons In order to construct attribute values based on attributes of the sons of a list node an at
61. ntents menu on the contents part of an open window The icon and frame menus contain general window commands whereas the title and contents menus are application menus are application specific Some menus are stay up able These menus have a pin at the top Choosing the pin makes the menu stay up A pinned up menu disappears when clicking on the pin RB Some menu alternatives are pull right able indicated by an arrow to the right Drag the mouse to the right and a new menu appears slay Up pn pull right arrow Expand after lt ARTUEM Fanta before A ie Show attribute Print aftr ibute facial To refer to menu commands we will use the following notation choice select choice in a popup menu window gt choice select choice in a popup menu of window choice gt subchoice pull right at choice and select subchoice in the appearing submenu choice gt txt select choice in a menu and answer txt ina textprompt Basic Commands on Windows Open Open window by double clicking LB on the icon or title of a closed window or choose open in the icon menu Close Close window by click on the icon of an opened window or choose close in the frame menu Move Move window by dragging title or frame LB Dragging the icon works only for closed windows Resize Resize window by holding on to the window frame MB and drag The cursor turns into a lower r
62. ode class containing attributes and equations which are general to all the node classes If no prefix is given non will be used in the generated structures When using the OOSL Generator to update an OOSL aspect messages will be pro duced in a message window for any node classes that already exist If they have a differ ent structure prefix or number type of sons than is derived from the abstract grammar aspect this is also reported and the node class of the OOSL window is changed to match its abstract aspect The bodies of existing node classes containing attributes and equa tions are always left intact The sons of a construction node are named with the prefix a_ added to the qualification of the son 38 of 56 APPLAB User s Guide version 1 2 The Version Handling System 7 0 The Version Handling System 7 1 7 2 7 3 This chapter introduces how to use the finer details of the version handling system of APPLAB and it explains how the version handling system affects the basic operations for entering exiting and saving grammars It is not necessary to read this chapter for normal use of APPLAB Introduction All grammars within APPLAB are uniformly version controlled using the same basic mechanisms The version handling system supports the user in organizing versions of grammars and maintains relations between those stored objects Two users may simulta neously work on the same revisions of the same gramm
63. ompt box where you can type in the new lexeme A list can be expanded by selecting one of its elements and selecting Expand after or Expand before Cut Copy Paste The system has an internal paste buffer which can hold any language construct This paste buffer can be used to move language constructs within a grammar aspect Unfortu nately the paste buffer does not work across different grammar aspects Cut Removes the current selection and replaces it with a place holder The removed language construct is placed in the internal paste buffer Copy Copies the current selection into the paste buffer Paste Replaces the currently selected placeholder with a copy of the paste buffer Paste after Inserts a copy of the paste buffer after the currently select ed list element Paste before Inserts a copy of the paste buffer before the currently se lected list element Some Hints One source of confusion is that some language constructs have the same extent on the screen This means that one cannot tell which one of them is selected This is e g the case for some lists with one element One cannot see the difference between selecting the only element and selecting the whole list with the only element This can be rather confusing E g if you have selected a list with one element where the element is a place holder you may think that the placeholder is selected But the expand command will not work as if you actually have sel
64. pand which states the node class type to be a construction A placeholder for a son now appears The Repeat St mt has two sons Stmt and Exp Define the first son by doing Expand gt dit lexeme and enter a_Stmt the name of the son variable Define its type by doing Expand gt E dit lexeme at the placeholder after ref and enter Stmt m To insert another declaration of a son select the Stmt son and do Expand After Let the second son be called a_Exp and be of type Exp Specify it in the same man ner as the Stmt son If the OOSL window is a bit garbled by now do a Misc gt Reunparse to refresh it The comment placeholder should now be automatically selected Expand it to NO_comment m The next placeholder contains the body of the node class Choose the entry un der Expand A declaration body of the node class appears with a selected placehol der m Enter an equation by choosing the eq entry under Expand Define the left hand side of the equation to be the attribute undeclaredEnv Choose from the Expand menu then Expand gt dit lexeme and enter undeclaredEnv m Enter the right hand side of the equation by text editing Choose Edit as text A one line text editor now appears Enter the text a_Stmt undeclaredEnv un ion a_Exp undeclaredEnv and press Return You can enlarge the text window by pulling its corners with the left mouse button The text will now be processed and if you
65. r It can be expressed in an abstract grammar for the parse grammar 7 See A Grammar Interpreting Parser in a Language Design Laboratory by E Bjarnason and G Hedin To be presented at the poster session of CC 96 8 This is the grammar used by the structure oriented editor when editing parse grammars in the PARSE window APPLAB User s Guide version 1 2 31 of 56 The Grammar Formalisms 5 3 1 1 ParseGrammar priorities amp configuration 2 priorities priority_level 3 priority_level assoc_kind amp prod_list 4 assoc_kind left right nonassoc NO_assoc 5 left _ 6 right _ 7 nonassoc _ 8 NO_assoc _ 9 prod_list production 10 production LEXE 11 configuration C_config_option 12 C_config_option StringQuote Comment ExtendedFocus NOStri ngs NO_left_factor NO_priorities 13 StringQuote LEXEM 14 Comment Keyword amp EndComment 15 Keyword LEXEM 16 EndComment Keyword EOLToken 17 EOLToken _ 18 ExtendedFocus _ 19 NOStrings _ 20 NO_left_factor _ 21 NO_priorities _ 1 A parse grammar consists of two parts one for defining priorities and one for config uring the parser component 2 The priorities are defined as a list of priority_level s 3 Each priority_level has an assoc_kind and a prod_list 4 An assoc_kind is either left right nona
66. ract and concrete grammar aspects in the same grammar Text editing of the struc tures in the target window is defined by the abstract concrete and parse grammar as pects The abstract concrete parse and oosl aspects are edited according to a fixed metagrammar for each aspect respectively 5 1 The Structure of Abstract Grammars An abstract grammar or more accurately the abstract aspect of a grammar only defines the structure of a language It is similar to a conventional BNF grammar but since the concrete syntax is omitted it only contains the nonterminals of a conventional grammar A production can be of four different types construction alternation list and lexeme The different types cannot be nested in one production Some examples are given be low 1 StatementList Statement List 2 Statement If While Assign Alternation 3 If Expression amp Statement amp Statement Construction 4 Expression ID Add Sub Mult DivAlternation 5 Plus Expression amp Expression Construction 6 ID LEXEME Lexeme 1 A StatementList consists of a number of statements specified in a list production 8 2 A statement can either be an If a While or an Assign statement speci fied in an alternation production 3 An If statement is an aggregation of an Expression a Statement and a Statement specified in a construction production n
67. ry 26 evolution graph 39 Evolution graph window 42 evolution graph window 19 42 43 exiting 19 expand 5 20 expand after 5 21 expand before 21 expand list 21 expansion 20 explain error 34 explain next error 34 explicit rebinding 46 extended focus 33 F find 22 fixed relation 46 fork revision 43 frame 15 front 16 G generate from ABSTRACT 38 grammar aspects 19 grammar formalisms 28 grammar window 19 icon 15 Index icon menu 15 ID 32 35 identifiers 32 import text 22 25 import text as 26 insert revision window 49 INT 32 35 K keyboard short cuts 23 keywords 32 L LB 15 left factoring 33 lexeme 5 lexical syntax 32 list 5 list nodes 37 locked 14 M MB 15 metagrammars 37 misc 5 mouse 15 move 16 N Names 13 35 NUM 32 35 numerical constants 32 0 OOSL 11 OOSL generator 38 OOSL grammar 11 33 OOSL grammar window 10 open 16 ormmessage 52 P PARSE 10 parse grammar 9 31 parse grammar window 9 paste 21 paste before 21 PBO 39 PBO window 19 42 placeholders 20 popup menu 15 precedence 10 31 predefined lexemes 35 pretty print 26 pretty printer 38 print attribute 23 production types 5 program base object 39 Q quit 14 19 24 R RB 15 REAL 32 35 rebuild menus 23 recompile OOSL grammar 34 redisplay 23 refresh 17 relations 39 rename 47 resize 16 reunparse 23 revision 25 revision description 39 revision id 39 revision name
68. s Save amp Quit Saves the contents of the window on the text file and quits APPLAB Save Saves the contents of the window on the text file Quit Quits APPLAB without saving any changes on the text file 24 of 56 APPLAB User s Guide version 1 2 The Grammar Editor 4 6 4 6 1 4 6 2 Text link windows appear when APPLAB is used for socket communication and when the system is started with the text option The name of a text file and the base gram mar to be used is given The text is then imported and translated into its corresponding structure according to the given base grammar The user can then edit the contents of the text file in the structure oriented editor and save the result as text on the original text file This option is useful for integrating APPLAB in an environment with other text based tools See section 8 0 for further details on how to use APPLAB in this way Editing In the Grammar Window Inserting and Deleting Grammar Aspects and Targets New target and grammar aspect windows can be inserted by menu commands in the grammar window Add Abstract Inserts a new abstract grammar aspect Add Concrete Inserts a new concrete grammar aspect Add Parse Inserts a new parse grammar aspect Add OOSL Inserts a new OOSL grammar aspect Add Target Inserts a new target structure EDIT Insert an unnamed grammar aspect After having selected one of these entries the system prompts for the name and revision of t
69. s also displayed in the Evolution Graph window Since the system crashed the previous time the grammar was edited the key is prob ably crossed over indicating that the key has not been returned properly To remedy this do the menu command Evolution Graph Window gt Misc gt Restore all Keys A promptbox asks if you want to restore all keys Click on the Yes button The cross over the key now disappears 2 The rightmost small box in the Evolution Graph window represents the latest revi sion Click on it and it becomes marked Then delete it by Evolution Graph Win 26 of 56 APPLAB User s Guide version 1 2 The Grammar Editor dow gt Delete Een aea Shaw cevimion ranei Enter maletin Shaw selection ittachodlnte Misc A promptbox asks if you want to delete the revision Click on the Yes button 3 Check if the cure worked by opening the latest remaining revision of the grammar by double clicking on the rightmost small box of the Evolution Graph Window If the grammar opens normally you may remove the backup copy If not refer to the trou ble shooting section in the chapter on version handling or contact the implementors APPLAB User s Guide version 1 2 27 of 56 The Grammar Formalisms 5 0 The Grammar Formalisms The grammar aspects in the different windows are expressed in different formalisms The underlying language of the structure in the target window is typically defined by the abst
70. s displayed for the selected PBO TREH A REGN je heeft n a pre es hala grar There are two ways of selecting a revision in the revision selection prompt m Double click on the revision m Click on a revision and the use the pop up menu command gt Choose sel ected Evaluation of Relations at Binding time The evaluation of relations at binding time follow two main directions depending on the value of the PBOId m lt SELF gt bound relations A relation with PBOId lt SELF gt is bound to the virtual copy of the current revi sion This means that it is possible to refer to an opened revision despite it not being inserted in the evolution graph The binding type and binding rule is overruled for lt SELF gt relations m File name bound relations For relations where the PBOId equals a filename the binding type is interpreted in order to select a revision 1 Dynamic binding The full file name of the PBOId is looked up and the binding rule of the relations is used in order to select a revision If no revision could be bound an explicit binding is initiated 2 Explicit binding An explicit binding is initiated The binding rule is overruled 3 Fixed binding APPLAB User s Guide version 1 2 41 of 56 The Version Handling System The full file name of the PBOId is looked up and the revision description of the rela tion is used for selecting a revision If no revision could be bound an explicit binding is in
71. se Expand after A placeholder for a produc tion appears The left hand side is automatically selected m Choose Expand gt Edit lexeme and enter the name of the production e g Re peatStmt followed by Return The right hand side of the production is now auto matically selected m Choose the amp entry under Expand which states the production type is a con struction A placeholder appears Do Expand gt Edit lexeme and fill in Stmt m Do Expand after and Expand gt Edit lexeme and fill in Exp We are now ready with the abstract production for the repeat statement but we also have to state that the repeat statement is a statement m Scroll the ABSTRACT window upwards until the Stmt production is found It is a fairly long alternation production stating the names of all statements m Select one name and do Expand after Fill in RepeatStmt using Expand gt Edit lexeme Be careful to spell the name right You could also use the sub menu All names gt and select RepeatStmt from it The text RepeatStmt is then inserted into the current lexeme The abstract grammar is now complete and we have to specify the concrete syntax of the repeat statement We suggest the following concrete production RepeatStmt repeat Ql muntir s 2 _ Do the following in the CONCRETE window m Select a whole production and do Expand after A Template for a concrete produc tion appears m Fill
72. sic Interaction 15 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 Windows 15 The Mouse 15 Popup Menus 15 Basic Commands on Windows 16 Additional Menu Commands on Windows Text 17 3 6 1 Positioning and Selection 17 3 6 2 Cut Copy and Paste 17 3 6 3 Scrolling 17 Textprompts 17 The broom 17 8 17 Contents i of iv 4 0 The Grammar Editor 19 4 1 Window Structure 19 4 2 Entering Exiting and Saving a Grammar 19 4 3 Creating a New Grammar 19 4 4 Editing In the Target and Grammar Aspect Windows 20 4 4 1 Placeholders 20 44 2 Selection 20 4 4 3 Expansion 20 444 Cut Copy Paste 21 4 4 5 Some Hints 21 44 6 Text Editing 21 4 4 7 Semantic Editing 22 4 4 8 Other Editor Commands in Grammar Aspect Windows 22 44 9 Short cuts 23 4 4 10 Short cuts to the Expand Menu 24 4 5 Editing In the Text Link Window 24 4 6 Editing In the Grammar Window 25 4 6 1 Inserting and Deleting Grammar Aspects and Targets 25 4 6 2 Other Commands 25 4 7 Restoring a Crashed Grammar 26 5 0 The Grammar Formalisms 28 5 1 The Structure of Abstract Grammars 28 5 2 The Structure of Concrete Grammars 29 5 3 The Structure of Parse Grammars 31 5 3 1 The Lexical Syntax 32 5 3 2 Configure Text Editing 33 5 4 The Structure of OOSL Grammars 33 5 4 1 Compiling an OOSL Grammar 34 5 4 2 Demand Attribute Evaluation 35 5 4 3 Defining the Names Menu 35 5 4 4 Predefined Lexeme Classes 35 5 4 5 Predefined Abstract Data Types 36 5 4 6 The Implemented Subset of Door
73. spects Contains one part of a grammar e g abstract grammar concrete grammar etc Target window Contains a target structure which is edited according to the abstract concrete and parse grammar as pects Text Link window Similar to a target window but its contents is linked to a text file 4 2 Entering Exiting and Saving a Grammar Entering Enter a grammar document lang gram by typing applab lang gram in a shelltool in the OpenWindows system or in X windows The PBO window containing the Evolution Graph of the grammar document now appears Each box represents a revision of the grammar Double click ing on one of them opens a grammar window for that revision Exiting Exit a grammar revision by grammar window gt Quit If any chang es have been made since the grammar document was last changed a prompt box with the alternatives Save Quit and Cancel will ap pear asking if you wish to save the changes Choosing Save will save the changes and then quit the program while Quit will quit without saving The Cancel option will neither save nor quit the current gram mar document To finish an APPLAB session each opened grammar window has to be exited and then do PBO window gt Quit Saving Save the grammar by grammar window gt Save It is recommended to save the grammar rather often since the system crashes occasionally Each save creates a new revision of the program A revision cannot
74. ssoc or NO_assoc 5 6 7 8 the left right nonassoc and NO_assoc produc tions do not have any descendants 9 prod_list is a list of production s 10 production contains the name of a production 11 The configuration is a list of C_config_option s 12 C_config_option is either StringQuote Comment ExtendedFocus NOStrings NO_left_factor or NO_priorities 13 StringQuote contains a character used to encap sulate strings 14 Comment contains a Keyword and an EndComment 15 Keyword is the text of a keyword 17 18 19 20 21 the EOLToken ExtendedFocus NOStrings NO_left_factor and NO_priorities productions do not have any descendants The Lexical Syntax In the current version of APPLAB the definition of lexical items are hand coded includ ing identifiers keywords numerical constants strings and comments Start and end to kens of strings and comments can be specified in the configure part of the parse grammar When doing textual editing in APPLAB special note is taken of the lexeme pro ductions ID NUM INT REAL and ANYLEX of the abstract grammar The ID pro duction matches an identifier the NUM INT and REAL productions are expected to be used for numerical constants while ANYLEX represents any combination of characters and should be used for strings and comments Thus when defining a grammar for a lan guage which is to be editable as text the ID NUM INT REAL and ANYLEX produc tions should be defined as lexem
75. t is important that the basefile and the revision files are kept togeth er in the same directory and that they are consistently named Therefore you should not move copy or remove any of these files using normal UNIX commands Instead use the following scripts gt ormmv lang gram x gram_ to change the name of a grammar 2 of 56 APPLAB User s Guide version 1 2 Introduction 1 6 gt ormmv lang gram dir to move a grammar to another directory gt ormcp lang gram x gram to copy a grammar gt ormcp lang gram dir to copy a grammar to another directory gt ormrm lang gram to remove a grammar These scripts work similarly to the standard UNIX mv cp and rm but they do not take options or multiple arguments Acknowledgments I would like to thank G rel Hedin for introducing me to the concept of application lan guages and for guiding me through the implementation work with APPLAB I would also like to thank Klas Nilsson and Mats Nyberg for useful comments and questions on APPLAB The following people were involved in the implementation of the Mj lner Orm system from which APPLAB evolved Boris Magnusson G rel Hedin Sten Min r Mats Bengtsson Magnus Taube Lars Ove Dahlin Dan Oscarsson Goran Fries Anders Gustavsson Pa r Anders Aronsson Roger Henriksson and Torsten Olsson APPLAB User s Guide version 1 2 3 of 56 Grammar Editing A Guided Tour 2 0 Grammar Editing A Guided Tour
76. t the pro gram document you are trying to open in an inconsistent state Usually the following er ror message is given in the Unix shell window Warning Wrong version of bytestring In this case you must remove the last inconsistently saved revision of the docu ment as described in section 4 7 Problems With Saving a Revision If APPLAB crashes when you save a revision of a document the reason could be that you are out of disk quota In this case you may need to restore consistency in the docu ment files as described in section 4 7 If an empty revision name has previously been given then no further revisions can be saved in that alternative This is a bug that will be fixed in future releases Dead Windows Sometimes a window seems dead and does not respond to mouse clicks etc The rea son may be that there is an unanswered promptbox connected to the window If you can not see any promptbox try closing the outermost APPLAB window and other top level windows on your screen The promptbox may be behind one of these windows It is also possible that the Caps Lock or Num Lock button is activated This also causes the window to act dead Problems With Editing Confusing Behaviour at Expand See section 4 4 5 The System Hangs If the whole APPLAB system suddenly hangs when you are text editing the reason could be that the grammar interpreting parser has reached a loop in the grammar You will need to cras
77. ted crashed the key will be lost This command resets the key for every alternative Note Do not use this command when there are other simultaneous users of the same PBO gt Misc gt Purge Removes revisions in the evolution graph according to the Purge attribute Uses the Purge attribute See the definition of the Purge attribute in the Predefined Attributes section 7 9 for more information Undocumented Features gt Attached Info gt Object Relation Menu gt gt Misc gt Compact gt Misc gt Redisplay gt Misc gt Debug gt Revision window The revision window contains the functionality to save and quit a revision of the PBO Save The save command stores the revision in the alternative it was created from and auto matically gives the revision a default name After the save operation the key or the in serted revision is owned by the current revision gt Save Restriction m If the revision is not owner of a key it is not possible to save the revision in the alter native it was created from Could not save as revision Save in new Alternative CANCEL 48 of 56 APPLAB User s Guide version 1 2 The Version Handling System 7 7 2 7 8 7 8 1 7 8 2 Instead the revision may be save in a new alternative or the user may cancel the save op eration If the revision is saved in a new alternative the user is prompted for an alterna tive name
78. than one revision is selected the operation will be applied to each revision in turn Select a revision Click on the revision of your choice Any previous selections will be de selected Revision 3 O 11 O0 O o Alternative o Alternative2 Click on the revision Toggle revision Click on a revision while pressing the shift key on the keyboard The state of the revision toggles between selected and not selected The operation will not affect previous revision selections The tog gle operation can be used for selecting more than one revision Evolution Graph D O O amp iv n Alternative O O Oo Alternative2 Click Shift Select alternative Click on the alternative name It is only possible to select one alter native at a time 44 of 56 APPLAB User s Guide version 1 2 The Version Handling System Evolution Graph maT 1 Alternativel or Alternative2 Click on the alternative name Remove selections It is possible to remove all previous selections by clicking in the area of the evolution graph without selecting a revision Evolution Graph O 4 4 CO o Alternativet LHL Oo Alternative2 Click inside the marked area 7 6 2 Selection of Revisions by Rule An alternative way of selecting revisions Revisions are selected by specifying the bind ing rule which is applied to the evolution graph gt Enter Selec
79. tion Criteria Sets the binding rule Revision name SELECT Alternative name myAlt Revision number gt gt Show selection Evaluates the binding rule and shows the selected revisions in the evolution graph APPLAB User s Guide version 1 2 45 of 56 The Version Handling System 7 6 3 Open Creates and opens virtual copies of selected revisions The copies are not added to the PBO and are not shown in the graph until the user saves them It is possible for a user to have several revisions open at the same time gt Open gt Dynamic Rebinding Opens selected revisions and binds the relations according to their binding types gt Open gt Explicit Rebinding Opens selected revisions and prompts the user for interactive bind ings of relations The binding types of the relations are overruled This menu alternative is used for interactively rebinding all rela tions of the revision e g when the relations should be rebound to another PBO gt Open gt Fixed Relation Opens the revisions using the revision description of the relation No rebinding of the relations are done The binding types of the re lations are overruled This menu alternative is used when the existing binding of the rela tion should be used e g in the case of error corrections Short cut A double click on a revision is a short cut for choosing a revision and then performing the gt Open gt Dynamic Rebinding com mand
80. tion is specifying a number of alternatives Its structure is a list of Identifiers each containing the production name of an alternative 5 A construction consists of a number of descendants The structure of the construction definition is thus a list of identifiers each specifying the production name of a descendant 6 A list specifies that a construct can have an arbitrary number of descendants all of the same type The structure of the list definition is a lexeme con taining the production name of the construct to be repeated 7 An Id contains a produc tion name and is thus a lexeme 8 A lexeme definition is a terminal node in a grammar The Structure of Concrete Grammars A concrete grammar or the concrete aspect of a grammar adds syntactic sugar delim iters and formatting information to the abstract grammar This is used by the structure oriented editor for presentation of the edited program or grammar Each production in the abstract grammar except for alternation productions has a production in the con crete grammar The production name in the concrete grammar production has to be the same as in the abstract grammar An example of a concrete grammar is given below The grammar describes the concrete aspect of the same language as the example of the ab stract aspect in the previous section 1 StatementList List before begin gt gt gt lt nl gt ISVS T KLS after lt lt lt lt nl gt end 2 If
81. tion startProd Grammar Files Grammars in APPLAB are stored in a binary format as so called program base objects or PBO s For each PBO there is a basefile and a number of revisionfiles as in the following example aGrammar gram basefile aGrammar gram_1 revisionfile aGrammar gram_5 revisionfile The revisionfiles contain the contents information whereas the basefile only contains information about the revisionfiles Note that the revisionfiles have filenames starting with a dot They will therefore normally not be listed by the UNIX s command To list all the files including the revi sionfiles use e g the command gt ls lsa It is important that the basefile and the revisionfiles are kept together in the same direc tory and that they are consistently named Therefore you should not move copy or re move any of these files using normal UNIX commands Instead use the following scripts gt ormmv lang gram x gram_ to change the name of a grammar gt ormmv lang gram dir to move a grammar to another directory gt ormcp lang gram x gram to copy a grammar gt ormcp lang gram dir to copy a grammar to another directory gt ormrm lang gram to remove a grammar These scripts work similarly to the standard UNIX my cp and rm but they do not take options or multiple arguments Environment Variable APPLAB makes use of the following environment variable setenv MJOLNERHOME dir used for findin
82. tion the OOSL aspect is read checked for semantic errors and compiled to internal data structures used to perform demand at tribute evaluation A message is given upon completion of compilation to indicate the outcome of the compilation When compiling by issuing the menu alternative Compile oosl in the menu of the OOSL window an error marker is set at the corresponding language construct in the OOSL window whenever an error is detected Focusing on this marking and choosing the menu alternative Explain error gives a short explanation of the error It is also pos sible to scroll through the errors with the menu alternative Explain next error The system then focuses on the next error and presents the error message associated with it The error markers remain in the window until the next compilation I e even if the error is corrected the error marking will remain in the window unless the whole construct is deleted until the grammar construct is correctly compiled 34 of 56 APPLAB User s Guide version 1 2 The Grammar Formalisms 5 4 2 5 4 3 5 4 4 Demand Attribute Evaluation As the user edits a program in the TARGET window it is possible to evaluate the OOSL attributes defined for the current language construct A list of the accessible attributes is presented when the user chooses Show Attributes in the menu of the TARGET win dow By choosing one of the attributes of this menu it will be evaluated and the result pres
83. urge command is executed The Purge contents is defined as PurgeContents KEEP Integer ALL Restrictions The source revision and fork revisions will not be deleted This means that the number of remaining revisions is greater or equal to the specified number of revi sions to keep If no Purge attribute exists the Purge command will use the PurgeCon tents KEEP ALL Examples KEEP 4 Keep the 4 last revisions in every alternative KEEP ALL No revisions will be removed m TimeStamp Contains the creation date and creation time of the PBO This attribute is automati cally set and should never be modified manually Attribute TimeStamp 1991 03 11 17 28 27 7 9 2 Revision Attributes There are currently no predefined revision attributes APPLAB User s Guide version 1 2 51 of 56 Unix Level 8 0 Unix Level This chapter explains how APPLAB works at the Unix level This information can be useful if you want to change the system configuration or if you get into some trouble For normal usage you do not need to know this 8 1 The applab Script The applab script starts an APPLAB session for a grammar file The synopsis for applab is gt applab m g p text importFile grammar startProd socket msgport filename m start APPLAB with a heap of Mbyte Default is 1 Mbyte g print a message for each garbage collection p prints a messa
84. without GC 7 6 Evolution Graph Window The evolution graph window displays all revisions of the PBO Fork revision Key Revision name s Alternative name Source revision Key removed A revision The first revision is called the source revision and is the original empty revision A number of consecutive revisions are called an alternative A revision may belong to sev eral alternatives A branch starts in a fork revision For every alternative there is a key to enable synchronization between users The user first opening the latest revision in an al ternative removes the key Only the user holding the key may add new revisions at the end of the alternative All other users have to branch and thus create new alternatives The names of the alternatives are always visible in the evolution graph window In order to see the name of a revision move the mouse to the symbol of the revision and the APPLAB User s Guide version 1 2 43 of 56 The Version Handling System name will be displayed in the upper left hand corner of the window This operation will only be in effect until the evolution graph is changed 7 6 1 Interactive Selection of Alternatives and Revisions The selection of alternatives and revisions is by direct manipulation with the mouse in the evolution graph The left mouse button is the selection button Commands in the re vision graph window s popup menu affect the selected objects in the graph If more
Download Pdf Manuals
Related Search
Related Contents
Samsung GT-I8580 User Manual Kenmore 587.1523 Dishwasher User Manual Copyright © All rights reserved.
Failed to retrieve file