-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Running ns formatted ActionLang code in tests working
- Loading branch information
1 parent
3430c81
commit afdfd82
Showing
40 changed files
with
550 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
version = '0.0.1-SNAPSHOT' | ||
|
||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
|
||
dependencies { | ||
} |
55 changes: 55 additions & 0 deletions
55
action-lang/src/main/java/me/retrodaredevil/action/lang/ActionLangUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package me.retrodaredevil.action.lang; | ||
|
||
import me.retrodaredevil.action.lang.translators.json.CustomNodeConfiguration; | ||
import me.retrodaredevil.action.lang.translators.json.NodeConfiguration; | ||
import me.retrodaredevil.action.lang.translators.json.SimpleNodeConfiguration; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public final class ActionLangUtil { | ||
private ActionLangUtil() { throw new UnsupportedOperationException(); } | ||
|
||
public static final Map<String, NodeConfiguration> NODE_CONFIG_MAP; | ||
static { | ||
Map<String, NodeConfiguration> configMap = new HashMap<>(); | ||
configMap.put("racer", CustomNodeConfiguration.RACER); | ||
|
||
SimpleNodeConfiguration.Builder builder = createDefaultNodeConfigurationBuilder(); | ||
|
||
// actions | ||
configMap.put("race", builder.copy().subNodes("racers").build()); | ||
configMap.put("scope", builder.copy().linkedNode("action").build()); | ||
configMap.put("act", builder.copy().args("name").linkedNode("action").build()); | ||
configMap.put("queue", builder.copy().subNodes("actions").build()); | ||
configMap.put("parallel", builder.copy().subNodes("actions").build()); | ||
configMap.put("print", builder.copy().args("message").linkedNode("expression").build()); | ||
configMap.put("call", builder.copy().args("name").build()); | ||
|
||
configMap.put("init", builder.copy().args("name").linkedNode("expression").build()); | ||
configMap.put("init-exp", builder.copy().args("name").linkedNode("expression").build()); | ||
configMap.put("set", builder.copy().args("name").linkedNode("expression").build()); | ||
configMap.put("set-exp", builder.copy().args("name").linkedNode("expression").build()); | ||
|
||
configMap.put("all", builder.copy().linkedNode("expression").build()); | ||
configMap.put("any", builder.copy().linkedNode("expression").build()); | ||
configMap.put("wait", builder.copy().args("duration").build()); | ||
|
||
// expressions | ||
configMap.put("const", builder.copy().args("value").build()); | ||
configMap.put("str", builder.copy().linkedNode("expression").build()); | ||
configMap.put("ref", builder.copy().args("name").build()); | ||
configMap.put("eval", builder.copy().args("name").build()); | ||
configMap.put("join", builder.copy().linkedNode("expression").build()); | ||
configMap.put("concat", builder.copy().subNodes("expressions").build()); | ||
// TODO consider adding union operation and other set operations: https://www.math.net/union | ||
|
||
NODE_CONFIG_MAP = Collections.unmodifiableMap(configMap); | ||
} | ||
public static SimpleNodeConfiguration.Builder createDefaultNodeConfigurationBuilder() { | ||
// we have the ability to modify the default builder in the future if we would like to | ||
return SimpleNodeConfiguration.builder(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
scope : queue { | ||
print "Hello there how are you?" | ||
log("Cool message", summary = true); call someAction | ||
// This code does not have to be run, just has to be parsed | ||
// This code cannot contain SolarThing specific nodes | ||
call someAction | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
client/src/main/java/me/retrodaredevil/solarthing/config/options/ActionConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package me.retrodaredevil.solarthing.config.options; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import me.retrodaredevil.solarthing.actions.config.ActionFormat; | ||
import me.retrodaredevil.solarthing.actions.config.ActionReference; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public final class ActionConfig { | ||
public static final ActionConfig EMPTY = new ActionConfig(Collections.emptyList()); | ||
private final List<Entry> entries; | ||
|
||
@JsonCreator | ||
public ActionConfig(@JsonProperty(value = "entries", required = true) List<Entry> entries) { | ||
this.entries = requireNonNull(entries); | ||
} | ||
|
||
public List<Entry> getEntries() { | ||
return entries; | ||
} | ||
|
||
public static final class Entry { | ||
private final ActionReference actionReference; | ||
private final boolean runOnce; | ||
|
||
@JsonCreator | ||
public Entry( | ||
@JsonProperty(value = "path", required = true) Path path, | ||
@JsonProperty("format") ActionFormat format, | ||
@JsonProperty("once") Boolean runOnce | ||
) { | ||
this.actionReference = new ActionReference( | ||
path, | ||
format == null ? ActionFormat.NOTATION_SCRIPT : format | ||
); | ||
this.runOnce = Boolean.TRUE.equals(runOnce); // by default false | ||
} | ||
|
||
public ActionReference getActionReference() { | ||
return actionReference; | ||
} | ||
|
||
public boolean isRunOnce() { | ||
return runOnce; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.