Search in sources :

Example 1 with RuntimeMap

use of priv.bajdcc.LALR1.grammar.runtime.data.RuntimeMap in project jMiniLang by bajdcc.

the class ModuleList method getCodePage.

@Override
public RuntimeCodePage getCodePage() throws Exception {
    if (runtimeCodePage != null)
        return runtimeCodePage;
    String base = ResourceLoader.load(getClass());
    Grammar grammar = new Grammar(base);
    RuntimeCodePage page = grammar.getCodePage();
    IRuntimeDebugInfo info = page.getInfo();
    info.addExternalValue("g_new_array", () -> new RuntimeObject(new RuntimeArray()));
    info.addExternalValue("g_new_map", () -> new RuntimeObject(new RuntimeMap()));
    buildMethod(info);
    return runtimeCodePage = page;
}
Also used : RuntimeArray(priv.bajdcc.LALR1.grammar.runtime.data.RuntimeArray) RuntimeMap(priv.bajdcc.LALR1.grammar.runtime.data.RuntimeMap) Grammar(priv.bajdcc.LALR1.grammar.Grammar)

Example 2 with RuntimeMap

use of priv.bajdcc.LALR1.grammar.runtime.data.RuntimeMap in project jMiniLang by bajdcc.

the class ModuleNet method parseInternal.

private static RuntimeObject parseInternal(Object o) {
    if (o instanceof JSONObject) {
        JSONObject obj = (JSONObject) o;
        RuntimeMap map = new RuntimeMap();
        obj.forEach((key, value) -> {
            map.put(key, parseInternal(value));
        });
        return new RuntimeObject(map);
    } else if (o instanceof JSONArray) {
        JSONArray obj = (JSONArray) o;
        RuntimeArray arr = new RuntimeArray();
        obj.forEach((key) -> {
            arr.add(parseInternal(key));
        });
        return new RuntimeObject(arr);
    } else {
        return new RuntimeObject(o);
    }
}
Also used : Document(org.dom4j.Document) Iterator(java.util.Iterator) Node(org.dom4j.Node) URL(java.net.URL) LALR1.grammar.runtime(priv.bajdcc.LALR1.grammar.runtime) ModuleNetClient(priv.bajdcc.LALR1.interpret.module.net.ModuleNetClient) ResourceLoader(priv.bajdcc.util.ResourceLoader) SAXReader(org.dom4j.io.SAXReader) Grammar(priv.bajdcc.LALR1.grammar.Grammar) InputStreamReader(java.io.InputStreamReader) ModuleNetServer(priv.bajdcc.LALR1.interpret.module.net.ModuleNetServer) RuntimeArray(priv.bajdcc.LALR1.grammar.runtime.data.RuntimeArray) JSONArray(com.alibaba.fastjson.JSONArray) Logger(org.apache.log4j.Logger) RuntimeMap(priv.bajdcc.LALR1.grammar.runtime.data.RuntimeMap) List(java.util.List) JSON(com.alibaba.fastjson.JSON) Matcher(java.util.regex.Matcher) URLConnection(java.net.URLConnection) JSONObject(com.alibaba.fastjson.JSONObject) BigInteger(java.math.BigInteger) BufferedReader(java.io.BufferedReader) Pattern(java.util.regex.Pattern) RuntimeArray(priv.bajdcc.LALR1.grammar.runtime.data.RuntimeArray) JSONObject(com.alibaba.fastjson.JSONObject) JSONArray(com.alibaba.fastjson.JSONArray) RuntimeMap(priv.bajdcc.LALR1.grammar.runtime.data.RuntimeMap)

Example 3 with RuntimeMap

use of priv.bajdcc.LALR1.grammar.runtime.data.RuntimeMap in project jMiniLang by bajdcc.

the class RuntimeMachine method opMap.

@Override
public void opMap() throws RuntimeException {
    int size = current();
    next();
    RuntimeMap map = new RuntimeMap();
    for (int i = 0; i < size; i++) {
        map.put(loadString(), load());
    }
    stack.pushData(new RuntimeObject(map));
}
Also used : RuntimeMap(priv.bajdcc.LALR1.grammar.runtime.data.RuntimeMap)

Aggregations

RuntimeMap (priv.bajdcc.LALR1.grammar.runtime.data.RuntimeMap)3 Grammar (priv.bajdcc.LALR1.grammar.Grammar)2 RuntimeArray (priv.bajdcc.LALR1.grammar.runtime.data.RuntimeArray)2 JSON (com.alibaba.fastjson.JSON)1 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 BigInteger (java.math.BigInteger)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Logger (org.apache.log4j.Logger)1 Document (org.dom4j.Document)1 Node (org.dom4j.Node)1 SAXReader (org.dom4j.io.SAXReader)1 LALR1.grammar.runtime (priv.bajdcc.LALR1.grammar.runtime)1