That's not where we want to be.

   #;:'NB.',LF
2
   #;:'NB.',CR
1

Also:
   (;:32{.a.)-:(0;sj;mj) sq 32{.a.
1

Thanks,

-- 
Raul

On Sun, Nov 8, 2020 at 10:03 AM Don Guinn <[email protected]> wrote:
>
> Would suggest that you add CR to the line 10 of sj as J treats CR like LF
> in a J script:
>
> mj=:10 (10 13)}mj  NB. LF and CR
>
> On Sun, Nov 8, 2020 at 6:38 AM Raul Miller <[email protected]> wrote:
>
> > I tested for that case:
> >
> >    #;:'NB.',LF,LF
> > 3
> >   #(0;sj;mj) sq 'NB.',LF,LF
> > 3
> >    #(0;sj;mj) sq 'NB.',LF,LF,LF
> > 4
> >
> > Thanks,
> >
> > --
> > Raul
> >
> > On Sat, Nov 7, 2020 at 7:00 PM Henry Rich <[email protected]> wrote:
> > >
> > > I have only desk-checked this.  { } look OK; but it looks like LF. will
> > > inflect the LF.  I could be way off in my analysis.
> > >
> > > LF outside of quotes is always a word of its own, admitting no
> > inflections.
> > >
> > > Henry Rich
> > >
> > > On 11/7/2020 5:04 PM, Raul Miller wrote:
> > > > Oops, typo in the documentation string that I didn't catch in the copy
> > > > and paste.
> > > >
> > > > Fixed here:
> > > >
> > > > mj=: 256$0                     NB. X other
> > > > mj=: 1 (9,a.i.' ')}mj          NB. S space and tab
> > > > mj=: 2 (,(a.i.'Aa')+/i.26)}mj  NB. A A-Z a-z excluding N B
> > > > mj=: 3 (a.i.'N')}mj            NB. N the letter N
> > > > mj=: 4 (a.i.'B')}mj            NB. B the letter B
> > > > mj=: 5 (a.i.'0123456789_')}mj  NB. 9 digits and _
> > > > mj=: 6 (a.i.'.')}mj            NB. . the decimal point
> > > > mj=: 7 (a.i.':')}mj            NB. : the colon
> > > > mj=: 8 (a.i.'''')}mj           NB. Q quote
> > > > mj=: 9 (a.i.'{')}mj            NB. { the left curly brace
> > > > mj=:10 (10)} mj                NB. LF
> > > > mj=:11 (a.i.'}')}mj            NB. } the right curly brace
> > > >
> > > > sj=: 0 10#:10*}.".;._2(0 :0)
> > > > ' X   S   A   N   B   9   .   :   Q    {    LF   }']0
> > > >   1.1 0.0 2.1 3.1 2.1 6.1 1.1 1.1 7.1 11.1 10.1 12.1 NB. 0 space
> > > >   1.2 0.3 2.2 3.2 2.2 6.2 1.0 1.0 7.2 11.2 10.2 12.2 NB. 1 other
> > > >   1.2 0.3 2.0 2.0 2.0 2.0 1.0 1.0 7.2 11.2 10.2 12.2 NB. 2 alp/num
> > > >   1.2 0.3 2.0 2.0 4.0 2.0 1.0 1.0 7.2 11.2 10.2 12.2 NB. 3 N
> > > >   1.2 0.3 2.0 2.0 2.0 2.0 5.0 1.0 7.2 11.2 10.2 12.2 NB. 4 NB
> > > >   9.0 9.0 9.0 9.0 9.0 9.0 1.0 1.0 9.0  9.0 10.2  9.0 NB. 5 NB.
> > > >   1.4 0.5 6.0 6.0 6.0 6.0 6.0 1.0 7.4 11.4 10.2 12.4 NB. 6 num
> > > >   7.0 7.0 7.0 7.0 7.0 7.0 7.0 7.0 8.0  7.0  7.0  7.0 NB. 7 '
> > > >   1.2 0.3 2.2 3.2 2.2 6.2 1.2 1.2 7.0 11.2 10.2 12.2 NB. 8 ''
> > > >   9.0 9.0 9.0 9.0 9.0 9.0 9.0 9.0 9.0  9.0 10.2  9.0 NB. 9 comment
> > > >   1.2 0.2 2.2 3.2 2.2 6.2 1.0 1.0 7.2 11.2 10.2 12.2 NB. 10 LF
> > > >   1.2 0.3 2.2 3.2 2.2 6.2 1.0 1.0 7.2 13.0 10.2  1.2 NB. 11 {
> > > >   1.2 0.3 2.2 3.2 2.2 6.2 1.0 1.0 7.2  1.2 10.2 14.0 NB. 12 }
> > > >   1.2 0.3 2.2 3.2 2.2 6.2 1.7 1.7 7.2  1.2 10.2  1.2 NB. 13 {{
> > > >   1.2 0.3 2.2 3.2 2.2 6.2 1.7 1.7 7.2  1.2 10.2  1.2 NB. 14 }}
> > > > )
> > > >
> > > > On Sat, Nov 7, 2020 at 5:02 PM Raul Miller <[email protected]>
> > wrote:
> > > >> I think this will do that:
> > > >>
> > > >> mj=: 256$0                     NB. X other
> > > >> mj=: 1 (9,a.i.' ')}mj          NB. S space and tab
> > > >> mj=: 2 (,(a.i.'Aa')+/i.26)}mj  NB. A A-Z a-z excluding N B
> > > >> mj=: 3 (a.i.'N')}mj            NB. N the letter N
> > > >> mj=: 4 (a.i.'B')}mj            NB. B the letter B
> > > >> mj=: 5 (a.i.'0123456789_')}mj  NB. 9 digits and _
> > > >> mj=: 6 (a.i.'.')}mj            NB. . the decimal point
> > > >> mj=: 7 (a.i.':')}mj            NB. : the colon
> > > >> mj=: 8 (a.i.'''')}mj           NB. Q quote
> > > >> mj=: 9 (a.i.'{')}mj            NB. { the left curly brace
> > > >> mj=:10 (10)} mj                NB. LF
> > > >> mj=:11 (a.i.'}')}mj            NB. } the right curly brace
> > > >>
> > > >> sj=: 0 10#:10*}.".;._2(0 :0)
> > > >> ' X   S   A   N   B   9   .   :   Q    {    }   LF ']0
> > > >>   1.1 0.0 2.1 3.1 2.1 6.1 1.1 1.1 7.1 11.1 10.1 12.1 NB. 0 space
> > > >>   1.2 0.3 2.2 3.2 2.2 6.2 1.0 1.0 7.2 11.2 10.2 12.2 NB. 1 other
> > > >>   1.2 0.3 2.0 2.0 2.0 2.0 1.0 1.0 7.2 11.2 10.2 12.2 NB. 2 alp/num
> > > >>   1.2 0.3 2.0 2.0 4.0 2.0 1.0 1.0 7.2 11.2 10.2 12.2 NB. 3 N
> > > >>   1.2 0.3 2.0 2.0 2.0 2.0 5.0 1.0 7.2 11.2 10.2 12.2 NB. 4 NB
> > > >>   9.0 9.0 9.0 9.0 9.0 9.0 1.0 1.0 9.0  9.0 10.2  9.0 NB. 5 NB.
> > > >>   1.4 0.5 6.0 6.0 6.0 6.0 6.0 1.0 7.4 11.4 10.2 12.4 NB. 6 num
> > > >>   7.0 7.0 7.0 7.0 7.0 7.0 7.0 7.0 8.0  7.0  7.0  7.0 NB. 7 '
> > > >>   1.2 0.3 2.2 3.2 2.2 6.2 1.2 1.2 7.0 11.2 10.2 12.2 NB. 8 ''
> > > >>   9.0 9.0 9.0 9.0 9.0 9.0 9.0 9.0 9.0  9.0 10.2  9.0 NB. 9 comment
> > > >>   1.2 0.2 2.2 3.2 2.2 6.2 1.0 1.0 7.2 11.2 10.2 12.2 NB. 10 LF
> > > >>   1.2 0.3 2.2 3.2 2.2 6.2 1.0 1.0 7.2 13.0 10.2  1.2 NB. 11 {
> > > >>   1.2 0.3 2.2 3.2 2.2 6.2 1.0 1.0 7.2  1.2 10.2 14.0 NB. 12 }
> > > >>   1.2 0.3 2.2 3.2 2.2 6.2 1.7 1.7 7.2  1.2 10.2  1.2 NB. 13 {{
> > > >>   1.2 0.3 2.2 3.2 2.2 6.2 1.7 1.7 7.2  1.2 10.2  1.2 NB. 14 }}
> > > >> )
> > > >>
> > > >>
> > > >> Thanks,
> > > >>
> > > >> --
> > > >> Raul
> > > >>
> > > >> On Sat, Nov 7, 2020 at 2:19 PM Henry Rich <[email protected]>
> > wrote:
> > > >>> That's good.  If anybody can see a problem with adding an opcode 7,
> > > >>> titled 'backtrack', which goes back to the previous character without
> > > >>> outputting anything, please speak up.
> > > >>>
> > > >>> To match (;: y), your state machine needs to treat LF as a special
> > > >>> character that ends a comment, does not end a quoted string, and
> > cannot
> > > >>> be inflected.  When not in a quoted string it becomes a word by
> > itself.
> > > >>>
> > > >>> Henry Rich
> > > >>>
> > > >>> On 11/7/2020 1:53 PM, Raul Miller wrote:
> > > >>>> I took the model proposed at
> > > >>>>
> > https://code.jsoftware.com/wiki/Vocabulary/semico#Running_the_Machine
> > > >>>> and fixed a few problems and added an opcode 7, and built a state
> > > >>>> table that satisfies the tests I put it through.
> > > >>>>
> > > >>>> It seems to work:
> > > >>>>
> > > >>>> sq=:4 :0
> > > >>>>     'f s m ijrd'=. x,(#x)}.0;0;'';0 _1 0 _1 assert. 2 <: #x
> > > >>>>     'i j r d'=. ijrd
> > > >>>>     'p pj'=. _1,j
> > > >>>>     if. 0 < L. m do.
> > > >>>>       n=. (y i.~;m) { (#m),~(#&>m)#i.#m
> > > >>>>     elseif. ''-:m do.
> > > >>>>       n=. y
> > > >>>>     elseif. do.
> > > >>>>       n=. (a.i.y){m
> > > >>>>     end.
> > > >>>>     result=. f {:: (0#a:);'';i.&.>0 2;0;0 3;0 6
> > > >>>>     while. i <: #n do.
> > > >>>>       if. i = #n do.
> > > >>>>         if. d >: 0 do. 'newrow action' =. (<r,c =. d) { s
> > > >>>>         elseif. j = _1 do. break.
> > > >>>>         elseif. f = 5 do. break.  NB. Don't output final flush
> > > >>>>         elseif. do. 'newrow action' =. 0 5
> > > >>>>         end.
> > > >>>>       else. 'newrow action' =. (<r,c =. i { n) { s
> > > >>>>       end.
> > > >>>>       assert. newrow < #s
> > > >>>>       if. f = 5 do. result =. result , i, j, r, c, newrow, action
> > end.
> > > >>>>       select. action
> > > >>>>         case. 0 do.
> > > >>>>         case. 6 do. break.
> > > >>>>         case. 7 do. i=. i-2
> > > >>>>         fcase. 2;3;4;5 do. NB. emit
> > > >>>>           assert. j >: 0
> > > >>>>           if. f ~: 5 do.
> > > >>>>             ej=. ((r=p)*action>3) { j,pj
> > > >>>>             select. f
> > > >>>>               case. 0 do. newdata =. < ej }. i {. y
> > > >>>>               case. 1 do. newdata =. ej }. i {. y
> > > >>>>               case. 2 do. newdata =. ej , i
> > > >>>>               case. 3 do. newdata =. (}:$s) #: r,c
> > > >>>>               case. 4 do. newdata =. ej , (i-ej) , (}:$s) #: r,c
> > > >>>>               case. do.
> > > >>>>                 'Invalid output type' 13!:8 (1)
> > > >>>>             end.
> > > >>>>             if. (action <: 3)+.r~:p do. result =. result , newdata
> > > >>>>             else. result =. newdata (<:#result)} result
> > > >>>>             end.
> > > >>>>           end.
> > > >>>>           if. r~:p do. pj=. j end.
> > > >>>>           p=. action {_1 _1 _1 _1,r,r
> > > >>>>         case. 1 do.
> > > >>>>           j =. (action e. 1 2 4) { _1,i
> > > >>>>         case. do.
> > > >>>>           'Invalid action' 13!:8 (1)
> > > >>>>       end. NB. select action
> > > >>>>       r =. newrow
> > > >>>>       i =. i + 1
> > > >>>>     end.
> > > >>>>     result
> > > >>>> )
> > > >>>>
> > > >>>> mj=: 256$0                     NB. X other
> > > >>>> mj=: 1 (9,a.i.' ')}mj          NB. S space and tab
> > > >>>> mj=: 2 (,(a.i.'Aa')+/i.26)}mj  NB. A A-Z a-z excluding N B
> > > >>>> mj=: 3 (a.i.'N')}mj            NB. N the letter N
> > > >>>> mj=: 4 (a.i.'B')}mj            NB. B the letter B
> > > >>>> mj=: 5 (a.i.'0123456789_')}mj  NB. 9 digits and _
> > > >>>> mj=: 6 (a.i.'.')}mj            NB. . the decimal point
> > > >>>> mj=: 7 (a.i.':')}mj            NB. : the colon
> > > >>>> mj=: 8 (a.i.'''')}mj           NB. Q quote
> > > >>>> mj=: 9 (a.i.'{')}mj            NB. { the left curly brace
> > > >>>> mj=:10 (a.i.'}')}mj            NB. } the right curly brace
> > > >>>>
> > > >>>> NB.0   1    2   3     4    5    6    7    8     9     10
> > > >>>> sj=: _2]\"1 }.".;._2 (0 : 0)
> > > >>>> ' X    S    A    N    B    9    .    :    Q     {      } ']0
> > > >>>>    1 1  0 0  2 1  3 1  2 1  6 1  1 1  1 1  7 1  10 1  11 1  NB.  0
> > space
> > > >>>>    1 2  0 3  2 2  3 2  2 2  6 2  1 0  1 0  7 2  10 2  11 2  NB.  1
> > other
> > > >>>>    1 2  0 3  2 0  2 0  2 0  2 0  1 0  1 0  7 2  10 2  11 2  NB.  2
> > alp/num
> > > >>>>    1 2  0 3  2 0  2 0  4 0  2 0  1 0  1 0  7 2  10 2  11 2  NB.  3 N
> > > >>>>    1 2  0 3  2 0  2 0  2 0  2 0  5 0  1 0  7 2  10 2  11 2  NB.  4
> > NB
> > > >>>>    9 0  9 0  9 0  9 0  9 0  9 0  1 0  1 0  9 0   9 0   9 0  NB.  5
> > NB.
> > > >>>>    1 4  0 5  6 0  6 0  6 0  6 0  6 0  1 0  7 4  10 4  11 4  NB.  6
> > num
> > > >>>>    7 0  7 0  7 0  7 0  7 0  7 0  7 0  7 0  8 0   7 0   7 0  NB.  7 '
> > > >>>>    1 2  0 3  2 2  3 2  2 2  6 2  1 2  1 2  7 0  10 2  11 2  NB.  8
> > ''
> > > >>>>    9 0  9 0  9 0  9 0  9 0  9 0  9 0  9 0  9 0   9 0   9 0  NB.  9
> > comment
> > > >>>>    1 2  0 3  2 2  3 2  2 2  6 2  1 0  1 0  7 2  12 0   1 2  NB. 10 {
> > > >>>>    1 2  0 3  2 2  3 2  2 2  6 2  1 0  1 0  7 2   1 2  13 0  NB. 11 }
> > > >>>>    1 2  0 3  2 2  3 2  2 2  6 2  1 7  1 7  7 2   1 2   1 2  NB. 12
> > {{
> > > >>>>    1 2  0 3  2 2  3 2  2 2  6 2  1 7  1 7  7 2   1 2   1 2  NB. 13
> > }}
> > > >>>> )
> > > >>>>
> > > >>>>      (0;sj;mj) sq '{{+/y}}'
> > > >>>> +--+-+-+-+--+
> > > >>>> |{{|+|/|y|}}|
> > > >>>> +--+-+-+-+--+
> > > >>>>      (0;sj;mj) sq '{{+/y}}}'
> > > >>>> +--+-+-+-+--+-+
> > > >>>> |{{|+|/|y|}}|}|
> > > >>>> +--+-+-+-+--+-+
> > > >>>>      (0;sj;mj) sq '{{.+/y}}.'
> > > >>>> +-+--+-+-+-+-+--+
> > > >>>> |{|{.|+|/|y|}|}.|
> > > >>>> +-+--+-+-+-+-+--+
> > > >>>>
> > > >>>> Thanks,
> > > >>>>
> > > >>>
> > > >>> --
> > > >>> 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
> > >
> > >
> > > --
> > > 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
> >
> ----------------------------------------------------------------------
> 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