discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] assert documentation.

MF
Michael Frey
Wed, Jan 23, 2019 2:30 PM

On 23.01.19 13:30, nop head wrote:

Isn't the let thing a syntax error? I.e. the arguments to let should
be assignment statements with name = expression, not just an
expression. let(a 42), let(a =)  and let(=42) are all syntax errors as
expected.

You can see it that way. Either we catch that during parsing or during
runtime.
Catching it in the parser requires more work, then catching it during
runtime.

Hm - I think you right, I'll give modifying the parser a try.

With kind regards,

Michael Frey

On 23.01.19 13:30, nop head wrote: > Isn't the let thing a syntax error? I.e. the arguments to let should > be assignment statements with name = expression, not just an > expression. let(a 42), let(a =)  and let(=42) are all syntax errors as > expected. > You can see it that way. Either we catch that during parsing or during runtime. Catching it in the parser requires more work, then catching it during runtime. Hm - I think you right, I'll give modifying the parser a try. With kind regards, Michael Frey
N
nophead
Wed, Jan 23, 2019 6:16 PM

Yes it looks like a parser bug to me because there is no equals sign. I don't
know how it gets an empty variable name and carries on. If you actually give
it an equals sign without a variable name it does give a syntax error.

The grammer here http://files.openscad.org/grammar.xhtml says it should be
ID = expr. How does the parser not give an error for just expr?

--
Sent from: http://forum.openscad.org/

Yes it looks like a parser bug to me because there is no equals sign. I don't know how it gets an empty variable name and carries on. If you actually give it an equals sign without a variable name it does give a syntax error. The grammer here http://files.openscad.org/grammar.xhtml says it should be ID = expr. How does the parser not give an error for just expr? -- Sent from: http://forum.openscad.org/
MF
Michael Frey
Wed, Jan 23, 2019 8:41 PM

On 23.01.19 19:16, nophead wrote:

Yes it looks like a parser bug to me because there is no equals sign. I don't
know how it gets an empty variable name and carries on. If you actually give
it an equals sign without a variable name it does give a syntax error.

The grammer here http://files.openscad.org/grammar.xhtml says it should be
ID = expr. How does the parser not give an error for just expr?

Modules and Functions accept named and unnamed variables.

TOK_LET beeing a valid module identifier:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L341-L345

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L351-L351

That is why I can not easily change the parser.

Any way: Let has has two more forms:

Expression:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L490

and list_comprehension_element:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L521

Eitherway, let takes arguments_call:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L628

which consists of many argument_call

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L647

and there is cause:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L648-L651

Note that we need this for unnamed parameters for functions and modules
calls.

To resolve the issue with let, we would need to duplicate/modify those
data structures.

I do not like the idea of increasing the parser complexity by
duplicating part of it.

I know that it is kind of hard to follow this links and my description,
but that is the nature of GNU/Bison parsers.

It takes time getting used to reading them.

With kind regards,

Michael Frey

On 23.01.19 19:16, nophead wrote: > Yes it looks like a parser bug to me because there is no equals sign. I don't > know how it gets an empty variable name and carries on. If you actually give > it an equals sign without a variable name it does give a syntax error. > > The grammer here http://files.openscad.org/grammar.xhtml says it should be > ID = expr. How does the parser not give an error for just expr? > Modules and Functions accept named and unnamed variables. TOK_LET beeing a valid module identifier: https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L341-L345 https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L351-L351 That is why I can not easily change the parser. Any way: Let has has two more forms: Expression: https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L490 and list_comprehension_element: https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L521 Eitherway, let takes arguments_call: https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L628 which consists of many argument_call https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L647 and there is cause: https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L648-L651 Note that we need this for unnamed parameters for functions and modules calls. To resolve the issue with let, we would need to duplicate/modify those data structures. I do not like the idea of increasing the parser complexity by duplicating part of it. I know that it is kind of hard to follow this links and my description, but that is the nature of GNU/Bison parsers. It takes time getting used to reading them. With kind regards, Michael Frey
RP
Ronaldo Persiano
Wed, Jan 23, 2019 8:44 PM

"Let" is not the only strange case. The following expressions are
syntactically acceptable too:

for( 0!=1 );
for( i=[0:10], i!=2);

but do not expect any reasonable semantics they might induce.

Em qua, 23 de jan de 2019 às 18:17, nophead nop.head@gmail.com escreveu:

Yes it looks like a parser bug to me because there is no equals sign. I
don't
know how it gets an empty variable name and carries on. If you actually
give
it an equals sign without a variable name it does give a syntax error.

The grammer here http://files.openscad.org/grammar.xhtml says it should be
ID = expr. How does the parser not give an error for just expr?

"Let" is not the only strange case. The following expressions are syntactically acceptable too: for( 0!=1 ); for( i=[0:10], i!=2); but do not expect any reasonable semantics they might induce. Em qua, 23 de jan de 2019 às 18:17, nophead <nop.head@gmail.com> escreveu: > Yes it looks like a parser bug to me because there is no equals sign. I > don't > know how it gets an empty variable name and carries on. If you actually > give > it an equals sign without a variable name it does give a syntax error. > > The grammer here http://files.openscad.org/grammar.xhtml says it should be > ID = expr. How does the parser not give an error for just expr? >
NH
nop head
Wed, Jan 23, 2019 8:50 PM

So the grammar documentation I found has nothing to do with the parser?
That grammar says let takes statements not arguments_call. That is the bug.

On Wed, 23 Jan 2019 at 20:41, Michael Frey michael.frey@gmx.ch wrote:

On 23.01.19 19:16, nophead wrote:

Yes it looks like a parser bug to me because there is no equals sign. I

don't

know how it gets an empty variable name and carries on. If you actually

give

it an equals sign without a variable name it does give a syntax error.

The grammer here http://files.openscad.org/grammar.xhtml says it should

be

ID = expr. How does the parser not give an error for just expr?

Modules and Functions accept named and unnamed variables.

TOK_LET beeing a valid module identifier:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L341-L345

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L351-L351

That is why I can not easily change the parser.

Any way: Let has has two more forms:

Expression:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L490

and list_comprehension_element:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L521

Eitherway, let takes arguments_call:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L628

which consists of many argument_call

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L647

and there is cause:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L648-L651

Note that we need this for unnamed parameters for functions and modules
calls.

To resolve the issue with let, we would need to duplicate/modify those
data structures.

I do not like the idea of increasing the parser complexity by
duplicating part of it.

I know that it is kind of hard to follow this links and my description,
but that is the nature of GNU/Bison parsers.

It takes time getting used to reading them.

With kind regards,

Michael Frey


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

So the grammar documentation I found has nothing to do with the parser? That grammar says let takes statements not arguments_call. That is the bug. On Wed, 23 Jan 2019 at 20:41, Michael Frey <michael.frey@gmx.ch> wrote: > On 23.01.19 19:16, nophead wrote: > > Yes it looks like a parser bug to me because there is no equals sign. I > don't > > know how it gets an empty variable name and carries on. If you actually > give > > it an equals sign without a variable name it does give a syntax error. > > > > The grammer here http://files.openscad.org/grammar.xhtml says it should > be > > ID = expr. How does the parser not give an error for just expr? > > > > Modules and Functions accept named and unnamed variables. > > TOK_LET beeing a valid module identifier: > > > https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L341-L345 > > > https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L351-L351 > > That is why I can not easily change the parser. > > Any way: Let has has two more forms: > > Expression: > > > https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L490 > > and list_comprehension_element: > > > https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L521 > > Eitherway, let takes arguments_call: > > > https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L628 > > which consists of many argument_call > > > https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L647 > > and there is cause: > > > https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L648-L651 > > Note that we need this for unnamed parameters for functions and modules > calls. > > To resolve the issue with let, we would need to duplicate/modify those > data structures. > > I do not like the idea of increasing the parser complexity by > duplicating part of it. > > > I know that it is kind of hard to follow this links and my description, > but that is the nature of GNU/Bison parsers. > > It takes time getting used to reading them. > > > With kind regards, > > Michael Frey > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Wed, Jan 23, 2019 8:52 PM

Sorry, I meant assignments, not arguments_call.

On Wed, 23 Jan 2019 at 20:50, nop head nop.head@gmail.com wrote:

So the grammar documentation I found has nothing to do with the parser?
That grammar says let takes statements not arguments_call. That is the bug.

On Wed, 23 Jan 2019 at 20:41, Michael Frey michael.frey@gmx.ch wrote:

On 23.01.19 19:16, nophead wrote:

Yes it looks like a parser bug to me because there is no equals sign. I

don't

know how it gets an empty variable name and carries on. If you actually

give

it an equals sign without a variable name it does give a syntax error.

The grammer here http://files.openscad.org/grammar.xhtml says it

should be

ID = expr. How does the parser not give an error for just expr?

Modules and Functions accept named and unnamed variables.

TOK_LET beeing a valid module identifier:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L341-L345

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L351-L351

That is why I can not easily change the parser.

Any way: Let has has two more forms:

Expression:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L490

and list_comprehension_element:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L521

Eitherway, let takes arguments_call:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L628

which consists of many argument_call

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L647

and there is cause:

https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L648-L651

Note that we need this for unnamed parameters for functions and modules
calls.

To resolve the issue with let, we would need to duplicate/modify those
data structures.

I do not like the idea of increasing the parser complexity by
duplicating part of it.

I know that it is kind of hard to follow this links and my description,
but that is the nature of GNU/Bison parsers.

It takes time getting used to reading them.

With kind regards,

Michael Frey


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Sorry, I meant assignments, not arguments_call. On Wed, 23 Jan 2019 at 20:50, nop head <nop.head@gmail.com> wrote: > So the grammar documentation I found has nothing to do with the parser? > That grammar says let takes statements not arguments_call. That is the bug. > > On Wed, 23 Jan 2019 at 20:41, Michael Frey <michael.frey@gmx.ch> wrote: > >> On 23.01.19 19:16, nophead wrote: >> > Yes it looks like a parser bug to me because there is no equals sign. I >> don't >> > know how it gets an empty variable name and carries on. If you actually >> give >> > it an equals sign without a variable name it does give a syntax error. >> > >> > The grammer here http://files.openscad.org/grammar.xhtml says it >> should be >> > ID = expr. How does the parser not give an error for just expr? >> > >> >> Modules and Functions accept named and unnamed variables. >> >> TOK_LET beeing a valid module identifier: >> >> >> https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L341-L345 >> >> >> https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L351-L351 >> >> That is why I can not easily change the parser. >> >> Any way: Let has has two more forms: >> >> Expression: >> >> >> https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L490 >> >> and list_comprehension_element: >> >> >> https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L521 >> >> Eitherway, let takes arguments_call: >> >> >> https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L628 >> >> which consists of many argument_call >> >> >> https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L647 >> >> and there is cause: >> >> >> https://github.com/openscad/openscad/blob/9f861b119fa61c0027e657c452ce02549affc500/src/parser.y#L648-L651 >> >> Note that we need this for unnamed parameters for functions and modules >> calls. >> >> To resolve the issue with let, we would need to duplicate/modify those >> data structures. >> >> I do not like the idea of increasing the parser complexity by >> duplicating part of it. >> >> >> I know that it is kind of hard to follow this links and my description, >> but that is the nature of GNU/Bison parsers. >> >> It takes time getting used to reading them. >> >> >> With kind regards, >> >> Michael Frey >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >
MK
Marius Kintel
Sat, Jan 26, 2019 6:01 PM

On Jan 23, 2019, at 15:50, nop head nop.head@gmail.com wrote:

So the grammar documentation I found has nothing to do with the parser? That grammar says let takes statements not arguments_call. That is the bug.

I cannot remember how I generated that diagram. It probably was an experiment where I tried to describe the grammar using EBNF or smth., but didn't fully encode the OpenSCAD grammar..

-Marius

> On Jan 23, 2019, at 15:50, nop head <nop.head@gmail.com> wrote: > > So the grammar documentation I found has nothing to do with the parser? That grammar says let takes statements not arguments_call. That is the bug. > I cannot remember how I generated that diagram. It probably was an experiment where I tried to describe the grammar using EBNF or smth., but didn't fully encode the OpenSCAD grammar.. -Marius
NH
nop head
Sat, Jan 26, 2019 6:07 PM

Is it easy to change the parser to match the grammar? I can't see why let
should use the arguments_call rule.

On Sat, 26 Jan 2019 at 18:02, Marius Kintel marius@kintel.net wrote:

On Jan 23, 2019, at 15:50, nop head nop.head@gmail.com wrote:

So the grammar documentation I found has nothing to do with the parser?

That grammar says let takes statements not arguments_call. That is the bug.

I cannot remember how I generated that diagram. It probably was an
experiment where I tried to describe the grammar using EBNF or smth., but
didn't fully encode the OpenSCAD grammar..

-Marius


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Is it easy to change the parser to match the grammar? I can't see why let should use the arguments_call rule. On Sat, 26 Jan 2019 at 18:02, Marius Kintel <marius@kintel.net> wrote: > > On Jan 23, 2019, at 15:50, nop head <nop.head@gmail.com> wrote: > > > > So the grammar documentation I found has nothing to do with the parser? > That grammar says let takes statements not arguments_call. That is the bug. > > > I cannot remember how I generated that diagram. It probably was an > experiment where I tried to describe the grammar using EBNF or smth., but > didn't fully encode the OpenSCAD grammar.. > > -Marius > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
MK
Marius Kintel
Sat, Jan 26, 2019 6:13 PM

On Jan 26, 2019, at 13:07, nop head nop.head@gmail.com wrote:

Is it easy to change the parser to match the grammar? I can't see why let should use the arguments_call rule.

The let() function yes, but the let() module isn't part of the grammar it's just a built-in module.

-Marius

> On Jan 26, 2019, at 13:07, nop head <nop.head@gmail.com> wrote: > > Is it easy to change the parser to match the grammar? I can't see why let should use the arguments_call rule. > The let() function yes, but the let() module isn't part of the grammar it's just a built-in module. -Marius
NH
nop head
Sat, Jan 26, 2019 6:17 PM

Oh I see, that is why it has grammar of a module call, which is similar to
assignments but not quite correct.

On Sat, 26 Jan 2019 at 18:13, Marius Kintel marius@kintel.net wrote:

On Jan 26, 2019, at 13:07, nop head nop.head@gmail.com wrote:

Is it easy to change the parser to match the grammar? I can't see why

let should use the arguments_call rule.

The let() function yes, but the let() module isn't part of the grammar
it's just a built-in module.

-Marius


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Oh I see, that is why it has grammar of a module call, which is similar to assignments but not quite correct. On Sat, 26 Jan 2019 at 18:13, Marius Kintel <marius@kintel.net> wrote: > > On Jan 26, 2019, at 13:07, nop head <nop.head@gmail.com> wrote: > > > > Is it easy to change the parser to match the grammar? I can't see why > let should use the arguments_call rule. > > > The let() function yes, but the let() module isn't part of the grammar > it's just a built-in module. > > -Marius > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >