ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Lua conditionals fail inside \starttexdefinition
@ 2012-09-04 12:21 Marco Patzer
  2012-09-04 12:26 ` Wolfgang Schuster
  0 siblings, 1 reply; 17+ messages in thread
From: Marco Patzer @ 2012-09-04 12:21 UTC (permalink / raw)
  To: ntg-context

Hi,

I discovered strange behaviour concerning Lua conditionals within
texdefinitions.

ConTeXt complains: 'then' expected near 'thenelseend'.

I guess it has something to do with how the content of a
texdefinitions is grabbed. Seems like a bug or is this by design?


% This works fine
\def\mycmd{%
  \startluacode
    if true then
    else
    end
  \stopluacode}

% This one fails
% \starttexdefinition mycmd
%   \startluacode
%     if true then
%     else
%     end
%   \stopluacode
% \stoptexdefinition

\startluacode
  userdata = userdata or { }
  function userdata.myfun()
    if true then
    else
    end
  end
\stopluacode

% This also works fine
\starttexdefinition mycmd
  \luacode{userdata.myfun()}
\stoptexdefinition

\mycmd


Marco

___________________________________________________________________________________
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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 12:21 Lua conditionals fail inside \starttexdefinition Marco Patzer
@ 2012-09-04 12:26 ` Wolfgang Schuster
  2012-09-04 18:24   ` Aditya Mahajan
  0 siblings, 1 reply; 17+ messages in thread
From: Wolfgang Schuster @ 2012-09-04 12:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 04.09.2012 um 14:21 schrieb Marco Patzer <homerow@lavabit.com>:

> Hi,
> 
> I discovered strange behaviour concerning Lua conditionals within
> texdefinitions.
> 
> ConTeXt complains: 'then' expected near 'thenelseend'.
> 
> I guess it has something to do with how the content of a
> texdefinitions is grabbed. Seems like a bug or is this by design?

When you use the texdefinition environment to create a command
the end of line character which results normally in a space is ignored
sees “thenelseend” as a single string, in such a case you can add
a space and put a comment sign at the end of the line.

> % This one fails
> % \starttexdefinition mycmd
> %   \startluacode
> %     if true then
> %     else
> %     end
> %   \stopluacode
> % \stoptexdefinition

\starttexdefintion mycmd
  \startluacode
    if true then %
    else %
    end
  \stopluacode
\stoptexdefinition

Wolfgang
___________________________________________________________________________________
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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 12:26 ` Wolfgang Schuster
@ 2012-09-04 18:24   ` Aditya Mahajan
  2012-09-04 18:34     ` Wolfgang Schuster
  0 siblings, 1 reply; 17+ messages in thread
From: Aditya Mahajan @ 2012-09-04 18:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1049 bytes --]

On Tue, 4 Sep 2012, Wolfgang Schuster wrote:

>
> Am 04.09.2012 um 14:21 schrieb Marco Patzer <homerow@lavabit.com>:
>
>> Hi,
>>
>> I discovered strange behaviour concerning Lua conditionals within
>> texdefinitions.
>>
>> ConTeXt complains: 'then' expected near 'thenelseend'.
>>
>> I guess it has something to do with how the content of a
>> texdefinitions is grabbed. Seems like a bug or is this by design?
>
> When you use the texdefinition environment to create a command
> the end of line character which results normally in a space is ignored
> sees “thenelseend” as a single string, in such a case you can add
> a space and put a comment sign at the end of the line.
>
>> % This one fails
>> % \starttexdefinition mycmd
>> %   \startluacode
>> %     if true then
>> %     else
>> %     end
>> %   \stopluacode
>> % \stoptexdefinition
>
> \starttexdefintion mycmd
>  \startluacode
>    if true then %
>    else %
>    end
>  \stopluacode
> \stoptexdefinition

Why does adding semicolon not work?

Aditya

[-- 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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 18:24   ` Aditya Mahajan
@ 2012-09-04 18:34     ` Wolfgang Schuster
  2012-09-04 18:44       ` Marco Patzer
  0 siblings, 1 reply; 17+ messages in thread
From: Wolfgang Schuster @ 2012-09-04 18:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 04.09.2012 um 20:24 schrieb Aditya Mahajan <adityam@umich.edu>:

> Why does adding semicolon not work?

Do you have a example?

Wolfgang
___________________________________________________________________________________
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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 18:34     ` Wolfgang Schuster
@ 2012-09-04 18:44       ` Marco Patzer
  2012-09-04 18:56         ` Herbert Voss
  2012-09-05  9:09         ` Hans Hagen
  0 siblings, 2 replies; 17+ messages in thread
From: Marco Patzer @ 2012-09-04 18:44 UTC (permalink / raw)
  To: ntg-context

On 2012-09-04 Wolfgang Schuster <wolfgang.schuster@gmail.com> wrote:

> > Why does adding semicolon not work?
> 
> Do you have a example?


\starttext
\startluacode
  if true then;
    context("true")
  else;
    context("false")
  end
\stopluacode
\stoptext


Marco

___________________________________________________________________________________
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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 18:44       ` Marco Patzer
@ 2012-09-04 18:56         ` Herbert Voss
  2012-09-04 19:05           ` Marco Patzer
  2012-09-04 19:05           ` Aditya Mahajan
  2012-09-05  9:09         ` Hans Hagen
  1 sibling, 2 replies; 17+ messages in thread
From: Herbert Voss @ 2012-09-04 18:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 04.09.2012 20:44, schrieb Marco Patzer:
> On 2012-09-04 Wolfgang Schuster <wolfgang.schuster@gmail.com> wrote:
>
>>> Why does adding semicolon not work?
>>
>> Do you have a example?
>
>
> \starttext
> \startluacode
>    if true then;
>      context("true")
>    else;
>      context("false")
>    end
> \stopluacode
> \stoptext

that is no Lua syntax

Herbert

___________________________________________________________________________________
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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 18:56         ` Herbert Voss
@ 2012-09-04 19:05           ` Marco Patzer
  2012-09-04 19:15             ` luigi scarso
  2012-09-04 19:18             ` Herbert Voss
  2012-09-04 19:05           ` Aditya Mahajan
  1 sibling, 2 replies; 17+ messages in thread
From: Marco Patzer @ 2012-09-04 19:05 UTC (permalink / raw)
  To: ntg-context

On 2012-09-04 Herbert Voss <Herbert.Voss@FU-Berlin.DE> wrote:

Hi Herbert,

> > \starttext
> > \startluacode
> >    if true then;
> >      context("true")
> >    else;
> >      context("false")
> >    end
> > \stopluacode
> > \stoptext
> 
> that is no Lua syntax

if true then;
  print("true")
else;
  print("false")
end

This snippet fed into a standalone Lua interpreter prints “true” on
the terminal.

I admit, I did not look up the syntax in the manual, but I have in
mind that semicolons can be used to separate statements that are on
one line.


Marco

___________________________________________________________________________________
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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 18:56         ` Herbert Voss
  2012-09-04 19:05           ` Marco Patzer
@ 2012-09-04 19:05           ` Aditya Mahajan
  2012-09-04 19:22             ` luigi scarso
  1 sibling, 1 reply; 17+ messages in thread
From: Aditya Mahajan @ 2012-09-04 19:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Tue, 4 Sep 2012, Herbert Voss wrote:

> Am 04.09.2012 20:44, schrieb Marco Patzer:
>> On 2012-09-04 Wolfgang Schuster <wolfgang.schuster@gmail.com> wrote:
>> 
>>>> Why does adding semicolon not work?
>>> 
>>> Do you have a example?
>> 
>> 
>> \starttext
>> \startluacode
>>    if true then;
>>      context("true")
>>    else;
>>      context("false")
>>    end
>> \stopluacode
>> \stoptext
>
> that is no Lua syntax

I thought that semicolons were optional in lua are equal to end of lines.

Aditya
___________________________________________________________________________________
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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 19:05           ` Marco Patzer
@ 2012-09-04 19:15             ` luigi scarso
  2012-09-04 19:18             ` Herbert Voss
  1 sibling, 0 replies; 17+ messages in thread
From: luigi scarso @ 2012-09-04 19:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

On Tue, Sep 4, 2012 at 9:05 PM, Marco Patzer <homerow@lavabit.com> wrote:

> On 2012-09-04 Herbert Voss <Herbert.Voss@FU-Berlin.DE> wrote:
>
> Hi Herbert,
>
> > > \starttext
> > > \startluacode
> > >    if true then;
> > >      context("true")
> > >    else;
> > >      context("false")
> > >    end
> > > \stopluacode
> > > \stoptext
> >
> > that is no Lua syntax
>
> if true then;
>   print("true")
> else;
>   print("false")
> end
>
> This snippet fed into a standalone Lua interpreter prints “true” on
> the terminal.
>
> Not in my lua interpreter: saving the snippet into test.lua
$>lua test.lua
gives
lua: test.lua:1: unexpected symbol near ';'


-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 1224 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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 19:05           ` Marco Patzer
  2012-09-04 19:15             ` luigi scarso
@ 2012-09-04 19:18             ` Herbert Voss
  2012-09-04 19:35               ` Marco Patzer
  1 sibling, 1 reply; 17+ messages in thread
From: Herbert Voss @ 2012-09-04 19:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 04.09.2012 21:05, schrieb Marco Patzer:

> if true then;
>    print("true")
> else;
>    print("false")
> end
>
> This snippet fed into a standalone Lua interpreter prints “true” on
> the terminal.
>
> I admit, I did not look up the syntax in the manual, but I have in
> mind that semicolons can be used to separate statements that are on
> one line.

voss@shania:~/ConTeXt> lua zzz.lua
lua: zzz.lua:1: unexpected symbol near ';'

voss@shania:~/ConTeXt> lua -v
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio

Herbert
___________________________________________________________________________________
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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 19:05           ` Aditya Mahajan
@ 2012-09-04 19:22             ` luigi scarso
  2012-09-04 19:28               ` Herbert Voss
  0 siblings, 1 reply; 17+ messages in thread
From: luigi scarso @ 2012-09-04 19:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

On Tue, Sep 4, 2012 at 9:05 PM, Aditya Mahajan <adityam@umich.edu> wrote:

> On Tue, 4 Sep 2012, Herbert Voss wrote:
>
>  Am 04.09.2012 20:44, schrieb Marco Patzer:
>>
>>> On 2012-09-04 Wolfgang Schuster <wolfgang.schuster@gmail.com> wrote:
>>>
>>>  Why does adding semicolon not work?
>>>>>
>>>>
>>>> Do you have a example?
>>>>
>>>
>>>
>>> \starttext
>>> \startluacode
>>>    if true then;
>>>      context("true")
>>>    else;
>>>      context("false")
>>>    end
>>> \stopluacode
>>> \stoptext
>>>
>>
>> that is no Lua syntax
>>
>
> I thought that semicolons were optional in lua are equal to end of lines.
>
> Aditya
>
> ______________________________**______________________________**
> _______________________
> 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 <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/<http://foundry.supelec.fr/projects/contextrev/>
> wiki     : http://contextgarden.net
> ______________________________**______________________________**
> _______________________
>


http://www.lua.org/manual/5.1/manual.html#2.4.4
"""
The unit of execution of Lua is called a chunk. A chunk is simply a
sequence of statements, which are executed sequentially. Each statement can
be optionally followed by a semicolon:
:
:
2.4.4 - Control Structures

The control structures if, while, and repeat have the usual meaning and
familiar syntax:

stat ::= while exp do block end
stat ::= repeat block until exp
stat ::= if exp then block {elseif exp then block} [else block] end
"""
(as conseguence
if exp then; block else; block end
is not valid
)

-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 3624 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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 19:22             ` luigi scarso
@ 2012-09-04 19:28               ` Herbert Voss
  0 siblings, 0 replies; 17+ messages in thread
From: Herbert Voss @ 2012-09-04 19:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 04.09.2012 21:22, schrieb luigi scarso:
>
> http://www.lua.org/manual/5.1/manual.html#2.4.4
> """
> The unit of execution of Lua is called a chunk. A chunk is simply a
> sequence of statements, which are executed sequentially. Each statement
> can be optionally followed by a semicolon:
> :
> :
> 2.4.4 - Control Structures
>
> The control structures if, while, and repeat have the usual meaning and
> familiar syntax:
>
> stat ::= while exp do block end
> stat ::= repeat block until exp
> stat ::= if exp then block {elseif exp then block} [else block] end
> """
> (as conseguence
> if exp then; block else; block end
> is not valid
> )

yes, see also: http://www.lua.org/manual/5.1/manual.html#8

Herbert

___________________________________________________________________________________
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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 19:18             ` Herbert Voss
@ 2012-09-04 19:35               ` Marco Patzer
  2012-09-04 19:39                 ` Herbert Voss
  2012-09-04 19:41                 ` luigi scarso
  0 siblings, 2 replies; 17+ messages in thread
From: Marco Patzer @ 2012-09-04 19:35 UTC (permalink / raw)
  To: ntg-context

On 2012-09-04 Herbert Voss <Herbert.Voss@FU-Berlin.DE> wrote:

> voss@shania:~/ConTeXt> lua zzz.lua
> lua: zzz.lua:1: unexpected symbol near ';'

marco@homerow:/tmp$ lua t.lua
true

> voss@shania:~/ConTeXt> lua -v
> Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio

marco@homerow:/tmp$ lua -v
Lua 5.2.1  Copyright (C) 1994-2012 Lua.org, PUC-Rio


Marco

___________________________________________________________________________________
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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 19:35               ` Marco Patzer
@ 2012-09-04 19:39                 ` Herbert Voss
  2012-09-04 19:47                   ` Marco Patzer
  2012-09-04 19:41                 ` luigi scarso
  1 sibling, 1 reply; 17+ messages in thread
From: Herbert Voss @ 2012-09-04 19:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 04.09.2012 21:35, schrieb Marco Patzer:
> On 2012-09-04 Herbert Voss <Herbert.Voss@FU-Berlin.DE> wrote:
>
>> voss@shania:~/ConTeXt> lua zzz.lua
>> lua: zzz.lua:1: unexpected symbol near ';'
>
> marco@homerow:/tmp$ lua t.lua
> true
>
>> voss@shania:~/ConTeXt> lua -v
>> Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
>
> marco@homerow:/tmp$ lua -v
> Lua 5.2.1  Copyright (C) 1994-2012 Lua.org, PUC-Rio

the syntax changes, see http://www.lua.org/manual/5.2/manual.html#9

Herbert
___________________________________________________________________________________
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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 19:35               ` Marco Patzer
  2012-09-04 19:39                 ` Herbert Voss
@ 2012-09-04 19:41                 ` luigi scarso
  1 sibling, 0 replies; 17+ messages in thread
From: luigi scarso @ 2012-09-04 19:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

On Tue, Sep 4, 2012 at 9:35 PM, Marco Patzer <homerow@lavabit.com> wrote:

> On 2012-09-04 Herbert Voss <Herbert.Voss@FU-Berlin.DE> wrote:
>
> > voss@shania:~/ConTeXt> lua zzz.lua
> > lua: zzz.lua:1: unexpected symbol near ';'
>
> marco@homerow:/tmp$ lua t.lua
> true
>
> > voss@shania:~/ConTeXt> lua -v
> > Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
>
> marco@homerow:/tmp$ lua -v
> Lua 5.2.1  Copyright (C) 1994-2012 Lua.org, PUC-Rio
>
>
Because in Lua 5.2 there is the empty statements
http://www.lua.org/manual/5.2/manual.html#3
"""
3.3.1 – Blocks

A block is a list of statements, which are executed sequentially:

block ::= {stat}
Lua has empty statements that allow you to separate statements with
semicolons, start a block with a semicolon or write two semicolons in
sequence:

stat ::= ‘;’
"""
So
stat ::= if exp then block {elseif exp then block} [else block] end

means that
if exp then
;
else
;
end
is valid.

Luatex still uses lua 5.1.4


-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 1938 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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 19:39                 ` Herbert Voss
@ 2012-09-04 19:47                   ` Marco Patzer
  0 siblings, 0 replies; 17+ messages in thread
From: Marco Patzer @ 2012-09-04 19:47 UTC (permalink / raw)
  To: ntg-context

On 2012-09-04 Herbert Voss <Herbert.Voss@FU-Berlin.DE> wrote:

> >> voss@shania:~/ConTeXt> lua -v
> >> Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> >
> > marco@homerow:/tmp$ lua -v
> > Lua 5.2.1  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> 
> the syntax changes, see http://www.lua.org/manual/5.2/manual.html#9

You're totally right. LuaTeX uses does not use lua 5.2 and therefore
the semicolon syntax is wrong. I also get an “unexpected symbol”
with lua5.1

Thanks for the clarification


Marco

___________________________________________________________________________________
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] 17+ messages in thread

* Re: Lua conditionals fail inside \starttexdefinition
  2012-09-04 18:44       ` Marco Patzer
  2012-09-04 18:56         ` Herbert Voss
@ 2012-09-05  9:09         ` Hans Hagen
  1 sibling, 0 replies; 17+ messages in thread
From: Hans Hagen @ 2012-09-05  9:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 4-9-2012 20:44, Marco Patzer wrote:
> On 2012-09-04 Wolfgang Schuster <wolfgang.schuster@gmail.com> wrote:
>
>>> Why does adding semicolon not work?
>>
>> Do you have a example?
>
>
> \starttext
> \startluacode
>    if true then;
>      context("true")
>    else;
>      context("false")
>    end
> \stopluacode
> \stoptext

\ctxlua{context(tostring(some condition)}

given that the condition returns true/false

-----------------------------------------------------------------
                                           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] 17+ messages in thread

end of thread, other threads:[~2012-09-05  9:09 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-04 12:21 Lua conditionals fail inside \starttexdefinition Marco Patzer
2012-09-04 12:26 ` Wolfgang Schuster
2012-09-04 18:24   ` Aditya Mahajan
2012-09-04 18:34     ` Wolfgang Schuster
2012-09-04 18:44       ` Marco Patzer
2012-09-04 18:56         ` Herbert Voss
2012-09-04 19:05           ` Marco Patzer
2012-09-04 19:15             ` luigi scarso
2012-09-04 19:18             ` Herbert Voss
2012-09-04 19:35               ` Marco Patzer
2012-09-04 19:39                 ` Herbert Voss
2012-09-04 19:47                   ` Marco Patzer
2012-09-04 19:41                 ` luigi scarso
2012-09-04 19:05           ` Aditya Mahajan
2012-09-04 19:22             ` luigi scarso
2012-09-04 19:28               ` Herbert Voss
2012-09-05  9:09         ` 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).