Re: how to solve this reduce/reduce conflict?

2022-09-23 Thread lostbits
To interject. The 'modern' notion of spaces is in accord to how we now understand how parser-generators work, most particularly how BNF works. But in times long past this understanding was not understood. In Fortran II, IV, 77 spaces had no meaning. This meant all of: xy and x y were the

Re: how to solve this reduce/reduce conflict?

2022-09-23 Thread AW
On 22/09/2022 21:34, Derek Clegg wrote: > This is horrid, and not how math works. Spaces necessarily mean nothing, > and imbuing them with meaning is nonsense. > if u want to say one-hundred-twenty-three u would not think, that C understands "1 23"... I feel like "-123" and "- 123" are not quite

Re: how to solve this reduce/reduce conflict?

2022-09-23 Thread Evan Lavelle
On 22/09/2022 21:34, Derek Clegg wrote: This is horrid, and not how math works. Spaces necessarily mean nothing, and imbuing them with meaning is nonsense. Please reconsider your grammar. It's a programming language, not maths. There are, of course, languages in which spaces necessarily

Re: how to solve this reduce/reduce conflict?

2022-09-22 Thread Derek Clegg
This is horrid, and not how math works. Spaces necessarily mean nothing, and imbuing them with meaning is nonsense. Please reconsider your grammar. > On Sep 22, 2022, at 8:28 PM, Lukas Arsalan wrote: > > On 2022-09-22T15:54:31UTC Hans Åberg wrote: >> Context switches are best avoided

Re: how to solve this reduce/reduce conflict?

2022-09-22 Thread Lukas Arsalan
On 2022-09-22T15:54:31UTC Hans Åberg wrote: > Context switches are best avoided unless absolutely necessary, in my > experience. > So if one designs ones own language, it might be good to try to avoid them > by a change in the grammar. > OK... I know that there are no signed numbers usually...

Re: how to solve this reduce/reduce conflict?

2022-09-22 Thread Hans Åberg
> On 22 Sep 2022, at 21:02, Lukas Arsalan wrote: > > On 2022-09-22T15:54:31UTC Hans Åberg wrote: >> Context switches are best avoided unless absolutely necessary, in my >> experience. >> So if one designs ones own language, it might be good to try to avoid them >> by a change in the grammar.

Re: how to solve this reduce/reduce conflict?

2022-09-22 Thread Lukas Arsalan
On 2022-09-22T07:57:45UTC Hans Åberg wrote: > On 22 Sep 2022, at 08:30, Lukas Arsalan wrote: >> [1] -1 --> "num" >> [2] 1-2 --> "num" "-" "num" >> [3] (-1^-2) --> "(" "num" "^" "num" ")" >> [4] 1--2 --> "num" "-" "num" >> [5] 1---3 --> "num" "-" "-" "num" >> [6] 1-2^3 --> "num" "-" "num" "^"

Re: how to solve this reduce/reduce conflict?

2022-09-22 Thread Hans Åberg
> On 22 Sep 2022, at 16:52, Lukas Arsalan wrote: > > On 2022-09-22T07:57:45UTC Hans Åberg wrote: >> On 22 Sep 2022, at 08:30, Lukas Arsalan wrote: >>> [1] -1 --> "num" >>> [2] 1-2 --> "num" "-" "num" >>> [3] (-1^-2) --> "(" "num" "^" "num" ")" >>> [4] 1--2 --> "num" "-" "num" >>> [5] 1---3

Re: how to solve this reduce/reduce conflict?

2022-09-22 Thread Hans Åberg
> On 22 Sep 2022, at 08:30, Lukas Arsalan wrote: > > Hi, > > At 2022-09-22T07:08:55CEST Akim Demaille wrote: >> This snippet is clearly ambiguous, since it allows two different parses of >> -1, which -Wcex nicely showed. >> > yes. right. > >> If I were you, I would handle this in the

Re: how to solve this reduce/reduce conflict?

2022-09-22 Thread Lukas Arsalan
Hi, At 2022-09-22T07:08:55CEST Akim Demaille wrote: > This snippet is clearly ambiguous, since it allows two different parses of > -1, which -Wcex nicely showed. > yes. right. > If I were you, I would handle this in the scanner.  IOW, the scanner should > be extended to support signed

Re: how to solve this reduce/reduce conflict?

2022-09-21 Thread Akim Demaille
Hi, > Le 21 sept. 2022 à 23:31, Lukas Arsalan a écrit : > > exp: >"-" "num"{ $$ = -*new Float($2); std::cout << "NUMinv" << $$ > << std::endl; } > | "num"{ $$ = new Float($1); std::cout << "num" << $$ << > std::endl; } > | "-" exp { $$ = -*$2;