C enum to PB

Everything else that doesn't fall into one of the other PB categories.
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

C enum to PB

Post by jack »

how would you translate this to PB:

Code: Select all

typedef enum {a, b, c} tks;

typedef struct tkrec {
  struct tkrec *next;
  tks kind;
  union {
    struct varrec *vp;
    float num;
    Char *sp;
    Char snch;
  } UU;
} tkrec;

KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

Code: Select all

Enumeration
   #a
   #b
   #c
EndEnumeration

Structure tkrec
  *next.tkrec
  kind.l
  StructureUnion
    *vp.varrec             ; where is the varrec struct ?
    num.f
    sp.s
    snch.l
  EndStructureUnion
EndStructure
I hope it should work.
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

thanks KarLKoX.
to my understanding, an enum in C is a list of constants, so that a 'typedef enum' is a structure of constants?
too bad PB does not accept constants in structures then you could do something like this:

Code: Select all

Structure tks
  Enumeration
    #a
    #b
    #c
  EndEnumeration
EndStructure
actually what I was contemplating on doing was to translate the public domain version of Chipmunk Basic to PB
but it's probably over my head, all this structures and pointers give me a headache.

thanks anyway :)
User avatar
griz
Enthusiast
Enthusiast
Posts: 167
Joined: Sun Jun 29, 2003 7:32 pm
Location: Canada

Post by griz »

I was contemplating on doing was to translate the public domain version of Chipmunk Basic to PB
Interesting... :)

I remember Chipmunk on the Mac years ago. There's always been lots of great resources for writing BASIC interpreters on Ron Nicholson's web page for Chipmunk Basic : http://www.nicholson.com/rhn/basic/.
Post Reply