ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [mkvi] comment handling bug
@ 2012-05-13 11:12 Philipp Gesang
  2012-05-14  7:35 ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Philipp Gesang @ 2012-05-13 11:12 UTC (permalink / raw)
  To: ConTeXt ML


[-- Attachment #1.1: Type: text/plain, Size: 935 bytes --]

Hi all,

seems the mkvi-style macros have trouble with groups in comments:

········································································
% macros=mkvi
\def\dosomething#content{%%% <= fine with “#1”
  % { %%% Open unbalanced brace breaks macros.
}

\starttext \dosomething {foo} \stoptext
········································································

Fails here with:

  <to be read again> 
                    c
  l.2 \def\dosomething#c
                        ontent{%%% <= fine with “#1”

Removing the comment, closing the group or reverting to TEX-style
argument numbering makes this behavior disappear.

Philipp


-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [mkvi] comment handling bug
  2012-05-13 11:12 [mkvi] comment handling bug Philipp Gesang
@ 2012-05-14  7:35 ` Hans Hagen
  2012-05-14 13:22   ` Philipp Gesang
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2012-05-14  7:35 UTC (permalink / raw)
  To: ConTeXt ML

On 13-5-2012 13:12, Philipp Gesang wrote:
> Hi all,
>
> seems the mkvi-style macros have trouble with groups in comments:
>
> ········································································
> % macros=mkvi
> \def\dosomething#content{%%%<= fine with “#1”
>    % { %%% Open unbalanced brace breaks macros.
> }
>
> \starttext \dosomething {foo} \stoptext
> ········································································
>
> Fails here with:
>
>    <to be read again>
>                      c
>    l.2 \def\dosomething#c
>                          ontent{%%%<= fine with “#1”
>
> Removing the comment, closing the group or reverting to TEX-style
> argument numbering makes this behavior disappear.

Indeed there are some limitations to the parser. I'll note it down as 
low priority issue.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [mkvi] comment handling bug
  2012-05-14  7:35 ` Hans Hagen
@ 2012-05-14 13:22   ` Philipp Gesang
  2012-05-14 13:59     ` Philipp Gesang
  0 siblings, 1 reply; 5+ messages in thread
From: Philipp Gesang @ 2012-05-14 13:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1967 bytes --]

On 2012-05-14 09:35, Hans Hagen wrote:
> On 13-5-2012 13:12, Philipp Gesang wrote:
> >Hi all,
> >
> >seems the mkvi-style macros have trouble with groups in comments:
> >
> >········································································
> >% macros=mkvi
> >\def\dosomething#content{%%%<= fine with “#1”
> >   % { %%% Open unbalanced brace breaks macros.
> >}
> >
> >\starttext \dosomething {foo} \stoptext
> >········································································
> >
> >Fails here with:
> >
> >   <to be read again>
> >                     c
> >   l.2 \def\dosomething#c
> >                         ontent{%%%<= fine with “#1”
> >
> >Removing the comment, closing the group or reverting to TEX-style
> >argument numbering makes this behavior disappear.
> 
> Indeed there are some limitations to the parser. I'll note it down
> as low priority issue.

Would it be possible to modify the comment pattern so that it
accept initial spaces? At least it fixes my problem.

Philipp

--- /home/laokoon/base/luat-mac.lua 2012-05-14 14:52:40.674091445 +0200
+++ luat-mac.lua    2012-05-14 15:18:35.968999022 +0200
@@ -110,8 +110,10 @@
 
 local commenttoken   = P("%")
 local crorlf         = S("\n\r")
-local commentline    = commenttoken * ((Carg(1) * C((1-crorlf)^0))/function(strip,s) return strip and "" or s end)
-local commentline    = commenttoken * ((1-crorlf)^0)
+--local commentline    = commenttoken * ((Carg(1) * C((1-crorlf)^0))/function(strip,s) return strip and "" or s end)
+--local commentline    = commenttoken * ((1-crorlf)^0)
+local commentstart   = space^0 * commenttoken
+local commentline    = commentstart * ((1-crorlf)^0)
 local leadingcomment = (commentline * crorlf^1)^1
 local furthercomment = (crorlf^1 * commentline)^1

[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [mkvi] comment handling bug
  2012-05-14 13:22   ` Philipp Gesang
@ 2012-05-14 13:59     ` Philipp Gesang
  2012-05-15 14:52       ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Philipp Gesang @ 2012-05-14 13:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2829 bytes --]

On 2012-05-14 15:22, Philipp Gesang wrote:
> On 2012-05-14 09:35, Hans Hagen wrote:
> > On 13-5-2012 13:12, Philipp Gesang wrote:
> > >Hi all,
> > >
> > >seems the mkvi-style macros have trouble with groups in comments:
> > >
> > >········································································
> > >% macros=mkvi
> > >\def\dosomething#content{%%%<= fine with “#1”
> > >   % { %%% Open unbalanced brace breaks macros.
> > >}
> > >
> > >\starttext \dosomething {foo} \stoptext
> > >········································································
> > >
> > >Fails here with:
> > >
> > >   <to be read again>
> > >                     c
> > >   l.2 \def\dosomething#c
> > >                         ontent{%%%<= fine with “#1”
> > >
> > >Removing the comment, closing the group or reverting to TEX-style
> > >argument numbering makes this behavior disappear.
> > 
> > Indeed there are some limitations to the parser. I'll note it down
> > as low priority issue.
> 
> Would it be possible to modify the comment pattern so that it
> accept initial spaces? At least it fixes my problem.

I take that back, sorry for the noise. The better solution
appears to be adding the “leadingcomment” pattern to the rule
that handles balanced braces:

········································································

--- /home/laokoon/base/luat-mac.lua 2012-05-14 14:52:40.674091445 +0200
+++ luat-mac.lua    2012-05-14 15:55:50.683559201 +0200
@@ -110,7 +110,7 @@
 
 local commenttoken   = P("%")
 local crorlf         = S("\n\r")
-local commentline    = commenttoken * ((Carg(1) * C((1-crorlf)^0))/function(strip,s) return strip and "" or s end)
+--local commentline    = commenttoken * ((Carg(1) * C((1-crorlf)^0))/function(strip,s) return strip and "" or s end)
 local commentline    = commenttoken * ((1-crorlf)^0)
 local leadingcomment = (commentline * crorlf^1)^1
 local furthercomment = (crorlf^1 * commentline)^1
@@ -160,6 +160,7 @@
                     + V("texcode")
                     + V("braced")
                     + furthercomment
+                    + leadingcomment
                     + nobrace
                   )^0
              -- * rightbrace^-1, -- the -1 catches errors

········································································

Now definitions with commented-out unbalanced stuff like

  \def\dosomething#content{%%% {{
    % { }{{ %%
    \bgroup\italic#content\egroup
  }

will work too.

Philipp



[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [mkvi] comment handling bug
  2012-05-14 13:59     ` Philipp Gesang
@ 2012-05-15 14:52       ` Hans Hagen
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2012-05-15 14:52 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 14-5-2012 15:59, Philipp Gesang wrote:
> + leadingcomment

ok

-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-15 14:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-13 11:12 [mkvi] comment handling bug Philipp Gesang
2012-05-14  7:35 ` Hans Hagen
2012-05-14 13:22   ` Philipp Gesang
2012-05-14 13:59     ` Philipp Gesang
2012-05-15 14:52       ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).