Skip to content

Instantly share code, notes, and snippets.

@alksl
Created January 26, 2014 12:30
Show Gist options
  • Save alksl/8632046 to your computer and use it in GitHub Desktop.
Save alksl/8632046 to your computer and use it in GitHub Desktop.
#ifndef _SCHEMESE_SCANNER_H_
#define _SCHEMESE_SCANNER_H_
#include <iostream>
#include <vector>
#include <string>
namespace Schemese {
/*
* Start compound tokens at end of unicode range
* for future considirations.
*/
#define TOKENS_START 0x110000
enum SchemeseTokenType {
LPAREN = '(',
RPAREN = ')',
LBRACKET = '{',
RBRACKET = '}',
QUOTE = ''',
BACKQUOTE = '`',
IDENTIFIER = TOKENS_START,
BOOLEAN,
VECTOR,
BYTE_VECTOR,
INTEGER,
REAL,
CHARACTER,
STRING
};
struct Token {
SchemeseTokenType type;
std::string text;
};
class Scanner {
public:
Scanner(std::istream input);
Token scan();
Token peek();
void put_back(Token& token);
private:
std::vector<Token> token_buffer;
};
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment