So... here's a first, crude draft of ddrep. It's also obsolete though,
since it includes redundant shape information in certain cases.

ar     =: 5!:1
boxed  =: 32&= @ (3!:0)
oarg   =: >@(1&{)
mtv    =: i.@0:
paren  =: ('('&,)@(,&')')
symb   =: $&' '@(e.&'.:')@{. , ]
quote  =: ''''
alp    =: (,65 97+/i.26){a.
dig    =: '0123456789'

slist  =: $&','@(1&=)
shape  =: mtv`slist`(,&'$'@":)@.(2&<.@#)`('i.'&,@":) @. (0&e.) @ $
vchar  =: >:@(quote&=)@, quote&,@(,&quote)@# ,
vbox   =: }. @ ; @: (','&,@paren@('<'&,)@lnoun&.>)
value  =: vchar`vbox`(":!.18@,) @. (2 32&i.@(3!:0 * *@(*/)@$))
lnoun  =: shape , value

dotco  =: 2&=@# *. e.&'.:'@{:
name   =: e.&alp@{. *. *./@(e.&(alp,dig,'_'))@}: *. e.&(alp,dig,'_.:')@{:
num    =: e.&(dig,'_')@{. *. *./@(e.&(dig,'_ .ejdr'))
qstr   =: mtv -: -.@(~:/\)@e.&quote -.&quote@# ]
pstr   =: -.@(0&e.)@}:@(+/\)@({&1 _1 0)@('()'&i.)
nopar  =: 1&=@# +. dotco +. name +. num +. qstr +. pstr
cp     =: paren`] @. nopar

bp     =: ]`cp@.(' '&e.)
hfork  =: }.@;@:(' '&,@bp&.>)@]
left   =: bp@>@{.
right  =: mtv`(cp@>@{:)@.(1&<@#)
ins    =: left@] , symb@>@[ , right@]
act    =: ;@:(cp&.>)@]
insert =: hfork`hfork`act`act`act`maybedd`ins @. ('23456:'&i.@{.@>@[)
maybedd=:{{
  if. x-:<,':' do.
    typ=. '01234' i.left y
    if. 5>typ do.
      bod=. ".right y
      if. 1=#bod do.
        '{{',(symb,bod),'}}' return.
      else.
        ('{{)',typ{'nacvd'),}:;<@,&LF@dtb"1 bod,'}}' return.
      end.
    end.
  end.
  x ins y
}}

ddx     =: {. insert ddr&.>@oarg
ddtie   =: lr`(}.@;@:('`'&,@cp@ddr&.>)@oarg) @. ((<,'0')&=@{.)
ddgl    =: {. insert (ddtie&.>@{. , ddr  &.>@}.)@oarg
ddgr    =: {. insert (ddr  &.>@{. , ddtie&.>@}.)@oarg
ddg     =: ddgr`ddgl`ddx @. (i.&(<,'`')@oarg)
ddtil   =: ddx`(oarg@>@{.@oarg) @. ((<,'0')&=@{.@>@{.@oarg)
ddcase  =: (cp@lnoun@oarg)`ddgl`ddgl`ddg`ddtil`ddx @. ((;:'0@.`:4~')&i.@{.)
ddr     =: symb`[email protected]

ddrep   =: ddr @ > @ ar

Still, ... it's a start...

Next, I should look at the test cases for lrep in jsource.

-- 
Raul

On Fri, Oct 30, 2020 at 12:24 PM Raul Miller <[email protected]> wrote:
>
> Actually... where I used '''' I should have used the name 'quote', to
> be consistent with the rest of the code.
>
> I should have noticed that quicker.
>
> Thanks,
>
> --
> Raul
>
> On Fri, Oct 30, 2020 at 12:22 PM Raul Miller <[email protected]> wrote:
> >
> > Ok... it looks like https://www.jsoftware.com/ioj/iojRep.htm has been 
> > damaged.
> >
> > I am also not certain about the tree rep code -- it includes no
> > example uses, and it uses adverb and conjunction trains so that it
> > looks like 'tree' was intended to be an adverb. So maybe there's a
> > line missing somewhere, or something...
> >
> > Anyways, for the lrep definition, qstr should be:
> >
> > qstr   =: mtv -: -.@(~:/\)@e.&'''' -.&''''@# ]
> >
> > In other words, remove the first, third, fifth, etc. quote character
> > and all following non-quote characters (up to the second, fourth,
> > sixth, etc. quote characters). Then remove all remaining quote
> > characters. If the result is an empty string, treat this as a quoted
> > string. This is used to determine whether or not parenthesis are
> > needed.
> >
> > For example, '1' doesn't need parenthesis but '1'&= does.
> >
> > Similarly, vchar needs to be defined as
> >
> > vchar  =: >:@(quote&=)@, quote&,@(,&'''')@# ,
> >
> > (And remember that 'type' needs to be replaced with 3!:0 to make the
> > lrep code on that page work.)
> >
> > But, also, this is an old version of lrep and explicit definitions
> > nowadays get handled differently. But that's actually perfect, since
> > that's what I also want to deal with differently, for direct
> > definitions. I just need to figure out where the logical place would
> > be, to make this change.
> >
> > Thanks,
> >
> > --
> > Raul
> >
> > On Thu, Oct 29, 2020 at 9:40 PM Henry Rich <[email protected]> wrote:
> > >
> > > No kidding.  You can do what I do - add comments.  After a while whole
> > > sections become comprehensible.
> > >
> > > Henry Rich
> > >
> > > On 10/29/2020 9:38 PM, Raul Miller wrote:
> > > > I wish there were more text describing its principles.
> > >
> > >
> > > --
> > > This email has been checked for viruses by AVG.
> > > https://www.avg.com
> > >
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to