-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparser.cpp
More file actions
51 lines (48 loc) · 1.3 KB
/
parser.cpp
File metadata and controls
51 lines (48 loc) · 1.3 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
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <unistd.h>
#include <boost/filesystem.hpp> // -lboost_system: Write this while compiling, this prevents
// the linker error.
#include <boost/algorithm/string/replace.hpp>
#include "lexical.h"
#include "syntax.h"
#include "processctrl.h"
int cmdSyntaxAnalysis(string cmd)
{
std::vector <std::string> tokenStream;
std::vector <char*> tokens;
std::unordered_map <key, value> table;
int flag;
int whichTypeofExecution = 0;
int pipeCount = 0;
cmdLexicalAnalysis(cmd, tokenStream, tokens, pipeCount);
constructTable(table);
if(! tokenStream.empty())
tokenStream.push_back("<$>");
// tokenStream.push_back("<string>");
// tokenStream.push_back("<string>");
// tokenStream.push_back("<string>");
// tokenStream.push_back("<string>");
// tokenStream.push_back("<unix_command>");
flag = parser(table, tokenStream);
if (flag == 1)
{
try
{
processctrl(cmd, tokens, pipeCount, whichTypeofExecution);
// processctrl(cmd, tokens);
}
catch(int x)
{
std::cout << "Maybe memory is not available for one more process...:-(" << std::endl;
}
}
return 0;
}