Jump to page: 1 2
Thread overview
[Issue 1351] New: Discrepancies in the language specification
Jul 20, 2007
d-bugmail
Jul 20, 2007
d-bugmail
Jul 20, 2007
BCS
Jul 20, 2007
d-bugmail
Jul 26, 2007
d-bugmail
Jul 27, 2007
d-bugmail
Jul 27, 2007
d-bugmail
Jul 31, 2007
d-bugmail
Jul 31, 2007
d-bugmail
Jul 31, 2007
d-bugmail
Jul 31, 2007
d-bugmail
Jun 14, 2010
Ellery Newcomer
Nov 09, 2010
Walter Bright
Nov 09, 2010
Ellery Newcomer
Nov 09, 2010
Ellery Newcomer
Nov 09, 2010
Walter Bright
Nov 09, 2010
Ellery Newcomer
Nov 09, 2010
Walter Bright
July 20, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1351

           Summary: Discrepancies in the language specification
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: aziz.kerim@gmail.com


In the process of writing my own lexer and parser of the D programming language, I have found plenty of discrepancies in the language specification and I have some suggestions. Here we go:

.) module.html
The DeclDef rule has many subrules which should link to the page where they're
defined.
        DebugSpecification // Replace with ConditionalDeclaration
        VersionSpecification // ditto

.) declaration.html
Introduce a new rule "IntegralType" which will contain only the integral types
of D (bool - void from BasicType). This is useful for a subrule in
PrimaryExpression (see below.)
        IntegralType:
                bool
                byte
                ...
                void
        BasicType:
                IntegralType
                .IdentifierList
                IdentifierList
                Typeof
                Typeof . IdentifierList
        BasicType2:
                [ Expression .. Expression ] // Slice expression is missing.
        Declarator:
                () Declarator // Has a trailing space. Should be "( Declarator
)".
                Identifier DeclaratorSuffixes
                () Declarator  DeclaratorSuffixes // Should be "( Declarator )
DeclaratorSuffixes"
        DeclaratorSuffix:
                [ Expression .. Expression ] // Slice expression is missing.

.) attribute.html
Attribute:
        synchronized // missing
.) expression.html
EqualExpression:
        ShiftExpression
        ShiftExpression == ShiftExpression
        ShiftExpression != ShiftExpression
        ShiftExpression is ShiftExpression // This is covered in
IdentityExpression already.
        ShiftExpression !is ShiftExpression // ditto

UnaryExpression:
        NewExpression
        NewAnonClassExpression // Should be contained by NewExpression.
NewExpression:
        NewArguments ClassArguments BaseClasslistopt { DeclDefs } // Should be
removed and replaced by NewAnonClassExpression.

PostfixExpression:
        PostfixExpression . Identifier // Identifier should be replaced by
IdentifierList so that TemplateInstance is covered as well.

PrimaryExpression:
        Identifier // Should be replaced by IdentifierList
        .Identifier // Should be replaced by ". IdentifierList"
        BasicType . Identifier // BasicType should be replaced by IntegralType
as suggested above.
        typeof ( Expression ) // missing
        typeof ( Expression ) . IdentifierList // missing

KeyExpression:
        ConditionalExpression // Should be AssignExpression.

ValueExpression:
        ConditionalExpression // Should be AssignExpression.

FunctionLiteral // missing colon
        function Typeopt ( ParameterList )opt FunctionBody // Allows for
literals like "function int {}". Is this legal?

IsExpression:
        is ( Type Identifier ) // Doesn't allow for "is (int x[] == int[])"
        is ( Type Identifier : TypeSpecialization )
        is ( Type Identifier == TypeSpecialization )
TypeSpecialization:
        return // missing

.) class.html
Protection:
        private
        package
        public
        export // inheriting by export doesn't make any sense.

.) enum.html
EnumDeclaration:
        enum EnumBody // Allows for "enum;"

.) template.html
TemplateDeclaration:
        template TemplateIdentifier ( TemplateParameterList )
                { DeclDefs } // Should be on the above line.
TemplateParameterList // Has no colon.


-- 

July 20, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1351





------- Comment #1 from aziz.kerim@gmail.com  2007-07-20 15:36 -------
Forgot the following:

.) statement.html#SwitchStatement
Quote: "The case expressions, ExpressionList, are a comma separated list of
expressions."
"expressions" should be <a href="...">AssignExpression</a>s.


-- 

July 20, 2007
Reply to d-bugmail@puremagic.com,

> http://d.puremagic.com/issues/show_bug.cgi?id=1351
> 
> ------- Comment #1 from aziz.kerim@gmail.com  2007-07-20 15:36 -------
> Forgot the following:
> 
> .) statement.html#SwitchStatement
> Quote: "The case expressions, ExpressionList, are a comma separated
> list of
> expressions."
> "expressions" should be <a href="...">AssignExpression</a>s.

* All non terminals in the grammar should be links to there definitions.
* There should be a page that is just the grammar rules (and it should NOT be maintained by hand)


July 20, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1351





------- Comment #3 from aziz.kerim@gmail.com  2007-07-20 16:27 -------
One more thing:

AutoDeclaration:
        StorageClasses Identifier = AssignExpression ; // doesn't allow for
multiple declarations

Currently you can write things like:

auto bla = 2, foo = "abc";

'bla' will be of type int and foo will be of type char[]. Maybe this needs to be changed because it's inconsistent with the syntax of non-auto declarations:

int bla = 2, foo = "abc"; // error because foo is of type int.

When we have:

auto id1 = init(), id2, id3; // id2 and id3 should be of type typeof(id1).

What do you think about this issue?


-- 

July 26, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1351





------- Comment #4 from aziz.kerim@gmail.com  2007-07-26 14:24 -------
In http://www.digitalmars.com/d/expression.html#CharacterLiteral you write:

"Character literals are single characters and resolve to one of type char, wchar, or dchar. If the literal is a \u escape sequence, it resolves to type wchar. If the literal is a \U escape sequence, it resolves to type dchar. Otherwise, it resolves to the type with the smallest size it will fit into."

Which type does a character literal with an HTML entity have (e.g. '\&xyz;')?

Please clarify if this correct:

uint c;
// statements ...
if (c < 128)
  // c is char
else if(c <= 0xFFFF)
  // c is wchar
else
  // c is dchar


-- 

July 27, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1351


smjg@iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com




------- Comment #5 from smjg@iname.com  2007-07-27 10:07 -------
(In reply to comment #4)
> "[...]
> Otherwise, it resolves to the type with the smallest size it will fit into."
> 
> Which type does a character literal with an HTML entity have (e.g. '\&xyz;')?

The last sentence you've quoted makes it seem clear to me.

> Please clarify if this correct:
> 
> uint c;
> // statements ...
> if (c < 128)
>   // c is char

If c is a uint, then c is a uint.  But what you seem to mean by it seems right to me.


-- 

July 27, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1351





------- Comment #6 from smjg@iname.com  2007-07-27 10:34 -------
(In reply to comment #0)
> FunctionLiteral // missing colon
>         function Typeopt ( ParameterList )opt FunctionBody // Allows for
> literals like "function int {}". Is this legal?

If it weren't meant to be, surely there wouldn't be the statement

"If omitted it defaults to the empty argument list ()."

in the paragraph immediately below that BNF.

But it does seem to be a mistake that that paragraph talks of ArgumentList instead of ParameterList.


-- 

July 31, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1351





------- Comment #7 from aziz.kerim@gmail.com  2007-07-31 02:23 -------
(In reply to comment #5)
> (In reply to comment #4)
> > "[...]
> > Otherwise, it resolves to the type with the smallest size it will fit into."
> > 
> > Which type does a character literal with an HTML entity have (e.g. '\&xyz;')?
> 
> The last sentence you've quoted makes it seem clear to me.

It actually does, but I think HTML entities have to be explicitly mentioned as
well. Because:
auto foo = '\&amp;';
pragma(msg, typeof(foo).stringof); // prints dchar instead of char (which an
ampersand should fit into)

> If c is a uint, then c is a uint.  But what you seem to mean by it seems right to me.
Yes, what I mean is that c contains a decoded Unicode character and the if statements are there to determine the type of the character literal.


-- 

July 31, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1351





------- Comment #8 from aziz.kerim@gmail.com  2007-07-31 02:28 -------
(In reply to comment #6)
> (In reply to comment #0)
> > FunctionLiteral // missing colon
> >         function Typeopt ( ParameterList )opt FunctionBody // Allows for
> > literals like "function int {}". Is this legal?
> 
> If it weren't meant to be, surely there wouldn't be the statement
> 
> "If omitted it defaults to the empty argument list ()."

Ok, but DMD doesn't allow you to declare such delegate or function literals:
auto bla = delegate void {}; // Error: found '{' when expecting '('   (other
errors omitted)
Seems to be a bug in the compiler or the specification.

> But it does seem to be a mistake that that paragraph talks of ArgumentList instead of ParameterList.

Yep, ArgumentList should be ParameterList in that paragraph.


-- 

July 31, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1351





------- Comment #9 from aziz.kerim@gmail.com  2007-07-31 02:45 -------
Regarding http://www.digitalmars.com/d/statement.html#ForeachStatement :

You talk twice about NoScopeNonEmptyStatement but it should be ScopeStatement as defined in the BNF rule.


-- 

« First   ‹ Prev
1 2