www.digitalmars.com         C & C++   DMDScript  

D - Lexer / Tokeniser querys

reply C.R.Chafer <blackmarlin nospam.asean-mail.com> writes:
Hello folks,  I have been writing a flex compatible lexer for D and have 
come up against the following points in the docs.

S.      hexadecimal floats are in the spec only prefixed with 0x
Q.      should 0X be allowed as well?

S.      imaginary numbers are only identified with i or I
Q.      should j or J be allow too (as this is commonly used
        in the engineering world)

S.      <>
Q.      What is this expression? Is it a not equal?

S.      >>> and >>
Q.      this is shift arithmetric right and shift right?

(source for the lexer is in the D.gnu news group)

C 2002/6/11
Jun 11 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"C.R.Chafer" <blackmarlin nospam.asean-mail.com> wrote in message
news:ae5bo3$2u97$2 digitaldaemon.com...

 Hello folks,  I have been writing a flex compatible lexer for D and have
 come up against the following points in the docs.

 S.      hexadecimal floats are in the spec only prefixed with 0x
 Q.      should 0X be allowed as well?

Well, it is in DMD.
 S.      imaginary numbers are only identified with i or I
 Q.      should j or J be allow too (as this is commonly used
         in the engineering world)

Never heard of it before, really. The "i" suffix is a traditional math approach.
 S.      <>
 Q.      What is this expression? Is it a not equal?

Floating-point inequality (RTFM the section on operators).
Jun 11 2002
next sibling parent reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
Pavel Minayev wrote:

 S.      imaginary numbers are only identified with i or I
 Q.      should j or J be allow too (as this is commonly used
         in the engineering world)

Never heard of it before, really. The "i" suffix is a traditional math approach.

I ran into this when studying electrical engineering. The phase & amplitude of sinusoidal AC signals are modeled with complex numbers. Since i usually was a variable name for current, they didn't want to use i as the imaginary number. Thus, the use of j: v = 1 + 3j; i = 2 + 4j; It's not a key feature, but it's probably a good one. -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]
Jun 11 2002
parent "Juan Carlos Arevalo Baeza" <jcab roningames.com> writes:
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
news:3D064128.BD5286BB deming-os.org...

 Never heard of it before, really. The "i" suffix is a traditional math
 approach.


Yes, "i" and "j" are both used. Math, physics and engineering types do have different ways of expressing the same things. Like the difference between F'(x) and dF(x)/dx to express derivatives.
 Thus, the use of j:
     v = 1 + 3j;
     i = 2 + 4j;

 It's not a key feature, but it's probably a good one.

I only see one problem, though: another cool feature of the language would be to natively support quaternions (4D complex numbers that are widely used in 3D animation), which use "i", "j" and "k" as the three imaginary parts: v = 1 + 3i + 4j - 2k; <ahem> <cough> Still, I believe it would be best if such mathematical concepts could be implemented by libraries instead of having to be native to the language itself. </cough> </ahem> Salutaciones, JCAB
Jun 11 2002
prev sibling parent C.R.Chafer <blackmarlin nospam.asean-mail.com> writes:
Pavel Minayev wrote:

 "C.R.Chafer" <blackmarlin nospam.asean-mail.com> wrote in message
 news:ae5bo3$2u97$2 digitaldaemon.com...
 
 Hello folks,  I have been writing a flex compatible lexer for D and have
 come up against the following points in the docs.

 S.      hexadecimal floats are in the spec only prefixed with 0x
 Q.      should 0X be allowed as well?

Well, it is in DMD.

Though so - must be a bug in the docs.
 S.      imaginary numbers are only identified with i or I
 Q.      should j or J be allow too (as this is commonly used
         in the engineering world)

Never heard of it before, really. The "i" suffix is a traditional math approach.

And the "j" suffix the traditional engineering approach (due to "i" being commanly used to represent a current variable).
 S.      <>
 Q.      What is this expression? Is it a not equal?

Floating-point inequality (RTFM the section on operators).

Yes, my fault - found it ment unordered compare about 5 minutes after I posted this. C 2002/6/11
Jun 12 2002