repl.it
@SharkFin/

DotFin

C++11

the DotFin programming language --- Heavy WIP

fork
loading
Files
  • main.cpp
  • classes
  • functions
  • math
  • lang.fin
  • planning.txt
main.cpp
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
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <regex>
#include <vector>

#include "functions/splitLines.h"
#include "functions/print.h"
#include "functions/variable.h"
#include "functions/comment.h"
#include "functions/escapeInQuotes.h"
#include "functions/unEscape.h"

#include "math/operation.h"

#include "classes/variables.h"

int main(int argc, char** argv) {
	// The args are here for if I want to use them in the future
	// So that you can run command './main file.fin' to run the program
	std::string fileNamePassed(*argv);
	std::ifstream text;
	text.open("lang.fin");

	if (!text.is_open()) {
		std::cout << "Failed to open" << std::endl;
	}

	// Open an input file stream
	std::ifstream finFile("lang.fin");

	// Create the array of variables
	std::vector<Variable> varArray;
	varArray.push_back(Variable("", "undefined", "default", varArray, true));

	// The depth will hold how far into {} the code is. The variables will also have to be modified to hold the scope that they are defined in. The class for functions could be passed as the scope to the created variable. Function classes should also hold their parent so we can get the variables from that scope as well. Then obviously the global variables are global.
	int depth = 0;
	std::string tokens = ";/+-*(){}&^%.";

	// Loop through each line
	for(std::string fileStr; getline( finFile, fileStr );) {
		std::string file = removeComments(fileStr);
		file = escapeInQuotes(file, tokens);

		// Loop through each statement on a line
		for(std::string fileStr : splitLines(file)) {
			// Check and complete operations
			fileStr = completeOperation(fileStr, varArray);

			// Unescape ; that's in quotes
			fileStr = unEscape(fileStr, tokens);

			// check for variable
			findVariable(fileStr, varArray);

			// check for print statement
			findPrint(fileStr, varArray);
		}
	}

	std::cout << std::endl;
	return 1;
}
?