/* * A header file for a simple lexer. A lexer is just a device * used to subdivide a string into logical symbols. */ #ifndef LEXER_H #define LEXER_H typedef enum {LPAREN, RPAREN, OPERATOR, NUMBER, EOS, ERROR} Lexeme; typedef struct LexicalElement { Lexeme type; union { double num; //numeric value char c; //character value } value; } LexicalElement; /* * Return the next lexical element in the string s. * Passing NULL into s, will cause the lexer to read the next element out * of the last string passed in. */ LexicalElement nextElement(char *s); #endif