-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.h
More file actions
102 lines (82 loc) · 2.1 KB
/
Copy pathparser.h
File metadata and controls
102 lines (82 loc) · 2.1 KB
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
95
96
97
98
99
100
101
102
//
// parser.h
// Project2
//
// Created by Michael Bird on 7/10/14.
// Copyright (c) 2014 Michael Bird. All rights reserved.
//
#ifndef __Project2__parser__
#define __Project2__parser__
#include <iostream>
#include <string>
#include <vector>
#include "LexicalAnalyzer.h"
#include "Predicate.h"
#include "DatalogProgram.h"
#include "Rule.h"
#include "Parameter.h"
#include "Token.h"
using namespace std;
/*
<Datalog Program> -> Schemes : <Scheme List>
Facts : <Fact List>
Rules : <Rule List>
Queries : <Query List>
EOF
<Scheme List> -> <Scheme> <Scheme List>
<Scheme List> -> <Scheme>
<Scheme> -> <Predicate>
<Fact List> -> <Fact> <Fact List>
<Fact List> -> e
<Fact> -> <Predicate> .
<Rule List> -> <Rule> <Rule List>
<Rule List> -> e
<Rule> -> <Predicate> :- <Predicate List> .
<Query List> -> <Query> <Query List>
<Query List> -> <Query>
<Query> -> <Predicate> ?
<Predicate List> -> <Predicate> , <Predicate List>
<Predicate List> -> <Predicate>
<Predicate> -> Identifier ( <Parameter List> )
<Parameter List> -> <Parameter> , <Parameter List>
<Parameter List> -> <Parameter>
<Parameter> -> String | Identifier
*/
//vector<predicate> schemes;
class parser {
public:
parser();
~parser();
void parse(vector<Token> tokenlist);
void get_token_type();
void get_token_value();
void get_token_line();
void update_token();
string current_token_type;
string current_token_value;
int current_token_line;
unsigned int index=0;
DataLog get_datalog_object();
private:
Predicate P;
DataLog D;
Rule R;
Parameter Par;
Token T;
void error();
void match(string token_type);
void schemelist();
void scheme();
void factlist();
void fact();
void rulelist();
void rule();
void querylist();
void query();
void predicatelist();
void predicate();
void parameterlist();
void parameter();
vector<Token> tokenlist;
};
#endif /* defined(__Project2__parser__) */