[NTG-context] Re: regular expression as lua pattern

2024-05-29 Thread Pablo Rodriguez via ntg-context
On 5/29/24 13:00, Henning Hraban Ramm wrote:
> [...]
> See also Taco’s introduction to LPEG in
> https://articles.contextgarden.net/journal/2019/77-98.pdf

Many thanks for the reference, Hraban.

I need to start digesting that to learn about LPEG.

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: regular expression as lua pattern

2024-05-29 Thread Pablo Rodriguez via ntg-context
On 5/28/24 20:06, Hans Hagen wrote:
> On 5/28/2024 6:25 PM, Tomáš Hála wrote:
>> Hi Pablo,
>>
>> unfortunately, that it is not possible:
>>
>> http://lua-users.org/wiki/PatternsTutorial, section Limitations.
>
> \starttext
>   \startTEXpage[pagestate=start, offset=1em]
>  \startluacode
>  local pat = (lpeg.Cmt(lpeg.P("this") + lpeg.P("that"),
> function(str,_,s)
>  context(s)
>  return #str
>  end) + lpeg.P(1))^1
>  lpeg.match(pat,"how about this being that")
>
>  local pat = (lpeg.Cmt(lpeg.oneof({ "this", "that" }),
> function(str,_,s)
>  context(s)
>  return #str
>  end) + lpeg.P(1))^1
>  lpeg.match(pat,"how about this being that")
>  \stopluacode
>   \stopTEXpage
> \stoptext

Many thanks for your reply, Hans.

I will have to study it becasue LPEGs is new stuff for me.

Many thanks for your help,

Pablo

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: regular expression as lua pattern

2024-05-29 Thread Henning Hraban Ramm

Am 28.05.24 um 20:06 schrieb Hans Hagen:

On 5/28/2024 6:25 PM, Tomáš Hála wrote:

Hi Pablo,

unfortunately, that it is not possible:

http://lua-users.org/wiki/PatternsTutorial, section Limitations.


\starttext
 \startTEXpage[pagestate=start, offset=1em]
     \startluacode
     local pat = (lpeg.Cmt(lpeg.P("this") + lpeg.P("that"), 
function(str,_,s)

     context(s)
     return #str
     end) + lpeg.P(1))^1
     lpeg.match(pat,"how about this being that")

     local pat = (lpeg.Cmt(lpeg.oneof({ "this", "that" }), 
function(str,_,s)

     context(s)
     return #str
     end) + lpeg.P(1))^1
     lpeg.match(pat,"how about this being that")
     \stopluacode
 \stopTEXpage
\stoptext


See also Taco’s introduction to LPEG in 
https://articles.contextgarden.net/journal/2019/77-98.pdf


Hraban


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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: regular expression as lua pattern

2024-05-28 Thread Hans Hagen

On 5/28/2024 6:25 PM, Tomáš Hála wrote:

Hi Pablo,

unfortunately, that it is not possible:

http://lua-users.org/wiki/PatternsTutorial, section Limitations.


\starttext
\startTEXpage[pagestate=start, offset=1em]
\startluacode
local pat = (lpeg.Cmt(lpeg.P("this") + lpeg.P("that"), 
function(str,_,s)

context(s)
return #str
end) + lpeg.P(1))^1
lpeg.match(pat,"how about this being that")

local pat = (lpeg.Cmt(lpeg.oneof({ "this", "that" }), 
function(str,_,s)

context(s)
return #str
end) + lpeg.P(1))^1
lpeg.match(pat,"how about this being that")
\stopluacode
\stopTEXpage
\stoptext



On Tue, May 28, 2024 at 06:12:51PM +0200, Pablo Rodriguez via ntg-context wrote:

Dear list,

I have the following sample:

\starttext
\startTEXpage[pagestate=start, offset=1em]
\startluacode
local str = "this is that"
context(str:match("(this|these)"))
\stopluacode
\stopTEXpage
\stoptext

In short, I would like to know whether it is possible to have the
regular expression (this|these) as a Lua pattern.

I mean, I need complete strings and I haven’t found the way to do it.

Many thanks for your help,

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


--

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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 / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: regular expression as lua pattern

2024-05-28 Thread Pablo Rodriguez via ntg-context
On 5/28/24 18:25, Tomáš Hála wrote:
> Hi Pablo,
>
> unfortunately, that it is not possible:
>
> http://lua-users.org/wiki/PatternsTutorial, section Limitations.

Many thanks for your reply, Tomáš.

It is clear to me now.

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: regular expression as lua pattern

2024-05-28 Thread Tomáš Hála
Hi Pablo,

unfortunately, that it is not possible:

http://lua-users.org/wiki/PatternsTutorial, section Limitations.

The best,

Tomáš


On Tue, May 28, 2024 at 06:12:51PM +0200, Pablo Rodriguez via ntg-context wrote:
> Dear list,
> 
> I have the following sample:
> 
>   \starttext
>   \startTEXpage[pagestate=start, offset=1em]
>   \startluacode
>   local str = "this is that"
>   context(str:match("(this|these)"))
>   \stopluacode
>   \stopTEXpage
>   \stoptext
> 
> In short, I would like to know whether it is possible to have the
> regular expression (this|these) as a Lua pattern.
> 
> I mean, I need complete strings and I haven’t found the way to do it.
> 
> Many thanks for your help,
> 
> Pablo
> ___
> If your question is of interest to others as well, please add an entry to the 
> Wiki!
> 
> maillist : ntg-context@ntg.nl / 
> https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive  : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___