All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jtransc.media.limelibgdx.util.Operators Maven / Gradle / Ivy

Go to download

JVM AOT compiler currently generating JavaScript, Haxe, with initial focus on Kotlin and games.

There is a newer version: 0.6.7
Show newest version
package com.jtransc.media.limelibgdx.util;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

public class Operators {
	static public HashMap BINOPS = constructOperators(new String[][]{
		new String[] { "=" },
		new String[] { "*", "/", "%" },
		new String[] { "+", "-" },
		new String[] { "<<", ">>", ">>>" },
		new String[] { "<", ">", "<=", ">=" },
		new String[] { "==", "!=" },
		new String[] { "&" },
		new String[] { "^" },
		new String[] { "|" },
		new String[] { "&&" },
		new String[] { "||" },
	});

	static public HashMap UNOPS = constructOperators(new String[][]{
		new String[] { "!" },
		new String[] { "~" },
		new String[] { "++" },
		new String[] { "--" },
		new String[] { "-" },
		new String[] { "+" },
	});

	static public HashMap SYMBOLS = constructOperators(new String[][]{
		new String[] { "(", ")" },
		new String[] { "[", "]" },
		new String[] { "{", "}" },
		new String[] { "." },
		new String[] { "," },
		new String[] { ";" },
		new String[] { "//", "/*", "*/" }, // Comments
	});

	static public final Set ALL = new HashSet() {{
		addAll(Operators.SYMBOLS.keySet());
		addAll(Operators.BINOPS.keySet());
		addAll(Operators.UNOPS.keySet());
	}};

	static private HashMap constructOperators(String[][] opsList) {
		HashMap out = new HashMap<>();
		int priority = 0;
		for (String[] ops : opsList) {
			for (String op : ops) {
				out.put(op, priority);
			}
			priority++;
		}

		return out;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy