1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #ifndef _LEXER_H
- #define _LEXER_H
- // Standard includes
- #include <string>
- // LLVM includes
- #include "llvm/IR/IRBuilder.h"
- #include "llvm/IR/DIBuilder.h"
- // Local includes
- //#include "Ast.h"
- namespace lexer {
- // The lexer returns tokens [0-255] if it is an unknown character, otherwise one
- // of these for known things.
- enum Token {
- tok_eof = -1,
- // commands
- tok_def = -2,
- tok_extern = -3,
- // primary
- tok_identifier = -4,
- tok_number = -5,
- // control
- tok_if = -6,
- tok_then = -7,
- tok_else = -8,
- tok_for = -9,
- tok_in = -10,
- // operators
- tok_binary = -11,
- tok_unary = -12,
- // var definition
- tok_var = -13
- };
- //static llvm::IRBuilder<> ast::AstObjects::Builder(getGlobalContext());
- struct SourceLocation {
- int Line;
- int Col;
- };
- static SourceLocation CurLoc;
- static SourceLocation LexLoc = {1, 0};
- static int advance();
- struct LexerObjects {
- public:
- static std::string IdentifierStr; // Filled in if tok_identifier
- static double NumVal;
- };
- int gettok();
- }
- #endif
|