Skip to content

Commit 1d79382

Browse files
felekfelek
authored andcommitted
Change to new run mode of fels runner
1 parent ee9233b commit 1d79382

File tree

13 files changed

+59
-120
lines changed

13 files changed

+59
-120
lines changed
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
eclipse.preferences.version=1
22
encoding//src/main/java=UTF-8
3-
encoding//src/main/resources=UTF-8
4-
encoding//src/test/java=UTF-8
53
encoding/<project>=UTF-8

main.fels

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using sfm
2+
3+
range(6){
4+
println("This is range loop!")
5+
}

src/main/java/net/felsstudio/fels/Start/Main.java

Lines changed: 35 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -10,123 +10,46 @@
1010

1111
public class Main {
1212
public static void main(String[] args) throws IOException {
13+
//fels run/help
14+
if(args[0].equalsIgnoreCase("run")) {
15+
run(args);
16+
}else if(args[0].equalsIgnoreCase("help")) {
17+
help();
18+
}else if(args[0].equalsIgnoreCase("version")) {
19+
version();
20+
};
21+
}
1322

14-
System.out.println("=========================================================================================");
15-
System.out.println(" WELCOME IN FELS ");
16-
System.out.println("setAS <DOSHOWVARS> <DOSHOWTOKENS> <DOSHOWME> <SOSHOWAST> - set auto start setting");
17-
System.out.println("debugger <PROJECT_NAME> - open debug setting of <PROJECT_NAME> project");
18-
System.out.println("run <NAME> - run you project");
19-
System.out.println("new <NAME> <VERSION> <AUTHOR> - create new project");
20-
System.out.println("setArgs <DOSHOWVARS> <DOSHOWTOKENS> <DOSHOWME> <SOSHOWAST> - set args");
21-
System.out.println("help - about of FELS");
22-
System.out.println("version - version of FELS");
23-
System.out.println("cls - clear console");
24-
System.out.println("exit - exit from program");
25-
System.out.println("=========================================================================================");
26-
27-
var scan = new Scanner(System.in);
28-
29-
var v = new vals();
30-
31-
if(Files.exists(Paths.get("as.fsf"))){
32-
try(BufferedReader br = Files.newBufferedReader(Paths.get("as.fsf"))) {
33-
v.doShowVars = Boolean.parseBoolean(br.readLine().toString());
34-
v.doShowTokens = Boolean.parseBoolean(br.readLine().toString());
35-
v.doShowMe = Boolean.parseBoolean(br.readLine().toString());
36-
v.doShowAst = Boolean.parseBoolean(br.readLine().toString());
37-
}catch(IOException e){
38-
e.printStackTrace();
23+
private static void run(String[] args) throws IOException {
24+
RunData run = new RunData();
25+
//fels run
26+
for(int i = 1;i < args.length-1;i++){
27+
switch(args[i]){
28+
case "-dsv":
29+
run.doShowVars = true;
30+
case "-dst":
31+
run.doShowTokens = true;
32+
case "-dsmt":
33+
run.doShowMT = true;
34+
case "-dsast":
35+
run.doShowAST = true;
36+
case "-file":
37+
run.startFile = args[++i];
3938
}
40-
System.out.println("Settings up automatically from as.fsf file");
4139
}
4240

43-
while (true) {
44-
System.out.print("FELS v"+ Information.FELS_VERSION+">>>");
45-
var line = scan.nextLine().split(" ");
46-
47-
switch (line[0]) {
48-
case "debugger" ->{
49-
System.out.println("This feature in development");
50-
//TODO("CREATE THIS DEBUGGER!!!")
51-
}
52-
53-
case "setAS" -> {
54-
try {
55-
new File("as.fsf");
56-
57-
try(BufferedWriter bw = new BufferedWriter(new FileWriter("as.fsf"))){
58-
bw.write(line[1] + "\n");
59-
bw.write(line[2] + "\n");
60-
bw.write(line[3] + "\n");
61-
bw.write(line[4] + "\n");
62-
}catch(IOException exc){
63-
exc.printStackTrace();
64-
}
65-
} catch (Exception exc) {
66-
System.err.println("FELS [ERROR] " + exc.getMessage());
67-
}
68-
System.out.println("FELS [ SUCCESSFUL ] setting up auto setting");
69-
}
70-
71-
case "run" ->{
72-
try {
73-
Starter.start(v.doShowVars, v.doShowTokens, v.doShowMe, v.doShowAst, line[1]+"\\src\\main.fels");
74-
} catch (Exception exc) {
75-
System.err.println("FELS [ERROR] " + exc.getMessage());
76-
}
77-
}
78-
79-
case "setArgs" -> {
80-
if (line[1].equals(":f")) {
81-
var lines = new Saver().read();
82-
v.doShowVars = Boolean.parseBoolean(lines[0]);
83-
v.doShowTokens = Boolean.parseBoolean(lines[1]);
84-
v.doShowMe = Boolean.parseBoolean(lines[2]);
85-
v.doShowAst = Boolean.parseBoolean(lines[3]);
86-
System.out.println("FELS [ SUCCESSFUL ] setting up setting");
87-
continue;
88-
}
89-
try {
90-
var lines = new Saver().read();
91-
v.doShowVars = Boolean.parseBoolean(lines[0]);
92-
v.doShowTokens = Boolean.parseBoolean(lines[1]);
93-
v.doShowMe = Boolean.parseBoolean(lines[2]);
94-
v.doShowAst = Boolean.parseBoolean(lines[3]);
95-
} catch (Exception exc) {
96-
System.err.println("FELS [ERROR] " + exc.getMessage());
97-
}
98-
System.out.println("FELS [ SUCCESSFUL ] setting up setting");
99-
}
100-
101-
case "help" -> {
102-
System.out.println("FELS programming language V."+Information.FELS_VERSION);
103-
System.out.println("Copyright $"+Information.FELS_AUTHOR);
104-
System.out.println("FELS console V.0.1");
105-
}
106-
107-
case "version" -> System.out.println("FELS programming language V."+Information.FELS_VERSION);
108-
case "exit" -> {
109-
System.out.println("FELS [ SUCCESSFUL ] exiting from console");
110-
System.exit(0);
111-
}
112-
113-
case "save" -> {
114-
var s = new Saver();
115-
s.save(v);
116-
System.out.println("FELS [ SUCCESSFUL ] run setting save to saver.fsf");
117-
}
41+
Starter.start(run.doShowVars,run.doShowTokens,run.doShowMT,run.doShowAST,run.startFile);
42+
}
11843

119-
case "cls" -> {
120-
System.out.println("\u001b[H\u001b[2J");
121-
System.out.flush();
122-
}
44+
private static void help(){
45+
System.out.println("====FELS PROGRAMMING LANGUAGE====\n"+
46+
"FELS VERSION>>> "+ Information.FELS_VERSION+
47+
"\nFELS AUTHOR>>> "+Information.FELS_AUTHOR+
48+
"\nFELS LOADER VERSION>>> "+Information.LOADER_VERSION+
49+
"\nDATE>>> "+Information.DATE);
50+
}
12351

124-
case "new" ->{
125-
var p = new Project(line[1],line[2],line[3]);
126-
p.createProject();
127-
System.out.println("FELS [ SUCCESSFUL ] setting up project");
128-
}
129-
}
130-
}
52+
private static void version(){
53+
System.out.println("FELS VERSION>>> "+Information.FELS_VERSION);
13154
}
13255
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package main.java.net.felsstudio.fels.Start;
2+
3+
public class RunData {
4+
boolean doShowVars = false;
5+
boolean doShowTokens = false;
6+
boolean doShowMT = false;
7+
boolean doShowAST = false;
8+
String startFile = null;
9+
}

src/main/java/net/felsstudio/fels/parser/ast/PassStatement.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ public void accept(@Nullable Visitor visitor) {
1818
public <R, T> R accept(@Nullable ResultVisitor<R, T> visitor, T input) {
1919
return null;
2020
}
21+
22+
@Override
23+
public String toString() {
24+
return "pass statement";
25+
}
2126
}

src/main/java/net/felsstudio/fels/parser/ast/RangeLoopStatement.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,9 @@ public void accept(@Nullable Visitor visitor) {
3636
public <R, T> R accept(@Nullable ResultVisitor<R, T> visitor, T input) {
3737
return null;
3838
}
39+
40+
@Override
41+
public String toString() {
42+
return "range loop statement";
43+
}
3944
}
-3.95 KB
Binary file not shown.
42 Bytes
Binary file not shown.
109 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)