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
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/
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:
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:
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
"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?
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:
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:
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:
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:
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
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
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
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
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