-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput.h
41 lines (34 loc) · 996 Bytes
/
input.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
#ifndef INPUT_H
#define INPUT_H
#include <string>
#include <vector>
#include <map>
#include <iostream>
#include <fstream>
#include "notes.h"
#include "output.h"
enum State { START, WHITESEP, _16, _32, DURATION, DOT, DOT2, SHARP, NOTE,
OCTAVE, TRIPLET, REST };
typedef enum TokenType {
NOTHING, NUMBER, STRING, TSHARP, TDOT, DASH, PLUS, EQUALS,
RIGHT_ANGLE_BRACKET, LEFT_ANGLE_BRACKET, RIGHT_SQUARE_BRACKET, LEFT_SQUARE_BRACKET, RIGHT_PARENTHESIS, LEFT_PARENTHESIS,
WHITESPACE, NEWLINE, END_OF_FILE
}ETokenType;
const std::map<char, TokenType> CharTokenType
{
{'#', TSHARP},
{'.', TDOT},
{'-', DASH},
{'+', PLUS},
{'=', EQUALS},
{'(', LEFT_PARENTHESIS},
{')', RIGHT_PARENTHESIS},
{'[', LEFT_ANGLE_BRACKET},
{']', RIGHT_ANGLE_BRACKET},
{'<', LEFT_ANGLE_BRACKET},
{'>', RIGHT_ANGLE_BRACKET}
};
std::string printTokenType(ETokenType t);
ETokenType getNextToken(std::ifstream &sourceFile, std::string &data);
int parse(std::ifstream &sourceFile);
#endif