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 same
   do 100 i = 1, 2, 3 and do1 00  i= 1 ,2   , 3 were the same.

We now have a better understanding of BNF and compiling. The issue 
should be one of support. Towards this end let me make the following 
observations:


1.    Spaces should be used as delimiters because it makes parsing easier.
2.    If spaces are to have a special place then, if possible, the issue 
of treating spaces should be in flex.
3.    If flex does not work, then the parser must be used. As in 
(Fortran II, IV, 77)


   doloop : "do" number id "=" number "," number "," number
 |  id "=" number "," number "," number
   and I realize this is not complete, this is only an example.

   The thing that distinguishes an assignment (id "=" number) from a
   doloop is the ",".

Based on your example I assume that having flex change "1 23" into "123" 
would be a better approach then using the parser. In this case it might 
be better to substitute some else for a space. If I remember correctly, 
Ada allows 1_234_567 whereas you would (perhaps) write this as "1 234 567".


As to the reason that spaces are used in your application I think that 
this will make life difficult for you, and I personally would not do it. 
In similar manner some of your comments do not accord well with current 
practices, such as the separate meanings given "- 123" and "-123". I 
think you will face increasing difficulty in implementing some of your 
ideas and I would encourage you to redirect your efforts to more 
conventional approaches.


The example given on typesetters has little relevance. Typesetters deal 
with the visual spectra. Parsers and lexers do not deal with the visual 
spectra, and they have well though out means of describing things.


But, it's your code and your issue and I don't care.

art

On 9/23/2022 4:52 AM, AW wrote:

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 the same...
That feels more natural to me...
But I noticed that it was quite tricky to teach flex the difference
between sign and unary-inversion-operator... 

On 2022-09-23T12:47:23CEST Evan Lavelle  wrote:

It's a programming language, not maths. There are, of course, languages
in which spaces necessarily mean something. But I can't bring myself to
use any of them.


Maybe this example demonstrates a use: "123" is usually not the same as "12  
    3"...
Maybe something like "1 234 567" might be used in newspapers for "1234567",
but the professional typesetters use special space symbols then,
which are thinner and they stick hard to their neighbors,
so that a newline is impossible at them... 

-arne




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 the same...
That feels more natural to me...
But I noticed that it was quite tricky to teach flex the difference
between sign and unary-inversion-operator... 

On 2022-09-23T12:47:23CEST Evan Lavelle  wrote:
> It's a programming language, not maths. There are, of course, languages 
> in which spaces necessarily mean something. But I can't bring myself to 
> use any of them.
>
Maybe this example demonstrates a use: "123" is usually not the same as "12 
 3"...
Maybe something like "1 234 567" might be used in newspapers for "1234567",
but the professional typesetters use special space symbols then,
which are thinner and they stick hard to their neighbors,
so that a newline is impossible at them... 

-arne




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 mean something. But I can't bring myself to 
use any of them.


I don't like it, but chacun a son gout.