BNFC / bnfc

BNF Converter
http://bnfc.digitalgrammars.com/
586 stars 165 forks source link

3 simple issues #295

Closed maxlooo closed 4 years ago

maxlooo commented 4 years ago

Hi, Sorry about my confusion as I'm new to this..

First Issue On the webpage: http://bnfc.digitalgrammars.com/tutorial/bnfc-tutorial.html Both token CIdent (letter | (letter | digit | '_')*) ; and position token CIdent (letter | (letter | digit | '_')*) ; have similar syntax, and both have (letter | (letter.
Why is the pipe (union) used for both cases? The first letter should be a token for the first letter. And then comes the second and subsequent tokens. So the correct syntax should be: (letter (letter | digit | '_')*) ;.

Second Issue In LBNF-report.pdf page 5, it was stated that the Position Token Rule is such that datatypes defined this way will carry position information. Is the position information only for the Layout Syntax?

Third Issue In LBNF-report.pdf page 13, how does <Reg2> − <Reg2> work? Usually for normal regex syntax A-Z, it would mean letters from upper case A to Z. Would it become A-A for <Reg2> − <Reg2>? Shouldn't it be <Reg1> − <Reg2>?

Thanks!

andreasabel commented 4 years ago

Thanks, @maxlooo, I fixed the first issue in the repo. You are right, the | is wrong.

Concerning the other issues, I do not know what the problem is or what your proposal is how to write things differently.

Is the position information only for the Layout Syntax?

No, it is not needed for layout. You can use it for error reporting, for instance.

how does <Reg2> − <Reg2> work? Usually for normal regex syntax A-Z, it would mean letters from upper case A to Z. Would it become A-A for <Reg2> − <Reg2>? Shouldn't it be <Reg1> − <Reg2>?

This is not a range expression, but a set difference. Consequently, <Reg2> − <Reg2> would not match any string, it is the zero regular expression. (This might not work on all backends, thoughl)