CSCE 315 Programing Studio: Fall 2020 Read-Only Bulletin Board

Last modified: 8/13/20, 10:53PM (Thu)

This page will have all relevant email transactions with the students regarding the AI course, so that everyone has equal information regarding the course material.

Newest transactions will be posted on the top. Regularly view this page to see what's going on between other students and the instructor.

All sensitive material such as your name, email address, etc. will be removed, and also any part of code that is not relevant to the discussion will not be uploaded here.


Article List

Date: 01/20/2016 Title: Neat Compiler Trick


Articles

Date: 01/20/2016 Title: Neat Compiler Trick

Here's a small trick to make it easier to define tokens and their corresponding
strings. See Steve Oualline, Practical C++ Programming, O'Reilly and Associates, Inc., 1995. pp460-461.

//----------------------------------------------------------------------------
//  Using the define trick to generate tokens and their strings
//----------------------------------------------------------------------------

#define _TOK T(_tik),T(_tak),T(_tok),T(_toe)

#define T(X) X
enum TOKTYPE { _TOK };

#undef T
#define T(X) #X
char TOKSTR[4][20]={ _TOK };


// The above is equivalent to

enum TOKTYPE { _tik, _tak, _tok, _toe };

char TOKSTR[4][20]={"_tik", "_tak", "_tok", "_toe" };