[Wikitech-l] Lua: parser interface

2012-05-01 Thread Tim Starling
I've written up a proposed interface between the MediaWiki parser and Lua: In summary: the Lua function is called with a single argument, which is an object representing the parser interface. The object is roughly equiva

Re: [Wikitech-l] Lua: parser interface

2012-05-01 Thread Victor Vasiliev
Thank you for bringing those issues to the public discussion, Tim, they are really worth it. On Tue, May 1, 2012 at 11:15 AM, Tim Starling wrote: > I've written up a proposed interface between the MediaWiki parser and Lua: > >

Re: [Wikitech-l] Lua: parser interface

2012-05-01 Thread Gabriel Wicke
On 05/01/2012 09:15 AM, Tim Starling wrote: > In summary: the Lua function is called with a single argument, which > is an object representing the parser interface. The object is roughly > equivalent to a PPFrame. +1 for the abstract frame object. > The object would have a property called "args",

Re: [Wikitech-l] Lua: parser interface

2012-05-01 Thread Tim Starling
On 02/05/12 03:24, Victor Vasiliev wrote: > I am a bit leery though about the part where you suggest that > name-value arguments ({{#invoke:module|func|param=value}}) should be > parsed by engine, not the script. Don't you have to expand those > arguments in order to parse them, hence making any fo

Re: [Wikitech-l] Lua: parser interface

2012-05-01 Thread Victor Vasiliev
On Wed, May 2, 2012 at 4:21 AM, Tim Starling wrote: > We can limit the input size, or temporarily reduce the general parser > limits like post-expand include size and node count. We can also hook > into PPFrame::expand() to periodically check for a Lua timeout, if > that is necessary. > > The prep

Re: [Wikitech-l] Lua: parser interface

2012-05-01 Thread Tim Starling
On 02/05/12 04:51, Gabriel Wicke wrote: > frame.args.name.expandTo( 'text/x-mediawiki' ) --- returns "value" > > This would make it possible to work with other formats apart from wikitext. I can see how that would make sense when you're writing a parser, but given the target audience for the Lu

Re: [Wikitech-l] Lua: parser interface

2012-05-01 Thread Tim Starling
On 02/05/12 11:28, Victor Vasiliev wrote: >> The scenario you give in brackets will not happen. If a Lua timeout >> occurs when the parser is executing, the Lua script will terminate >> when the parser returns control to it. The timeout is not missed. > > But the parser working time would still be

Re: [Wikitech-l] Lua: parser interface

2012-05-02 Thread Platonides
Is it possible to hook Lua function calls? If so, I'd make a template expansion a "call" to a function with that name. That was the interface I envisioned when thinking how I'd do it if making the language from scratch to suit wikitext (I drafted some code, but didn't reach to a barely mature level

Re: [Wikitech-l] Lua: parser interface

2012-05-02 Thread Victor Vasiliev
On Wed, May 2, 2012 at 2:28 PM, Platonides wrote: > Is it possible to hook Lua function calls? If so, I'd make a template > expansion a "call" to a function with that name. > That was the interface I envisioned when thinking how I'd do it if > making the language from scratch to suit wikitext > (I

Re: [Wikitech-l] Lua: parser interface

2012-05-02 Thread Gabriel Wicke
On 05/02/2012 04:01 AM, Tim Starling wrote: > How about frame.args.name as an abbreviation for > frame:getArgument('name'):expandTo( 'text/x-mediawiki' ) ? Yep, that looks good to me. Maybe the specialized wikitext argument variant could be called 'wikitextArgs' so that the general variant can be