Literals UO"2C" = B"011_CCC"?

V

valtih1978

Guest
LRM says that literally
UO"2C" -- Equivalent to B"011_CCC" -- that is a copy and paste
Octavian 2 has binary equivalent of 010 rather than 011, isn't it?
 
I discovered it doing some parsing. I have also noticed that I cannot
parse the bit string literals because

bit_string_literal ::= [ integer ] base_specifier " [ bit_value ] "

Please note that bit_value is enclosed into the quotes.

bit_value ::= graphic_character { [ underline ] graphic_character }
graphic_character ::= basic_graphic_character | lower_case_letter |
other_special_character
basic_graphic_character ::=
upper_case_letter | digit | special_character | space_character

where special characters are " # & ' () * + , - . / : ; < = > ? @ [ ] _
` -- Please note that the first special character is exactly the
quotation mark. Such definition makes the bit_string_literal closing
literal a part of the literal itself and parser runs into the end of
stream. How do you handle such cases?
 
On Friday, December 25, 2015 at 11:43:41 AM UTC-5, valtih1978 wrote:
I discovered it doing some parsing. I have also noticed that I cannot
parse the bit string literals because

bit_string_literal ::= [ integer ] base_specifier " [ bit_value ] "

Please note that bit_value is enclosed into the quotes.

bit_value ::= graphic_character { [ underline ] graphic_character }
graphic_character ::= basic_graphic_character | lower_case_letter |
other_special_character
basic_graphic_character ::=
upper_case_letter | digit | special_character | space_character

where special characters are " # & ' () * + , - . / : ; < = > ? @ [ ] _
` -- Please note that the first special character is exactly the
quotation mark. Such definition makes the bit_string_literal closing
literal a part of the literal itself and parser runs into the end of
stream. How do you handle such cases?

The double quote that is to be included in the literal would have to be preceded by a backslash. Also note the definition of a string literal is:

string_literal ::= " { graphic_character } "

You would have the same issue here trying to insert a " into a string.

Kevin Jennings
 
On 12/25/2015 11:43 AM, valtih1978 wrote:
I discovered it doing some parsing. I have also noticed that I cannot
parse the bit string literals because

bit_string_literal ::= [ integer ] base_specifier " [ bit_value ] "

Please note that bit_value is enclosed into the quotes.

bit_value ::= graphic_character { [ underline ] graphic_character }
graphic_character ::= basic_graphic_character | lower_case_letter |
other_special_character
basic_graphic_character ::=
upper_case_letter | digit | special_character | space_character

where special characters are " # & ' () * + , - . / : ; < = > ? @ [ ] _
` -- Please note that the first special character is exactly the
quotation mark. Such definition makes the bit_string_literal closing
literal a part of the literal itself and parser runs into the end of
stream. How do you handle such cases?

So you are trying to write a parser for VHDL? Obviously you scan the
input text until you encounter another quote character. I know some
languages allow quotes to be embedded in strings by using two quotes in
a row, so the scanning is not so simple. You have to scan for a quote
followed by a character that is not a quote. But I don't think VHDL
does this.

--

Rick
 
So you are trying to write a parser for VHDL? Obviously you scan the
input text until you encounter another quote character.

Obviously, I am doing quite the opposite thing. I follow the grammar
rules instead of scanning for the second mark. I have failed exactly
because not following this simplistic approach. Probably I am the only
one on the planet who does not do that.

I know some
languages allow quotes to be embedded in strings by using two quotes in
a row, so the scanning is not so simple. You have to scan for a quote
followed by a character that is not a quote. But I don't think VHDL
does this.

The duplication of quotation mark is stipulated in the `string_literal`
chapter in LRM. It is also interesting how good this stipulation matches
with the grammar rules, presented in parallel. Yet, I do not see such a
remark in the `bit_string_literal` rule, discussed separately in the LRM.

I looked into example parser,
https://sourceforge.net/p/zamiacad/code/ci/master/tree/src/org/zamia/vhdl/vhdl2008/VHDL2008.jj.
They simply throw the quotation mark out of the special character list
and then add it separately as an alternative to graphic_character in the
string_literal definition. But they do not supply " char in the bit
string definition, which means that they do not support " in the
bitstring literals.

I am looking to know how it is supposed to be done and what does VHDL
community does.
 
On 12/26/2015 1:28 PM, valtih1978 wrote:
So you are trying to write a parser for VHDL? Obviously you scan the
input text until you encounter another quote character.

Obviously, I am doing quite the opposite thing. I follow the grammar
rules instead of scanning for the second mark. I have failed exactly
because not following this simplistic approach. Probably I am the only
one on the planet who does not do that.

I know some
languages allow quotes to be embedded in strings by using two quotes in
a row, so the scanning is not so simple. You have to scan for a quote
followed by a character that is not a quote. But I don't think VHDL
does this.

The duplication of quotation mark is stipulated in the `string_literal`
chapter in LRM. It is also interesting how good this stipulation matches
with the grammar rules, presented in parallel. Yet, I do not see such a
remark in the `bit_string_literal` rule, discussed separately in the LRM.

I looked into example parser,
https://sourceforge.net/p/zamiacad/code/ci/master/tree/src/org/zamia/vhdl/vhdl2008/VHDL2008.jj.
They simply throw the quotation mark out of the special character list
and then add it separately as an alternative to graphic_character in the
string_literal definition. But they do not supply " char in the bit
string definition, which means that they do not support " in the
bitstring literals.

I am looking to know how it is supposed to be done and what does VHDL
community does.

I'm unclear. If you are following "all" the grammar rules, what exactly
is your concern?

--

Rick
 
> You would have the same issue here trying to insert a " into a string.

Where did you read about that?

Also note the definition of a string literal is:

string_literal ::= " { graphic_character } "

You would have the same issue here trying to insert a " into a string.

Yes, I reported that already to the rickman. I reported that I have
discovered that LRM mandates user to duplicate the double quote marks in
the VHDL source string literals to produce a single quotation in the
running program. The Bible says so textually but LRM grammar productions
seem to contradict the text. LRM does not even stipulate this issue in
the bit_string_literal declaration at all. So I wonder, how did you know
that \" must be used there instead of quotation duplication? Did you
confuse user input with mine parser code, written in derivative of C?
 
On 12/26/2015 7:59 PM, valtih1978 wrote:
You would have the same issue here trying to insert a " into a string.

Where did you read about that?

Also note the definition of a string literal is:

string_literal ::= " { graphic_character } "

You would have the same issue here trying to insert a " into a string.

Yes, I reported that already to the rickman. I reported that I have
discovered that LRM mandates user to duplicate the double quote marks in
the VHDL source string literals to produce a single quotation in the
running program. The Bible says so textually but LRM grammar productions
seem to contradict the text. LRM does not even stipulate this issue in
the bit_string_literal declaration at all. So I wonder, how did you know
that \" must be used there instead of quotation duplication? Did you
confuse user input with mine parser code, written in derivative of C?

Except you showed BNF for "bit_string_literal" while the double quote
only had meaning in the more literal "string_literal". Is the
"string_literal" defined the same way? If your problem is in the
"bit_string_literal" why are you trying to embed quotes in it?

--

Rick
 
Except you showed BNF for "bit_string_literal" while the double quote
only had meaning in the more literal "string_literal".

Who says that any why does LRM say otherwise? I have demonstrated the
grammar that says that all special characters, including the quotes, are
allowed in the bit string literal, in the same way as they are included
in the string literal.

Is the
"string_literal" defined the same way?

You are responding under KJ's remark saying that the string literal

string_literal ::= " { graphic_character } "

is defined the same way. So, I do not understand this the question.

If your problem is in the
"bit_string_literal" why are you trying to embed quotes in it?

Because I tried to implement the spec rather than my fantasies or to
embed the quotes into the string. I think that if spec admits embedded
quotes, they must be supported.
 
On 12/27/2015 2:48 AM, valtih1978 wrote:
Except you showed BNF for "bit_string_literal" while the double quote
only had meaning in the more literal "string_literal".

Who says that any why does LRM say otherwise? I have demonstrated the
grammar that says that all special characters, including the quotes, are
allowed in the bit string literal, in the same way as they are included
in the string literal.

Is the
"string_literal" defined the same way?

You are responding under KJ's remark saying that the string literal

string_literal ::= " { graphic_character } "

is defined the same way. So, I do not understand this the question.

If your problem is in the
"bit_string_literal" why are you trying to embed quotes in it?

Because I tried to implement the spec rather than my fantasies or to
embed the quotes into the string. I think that if spec admits embedded
quotes, they must be supported.

You mean you tried to implement the BNF which seems to not describe the
language 100%. To think that a bit literal can contain every letter of
the alphabet is a bit silly. They can't because a bit string literal
only has meaning when it contains the few characters that are allowed.

The VHDL spec is more than just the BNF lists.

--

Rick
 
You mean you tried to implement the BNF which seems to not describe the
language 100%.The VHDL spec is more than just the BNF lists.

Yes, I tried. Yes, BNF is incomplete and water is liquid. But the
problem that I address here is that BNF seems to contain a fatal error.
Saying that I see it because it does not specify the language 100% is a
little bit inappropriate, isn't it? It is like if instruction to go
shopping would instruct you to kill youself at one point. You may defend
the instruction saying that "it is incomplete" but this would make the
situation even more ridiculous. And it does.

To think that a bit literal can contain every letter of
the alphabet is a bit silly.

What if BNF admits every character? Have you ever looked at the
appropriate lines I have copy pasted before starting to teach me? I do
not need to learn the kid stuff. I have a concrete question and need to
know where is the error concretely.

They can't because a bit string literal
only has meaning when it contains the few characters that are allowed.

Any user-defined literal or identifier falls into this category.
Everything that user defines must consist solely of few allowed
characters. But, it is again as informative as "the water is wet" above.
Simply saying "only permitted characters make sense" does not point us
to which of the characters are permitted exactly, isn't it?

Can you stop speaking misteriously with insinuations, and start telling
exactly which characters are defined legit in LRM. I do not tolerate
when people ignore my questions or draw them into 0-information, I hate
intellectual pretense and not going to learn trivial, obvious things.
 
On 12/27/2015 2:01 PM, valtih1978 wrote:
You mean you tried to implement the BNF which seems to not describe the
language 100%.The VHDL spec is more than just the BNF lists.

Yes, I tried. Yes, BNF is incomplete and water is liquid. But the
problem that I address here is that BNF seems to contain a fatal error.
Saying that I see it because it does not specify the language 100% is a
little bit inappropriate, isn't it? It is like if instruction to go
shopping would instruct you to kill youself at one point. You may defend
the instruction saying that "it is incomplete" but this would make the
situation even more ridiculous. And it does.

To think that a bit literal can contain every letter of
the alphabet is a bit silly.

What if BNF admits every character? Have you ever looked at the
appropriate lines I have copy pasted before starting to teach me? I do
not need to learn the kid stuff. I have a concrete question and need to
know where is the error concretely.

They can't because a bit string literal
only has meaning when it contains the few characters that are allowed.

Any user-defined literal or identifier falls into this category.
Everything that user defines must consist solely of few allowed
characters. But, it is again as informative as "the water is wet" above.
Simply saying "only permitted characters make sense" does not point us
to which of the characters are permitted exactly, isn't it?

Can you stop speaking misteriously with insinuations, and start telling
exactly which characters are defined legit in LRM. I do not tolerate
when people ignore my questions or draw them into 0-information, I hate
intellectual pretense and not going to learn trivial, obvious things.

I have no idea what you are complaining about. You have the VHDL spec,
it clearly says you can embed the quote character in a string by using
two in succession. What are you going on about? Either implement the
language or give up. I don't know any other alternatives.

I've already suggested that you need to ignore the BNF where it is wrong.

Or is there a useful question in there somewhere that I missed?

If you want, send me a copy of the version of the spec you are
implementing and I'll take a look to show you where the various strings
are fully explained. I believe I have PDFs of each version other than
2008.

--

Rick
 
On 12/27/2015 2:01 PM, valtih1978 wrote:
You mean you tried to implement the BNF which seems to not describe the
language 100%.The VHDL spec is more than just the BNF lists.

Yes, I tried. Yes, BNF is incomplete and water is liquid. But the
problem that I address here is that BNF seems to contain a fatal error.
Saying that I see it because it does not specify the language 100% is a
little bit inappropriate, isn't it? It is like if instruction to go
shopping would instruct you to kill youself at one point. You may defend
the instruction saying that "it is incomplete" but this would make the
situation even more ridiculous. And it does.

To think that a bit literal can contain every letter of
the alphabet is a bit silly.

What if BNF admits every character? Have you ever looked at the
appropriate lines I have copy pasted before starting to teach me? I do
not need to learn the kid stuff. I have a concrete question and need to
know where is the error concretely.

They can't because a bit string literal
only has meaning when it contains the few characters that are allowed.

Any user-defined literal or identifier falls into this category.
Everything that user defines must consist solely of few allowed
characters. But, it is again as informative as "the water is wet" above.
Simply saying "only permitted characters make sense" does not point us
to which of the characters are permitted exactly, isn't it?

Can you stop speaking misteriously with insinuations, and start telling
exactly which characters are defined legit in LRM. I do not tolerate
when people ignore my questions or draw them into 0-information, I hate
intellectual pretense and not going to learn trivial, obvious things.

Here are the appropriate sections from the 1993 standard...

String Literals
String literals are composed as a sequence of graphic characters
(letters, digits, special characters) enclosed between two quotation
marks (double quotes). They are usually used for warnings or reports
which are displayed during simulation (Example 3).


Bit string literals
Bit string literals represent values of string literals that denote
sequences of extended digits, range of which depends on the specified base.
The base specifier determines the base of the digits: letter B used as a
base specifier denotes binary digits (0 or 1), letter O - octal digits
(0 to 7) and letter X - hexadecimal (digits 0 to 9 and letters A to F,
case insensitive). Underlines can be used to increase readability and
have no impact on the value.

All values specified as bit string literals are converted into binary
representation without underlines. Binary strings remain unchanged (only
underlines are removed), each octal digit is converted into three bits
and each hexadecimal into four bits (Example 4).


What is not clear about that?

--

Rick
 
On Sunday, December 27, 2015 at 2:01:13 PM UTC-5, valtih1978 wrote:
You mean you tried to implement the BNF which seems to not describe the
language 100%.The VHDL spec is more than just the BNF lists.

Yes, I tried. Yes, BNF is incomplete and water is liquid. But the
problem that I address here is that BNF seems to contain a fatal error.

There is more to the language specification than the BNF. In this particular case, the following text is relevant (all from VHDL-2008)

Section 15.8 (Bit String Literals): "A bit string literal has a value that is a string literal"

Section 15.7 (String literals): "If a quotation mark value is to be represented in the sequence of character values, then a pair of adjacent quotation marks shall be written at the corresponding place within the string literal. (This means that a string literal that includes two adjacent quotation marks is never interpreted as two adjacent string literals.)"

There is an example which shows that """" (four consecutive quotation marks) is a string literal of length 1. In order for two consecutive quotation marks to be allowed as a 'special_character', it would have to define the quotation mark character to be one of the special characters since you can't have two of something until you at least have one. They could possibly have added a footnote to indicate that really the special character is "", but they didn't. But they did explain how you get a " by using "". If you want to fixate that the BNF has a 'fatal error', knock yourself out, but to do that you have to ignore what was specifically explained in section 15.7 regarding the quotation mark.

If you'd like another example of a discrepancy between BNF and the text, here you go...
Section 5.2.3.1 (General Integer types)
"An implementation may restrict the bounds of the range constraint of integer types other than type
universal_integer. However, an implementation shall allow the declaration of any integer type whose range is wholly contained within the bounds -2147483647 and +2147483647 inclusive."

Section 9.3.2 Literals
"numeric_literal ::= abstract_literal | physical_literal
Numeric literals include literals of the abstract types universal_integer and universal_real, as well as literals of physical types. Abstract literals are defined in 15.5; physical literals are defined in 5.2.4.1."

So, clearly -1 should be considered a numeric literal. But now look at the BNF. abstract_literals are numeric_literals.

Section 15.5.1: abstract_literal ::= decimal_literal
Section 15.5.2: decimal_literal ::= integer [ . integer ] [ exponent ]
integer ::= digit { [ underline ] digit }
exponent ::= E [ + ] integer | E - integer

Now, where is the minus sign in the BNF? It's not there. So while the section that defines integer literals specifically says that -2147483647 is a literal, the BNF does not support this since there is no way to put in the minus sign per the BNF. So these two sections of the specification conflict. To me, a reasonable interpretation to make is that since there is a conflict with the specification itself, that there should be no flagging of an error by a tool if source code adheres to the narrative but not the BNF. The BNF is no more 'correct' than narrative (unless there is such a disclaimer somewhere in the specification that says so). So the text -1 should be interpreted as an integer literal. Not all folks agree and they think that the BNF must trump narrative and think that they are making their tool adhere 'closer' to the standard by using this interpretation when it is convenient...but they are ignoring something specifically called out in the standard. Oh well.

Kevin Jennings
 
On Sun, 27 Dec 2015 17:33:10 -0800, KJ wrote:

If you'd like another example of a discrepancy between BNF and the text,
here you go...
Section 5.2.3.1 (General Integer types)
"An implementation may restrict the bounds of the range constraint of
integer types other than type universal_integer. However, an
implementation shall allow the declaration of any integer type whose
range is wholly contained within the bounds -2147483647 and +2147483647
inclusive."

The term "literal" does not appear here, nor is there any statement that
every valid value is directly representable as a literal. ( More
precisely, any such statement is not part of the quoted material. I
haven't found one elsewhere either)

Section 9.3.2 Literals "numeric_literal ::= abstract_literal |
physical_literal Numeric literals include literals of the abstract types
universal_integer and universal_real, as well as literals of physical
types. Abstract literals are defined in 15.5; physical literals are
defined in 5.2.4.1."

Nor does this state that the range of literals covers the entire range of
values.

> So, clearly -1 should be considered a numeric literal.

I think that requires an inference that is not stated in the quoted
passages above.

But now look at
the BNF. abstract_literals are numeric_literals.

Section 15.5.1: abstract_literal ::= decimal_literal Section 15.5.2:
decimal_literal ::= integer [ . integer ] [ exponent ]
integer ::= digit { [ underline ] digit } exponent ::= E [ + ]
integer | E - integer

Now, where is the minus sign in the BNF? It's not there.

Which suggests an alternative inference : only the naturals are
representable as literals; negative values are expressed as the result of
a negation operator on a positive literal.

So while the
section that defines integer literals specifically says that -2147483647
is a literal,

Where exactly?

the BNF does not support this since there is no way to put
in the minus sign per the BNF. So these two sections of the
specification conflict.

The conflict exists only if the former section of the specification
actually exists, which is not established by the quoted material.

To me, a reasonable interpretation to make is
that since there is a conflict with the specification itself, that there
should be no flagging of an error by a tool if source code adheres to
the narrative but not the BNF.

But in the absence of conflict, there is no need to deviate from the BNF.

So the text -1 should be interpreted as an
integer literal. Not all folks agree and they think that the BNF must
trump narrative

The BNF unambiguously parses -1 as [unary operator][literal]. If you
additionally allow negative literals, how do you resolve the resulting
ambiguous parsing?

Considering also that operators are overloadable on return type...

-- Brian
 
On Monday, December 28, 2015 at 8:11:29 AM UTC-5, Brian Drummond wrote:
On Sun, 27 Dec 2015 17:33:10 -0800, KJ wrote:

If you'd like another example of a discrepancy between BNF and the text,
here you go...
Section 5.2.3.1 (General Integer types)
"An implementation may restrict the bounds of the range constraint of
integer types other than type universal_integer. However, an
implementation shall allow the declaration of any integer type whose
range is wholly contained within the bounds -2147483647 and +2147483647
inclusive."

The term "literal" does not appear here,
snip
More precisely, any such statement is not part of the quoted material. I
haven't found one elsewhere either)

You didn't look too hard. I see you chose to write this before you read the next paragraph that I wrote or the section that I referenced in the specification. Maybe you'll read it this time.

section 5.2.3.1 (Integer types general)
"Integer literals are the literals of an anonymous predefined type that is called universal_integer in this standard. Other integer types have no literals. However, for each integer type there exists an implicit conversion that converts a value of type universal_integer into the corresponding value (if any) of the integer type (see 9.3.6)."

Section 9.3.2 Literals "numeric_literal ::= abstract_literal |
physical_literal Numeric literals include literals of the abstract types
universal_integer and universal_real, as well as literals of physical
types. Abstract literals are defined in 15.5; physical literals are
defined in 5.2.4.1."

Nor does this state that the range of literals covers the entire range of
values.

You've gone off the deep end now. The sections I've cited do establish the range.

So, clearly -1 should be considered a numeric literal.

I think that requires an inference that is not stated in the quoted
passages above.

Then you're part of the small group that accepts:
1. "Integer literals are the literals of an anonymous predefined type that is called universal_integer" (5.2.3.1)
2. "Numeric literals include literals of the abstract types universal_integer" (9.3.2)
3. "integer type whose range is wholly contained within the bounds -2147483647 and +2147483647 inclusive." (5.2.3.1)
4. "...may restrict the bounds of the range constraint of integer types other than type universal_integer" 5.2.3.1

But do not think that -1 is a numeric literal.

Now, where is the minus sign in the BNF? It's not there.

Which suggests an alternative inference : only the naturals are
representable as literals; negative values are expressed as the result of
a negation operator on a positive literal.

Which contradicts the previously cited section 5.2.3.1 "integer type whose range is wholly contained within the bounds -2147483647 and +2147483647 inclusive."

the BNF does not support this since there is no way to put
in the minus sign per the BNF. So these two sections of the
specification conflict.

The conflict exists only if the former section of the specification
actually exists, which is not established by the quoted material.

It is established, you don't accept it. There is a difference. Or if you'd prefer, I don't accept the position that you've put forth and you do not accept mine.

The BNF unambiguously parses -1 as [unary operator][literal]. If you
additionally allow negative literals, how do you resolve the resulting
ambiguous parsing?

Correcting the problem is not my job, I'm simply pointing out the discrepancy. As you already know, the discrepancy has also been pointed out to the proper authorities who decline official comment as representatives of the VHDL standard.

The narrative of the specification establishes that negative numbers are numeric literals. The BNF does not. If there is something in the language specification that says the narrative can be ignored in case of a conflict with the BNF, then you would do well to quote that rather than trundling down the path you're on.

Kevin Jennings
 
The LRM is the conjunction of the BNF rules and the text. If a rule is concisely and accurately specified in the BNF, then there is no additional text. OTOH, some of the BNF is more general and the text provides further constraints.

Perhaps you can download one of the free simulators and test out the cases you are concerned about. IE, how other simulators handle " in a string.
 
On 28.12.2015 3:33, KJ wrote:
There is more to the language specification than the BNF. In this
particular case, the following text is relevant (all from VHDL-2008)

Section 15.7 (String literals): "If a quotation mark value is to
be represented in the sequence of character values, then a pair
of adjacent quotation marks shall be written at the corresponding
place within the string literal. (This means that a string literal
that includes two adjacent quotation marks is never interpreted as
two adjacent string literals.)"

There is an example which shows that """" (four consecutive quotation
marks) is a string literal of length 1.

Yes, I know. We have established this already.

Section 15.8 (Bit String Literals): "A bit string literal has a
value that is a string literal"

I have overlooked it indeed.

But, think a little. What does it mean? IMO, it addresses the output of
the conversion. The bit string literal is a function that takes integers
in various bases and produces binary strings. It produces string
literals. Binary vectors are nothing more than just string literals.
There is a bit_string_literal form which allows you to avoid specifying
every single bit (which is a pain even for short 8-bit words) in the
more compact form, like 16"FFFFFFFF" instead of 32 ones. The bit string
literal supports special characters for don't care-like bit strings. The
standard just says that characters besides digits and "ABCDF" are
copy-pasted into the output string literal. So, 16"F-" is translated
into "1111----". The result is string_literal. This way, standard admits
double quotes, if you place them instead of don't care '-' sign. Now,
what does the fact that value is the same as quadrupled '"' character
tell to us? What should the input bit_string_literal look like?

Does LRM stipulate this case? Is it ok? And what should poor compiler do?

To revise,
string_literal ::= " { graphic_character } "
bit_string_literal ::= [ integer ] base_specifier " [ bit_value ] "
bit_value ::= graphic_character { [ underline ] graphic_character }
graphic_character :: == something including quotation mark

if user enters "" for every " in the parsed string_literal, what should
be the input for bit_string_literal to achieve the same result?

If you'd like another example of a discrepancy between BNF and the text, here you go...
Section 5.2.3.1 (General Integer types)
"An implementation may restrict the bounds of the range constraint of integer types other than type
universal_integer. However, an implementation shall allow the declaration of any integer type whose range is wholly contained within the bounds -2147483647 and +2147483647 inclusive."

Section 9.3.2 Literals
"numeric_literal ::= abstract_literal | physical_literal
Numeric literals include literals of the abstract types universal_integer and universal_real, as well as literals of physical types. Abstract literals are defined in 15.5; physical literals are defined in 5.2.4.1."

So, clearly -1 should be considered a numeric literal. But now look at the BNF. abstract_literals are numeric_literals.

Section 15.5.1: abstract_literal ::= decimal_literal
Section 15.5.2: decimal_literal ::= integer [ . integer ] [ exponent ]
integer ::= digit { [ underline ] digit }
exponent ::= E [ + ] integer | E - integer

Now, where is the minus sign in the BNF? It's not there. So while the section that defines integer literals specifically says that -2147483647 is a literal, the BNF does not support this since there is no way to put in the minus sign per the BNF. So these two sections of the specification conflict. To me, a reasonable interpretation to make is that since there is a conflict with the specification itself, that there should be no flagging of an error by a tool if source code adheres to the narrative but not the BNF. The BNF is no more 'correct' than narrative (unless there is such a disclaimer somewhere in the specification that says so). So the text -1 should be interpreted as an integer literal. Not all folks agree and they think that the BNF must trump narrative and think that they are making their tool adhere 'closer' to the standard by using this interpretation when it is convenient...but they are ignoring something specifically called out in the standard. Oh well.

Uou say that narrative admits the negative integers whereas there is no
way to enter them in BNF. You call it a contradiction but I do not see
any problem here. You simply allocate internal variable of Int type for
every literal that you keep in your tool and do not use the negative
part of it. You will get negatives by applying the "-" operation to the
literal, as Brain pointed out. It is fine. The user writes -100 and it
is parsed as operation followed by literal. The code is parsed,
elaboreated and smoothly processed further by the back end. It is not
efficient but it is not stopper. Where is the conflict, where is the
problem?

I do not think that you can treat it equally with the issues that I have
raised. The double quote and physical unit is simply unparsable.
Yestuday, I have discovered one more conflict of this kind.

function_call ::= name [(args)]

How do you distinguish it from a simple identifier if arguments are not
specified?
 
On 12/28/2015 3:46 PM, valtih1978 wrote:
How do you distinguish it from a simple identifier if arguments are not
specified?

Context. It is not at all unusual for interpretation to depend on context.

--

Rick
 
On Monday, December 28, 2015 at 3:46:36 PM UTC-5, valtih1978 wrote:
On 28.12.2015 3:33, KJ wrote:
Section 15.8 (Bit String Literals): "A bit string literal has a
value that is a string literal"

I have overlooked it indeed.

snip> Now, what does the fact that value is the same as quadrupled '"'
character tell to us? What should the input bit_string_literal look like?

Section 15.8, says "For a character in the simplified value that is not interpreted as an extended digit, each character in the replacement sequence is the same as the character replaced."

So if you run across a " or a "" in the input, it should be copied over as-is into the output unchanged.

Does LRM stipulate this case? Is it ok? And what should poor compiler do?

Since a " would end up not being a legal bit value when you're all done converting and an error is going to be flagged anyway, I would think a compiler could stop and flag the error at that point.

<snip>
Uou say that narrative admits the negative integers whereas there is no
way to enter them in BNF. You call it a contradiction but I do not see
any problem here. You simply allocate internal variable of Int type for
every literal that you keep in your tool and do not use the negative
part of it. You will get negatives by applying the "-" operation to the
literal, as Brain pointed out. It is fine.

No it's not. There are instances where it mattered. One particular tool took a declaration that had a negative number where a numeric literal was expected and complained saying that it was not a numeric_literal.

I don't want to hijack this thread to go into that issue any further. My only point in bringing it up here is that since the LRM is produced by human beings, it is not out of the question that the BNF does not comply with the narrative but that does not imply that the narrative is wrong. Unless specifically disclaimed, the whole document is on equal footing.

I do not think that you can treat it equally with the issues that I have
raised.

Right, only things that you bring up are important. Gotcha.

The double quote and physical unit is simply unparsable.
Well, other tools I assume are able to parse it, although I admit I haven't bothered to try to insert a " into a bit string to see what happens. I'm only giving my take on why the "" appears to be the way to include the " and that the LRM does specify this (in my opinion, maybe not yours)

Yestuday, I have discovered one more conflict of this kind.

function_call ::= name [(args)]

How do you distinguish it from a simple identifier if arguments are not
specified?

In your example, 'name' will be the name of the function that has already been defined previously in the source code as a function with no arguments. The vocabulary keeps expanding as source code is processed. It starts with only the keywords, then adds on everything else that gets declared. Not sure why you see any issue here.

Kevin Jennings
 

Welcome to EDABoard.com

Sponsor

Back
Top