Skip to content

Commit 566b76e

Browse files
Merge pull request #8 from JunLang-dev/master
v1.13.2
2 parents c45ffac + d40b36d commit 566b76e

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

JunLang.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <sstream>
77
#include <condition_variable>
88
using namespace std;
9-
#define _VERSION_ "v1.13"
9+
#define _VERSION_ "v1.13.2"
1010
#define _DEFAULT_BUFFER_SIZE_ 1024
1111
string identifiers[] = {
1212
"output",
@@ -46,21 +46,22 @@ bool isInteger(string x) {
4646
return integer;
4747
}
4848
int main(int argc, char* argv[]) {
49-
try {
49+
if (argc >= 2) {
5050
string fileName = string(argv[1]);
5151
int bufferSize;
52-
try {
52+
if (argc == 3) {
5353
bufferSize = atoi(string(argv[2]).c_str());
5454
}
55-
catch (logic_error) {
55+
else {
5656
bufferSize = _DEFAULT_BUFFER_SIZE_;
5757
}
5858
char buffer[bufferSize];
5959
Variable variables[bufferSize];
6060
int variableCount = 0;
6161
ifstream file(fileName);
6262
if (!file.is_open()) {
63-
cerr << "[ERROR] File cannot open.";
63+
cerr << "[ERROR] File cannot open.\n";
64+
exit(0);
6465
}
6566
while (file.good()) {
6667
file.getline(buffer, sizeof(buffer));
@@ -91,10 +92,10 @@ int main(int argc, char* argv[]) {
9192
cout << string(*(it + 1)).substr(1, strlen((*(it + 1)).c_str()) - 2);
9293
break;
9394
}
94-
if (*it == identifiers[1]) {
95+
else if (*it == identifiers[1]) {
9596
cout << endl;
9697
}
97-
if (*it == identifiers[2]) {
98+
else if (*it == identifiers[2]) {
9899
bool duplicate = false;
99100
for (int i = 0; i <= variableCount; i++) {
100101
if (variables[i].name == *(it + 1)) {
@@ -108,7 +109,7 @@ int main(int argc, char* argv[]) {
108109
variables[variableCount++].name = *(it + 1);
109110
break;
110111
}
111-
if (*it == identifiers[3]) {
112+
else if (*it == identifiers[3]) {
112113
bool undeclared = true;
113114
for (int i = 0; i <= variableCount; i++) {
114115
if (variables[i].name == *(it + 1)) {
@@ -122,7 +123,7 @@ int main(int argc, char* argv[]) {
122123
}
123124
break;
124125
}
125-
if (*it == identifiers[4]) {
126+
else if (*it == identifiers[4]) {
126127
bool undeclared = true;
127128
for (int i = 0; i <= variableCount; i++) {
128129
if (variables[i].name == *(it + 1)) {
@@ -148,7 +149,7 @@ int main(int argc, char* argv[]) {
148149
}
149150
break;
150151
}
151-
if (*it == identifiers[4]) {
152+
else if (*it == identifiers[4]) {
152153
bool undeclared = true;
153154
for (int i = 0; i <= variableCount; i++) {
154155
if (variables[i].name == *(it + 1)) {
@@ -164,7 +165,7 @@ int main(int argc, char* argv[]) {
164165
}
165166
break;
166167
}
167-
if (*it == identifiers[5]) {
168+
else if (*it == identifiers[5]) {
168169
bool undeclared = true;
169170
for (int i = 0; i <= variableCount; i++) {
170171
if (variables[i].name == *(it + 1)) {
@@ -190,7 +191,7 @@ int main(int argc, char* argv[]) {
190191
}
191192
break;
192193
}
193-
if (*it == identifiers[6]) {
194+
else if (*it == identifiers[6]) {
194195
bool undeclared = true;
195196
for (int i = 0; i <= variableCount; i++) {
196197
if (variables[i].name == *(it + 1)) {
@@ -216,7 +217,7 @@ int main(int argc, char* argv[]) {
216217
}
217218
break;
218219
}
219-
if (*it == identifiers[7]) {
220+
else if (*it == identifiers[7]) {
220221
bool undeclared = true;
221222
for (int i = 0; i <= variableCount; i++) {
222223
if (variables[i].name == *(it + 1)) {
@@ -242,7 +243,7 @@ int main(int argc, char* argv[]) {
242243
}
243244
break;
244245
}
245-
if (*it == identifiers[8]) {
246+
else if (*it == identifiers[8]) {
246247
bool undeclared = true;
247248
for (int i = 0; i <= variableCount; i++) {
248249
if (variables[i].name == *(it + 1)) {
@@ -275,7 +276,7 @@ int main(int argc, char* argv[]) {
275276
}
276277
}
277278
}
278-
catch (logic_error) {
279+
else {
279280
cout << "JunLang " << _VERSION_ << endl;
280281
cout << "Usage: " << argv[0] << " [filename] <bufferSize>" << endl;
281282
}

JunLang.exe

-1.03 MB
Binary file not shown.

JunLang.out

-565 KB
Binary file not shown.

make.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)