www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Various documentation questions

reply Bernard Helyer <b.helyer gmail.com> writes:
I may be trying to write a D2 compiler in D2 (you can't prove 
anything!), it's early days, but I've run into a few things I'd like 
clarification on. This won't be the last of these posts, I'm sure of it! *g*

I'm not sure what are bugs, in documentation, in DMD, and in my 
understanding.


---

http://www.digitalmars.com/d/2.0/module.html#ModuleDeclaration

"module (system) ModuleFullyQualifiedName ;"

This syntax is not accepted by DMD.

---

http://www.digitalmars.com/d/2.0/module.html#ImportDeclaration

"static import ImportList ;"

is listed specifically, but static can be found under

http://www.digitalmars.com/d/2.0/attribute.html#AttributeSpecifier

which can have a DeclarationBlock afterward, which would include a 
single import statement, so surely the former is tautological?

---

http://www.digitalmars.com/d/2.0/lex.html#keyword

where do the  keywords fall?

---

http://www.digitalmars.com/d/2.0/lex.html#tokens

There is no '**' token listed. I assume this is an omission (and lex it 
as a separate token in SDC, and not two '*'s).

---

http://www.digitalmars.com/d/2.0/expression.html#PostfixExpression

"PostfixExpression . NewExpression"

Where is that valid?

---

http://www.digitalmars.com/d/2.0/expression.html#UnaryExpression

"( Type ) . Identifier"

why is that significant?

---
Jun 05 2010
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Bernard Helyer Wrote:

 I may be trying to write a D2 compiler in D2 (you can't prove 
 anything!), it's early days,
:-)
 http://www.digitalmars.com/d/2.0/lex.html#tokens
 
 There is no '**' token listed. I assume this is an omission (and lex it 
 as a separate token in SDC, and not two '*'s).
What is ** for? Bye, bearophile
Jun 05 2010
parent Bernard Helyer <b.helyer gmail.com> writes:
On 06/06/10 01:27, bearophile wrote:
 Bernard Helyer Wrote:

 I may be trying to write a D2 compiler in D2 (you can't prove
 anything!), it's early days,
:-)
 http://www.digitalmars.com/d/2.0/lex.html#tokens

 There is no '**' token listed. I assume this is an omission (and lex it
 as a separate token in SDC, and not two '*'s).
What is ** for? Bye, bearophile
Sorry, thinking in python. :o
Jun 05 2010
prev sibling next sibling parent Bernard Helyer <b.helyer gmail.com> writes:
On 06/06/10 01:22, Bernard Helyer wrote:
 I may be trying to write a D2 compiler in D2 (you can't prove
 anything!), it's early days, but I've run into a few things I'd like
 clarification on. This won't be the last of these posts, I'm sure of it!
 *g*

 I'm not sure what are bugs, in documentation, in DMD, and in my
 understanding.


 ---

 http://www.digitalmars.com/d/2.0/lex.html#tokens

 There is no '**' token listed. I assume this is an omission (and lex it
 as a separate token in SDC, and not two '*'s).

 ---
I was thinking Python. The exponentiation operator is '^^' and is also not listed as its own token (I made the same mistake in my lexer as I did in the post! I've got to fix it now! :D).
Jun 05 2010
prev sibling parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 06/05/2010 08:22 AM, Bernard Helyer wrote:
 I may be trying to write a D2 compiler in D2 (you can't prove
 anything!),
ditto, except mine is in java it's early days, but I've run into a few things I'd like
 clarification on. This won't be the last of these posts, I'm sure of it!
 *g*

 I'm not sure what are bugs, in documentation, in DMD, and in my
 understanding.


 ---

 http://www.digitalmars.com/d/2.0/module.html#ModuleDeclaration

 "module (system) ModuleFullyQualifiedName ;"

 This syntax is not accepted by DMD.

 ---

 http://www.digitalmars.com/d/2.0/module.html#ImportDeclaration

 "static import ImportList ;"

 is listed specifically, but static can be found under

 http://www.digitalmars.com/d/2.0/attribute.html#AttributeSpecifier

 which can have a DeclarationBlock afterward, which would include a
 single import statement, so surely the former is tautological?
from my reading, I don't think this is the case in dmd. It does literally parse 'static import'. same with static if, static assert, and maybe some others. I don't know, but I suspect that stuff like static public import blah; wouldn't give you a static import. I also don't know whether it would be reasonable to make it work like that. The trouble is static means something else for other declarations. Something like static: ... import blah; In the parser that I currently have, it would be rather obnoxious to tell the difference between that and 'static import blah;'. Well, maybe not.
 ---

 http://www.digitalmars.com/d/2.0/lex.html#keyword

 where do the  keywords fall?
' ' is a token which should be followed by an identifier
 ---

 http://www.digitalmars.com/d/2.0/lex.html#tokens

 There is no '**' token listed. I assume this is an omission (and lex it
 as a separate token in SDC, and not two '*'s).

 ---

 http://www.digitalmars.com/d/2.0/expression.html#PostfixExpression

 "PostfixExpression . NewExpression"

 Where is that valid?
I remember thinking the same thing. class A{ class B{ string s; } int i; } void main(){ //A.B b = new A.B; //Error: outer class A 'this' needed to 'new' nested class B A a = new A; A.B b = a.new B; }
 ---

 http://www.digitalmars.com/d/2.0/expression.html#UnaryExpression

 "( Type ) . Identifier"

 why is that significant?

 ---
I suppose it's a bid to reduce the amount of incorrect parsing that would result from Type . Identifier And to its credit, I don't think I have come across any trouble with it.
Jun 05 2010
parent reply Bernard Helyer <b.helyer gmail.com> writes:
On 06/06/10 03:26, Ellery Newcomer wrote:
 On 06/05/2010 08:22 AM, Bernard Helyer wrote:
 I may be trying to write a D2 compiler in D2 (you can't prove
 anything!),
ditto, except mine is in java
Awesome! :)
 http://www.digitalmars.com/d/2.0/module.html#ImportDeclaration

 "static import ImportList ;"

 is listed specifically, but static can be found under

 http://www.digitalmars.com/d/2.0/attribute.html#AttributeSpecifier

 which can have a DeclarationBlock afterward, which would include a
 single import statement, so surely the former is tautological?
from my reading, I don't think this is the case in dmd. It does literally parse 'static import'. same with static if, static assert, and maybe some others. I don't know, but I suspect that stuff like static public import blah; wouldn't give you a static import. I also don't know whether it would be reasonable to make it work like that. The trouble is static means something else for other declarations. Something like static: ... import blah; In the parser that I currently have, it would be rather obnoxious to tell the difference between that and 'static import blah;'. Well, maybe not.
Okay, I see.
 ---

 http://www.digitalmars.com/d/2.0/lex.html#keyword

 where do the  keywords fall?
' ' is a token which should be followed by an identifier
I did not know that. Thanks!
 http://www.digitalmars.com/d/2.0/expression.html#PostfixExpression

 "PostfixExpression . NewExpression"

 Where is that valid?
I remember thinking the same thing. class A{ class B{ string s; } int i; } void main(){ //A.B b = new A.B; //Error: outer class A 'this' needed to 'new' nested class B A a = new A; A.B b = a.new B; }
Funky. Thank you for the example.
 ---

 http://www.digitalmars.com/d/2.0/expression.html#UnaryExpression

 "( Type ) . Identifier"

 why is that significant?

 ---
I suppose it's a bid to reduce the amount of incorrect parsing that would result from Type . Identifier And to its credit, I don't think I have come across any trouble with it.
Maybe I'm having a slow morning, but I can't really grok that. Could you elaborate? Speak slowly. :)
Jun 05 2010
parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 06/05/2010 08:16 PM, Bernard Helyer wrote:
 On 06/06/10 03:26, Ellery Newcomer wrote:
 On 06/05/2010 08:22 AM, Bernard Helyer wrote:
 I may be trying to write a D2 compiler in D2 (you can't prove
 anything!),
ditto, except mine is in java
Awesome! :)
No. Java isn't. :) Although the jvm talk bearophile linked to suggested that the jvm would be relatively easy to generate machine code for.
 ---

 http://www.digitalmars.com/d/2.0/expression.html#UnaryExpression

 "( Type ) . Identifier"

 why is that significant?

 ---
I suppose it's a bid to reduce the amount of incorrect parsing that would result from Type . Identifier And to its credit, I don't think I have come across any trouble with it.
Maybe I'm having a slow morning, but I can't really grok that. Could you elaborate? Speak slowly. :)
expressions and types are ambiguous, so any place where both can appear will be trouble. Consider the token string Identifier [ Identifier ] . Identifier does the part before the dot represent a type, or an expression? It's impossible to say at parse time (in the general case), and the programmer will have cause to use both fairly often. And yes, ( Identifier [ Identifier ] ) . Identifier is just as ambiguous, but I think ( Expression ) . Identifier is much less common than Expression . Identifier Ugh. I suppose I'm going to have to write a Type -> Expression routine sometime soon.
Jun 05 2010
parent reply retard <re tard.com.invalid> writes:
Sat, 05 Jun 2010 23:03:34 -0500, Ellery Newcomer wrote:

 On 06/05/2010 08:16 PM, Bernard Helyer wrote:
 On 06/06/10 03:26, Ellery Newcomer wrote:
 On 06/05/2010 08:22 AM, Bernard Helyer wrote:
 I may be trying to write a D2 compiler in D2 (you can't prove
 anything!),
ditto, except mine is in java
Awesome! :)
No. Java isn't. :)
Why didn't you use some modern JVM language like Clojure or Scala? You hate D's competitors more than Java?
Jun 06 2010
parent Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 06/06/2010 03:15 AM, retard wrote:
 Sat, 05 Jun 2010 23:03:34 -0500, Ellery Newcomer wrote:

 On 06/05/2010 08:16 PM, Bernard Helyer wrote:
 On 06/06/10 03:26, Ellery Newcomer wrote:
 On 06/05/2010 08:22 AM, Bernard Helyer wrote:
 I may be trying to write a D2 compiler in D2 (you can't prove
 anything!),
ditto, except mine is in java
Awesome! :)
No. Java isn't. :)
Why didn't you use some modern JVM language like Clojure or Scala? You hate D's competitors more than Java?
I've thought about using Clojure. I suppose I've just been too lazy to bother learning it. Come to think of it though, it would make things much less painful, and I have been wishing for a pattern matching syntax forever. Maybe I will when I have some time.
Jun 06 2010