-
Notifications
You must be signed in to change notification settings - Fork 0
/
LexicalAnalyzer.h
executable file
·63 lines (48 loc) · 1.35 KB
/
LexicalAnalyzer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// LexicalAnalyzer.h
// Project1
//
// Created by Michael Bird on 6/25/14.
// Copyright (c) 2014 Michael Bird. All rights reserved.
#ifndef __Project2__LexicalAnalyzer__
#define __Project2__LexicalAnalyzer__
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include "Token.h"
using namespace std;
// list of enum types
enum {COMMA, PERIOD, Q_MARK, LEFT_PAREN, RIGHT_PAREN, COLON, COLON_DASH, SEMI_COLON, SCHEMES, FACTS, RULES, QUERIES, ID, STRING, DASH, QUOTATION, COMMENT, BACK_SLASH, DIGIT, UNDERSCORE, TAB, LETTER, INTEGER, ERROR, SPACE, STOP, PLUS_CODE, EPSILON};
// the class and its public and private methods and values
class LexAn
{
public:
LexAn();
~LexAn();
string input;
string line;
int char_class;
char next_char;
int token_type;
string lexeme;
// string tokenizer(int token);
string get_token_value();
string get_token_type();
int get_line_number();
int get_token();
string lex();
int rule1();
int rule2();
int rule3();
void new_input(string in);
//void toString();
void push_token();
int linenumber = 0;
vector<Token> lex(char* filename);
private:
void add_char();
void get_char();
vector<Token> tokenlist;
};
#endif /* defined(__Project2__LexicalAnalyzer__) */