I'll work on documentation. The big advantage of the jpp approach over gema is that it works on unmodified ijs files (with the caveat that certain complex multiline expressions need to be hinted with the magic ML constant (0), or that your multiline generator needs to be included in the nummultilines function for detection).
but the external approach could be used with the findlines (single line/selection) and findlines2 (enclosed multiline selection), and your examples show more customization options than what jpp "looks for". what jpp does is take any function that accepts quoted input, and processes the line to automatically insert the quoting, based on "." and/or ":" suffixes to the function. jd, wd, jhs, timex use a lot of quoted command functions, and I think its fairly easy to make parsers that help those, and in some case, none are necessary. jpp replaces the load command. It only processes top level statements, because 0 : 0 can contain arbitrary binary data, and if you want to process the lines of a multiline definition, its relatively straightforward to use jpp each cutLF 0 : 0 and then assign that to a function with 4 : (jpp each cutLF 0 : 0) ... ) or code =: (jpp each cutLF 0 : 0 A 4.. x+y ) The biggest missing explanation is the table BRAILLECODES NB. enter in console. Its is a table of 4 fields. 1st is the new primitive 4th is a function to execute. Currently "quote" or blank. I do not know of any viably useful alternatives to quote, and so currently this field is equivalent to a boolean of 1 (if quote) or 0 (if blank) 2nd field is "polymorphic" based on whether field 4 is blank. If 4th is blank, then this is the simple substitution of the primitive. it can include "braille-modified" expressions. If 4th field is not blank, (is quote) then 2nd field is what to substitute prior to putting a ( to the right of the expression. If 4th field is not blank, then 3rd field is what to substitute prior to putting a ) to the left of expression. There's probably no need for anything other than quote function because once you have quoted something, an adverb can create any form of speech from that. The big thing I need to document is the library of parsers and other functions that process quoted expressions. ________________________________ From: roger stokes <[email protected]> To: [email protected] Sent: Monday, March 27, 2017 11:34 AM Subject: Re: [Jprogramming] introducing j plus plus All the work that Pascal has done for jpp is appreciated. What would be nice now would be some user documentation with examples. I did look at the readme file, but could not understand it well enough to get any further. There is another approach possible to the project of a j preprocessor. There is an excellent macro processor, gema ( http://gema.sourceforge.net/new/index.shtml ) Here is a session transcript demonstrating how it could be used with J. (1!: 44) jpath '~temp' NB. all the files are set up in temp NB. suppose we aim to write monadic oneliner verbs in the form NB. NB. foo z =: expr NB. NB. allowing free choice of argument name without the need for quotes. NB. NB. the macro-expansion is to be: NB. NB. foo =: 3 : ('z=.y'; 'expr') NB. NB. step 1 is to create a file with the necessary macro defn. (0 : 0)(1!:2) < 'macrodefs.txt' <A> <A> \=\:\ <P> = $1 \=\: 3 \: (\'$2\=\.y\'\; \'$3 \') \N ) NB. step 2 is to define a load verb which calls the macro-processor mload =: 3 : 0 require 'task' assert. fexist y assert. fexist 'gema.exe' assert. fexist 'macrodefs.txt' _1 fork_jtask_ 'gema -f macrodefs.txt ',y , ' temp.ijs' load 'temp.ijs' ) NB. step 3 is to create a demo script with new-syntax verbs (0 : 0)(1!:2) < 'script.ijs' foo z =: z + 1 bar w =: (+/ % #) w ) NB. step 4 is to load the script, expanding the macros mload 'script.ijs' NB. step 5 is to show the results foo 3 : 0 z=.y z + 1 ) foo 3 4 bar 3 : 0 w=.y (+/ % #) w ) bar 2 3 4 3 Regards, Roger On Sun, Mar 26, 2017 at 6:28 PM, Jose Mario Quintana < [email protected]> wrote: > Before I show how the verb WhoAmI can be produced it might helpful to > explain how it works. The verb echoes its right argument (''), discards it > and anonymously reproduces, an exact copy of, itself; then, the reproduced > verb echoes its right argument ('I am presenting myself by executing this > sentence :)') discards it and anonymously reproduces an exact copy of > itself, and so on until there are no more arguments and the reproduced verb > shows up. > > The verb, with the aid of the Tacit Toolkit mentioned often in the > Adverbial Tacit Jym thread, can be written easily as a one-liner, > > WhoAmI=. (body f.<adv)&(body=. ([ amper >)x [ echo y)f. > > It uses the typical ancient trick that self-reproducing beings employ > (e.g., living beings): The whole being (WhoAmI) consists of a description > of the body (body f.<adv) bonded (&) to the body f. A variation of this > verb provides the means for producing general verbs that seemingly take > directly arguments as a strand (more on that later in a new thread). > > A self-contained version of WhoAmI can also be written as a > slightly longer one-liner (beware of line wrapping), > > WhoAmI=. (<@:(,^:(0:`(<'f.')))'body')&(body=. ([ (,^:(0:`(<'&'))) >)@:[ > [ echo @:])f. > > Incidentally, the display of the following sentence is slightly different > from the output in my original post (it includes extra blank lines > corresponding to the empty literals (''). It seems that JQT and JHS are > NOT behaving exactly in the same way. I am running here Win JQt05 whereas > I produced the original output with Safari on an iPad as a client of a > custom JHS on a Kindle Paperwhite server but I just confirmed that Win > JHS05 with MS Edge produces the same output (without extra blank lines). > > WhoAmI '' 'I am presenting myself by executing this sentence :)' '' > 'Spoiler coming in,' '' (,.|.i.33) '' (|.'...brev gnicudorper-fles eht ma > I') '' > > I am presenting myself by executing this sentence :) > > Spoiler coming in, > > 32 > 31 > 30 > 29 > 28 > 27 > 26 > 25 > 24 > 23 > 22 > 21 > 20 > 19 > 18 > 17 > 16 > 15 > 14 > 13 > 12 > 11 > 10 > 9 > 8 > 7 > 6 > 5 > 4 > 3 > 2 > 1 > 0 > > I am the self-reproducing verb... > > (<([ ,^:(0:`&) >)@:[ [ 0 0&$@(1!:2&2)@:])&(([ ,^:(0:`&) >)@:[ [ 0 > 0&$@(1!:2&2)@:]) > > > On Thu, Mar 23, 2017 at 11:26 AM, Jose Mario Quintana < > [email protected]> wrote: > > > Sure, the little puzzle, even after the spoiler, is not that easy :) ... > > Notice the smiley at the end of > > 'I am presenting myself by executing this sentence :)' > > > > There is no way the poor old untrusty linear representation (LR) ;) can > > faithfully represent WhoAmI for two reasons (another spoiler follows > > after a few blank lines): > > > > > > > > > > > > > > > > > > > > > > > > > > First, the Superbug is pestering the LR of certain embedded gerunds, for > > example, > > > > ^:(0:`(<'&')) > > ^:(0:`&) > > > > Last, but certainly not least, the LR is trying its best to deal with a > > noun that, arguably, should not be part of J's reality but fortunately it > > is. That is, a box containing a verb (in my mind this is the simplest > way > > for a noun to represent a verb , adverb or conjunction; to recover the > word > > just open the box); for example, if V is a box containing the verb * > > then, > > > > V > > ┌─┐ > > │*│ > > └─┘ > > (5!:5)<'V' > > <* > > > > Later I will show how I produced the recurrent verb WhoAmI which is, > > giving the illusion of, taking arguments as a strand. > > > > > > > > > > > > On Thu, Mar 23, 2017 at 12:15 AM, 'Pascal Jasmin' via Programming < > > [email protected]> wrote: > > > >> get syntax error > >> > >> > >> > >> > >> ________________________________ > >> From: Jose Mario Quintana <[email protected]> > >> To: "[email protected]" <[email protected]> > >> Sent: Wednesday, March 22, 2017 11:44 PM > >> Subject: Re: [Jprogramming] introducing j plus plus > >> > >> > >> > >> Thanks for the feedback Pascal. I just realized that I might have used > >> tacit anonymous continuations inadverterdly when I wrote, in Jx, the > tacit > >> recurrent (aka multiple) adverbs sa and sna which can convert > >> adverbs taking arguments as a gerund into adverbs taking arguments as a > >> strand [0]. Incidentally, I have rewriten similar versions of > >> adverbs which run in official J interpreters but that should be a > subject > >> for another thread in another time. > >> > >> In the meantime the following is a little puzzle in the same vain: > >> > >> > >> WhoAmI '' 'I am presenting myself by executing this sentence :)' '' > >> 'Spoiler coming in,' '' (,.|.i.33) '' (|.'...brev gnicudorper-fles eht > >> ma I') '' > >> I am presenting myself by executing this sentence :) > >> Spoiler coming in, > >> 32 > >> 31 > >> 30 > >> 29 > >> 28 > >> 27 > >> 26 > >> 25 > >> 24 > >> 23 > >> 22 > >> 21 > >> 20 > >> 19 > >> 18 > >> 17 > >> 16 > >> 15 > >> 14 > >> 13 > >> 12 > >> 11 > >> 10 > >> 9 > >> 8 > >> 7 > >> 6 > >> 5 > >> 4 > >> 3 > >> 2 > >> 1 > >> 0 > >> I am the self-reproducing verb... > >> (<([ ,^:(0:`&) >)@:[ [ 0 0&$@(1!:2&2)@:])&(([ ,^:(0:`&) >)@:[ [ 0 > >> 0&$@(1!:2&2)@:]) > >> > >> > >> [0] [Jprogramming] Tacit recursion without $: > >> > >> * > >> http://www.jsoftware.com/pipermail/programming/2014- > February/035416.html > >> <http://www.jsoftware.com/pipermail/programming/2014- > February/035416.html > >> >* > >> > >> > >> > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
