<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;"><div><br></div><div>I have created a stub PragmasHelp up at '<a target="_blank" href="https://www.squeaksource.com/Doc">https://www.squeaksource.com/Doc</a>'<br></div><div><br></div><div>I created it using Emacs Org mode and the super-beta DocOrgToCustomHelp  tool  which I will be figuring out how to include the dependencies for it later today.<br></div><div><br></div><div><br></div><div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>DocOrgToCustomHelp viewFromFileChooser.<br></div><div>DocOrgToCustomHelp createFromFileChooser.<br></div></blockquote><div><br></div></div><div><br></div><div><br></div><div>Creating content is a breeze..no need to program.<br></div><div><br></div><div><br></div><div>Below is the Markup for the PragmasHelp copied-n-pasted from Emacs. (Pillar style Markdown etc, will be in the pipeline...I gotta learn  (and Docuument with this handy-dandy tool !) the big XML package first.<br></div><div><br></div><div><br></div><div>If you want to edit in-line via email, I will be happy to update the PragmasHelp and upload it to Doc.<br></div><div><br></div><div><br></div><div><br></div><div>cheers,<br></div><div><br></div><div>t<br></div><div><br></div><div><br></div><div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>*  Pragmas [PragmasHelp]<br></div><div>** Overview<br></div><div><br></div><div>Many see pragmas as labels.  But they are executable.  With pragmas, to label is human, to execute is divine.<br></div><div><br></div><div>This is Eliot Miranda's comments on Pragmas from an email exchange on Squeak-Dev <br></div><div><br></div><div><br></div><div>#+BEGIN_EXAMPLE<br></div><div>  put code  or text that might be missed by the parser in between these example blocks.<br></div><div><br></div><div>  It is perfectly fine to put an entire page between them if you want<br></div><div><br></div><div><br></div><div><br></div><div>#+END_EXAMPLE<br></div><div><br></div><div><br></div><div>** Pragma Basics<br></div><div><br></div><div>  <br></div><div><br></div><div>** Pragma Uses<br></div><div>  <br></div><div><br></div><div>** A Pattern that Works [patternthatworks]<br></div><div><br></div><div>1. Create a builder object that understnds the pragma(s) in question<br></div><div>2. Visit the method(s) implementing the pragma<br></div><div>3. Send the pragma to the builder<br></div><div><br></div><div>** How Pragmas for Menus Should Be Done [pragmaformenus]<br></div><div><br></div><div><br></div><div>1. Give the base menu to a menudecorator builder which is parameterized with the name of the menu and class(es) involved in the menu.<br></div><div>2. Have the menu decorator builder visit the relevant pragma methods in the class(es)<br></div><div>3. Use the resulting decorated menu.<br></div><div><br></div><div>** Pragmas in Senders Of  [senders]<br></div><div><br></div><div>discusson of the code behind the 'Senders' button on the Browser<br></div><div><br></div><div><br></div><div>** Pragmas in Xtreams-Parsing  [PragmasXtreamsParsingHelp]<br></div><div>*** Associate a PEG Grammar Rule with a callback [xtreamscallbacks]<br></div><div><br></div><div>In the XTreams-parsing application that processes this document, we use a Pragma to associate a callback with one or more grammar rules.<br></div><div><br></div><div><br></div><div>#+BEGIN_EXAMPLE<br></div><div>The rules that handle '** Stuff Like This [optionalselector]...' handle 1 to eight '*' and are defined below.<br></div><div><br></div><div><br></div><div>HeadlineItem1   <- ^STAR{1} s HeadLineText  Paragraph*<br></div><div>HeadlineItem2    <- ^STAR{2} s HeadLineText  Paragraph*<br></div><div>HeadlineItem3    <- ^STAR{3} s HeadLineText  Paragraph*<br></div><div>HeadlineItem4    <- ^STAR{4} s HeadLineText  Paragraph*<br></div><div>HeadlineItem5    <- ^STAR{5} s HeadLineText  Paragraph*<br></div><div>HeadlineItem6    <- ^STAR{6} s HeadLineText  Paragraph*<br></div><div>HeadlineItem7    <- ^STAR{7} s HeadLineText  Paragraph*<br></div><div>HeadlineItem8    <- ^STAR{8} s HeadLineText  Paragraph*<br></div><div><br></div><div>#+END_EXAMPLE<br></div><div><br></div><div>When the parser matches a pattern, we can associate a callback that will be executed when the match occurs.<br></div><div>Below is the callback for the HeadlineItem rules above.<br></div><div><br></div><div>#+BEGIN_EXAMPLE<br></div><div><br></div><div>HeadlineItem:  starOrderedCollection topic: aHelpTopic content: anOrderedCollection<br></div><div><br></div><div><br></div><div><br></div><div><action: 'HeadlineItem1' arguments: #(2 4 5)><br></div><div><action: 'HeadlineItem2' arguments: #(2 4 5)><br></div><div><action: 'HeadlineItem3' arguments: #(2 4 5)><br></div><div><action: 'HeadlineItem4' arguments: #(2 4 5)><br></div><div><action: 'HeadlineItem5' arguments: #(2 4 5)><br></div><div><action: 'HeadlineItem6' arguments: #(2 4 5)><br></div><div><action: 'HeadlineItem7' arguments: #(2 4 5)><br></div><div><action: 'HeadlineItem8' arguments: #(2 4 5)><br></div><div><br></div><div><br></div><div>|ht  index ios |<br></div><div>index := starOrderedCollection size.<br></div><div>ht := aHelpTopic.<br></div><div>ios := (String streamContents:<br></div><div>[ : stream |<br></div><div>paragraphcache do:[:each |<br></div><div>stream nextPutAll: each.<br></div><div>]]).<br></div><div>ht contents: (ios contents).<br></div><div>ht priority: index.<br></div><div>(helptopiccache at: index) addLast: ht.<br></div><div>paragraphcache := OrderedCollection new.<br></div><div>transcripton ifTrue:[Transcript show:'HeadlineItem', (index asString) , '->' , (ht key);cr.   ].<br></div><div>^ht<br></div><div><br></div><div>#+END_EXAMPLE<br></div><div><br></div><div>Note that more than one Pragma can be placed in a callback. And that this one method handles all the rules.<br></div><div><br></div><div>In Xtreams-Parsing, look at any of the subclasses of PEGActor for the callbacks.<br></div><div>To see the Grammars for those callbacks, look at the class side of PEGParser.<br></div><div><br></div><div><br></div><div><br></div><div>** Common Methods  [commonmethods]<br></div><div><br></div><div>#+BEGIN_EXAMPLE<br></div><div>perform: withArguments:<br></div><div>#+END_EXAMPLE<br></div><div><br></div><div><br></div><div><br></div><div>#+BEGIN_EXAMPLE<br></div><div>sendTo:<br></div><div>#+END_EXAMPLE<br></div><div><br></div><div><br></div><div>#+BEGIN_EXAMPLE<br></div><div>sendMessage:<br></div><div>#+END_EXAMPLE<br></div><div><br></div><div><br></div></blockquote><div><br></div></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><br></body></html>