Skip to content
This repository has been archived by the owner on Sep 25, 2022. It is now read-only.

Commit

Permalink
Added Install<dot>scr, and more.
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatgec committed Aug 9, 2020
1 parent 9186129 commit f023d7a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 25 deletions.
Binary file modified fla
Binary file not shown.
67 changes: 44 additions & 23 deletions flascript/Interpreter/Import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@

bool check = false;

std::string FReadImport(std::string file) {
std::string line, text;
std::ifstream readfile(("/usr/include/flascript/" + file).c_str());
if(readfile.is_open()) {
while (std::getline(readfile, line)) {
text.append(line + "\n");
}
readfile.close();
return text;
} else {
printf("Unable to open file\n");
}
return "null";
}

void
FImport::Import(std::string file, std::string arg) {
FInterpreter inp;
Expand All @@ -54,6 +69,12 @@ FImport::Import(std::string file, std::string arg) {
std::cout << "import(\"" <<
assign << "\")" << " : File not found.\n";
}
} else {
inp.GetBtwString(arg, "(<", ">)", assign);
if(assign != "error") {
type = FReadImport(assign);
if(type != "null") { check = true; }
}
}
} else if(inp.FindObject(arg, "put") == true) {
inp.GetBtwString(arg, "[", "]", assign);
Expand All @@ -63,32 +84,32 @@ FImport::Import(std::string file, std::string arg) {
if(assign != "error") {
type = func.FRead(file);
if(type != "null") {
inp.GetBtwString(type, "import(\"", "\") -> " + assign, assign);
if(assign != "error") {
type = func.FRead(assign);
if(inp.FindObject(arg, "func ->") == true) {
inp.GetBtwString(arg, "[", " -> ", fnc);
inp.GetBtwString(arg, fnc + " -> ", " <-", put);
if(put != "error") {
inp.GetBtwString(type, put + " {", "}", type);
if(type != "error") {
inp.FlaScriptInterpreterWithArg(assign, type);
}
}
} else {
inp.GetBtwString(arg, " -> ", " <-", put);
if(put != "error") {
inp.GetBtwString(type, "defin[" + put + "] -> ", "<-", type);
if(type != "error") {
inp.FlaScriptInterpreterWithArg(assign, type);
}
}
}
std::string file;
inp.GetBtwString(type, "import(\"", "\") -> " + assign, file);
if(file != "error") {
type = func.FRead(file);
} else {
inp.GetBtwString(type, "import(<", ">) -> " + assign, file);
if(file != "error") type = FReadImport(file);
}
if(inp.FindObject(arg, "func ->") == true) {
inp.GetBtwString(arg, "[", " -> ", fnc);
inp.GetBtwString(arg, fnc + " -> ", " <-", put);
if(put != "error") {
inp.GetBtwString(type, put + " {", "}", type);
if(type != "error") inp.FlaScriptInterpreterWithArg(file, type);
}
} else {
inp.GetBtwString(arg, " -> ", " <-", put);
if(put != "error") {
inp.GetBtwString(type, "defin[" + put + "] -> ", "<-", type);
if(type != "error") inp.FlaScriptInterpreterWithArg(assign, type);
}
}

}
}
}
}
}
}

}
4 changes: 4 additions & 0 deletions init/install.fls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
main() -> main {
executepp("FlaScript Installer", "mkdir /usr/include/flascript")
executepp("FlaScript Installer", "cp -r ../stdlib/ /usr/include/flascript/")
}
3 changes: 3 additions & 0 deletions install.scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
system("g++ -I./include/ ./flascript/Interpreter/Interpreter.cpp ./flascript/Interpreter/Definitions.cpp ./flascript/Interpreter/Exec.cpp ./flascript/Interpreter/Read.cpp ./flascript/Interpreter/Print.cpp ./flascript/Interpreter/String.cpp ./flascript/Interpreter/Function.cpp ./flascript/FlaVersion.cpp ./flascript/FlaScriptMain.cpp -o fla ");
system("./fla --b test.fls");
return
6 changes: 6 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

g++ -I./include/ ./flascript/Interpreter/Interpreter.cpp ./flascript/Interpreter/Definitions.cpp ./flascript/Interpreter/Exec.cpp \
./flascript/Interpreter/Read.cpp ./flascript/Interpreter/Print.cpp ./flascript/Interpreter/String.cpp \
./flascript/Interpreter/Function.cpp ./flascript/Interpreter/Import.cpp ./flascript/FlaVersion.cpp \
./flascript/FlaScriptMain.cpp -o fla && ./fla --b test.fls
3 changes: 1 addition & 2 deletions test.fls
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import("stdlib/output/Colorized.flsh") -> color <-

import(<output/Colorized.flsh>) -> color <-

func -> Test() {
return var(string) -> Hello world! <-
Expand Down

0 comments on commit f023d7a

Please sign in to comment.