-
Notifications
You must be signed in to change notification settings - Fork 0
/
tokenizer.h
94 lines (78 loc) · 1.74 KB
/
tokenizer.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef THEOREMPROVER_TOKENIZER_H
#define THEOREMPROVER_TOKENIZER_H
#include <stdbool.h>
typedef struct token token;
/*
* Checks if the character is a whitespace.
*/
static inline bool is_whitespace(char c)
{
return c == ' ' || c == '\t';
}
/*
* Checks if the character is a propositional letter.
*/
static inline bool is_proposition(char c)
{
return c == 'p' || c == 'q' || c == 'r' || c == 'x' || c == 'y' || c == 'w'; // prop ::= p | q | r | x | y | w
}
/*
* Checks if the character is a logical binary connective.
*/
static inline bool is_binary_connective(char c)
{
return c == 'v' || c == '^' || c == '>'; // binary ::= v | ^ | >
}
/*
* Checks if the character is a logical conjunction.
*/
static inline bool is_and_connective(char c)
{
return c == '^';
}
/*
* Checks if the character is a logical disjunction.
*/
static inline bool is_or_connective(char c)
{
return c == 'v';
}
/*
* Checks if the character is a logical implication.
*/
static inline bool is_implies_connective(char c)
{
return c == '>';
}
/*
* Checks if the character is a logical negation.
*/
static inline bool is_negation(char c)
{
return c == '-';
}
/*
* Checks if the character is an open parenthesis.
*/
static inline bool is_left_parenthesis(char c)
{
return c == '(';
}
/*
* Checks if the character is a closed parenthesis.
*/
static inline bool is_right_parenthesis(char c)
{
return c == ')';
}
/*
* Checks for an end of input null character.
*/
static inline bool is_end(char c)
{
return c == '\0';
}
void read_whitespace(const char* formula, int* offset);
void read_symbol(const char* formula, int* offset, token* token);
void get_token(const char* formula, int* offset, token* token);
#endif //THEOREMPROVER_TOKENIZER_H