diff --git a/Compiler/Fparser.py b/Compiler/Fparser.py index bf785ca..53e29e2 100644 --- a/Compiler/Fparser.py +++ b/Compiler/Fparser.py @@ -2,8 +2,34 @@ -def readfile(filepath): +def readfile(filepath, printFile): with open(filepath, "r") as file: + fileExportBuffer = [] + lines = file.readlines() + print(lines) + + + + lineNum = 0 for line in lines: - print(line.strip()) + + line = line.strip() + fileExportBuffer.append(str(line)) + lineNum += 1 + + print(fileExportBuffer) + return fileExportBuffer + + +def meshBuffer(fileExportBuffer, devlog): + meshedbuffer = "" + for text in fileExportBuffer: + meshedbuffer += text + if devlog: print("Meshed :" , meshedbuffer) + return meshedbuffer + + + + + diff --git a/Compiler/Fwritter.py b/Compiler/Fwritter.py new file mode 100644 index 0000000..b82ec78 --- /dev/null +++ b/Compiler/Fwritter.py @@ -0,0 +1,81 @@ +from enum import StrEnum +from re import split + + +fileBuffer = [] +variables = [] + +class color(StrEnum): + RED = '\033[91m' + GREEN = '\033[92m' + YELLOW = '\033[93m' + BLUE = '\033[94m' + ENDC = '\033[0m' + + + +selectedApp = "" + +def log(text,colorCode): + + print(f"{colorCode} {text} {color.ENDC}") + + + + +def beginApp(name): + selectedApp = name + fileBuffer.append("προγραμμα "+ str(name)) + fileBuffer.append("αρχη") + + + + + + + + + + + + + + + + + + +def CompileApp(buffer,devlogs): + + + + + + + + +def grabScriptType(inBuffer: str,devlogs): + ScriptType = inBuffer.split(" ") + + match ScriptType[0]: + case "App" | "Program": + print("Application Script") + + if devlogs: print("App Name:" ,str(ScriptType[1])) + + CompileApp(inBuffer, True) + + + + + case "Lib" |"Library": + print("Library Script") + case "Ast" | "Asset": + print("Asset Script") + + + + case _: + log("Incorect Syntax @..." + str(ScriptType[0])+ " " +str(ScriptType[1])+"...", color.YELLOW) + log(" ╰──────> ERROR - ScriptType Not Declared", color.RED) + diff --git a/Compiler/__pycache__/Fparser.cpython-312.pyc b/Compiler/__pycache__/Fparser.cpython-312.pyc new file mode 100644 index 0000000..64b86bf Binary files /dev/null and b/Compiler/__pycache__/Fparser.cpython-312.pyc differ diff --git a/Compiler/__pycache__/Fwritter.cpython-312.pyc b/Compiler/__pycache__/Fwritter.cpython-312.pyc new file mode 100644 index 0000000..f46aa85 Binary files /dev/null and b/Compiler/__pycache__/Fwritter.cpython-312.pyc differ diff --git a/Compiler/ppc.py b/Compiler/ppc.py index 1f2c2fe..a9f1ac8 100644 --- a/Compiler/ppc.py +++ b/Compiler/ppc.py @@ -1,6 +1,7 @@ import configparser import argparse import Fparser +import Fwritter version = 1.0 @@ -30,8 +31,9 @@ def checkDeps(): def compileSingle(file): - Fparser.readfile(file) - + fileBuffer = Fparser.readfile(file, True) + meshBuffer = Fparser.meshBuffer(fileBuffer, True) + Fwritter.grabScriptType(meshBuffer,True) diff --git a/testFile.pc b/testFile.pc index 13bf3cd..fb9721e 100644 --- a/testFile.pc +++ b/testFile.pc @@ -1,10 +1,10 @@ App adder(){ - int value1 = 0 - int value2 = 0 + int value1 = 1; + int value2 = 2; - print("total" + intToString(value1 + value2)) + print("total" + intToString(value1 + value2)); return 0;