diff --git a/npm/package.json b/npm/package.json index 3c62fe97..27d7cc4d 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "skew", - "version": "0.7.38", + "version": "0.7.39", "author": "Evan Wallace", "description": "A compiler for the Skew programming language", "license": "MIT", diff --git a/skewc.js b/skewc.js index e3df82e8..fc94463a 100644 --- a/skewc.js +++ b/skewc.js @@ -23770,7 +23770,7 @@ Skew.YY_ACCEPT_LENGTH = 235; Skew.REMOVE_WHITESPACE_BEFORE = in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert({}, Skew.TokenKind.COLON, 0), Skew.TokenKind.COMMA, 0), Skew.TokenKind.DOT, 0), Skew.TokenKind.QUESTION_MARK, 0), Skew.TokenKind.RIGHT_BRACKET, 0), Skew.TokenKind.RIGHT_PARENTHESIS, 0); Skew.FORBID_XML_AFTER = in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert(in_IntMap.insert({}, Skew.TokenKind.CHARACTER, 0), Skew.TokenKind.DECREMENT, 0), Skew.TokenKind.DOUBLE, 0), Skew.TokenKind.DYNAMIC, 0), Skew.TokenKind.STRING_INTERPOLATION_END, 0), Skew.TokenKind.FALSE, 0), Skew.TokenKind.IDENTIFIER, 0), Skew.TokenKind.INCREMENT, 0), Skew.TokenKind.INT, 0), Skew.TokenKind.INT_BINARY, 0), Skew.TokenKind.INT_HEX, 0), Skew.TokenKind.INT_OCTAL, 0), Skew.TokenKind.NULL, 0), Skew.TokenKind.RIGHT_BRACE, 0), Skew.TokenKind.RIGHT_BRACKET, 0), Skew.TokenKind.RIGHT_PARENTHESIS, 0), Skew.TokenKind.STRING, 0), Skew.TokenKind.SUPER, 0), Skew.TokenKind.TRUE, 0); - Skew.VERSION = '0.7.38'; + Skew.VERSION = '0.7.39'; Skew.NATIVE_LIBRARY = '\nconst RELEASE = false\nconst ASSERTS = !RELEASE\n\nenum Target {\n NONE\n CPLUSPLUS\n CSHARP\n JAVASCRIPT\n}\n\nconst TARGET Target = .NONE\n\ndef @alwaysinline\ndef @deprecated\ndef @deprecated(message string)\ndef @entry\ndef @export\ndef @import\ndef @neverinline\ndef @prefer\ndef @rename(name string)\ndef @skip\ndef @spreads\n\n@spreads {\n def @using(name string) # For use with C#\n def @include(name string) # For use with C++\n}\n\n@import if TARGET == .NONE\n@skip if !ASSERTS\ndef assert(truth bool)\n\n@import if TARGET == .NONE\nnamespace Math {\n @prefer\n def abs(x double) double\n def abs(x int) int\n\n def acos(x double) double\n def asin(x double) double\n def atan(x double) double\n def atan2(x double, y double) double\n\n def sin(x double) double\n def cos(x double) double\n def tan(x double) double\n\n def floor(x double) double\n def ceil(x double) double\n def round(x double) double\n\n def exp(x double) double\n def log(x double) double\n def pow(x double, y double) double\n def random double\n def randomInRange(min double, max double) double\n def randomInRange(minInclusive int, maxExclusive int) int\n def sqrt(x double) double\n\n @prefer {\n def max(x double, y double) double\n def min(x double, y double) double\n def max(x double, y double, z double) double\n def min(x double, y double, z double) double\n def max(x double, y double, z double, w double) double\n def min(x double, y double, z double, w double) double\n def clamp(x double, min double, max double) double\n }\n\n def max(x int, y int) int\n def min(x int, y int) int\n def max(x int, y int, z int) int\n def min(x int, y int, z int) int\n def max(x int, y int, z int, w int) int\n def min(x int, y int, z int, w int) int\n def clamp(x int, min int, max int) int\n\n def E double { return 2.718281828459045 }\n def INFINITY double { return 1 / 0.0 }\n def NAN double { return 0 / 0.0 }\n def PI double { return 3.141592653589793 }\n def SQRT_2 double { return 2 ** 0.5 }\n}\n\n@import\nclass bool {\n def ! bool\n def toString string\n}\n\n@import\nclass int {\n def + int\n def - int\n def ~ int\n\n def +(x int) int\n def -(x int) int\n def *(x int) int\n def /(x int) int\n def %(x int) int\n def **(x int) int\n def <=>(x int) int\n def <<(x int) int\n def >>(x int) int\n def >>>(x int) int\n def &(x int) int\n def |(x int) int\n def ^(x int) int\n\n def %%(x int) int {\n return ((self % x) + x) % x\n }\n\n def <<=(x int) int\n def >>=(x int) int\n def &=(x int) int\n def |=(x int) int\n def ^=(x int) int\n\n if TARGET != .CSHARP && TARGET != .CPLUSPLUS {\n def >>>=(x int)\n }\n\n if TARGET != .JAVASCRIPT {\n def ++ int\n def -- int\n\n def %=(x int) int\n def +=(x int) int\n def -=(x int) int\n def *=(x int) int\n def /=(x int) int\n }\n\n def toString string\n}\n\nnamespace int {\n def MIN int { return -0x7FFFFFFF - 1 }\n def MAX int { return 0x7FFFFFFF }\n}\n\n@import\nclass double {\n def + double\n def ++ double\n def - double\n def -- double\n\n def *(x double) double\n def +(x double) double\n def -(x double) double\n def /(x double) double\n def **(x double) double\n def <=>(x double) int\n\n def %%(x double) double {\n return self - Math.floor(self / x) * x\n }\n\n def *=(x double) double\n def +=(x double) double\n def -=(x double) double\n def /=(x double) double\n\n def isFinite bool\n def isNaN bool\n\n def toString string\n}\n\n@import\nclass string {\n def +(x string) string\n def +=(x string) string\n def <=>(x string) int\n\n def count int\n def in(x string) bool\n def indexOf(x string) int\n def lastIndexOf(x string) int\n def startsWith(x string) bool\n def endsWith(x string) bool\n\n def [](x int) int\n def get(x int) string\n def slice(start int) string\n def slice(start int, end int) string\n def codePoints List\n def codeUnits List\n\n def split(x string) List\n def join(x List) string\n def repeat(x int) string\n def replaceAll(before string, after string) string\n\n def toLowerCase string\n def toUpperCase string\n def toString string { return self }\n}\n\nnamespace string {\n def fromCodePoint(x int) string\n def fromCodePoints(x List) string\n def fromCodeUnit(x int) string\n def fromCodeUnits(x List) string\n}\n\n@import if TARGET == .NONE\nclass StringBuilder {\n def new\n def append(x string)\n def toString string\n}\n\n@import\nclass List {\n def new\n def [...](x T) List\n\n def [](x int) T\n def []=(x int, y T) T\n\n def count int\n def isEmpty bool\n def resize(count int, defaultValue T)\n\n @prefer\n def append(x T)\n def append(x List)\n def appendOne(x T)\n\n @prefer\n def prepend(x T)\n def prepend(x List)\n\n @prefer\n def insert(x int, value T)\n def insert(x int, values List)\n\n def removeAll(x T)\n def removeAt(x int)\n def removeDuplicates\n def removeFirst\n def removeIf(x fn(T) bool)\n def removeLast\n def removeOne(x T)\n def removeRange(start int, end int)\n\n def takeFirst T\n def takeLast T\n def takeAt(x int) T\n def takeRange(start int, end int) List\n\n def first T\n def first=(x T) T { return self[0] = x }\n def last T\n def last=(x T) T { return self[count - 1] = x }\n\n def in(x T) bool\n def indexOf(x T) int\n def lastIndexOf(x T) int\n\n def all(x fn(T) bool) bool\n def any(x fn(T) bool) bool\n def clone List\n def each(x fn(T))\n def equals(x List) bool\n def filter(x fn(T) bool) List\n def map(x fn(T) R) List\n def reverse\n def shuffle\n def slice(start int) List\n def slice(start int, end int) List\n def sort(x fn(T, T) int)\n def swap(x int, y int)\n}\n\n@import\nclass StringMap {\n def new\n def {...}(key string, value T) StringMap\n\n def [](key string) T\n def []=(key string, value T) T\n\n def count int\n def isEmpty bool\n def keys List\n def values List\n\n def clone StringMap\n def each(x fn(string, T))\n def get(key string, defaultValue T) T\n def in(key string) bool\n def remove(key string)\n}\n\n@import\nclass IntMap {\n def new\n def {...}(key int, value T) IntMap\n\n def [](key int) T\n def []=(key int, value T) T\n\n def count int\n def isEmpty bool\n def keys List\n def values List\n\n def clone IntMap\n def each(x fn(int, T))\n def get(key int, defaultValue T) T\n def in(key int) bool\n def remove(key int)\n}\n\nclass Box {\n var value T\n}\n\n################################################################################\n# Implementations\n\nclass int {\n def **(x int) int {\n var y = self\n var z = x < 0 ? 0 : 1\n while x > 0 {\n if (x & 1) != 0 { z *= y }\n x >>= 1\n y *= y\n }\n return z\n }\n\n def <=>(x int) int {\n return ((x < self) as int) - ((x > self) as int)\n }\n}\n\nclass double {\n def **(x double) double {\n return Math.pow(self, x)\n }\n\n def <=>(x double) int {\n return ((x < self) as int) - ((x > self) as int)\n }\n}\n\nclass List {\n def resize(count int, defaultValue T) {\n assert(count >= 0)\n while self.count < count { append(defaultValue) }\n while self.count > count { removeLast }\n }\n\n def removeAll(value T) {\n var index = 0\n\n # Remove elements in place\n for i in 0..count {\n if self[i] != value {\n if index < i {\n self[index] = self[i]\n }\n index++\n }\n }\n\n # Shrink the array to the correct size\n while index < count {\n removeLast\n }\n }\n\n def removeDuplicates {\n var index = 0\n\n # Remove elements in place\n for i in 0..count {\n var found = false\n var value = self[i]\n for j in 0..i {\n if value == self[j] {\n found = true\n break\n }\n }\n if !found {\n if index < i {\n self[index] = self[i]\n }\n index++\n }\n }\n\n # Shrink the array to the correct size\n while index < count {\n removeLast\n }\n }\n\n def shuffle {\n var n = count\n for i in 0..n - 1 {\n swap(i, i + ((Math.random * (n - i)) as int))\n }\n }\n\n def swap(i int, j int) {\n assert(0 <= i && i < count)\n assert(0 <= j && j < count)\n var temp = self[i]\n self[i] = self[j]\n self[j] = temp\n }\n}\n\nnamespace Math {\n def randomInRange(min double, max double) double {\n assert(min <= max)\n var value = min + (max - min) * random\n assert(min <= value && value <= max)\n return value\n }\n\n def randomInRange(minInclusive int, maxExclusive int) int {\n assert(minInclusive <= maxExclusive)\n var value = minInclusive + ((maxExclusive - minInclusive) * random) as int\n assert(minInclusive <= value && (minInclusive != maxExclusive ? value < maxExclusive : value == maxExclusive))\n return value\n }\n\n if TARGET != .JAVASCRIPT {\n def max(x double, y double, z double) double {\n return max(max(x, y), z)\n }\n\n def min(x double, y double, z double) double {\n return min(min(x, y), z)\n }\n\n def max(x int, y int, z int) int {\n return max(max(x, y), z)\n }\n\n def min(x int, y int, z int) int {\n return min(min(x, y), z)\n }\n\n def max(x double, y double, z double, w double) double {\n return max(max(x, y), max(z, w))\n }\n\n def min(x double, y double, z double, w double) double {\n return min(min(x, y), min(z, w))\n }\n\n def max(x int, y int, z int, w int) int {\n return max(max(x, y), max(z, w))\n }\n\n def min(x int, y int, z int, w int) int {\n return min(min(x, y), min(z, w))\n }\n }\n\n def clamp(x double, min double, max double) double {\n return x < min ? min : x > max ? max : x\n }\n\n def clamp(x int, min int, max int) int {\n return x < min ? min : x > max ? max : x\n }\n}\n'; Skew.NATIVE_LIBRARY_CPP = '\n@import {\n def __doubleToString(x double) string\n def __intToString(x int) string\n\n @rename("std::isnan")\n def __doubleIsNaN(x double) bool\n\n @rename("std::isfinite")\n def __doubleIsFinite(x double) bool\n}\n\nclass bool {\n def toString string {\n return self ? "true" : "false"\n }\n}\n\nclass int {\n def toString string {\n return __intToString(self)\n }\n\n def >>>(x int) int {\n return (self as dynamic.unsigned >> x) as int\n }\n}\n\nclass double {\n def toString string {\n return __doubleToString(self)\n }\n\n def isNaN bool {\n return __doubleIsNaN(self)\n }\n\n def isFinite bool {\n return __doubleIsFinite(self)\n }\n}\n\nclass string {\n @rename("compare")\n def <=>(x string) int\n\n @rename("contains")\n def in(x string) bool\n}\n\n@rename("Skew::List")\nclass List {\n @rename("contains")\n def in(x T) bool\n}\n\n@rename("Skew::StringMap")\nclass StringMap {\n @rename("contains")\n def in(x string) bool\n}\n\n@rename("Skew::IntMap")\nclass IntMap {\n @rename("contains")\n def in(x int) bool\n}\n\n@import\n@rename("Skew::StringBuilder")\nclass StringBuilder {\n}\n\n@import\n@rename("Skew::Math")\nnamespace Math {\n}\n\n@import\ndef assert(truth bool)\n'; Skew.NATIVE_LIBRARY_CS = '\n@using("System.Diagnostics")\ndef assert(truth bool) {\n dynamic.Debug.Assert(truth)\n}\n\n@using("System")\nvar __random dynamic.Random = null\n\n@using("System")\n@import\nnamespace Math {\n @rename("Abs") if TARGET == .CSHARP\n def abs(x double) double\n @rename("Abs") if TARGET == .CSHARP\n def abs(x int) int\n\n @rename("Acos") if TARGET == .CSHARP\n def acos(x double) double\n @rename("Asin") if TARGET == .CSHARP\n def asin(x double) double\n @rename("Atan") if TARGET == .CSHARP\n def atan(x double) double\n @rename("Atan2") if TARGET == .CSHARP\n def atan2(x double, y double) double\n\n @rename("Sin") if TARGET == .CSHARP\n def sin(x double) double\n @rename("Cos") if TARGET == .CSHARP\n def cos(x double) double\n @rename("Tan") if TARGET == .CSHARP\n def tan(x double) double\n\n @rename("Floor") if TARGET == .CSHARP\n def floor(x double) double\n @rename("Ceiling") if TARGET == .CSHARP\n def ceil(x double) double\n @rename("Round") if TARGET == .CSHARP\n def round(x double) double\n\n @rename("Exp") if TARGET == .CSHARP\n def exp(x double) double\n @rename("Log") if TARGET == .CSHARP\n def log(x double) double\n @rename("Pow") if TARGET == .CSHARP\n def pow(x double, y double) double\n @rename("Sqrt") if TARGET == .CSHARP\n def sqrt(x double) double\n\n @rename("Max") if TARGET == .CSHARP\n def max(x double, y double) double\n @rename("Max") if TARGET == .CSHARP\n def max(x int, y int) int\n\n @rename("Min") if TARGET == .CSHARP\n def min(x double, y double) double\n @rename("Min") if TARGET == .CSHARP\n def min(x int, y int) int\n\n def random double {\n __random ?= dynamic.Random.new()\n return __random.NextDouble()\n }\n}\n\nclass double {\n def isFinite bool {\n return !isNaN && !dynamic.double.IsInfinity(self)\n }\n\n def isNaN bool {\n return dynamic.double.IsNaN(self)\n }\n}\n\n@using("System.Text")\n@import\nclass StringBuilder {\n @rename("Append")\n def append(x string)\n\n @rename("ToString")\n def toString string\n}\n\nclass bool {\n @rename("ToString")\n def toString string {\n return self ? "true" : "false"\n }\n}\n\nclass int {\n @rename("ToString")\n def toString string\n\n def >>>(x int) int {\n return dynamic.unchecked(self as dynamic.uint >> x) as int\n }\n}\n\nclass double {\n @rename("ToString")\n def toString string\n}\n\nclass string {\n @rename("CompareTo")\n def <=>(x string) int\n\n @rename("StartsWith")\n def startsWith(x string) bool\n\n @rename("EndsWith")\n def endsWith(x string) bool\n\n @rename("Contains")\n def in(x string) bool\n\n @rename("IndexOf")\n def indexOf(x string) int\n\n @rename("LastIndexOf")\n def lastIndexOf(x string) int\n\n @rename("Replace")\n def replaceAll(before string, after string) string\n\n @rename("Substring") {\n def slice(start int) string\n def slice(start int, end int) string\n }\n\n @rename("ToLower")\n def toLowerCase string\n\n @rename("ToUpper")\n def toUpperCase string\n\n def count int {\n return (self as dynamic).Length\n }\n\n def get(index int) string {\n return fromCodeUnit(self[index])\n }\n\n def repeat(times int) string {\n var result = ""\n for i in 0..times {\n result += self\n }\n return result\n }\n\n @using("System.Linq")\n @using("System")\n def split(separator string) List {\n var separators = [separator]\n return dynamic.Enumerable.ToList((self as dynamic).Split(dynamic.Enumerable.ToArray(separators as dynamic), dynamic.StringSplitOptions.None))\n }\n\n def join(parts List) string {\n return dynamic.string.Join(self, parts)\n }\n\n def slice(start int, end int) string {\n return (self as dynamic).Substring(start, end - start)\n }\n\n def codeUnits List {\n var result List = []\n for i in 0..count {\n result.append(self[i])\n }\n return result\n }\n}\n\nnamespace string {\n def fromCodeUnit(codeUnit int) string {\n return dynamic.string.new(codeUnit as dynamic.char, 1)\n }\n\n def fromCodeUnits(codeUnits List) string {\n var builder = StringBuilder.new\n for codeUnit in codeUnits {\n builder.append(codeUnit as dynamic.char)\n }\n return builder.toString\n }\n}\n\n@using("System.Collections.Generic")\nclass List {\n @rename("Contains")\n def in(x T) bool\n\n @rename("Add")\n def append(value T)\n\n @rename("AddRange")\n def append(value List)\n\n def sort(x fn(T, T) int) {\n # C# doesn\'t allow an anonymous function to be passed directly\n (self as dynamic).Sort((a T, b T) => x(a, b))\n }\n\n @rename("Reverse")\n def reverse\n\n @rename("RemoveAll")\n def removeIf(x fn(T) bool)\n\n @rename("RemoveAt")\n def removeAt(x int)\n\n @rename("Remove")\n def removeOne(x T)\n\n @rename("TrueForAll")\n def all(x fn(T) bool) bool\n\n @rename("ForEach")\n def each(x fn(T))\n\n @rename("FindAll")\n def filter(x fn(T) bool) List\n\n @rename("ConvertAll")\n def map(x fn(T) R) List\n\n @rename("IndexOf")\n def indexOf(x T) int\n\n @rename("LastIndexOf")\n def lastIndexOf(x T) int\n\n @rename("Insert")\n def insert(x int, value T)\n\n @rename("InsertRange")\n def insert(x int, value List)\n\n def appendOne(x T) {\n if !(x in self) {\n append(x)\n }\n }\n\n def removeRange(start int, end int) {\n (self as dynamic).RemoveRange(start, end - start)\n }\n\n @using("System.Linq") {\n @rename("SequenceEqual")\n def equals(x List) bool\n\n @rename("First")\n def first T\n\n @rename("Last")\n def last T\n }\n\n def any(callback fn(T) bool) bool {\n return !all(x => !callback(x))\n }\n\n def isEmpty bool {\n return count == 0\n }\n\n def count int {\n return (self as dynamic).Count\n }\n\n def prepend(value T) {\n insert(0, value)\n }\n\n def prepend(values List) {\n var count = values.count\n for i in 0..count {\n prepend(values[count - i - 1])\n }\n }\n\n def removeFirst {\n removeAt(0)\n }\n\n def removeLast {\n removeAt(count - 1)\n }\n\n def takeFirst T {\n var value = first\n removeFirst\n return value\n }\n\n def takeLast T {\n var value = last\n removeLast\n return value\n }\n\n def takeAt(x int) T {\n var value = self[x]\n removeAt(x)\n return value\n }\n\n def takeRange(start int, end int) List {\n var value = slice(start, end)\n removeRange(start, end)\n return value\n }\n\n def slice(start int) List {\n return slice(start, count)\n }\n\n def slice(start int, end int) List {\n return (self as dynamic).GetRange(start, end - start)\n }\n\n def clone List {\n var clone = new\n clone.append(self)\n return clone\n }\n}\n\n@using("System.Collections.Generic")\n@rename("Dictionary")\nclass StringMap {\n def count int {\n return (self as dynamic).Count\n }\n\n @rename("ContainsKey")\n def in(key string) bool\n\n @rename("Remove")\n def remove(key string)\n\n def isEmpty bool {\n return count == 0\n }\n\n def {...}(key string, value T) StringMap {\n (self as dynamic).Add(key, value)\n return self\n }\n\n def get(key string, value T) T {\n return key in self ? self[key] : value\n }\n\n def keys List {\n return dynamic.System.Linq.Enumerable.ToList((self as dynamic).Keys)\n }\n\n def values List {\n return dynamic.System.Linq.Enumerable.ToList((self as dynamic).Values)\n }\n\n def clone StringMap {\n var clone = new\n for key in keys {\n clone[key] = self[key]\n }\n return clone\n }\n\n def each(x fn(string, T)) {\n for pair in self as dynamic {\n x(pair.Key, pair.Value)\n }\n }\n}\n\n@using("System.Collections.Generic")\n@rename("Dictionary")\nclass IntMap {\n def count int {\n return (self as dynamic).Count\n }\n\n @rename("ContainsKey")\n def in(key int) bool\n\n @rename("Remove")\n def remove(key int)\n\n def isEmpty bool {\n return count == 0\n }\n\n def {...}(key int, value T) IntMap {\n (self as dynamic).Add(key, value)\n return self\n }\n\n def get(key int, value T) T {\n return key in self ? self[key] : value\n }\n\n def keys List {\n return dynamic.System.Linq.Enumerable.ToList((self as dynamic).Keys)\n }\n\n def values List {\n return dynamic.System.Linq.Enumerable.ToList((self as dynamic).Values)\n }\n\n def clone IntMap {\n var clone = new\n for key in keys {\n clone[key] = self[key]\n }\n return clone\n }\n\n def each(x fn(int, T)) {\n for pair in self as dynamic {\n x(pair.Key, pair.Value)\n }\n }\n}\n'; diff --git a/src/frontend/version.sk b/src/frontend/version.sk index 610c4e4d..ffb863d0 100644 --- a/src/frontend/version.sk +++ b/src/frontend/version.sk @@ -1,3 +1,3 @@ namespace Skew { - const VERSION = "0.7.38" + const VERSION = "0.7.39" }