UNPKG

minigrace

Version:

A compiler for the Grace programming language

805 lines (792 loc) 37.6 kB
let gracecode_unicode_sourceFile = "/Users/black/Development/mg/gracelang/minigrace/unicode.grace"; let gracecode_unicode_sha256 = "bea4c9784ab6619977a3a39123ef264c096ddd7b60f52b5a864b62c689755362"; let gracecode_unicode_minigraceRevision = "b57591d29fc5ee5270d114920bf671367b8c3ecb"; let gracecode_unicode_minigraceGeneration = "5171"; if (typeof gctCache !== "undefined") gctCache["unicode"] = "dialect:\n standard\nfreshScopes:\nmethodTypes:$100:\n bidirectional(char:String) \u2192 String\n category(char:String) \u2192 String\n combining(char:String) \u2192 Number\n create(codepoint:Number) \u2192 String\n inCategory(char:Unknown, cat:String) \u2192 Boolean\n isControl(char:Unknown) \u2192 Boolean\n isLetter(char:Unknown) \u2192 Boolean\n isNumber(char:Unknown) \u2192 Boolean\n isSeparator(char:Unknown) \u2192 Boolean\n isSymbolMathematical(char:Unknown) \u2192 Boolean\n lookup(uName:String) \u2192 String\n mirrored(char:String) \u2192 Boolean\n name(char:String) \u2192 String\n pattern(cs:Collection) \u2192 Pattern\n pattern(cs:Collection)not(ncs:Collection) \u2192 Pattern\nmodules:\n standard\npath:\n /Users/black/Development/mg/gracelang/minigrace/unicode.grace\nscope:$100:\n asDebugString String (go) $scope_string\n asString String (go) $scope_string\n basicAsString String (go) $scope_string\n bidirectional(1) String (mth) $scope_done\n category(1) String (mth) $scope_done\n combining(1) Number (mth) $scope_done\n create(1) String (mth) $scope_done\n inCategory(2) Boolean (mth) $scope_done\n isControl(1) Boolean (mth) $scope_done\n isLetter(1) Boolean (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n isNumber(1) Boolean (mth) $scope_done\n isSeparator(1) Boolean (mth) $scope_done\n isSymbolMathematical(1) Boolean (mth) $scope_done\n lookup(1) String (mth) $scope_done\n mirrored(1) Boolean (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n name(1) String (mth) $scope_done\n pattern(1) Pattern (mth) $scope_done\n pattern(1)not(1) Pattern (mth) $scope_done\nself:\n $100\ntypes:\n"; if (typeof originalSourceLines !== "undefined") { originalSourceLines["unicode"] = [ "dialect \"standard\"", "", "def thisModule = self", "", "method category(char:String) -> String {", " // Return a string containing the Unicode category of the first", " // character in the 'char' (e.g., \"Nd\").", " native \"js\" code ‹", " return new GraceString(unicode.category(var_char._value));", " ›", "}", "method bidirectional(char:String) -> String {", " // Return a String indicating the bidirectionality of the first", " // character in 'char', as provided in the Unicode tables.", " native \"js\" code ‹›", "}", "method combining(char:String) -> Number {", " // Return a Grace Number containing the Unicode combining class of", " // the first character in the String argument (e.g. 10).", " native \"js\" code ‹›", "}", "method mirrored(char:String) -> Boolean {", " // Is the first character in 'char'", " // marked as mirrored in the Unicode database?", " native \"js\" code ‹›", "}", "method name(char:String) -> String {", " // Return the Unicode name of the first character in 'char'", " // (e.g., \"LATIN SMALL LETTER A WITH DIARESIS\").", " native \"js\" code ‹", " return new GraceString(unicode.name(var_char._value));", " ›", "}", "method inCategory(char, cat:String) -> Boolean {", " // Is the first character of 'char' in the Unicode category 'cat'?", " // 'cat' can be either one or two characters, testing for either", " // a broad category (like \"N\") or a specific one (like \"Nd\").", " native \"js\" code ‹", " let v = var_char._value;", " let s = (typeof v === 'number') ? String.fromCharCode(v) :", " (typeof v === 'string') ? v : safeJsString(var_char);", " return ((unicode.inCategory(s, var_cat._value)) ? GraceTrue : GraceFalse);", " ›", "}", "method isSeparator(char) -> Boolean {", " // Is 'char' a separator?", " native \"js\" code ‹", " let v = var_char._value;", " let s = (typeof v === 'number') ? String.fromCharCode(v) :", " (typeof v === 'string') ? v : safeJsString(var_char);", " return ( ( unicode.inCategory(s, \"Zs\") ||", " unicode.inCategory(s, \"Zp\") ||", " unicode.inCategory(s, \"Zl\") ) ? GraceTrue : GraceFalse);", " ›", "}", "method isControl(char) -> Boolean {", " // Is 'char' a control character?", " native \"js\" code ‹", " let v = var_char._value;", " let s = (typeof v === 'number') ? String.fromCharCode(v) :", " (typeof v === 'string') ? v : safeJsString(var_char);", " return ( ( unicode.inCategory(s, \"Cf\") ||", " unicode.inCategory(s, \"Cc\") ||", " unicode.inCategory(s, \"Co\") ||", " unicode.inCategory(s, \"Cs\") ) ? GraceTrue : GraceFalse);", " ›", "}", "method isLetter(char) -> Boolean {", " // Is 'char' a letter?", " native \"js\" code ‹", " var s;", " let v = var_char._value", " if (typeof v === 'number') {", " s = String.fromCharCode(v);", " } else if (typeof v === 'string') {", " s = v;", " } else {", " s = safeJsString(var_char);", " }", " return ( ( unicode.inCategory(s, \"Ll\") ||", " unicode.inCategory(s, \"Lu\") ||", " unicode.inCategory(s, \"Lo\") ||", " unicode.inCategory(s, \"Lm\") ) ? GraceTrue : GraceFalse);", " ›", "}", "method isNumber(char) -> Boolean {", " // Is 'char' a digit?", " native \"js\" code ‹", " let v = var_char._value;", " let s = (typeof v === 'number') ? String.fromCharCode(v) :", " (typeof v === 'string') ? v : safeJsString(var_char);", " return ( ( unicode.inCategory(s, \"Nd\") ||", " unicode.inCategory(s, \"No\") ||", " unicode.inCategory(s, \"Nl\") ) ? GraceTrue : GraceFalse);", " ›", "}", "method isSymbolMathematical(char) -> Boolean {", " // Is 'char' a mathematical symbol?", " native \"js\" code ‹", " let v = var_char._value;", " let s = (typeof v === 'number') ? String.fromCharCode(v) :", " (typeof v === 'string') ? v : safeJsString(var_char);", " return ((unicode.inCategory(s, \"Sm\")) ? GraceTrue : GraceFalse);", " ›", "}", "method create(codepoint:Number) -> String {", " // Return a string of length 1 containing the Unicode codepoint", " native \"js\" code ‹", " return new GraceString(String.fromCharCode(var_codepoint._value));", " ›", "}", "method lookup(uName:String) -> String {", " // Return the single-character-string representing the unicode codepoint ", " // named by 'uName'. Takes log N time, were N is the number of", " // named Unicode codepoints.", " // NB -- currently missing from the Javascript implementation", " native \"js\" code ‹›", "}", "method pattern(cs:Collection) -> Pattern {", " // Returns a pattern that matches any of the Unicode characters in cs.", " // Each c in cs can be a number, meaning the Unicode character with codepoint c,", " // or a one or two letter string indicating a Unicode category.", " native \"js\" code ‹return new GraceUnicodePattern(var_cs);›", "}", "method pattern(cs:Collection)not(ncs:Collection) -> Pattern {", " // Returns a pattern that matches any of the Unicode characters in cs and ", " // not in ncs. Each c in cs and ncs can be a number, meaning the", " // Unicode character with codepoint c, or a one or two letter string ", " // indicating a Unicode category.", " // For example, pattern [\"C\"] not [10, 13] mathches any Unicode Control", " // character (in category \"C\") other than U+0010 and U+0013 (LF and CR)", " native \"js\" code ‹", " return new GraceUnicodePattern(var_cs, var_ncs);", " ›", "}", "native \"js\" code ‹", " function GraceUnicodePattern(pos, neg) {", " // this.pos and this.neg are Collections of positive and negative items; neg is optional", " this.pos = pos._value;", " // APB: 2016 06 11 This is a horrible hack.", " // pos._value pos._value is defined => pos is a GraceSequence", " // TODO: check that class is sequence.", " if (! this.pos) {", " this.pos = [];", " var iter = callmethod(pos, \"iterator\", [0]);", " while (Grace_isTrue(callmethod(iter, \"hasNext\", [0]))) {", " var p = callmethod(iter, \"next\", [0]);", " this.pos.push(p);", " }", " }", " if (neg) {", " this.neg = neg._value;", " if (! this.neg) {", " this.neg = [];", " var niter = callmethod(pos, \"iterator\", [0]);", " while (Grace_isTrue(callmethod(niter, \"hasNext\", [0]))) {", " var n = callmethod(niter, \"next\", [0]);", " this.neg.push(n);", " }", " }", " }", " }", "", " GraceUnicodePattern.prototype =", " emptyGraceObject(\"unicodePattern\", \"unicode\", lineNumber+1);", " GraceUnicodePattern.prototype.methods['matches(1)'] =", " function(argcv, o) {", " var success = false;", " var cc = o._value;", " if (cc.charCodeAt)", " cc = cc.charCodeAt(0);", " for (var i=0; i<this.pos.length; i++) {", " var t = this.pos[i];", " if (typeof t._value === \"number\") {", " if (cc === t._value) {", " success = true;", " break;", " }", " } else {", " if (unicode.inCategory(cc, t._value)) {", " success = true;", " break;", " }", " }", " }", " if (this.neg) {", " if (this.pos.length === 0)", " success = true;", " for (var j=0; j<this.neg.length; j++) {", " var u = this.neg[j];", " if (typeof u._value === \"number\") {", " if (cc === u._value) {", " success = false;", " break;", " }", " } else {", " if (unicode.inCategory(cc, u._value)) {", " success = false;", " break;", " }", " }", " }", " }", " return success ? GraceTrue : GraceFalse;", " };", "›" ]; } function gracecode_unicode() { importedModules["unicode"] = this; const var_$module = this; this.definitionModule = "unicode"; this.definitionLine = 1; setLineNumber(1); // compilenode dialect // Dialect "standard" const var_$dialect = do_import("standard", gracecode_standard); this.outer = var_$dialect; this.closureKeys = this.closureKeys || []; this.closureKeys.push("outer_unicode_1"); this.outer_unicode_1 = var_$dialect; var func0 = function(argcv, var_char) { // method category(_), line 5 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("category(_)", 0, numArgs - 1); } setLineNumber(5); // compilenode member var call1 = selfRequest(var_$dialect, "String", [0]); assertTypeOrMsg(var_char, call1, "argument to request of `category(_)`", "String"); setLineNumber(8); // compilenode call var result = GraceDone; // start native code from line 8 return new GraceString(unicode.category(var_char._value)); // end native code insertion setLineNumber(5); // compilenode member var call3 = selfRequest(var_$dialect, "String", [0]); setLineNumber(8); // typecheck assertTypeOrMsg(result, call3, "result of method category(_)", "String"); return result; }; // end of method category(_) setLineNumber(5); // compilenode member var call4 = selfRequest(var_$dialect, "String", [0]); func0.paramTypes = [call4]; var call5 = selfRequest(var_$dialect, "String", [0]); func0.returnType = call5; this.methods["category(1)"] = func0; func0.methodName = "category(1)"; func0.paramCounts = [1]; func0.paramNames = ["char"]; func0.definitionLine = 5; func0.definitionModule = "unicode"; var func6 = function(argcv, var_char) { // method bidirectional(_), line 12 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("bidirectional(_)", 0, numArgs - 1); } setLineNumber(12); // compilenode member var call7 = selfRequest(var_$dialect, "String", [0]); assertTypeOrMsg(var_char, call7, "argument to request of `bidirectional(_)`", "String"); setLineNumber(15); // compilenode call var result = GraceDone; // start native code from line 15 // end native code insertion setLineNumber(12); // compilenode member var call9 = selfRequest(var_$dialect, "String", [0]); setLineNumber(15); // typecheck assertTypeOrMsg(result, call9, "result of method bidirectional(_)", "String"); return result; }; // end of method bidirectional(_) setLineNumber(12); // compilenode member var call10 = selfRequest(var_$dialect, "String", [0]); func6.paramTypes = [call10]; var call11 = selfRequest(var_$dialect, "String", [0]); func6.returnType = call11; this.methods["bidirectional(1)"] = func6; func6.methodName = "bidirectional(1)"; func6.paramCounts = [1]; func6.paramNames = ["char"]; func6.definitionLine = 12; func6.definitionModule = "unicode"; var func12 = function(argcv, var_char) { // method combining(_), line 17 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("combining(_)", 0, numArgs - 1); } setLineNumber(17); // compilenode member var call13 = selfRequest(var_$dialect, "String", [0]); assertTypeOrMsg(var_char, call13, "argument to request of `combining(_)`", "String"); setLineNumber(20); // compilenode call var result = GraceDone; // start native code from line 20 // end native code insertion setLineNumber(17); // compilenode member var call15 = selfRequest(var_$dialect, "Number", [0]); setLineNumber(20); // typecheck assertTypeOrMsg(result, call15, "result of method combining(_)", "Number"); return result; }; // end of method combining(_) setLineNumber(17); // compilenode member var call16 = selfRequest(var_$dialect, "String", [0]); func12.paramTypes = [call16]; var call17 = selfRequest(var_$dialect, "Number", [0]); func12.returnType = call17; this.methods["combining(1)"] = func12; func12.methodName = "combining(1)"; func12.paramCounts = [1]; func12.paramNames = ["char"]; func12.definitionLine = 17; func12.definitionModule = "unicode"; var func18 = function(argcv, var_char) { // method mirrored(_), line 22 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("mirrored(_)", 0, numArgs - 1); } setLineNumber(22); // compilenode member var call19 = selfRequest(var_$dialect, "String", [0]); assertTypeOrMsg(var_char, call19, "argument to request of `mirrored(_)`", "String"); setLineNumber(25); // compilenode call var result = GraceDone; // start native code from line 25 // end native code insertion setLineNumber(22); // compilenode member var call21 = selfRequest(var_$dialect, "Boolean", [0]); setLineNumber(25); // typecheck assertTypeOrMsg(result, call21, "result of method mirrored(_)", "Boolean"); return result; }; // end of method mirrored(_) setLineNumber(22); // compilenode member var call22 = selfRequest(var_$dialect, "String", [0]); func18.paramTypes = [call22]; var call23 = selfRequest(var_$dialect, "Boolean", [0]); func18.returnType = call23; this.methods["mirrored(1)"] = func18; func18.methodName = "mirrored(1)"; func18.paramCounts = [1]; func18.paramNames = ["char"]; func18.definitionLine = 22; func18.definitionModule = "unicode"; var func24 = function(argcv, var_char) { // method name(_), line 27 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("name(_)", 0, numArgs - 1); } setLineNumber(27); // compilenode member var call25 = selfRequest(var_$dialect, "String", [0]); assertTypeOrMsg(var_char, call25, "argument to request of `name(_)`", "String"); setLineNumber(30); // compilenode call var result = GraceDone; // start native code from line 30 return new GraceString(unicode.name(var_char._value)); // end native code insertion setLineNumber(27); // compilenode member var call27 = selfRequest(var_$dialect, "String", [0]); setLineNumber(30); // typecheck assertTypeOrMsg(result, call27, "result of method name(_)", "String"); return result; }; // end of method name(_) setLineNumber(27); // compilenode member var call28 = selfRequest(var_$dialect, "String", [0]); func24.paramTypes = [call28]; var call29 = selfRequest(var_$dialect, "String", [0]); func24.returnType = call29; this.methods["name(1)"] = func24; func24.methodName = "name(1)"; func24.paramCounts = [1]; func24.paramNames = ["char"]; func24.definitionLine = 27; func24.definitionModule = "unicode"; var func30 = function(argcv, var_char, var_cat) { // method inCategory(_,_), line 34 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 2) && (numArgs !== 2)) { raiseTypeArgError("inCategory(_,_)", 0, numArgs - 2); } setLineNumber(34); // compilenode member var call31 = selfRequest(var_$dialect, "String", [0]); assertTypeOrMsg(var_cat, call31, "argument 2 in request of `inCategory(_,_)`", "String"); setLineNumber(38); // compilenode call var result = GraceDone; // start native code from line 38 let v = var_char._value; let s = (typeof v === 'number') ? String.fromCharCode(v) : (typeof v === 'string') ? v : safeJsString(var_char); return ((unicode.inCategory(s, var_cat._value)) ? GraceTrue : GraceFalse); // end native code insertion setLineNumber(34); // compilenode member var call33 = selfRequest(var_$dialect, "Boolean", [0]); setLineNumber(38); // typecheck assertTypeOrMsg(result, call33, "result of method inCategory(_,_)", "Boolean"); return result; }; // end of method inCategory(_,_) setLineNumber(34); // compilenode member var call34 = selfRequest(var_$dialect, "String", [0]); func30.paramTypes = [type_Unknown, call34]; var call35 = selfRequest(var_$dialect, "Boolean", [0]); func30.returnType = call35; this.methods["inCategory(2)"] = func30; func30.methodName = "inCategory(2)"; func30.paramCounts = [2]; func30.paramNames = ["char", "cat"]; func30.definitionLine = 34; func30.definitionModule = "unicode"; var func36 = function(argcv, var_char) { // method isSeparator(_), line 45 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("isSeparator(_)", 0, numArgs - 1); } setLineNumber(47); // compilenode call var result = GraceDone; // start native code from line 47 let v = var_char._value; let s = (typeof v === 'number') ? String.fromCharCode(v) : (typeof v === 'string') ? v : safeJsString(var_char); return ( ( unicode.inCategory(s, "Zs") || unicode.inCategory(s, "Zp") || unicode.inCategory(s, "Zl") ) ? GraceTrue : GraceFalse); // end native code insertion setLineNumber(45); // compilenode member var call38 = selfRequest(var_$dialect, "Boolean", [0]); setLineNumber(47); // typecheck assertTypeOrMsg(result, call38, "result of method isSeparator(_)", "Boolean"); return result; }; // end of method isSeparator(_) setLineNumber(45); // compilenode member var call39 = selfRequest(var_$dialect, "Boolean", [0]); func36.returnType = call39; this.methods["isSeparator(1)"] = func36; func36.methodName = "isSeparator(1)"; func36.paramCounts = [1]; func36.paramNames = ["char"]; func36.definitionLine = 45; func36.definitionModule = "unicode"; var func40 = function(argcv, var_char) { // method isControl(_), line 56 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("isControl(_)", 0, numArgs - 1); } setLineNumber(58); // compilenode call var result = GraceDone; // start native code from line 58 let v = var_char._value; let s = (typeof v === 'number') ? String.fromCharCode(v) : (typeof v === 'string') ? v : safeJsString(var_char); return ( ( unicode.inCategory(s, "Cf") || unicode.inCategory(s, "Cc") || unicode.inCategory(s, "Co") || unicode.inCategory(s, "Cs") ) ? GraceTrue : GraceFalse); // end native code insertion setLineNumber(56); // compilenode member var call42 = selfRequest(var_$dialect, "Boolean", [0]); setLineNumber(58); // typecheck assertTypeOrMsg(result, call42, "result of method isControl(_)", "Boolean"); return result; }; // end of method isControl(_) setLineNumber(56); // compilenode member var call43 = selfRequest(var_$dialect, "Boolean", [0]); func40.returnType = call43; this.methods["isControl(1)"] = func40; func40.methodName = "isControl(1)"; func40.paramCounts = [1]; func40.paramNames = ["char"]; func40.definitionLine = 56; func40.definitionModule = "unicode"; var func44 = function(argcv, var_char) { // method isLetter(_), line 68 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("isLetter(_)", 0, numArgs - 1); } setLineNumber(70); // compilenode call var result = GraceDone; // start native code from line 70 var s; let v = var_char._value if (typeof v === 'number') { s = String.fromCharCode(v); } else if (typeof v === 'string') { s = v; } else { s = safeJsString(var_char); } return ( ( unicode.inCategory(s, "Ll") || unicode.inCategory(s, "Lu") || unicode.inCategory(s, "Lo") || unicode.inCategory(s, "Lm") ) ? GraceTrue : GraceFalse); // end native code insertion setLineNumber(68); // compilenode member var call46 = selfRequest(var_$dialect, "Boolean", [0]); setLineNumber(70); // typecheck assertTypeOrMsg(result, call46, "result of method isLetter(_)", "Boolean"); return result; }; // end of method isLetter(_) setLineNumber(68); // compilenode member var call47 = selfRequest(var_$dialect, "Boolean", [0]); func44.returnType = call47; this.methods["isLetter(1)"] = func44; func44.methodName = "isLetter(1)"; func44.paramCounts = [1]; func44.paramNames = ["char"]; func44.definitionLine = 68; func44.definitionModule = "unicode"; var func48 = function(argcv, var_char) { // method isNumber(_), line 86 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("isNumber(_)", 0, numArgs - 1); } setLineNumber(88); // compilenode call var result = GraceDone; // start native code from line 88 let v = var_char._value; let s = (typeof v === 'number') ? String.fromCharCode(v) : (typeof v === 'string') ? v : safeJsString(var_char); return ( ( unicode.inCategory(s, "Nd") || unicode.inCategory(s, "No") || unicode.inCategory(s, "Nl") ) ? GraceTrue : GraceFalse); // end native code insertion setLineNumber(86); // compilenode member var call50 = selfRequest(var_$dialect, "Boolean", [0]); setLineNumber(88); // typecheck assertTypeOrMsg(result, call50, "result of method isNumber(_)", "Boolean"); return result; }; // end of method isNumber(_) setLineNumber(86); // compilenode member var call51 = selfRequest(var_$dialect, "Boolean", [0]); func48.returnType = call51; this.methods["isNumber(1)"] = func48; func48.methodName = "isNumber(1)"; func48.paramCounts = [1]; func48.paramNames = ["char"]; func48.definitionLine = 86; func48.definitionModule = "unicode"; var func52 = function(argcv, var_char) { // method isSymbolMathematical(_), line 97 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("isSymbolMathematical(_)", 0, numArgs - 1); } setLineNumber(99); // compilenode call var result = GraceDone; // start native code from line 99 let v = var_char._value; let s = (typeof v === 'number') ? String.fromCharCode(v) : (typeof v === 'string') ? v : safeJsString(var_char); return ((unicode.inCategory(s, "Sm")) ? GraceTrue : GraceFalse); // end native code insertion setLineNumber(97); // compilenode member var call54 = selfRequest(var_$dialect, "Boolean", [0]); setLineNumber(99); // typecheck assertTypeOrMsg(result, call54, "result of method isSymbolMathematical(_)", "Boolean"); return result; }; // end of method isSymbolMathematical(_) setLineNumber(97); // compilenode member var call55 = selfRequest(var_$dialect, "Boolean", [0]); func52.returnType = call55; this.methods["isSymbolMathematical(1)"] = func52; func52.methodName = "isSymbolMathematical(1)"; func52.paramCounts = [1]; func52.paramNames = ["char"]; func52.definitionLine = 97; func52.definitionModule = "unicode"; var func56 = function(argcv, var_codepoint) { // method create(_), line 106 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("create(_)", 0, numArgs - 1); } setLineNumber(106); // compilenode member var call57 = selfRequest(var_$dialect, "Number", [0]); assertTypeOrMsg(var_codepoint, call57, "argument to request of `create(_)`", "Number"); setLineNumber(108); // compilenode call var result = GraceDone; // start native code from line 108 return new GraceString(String.fromCharCode(var_codepoint._value)); // end native code insertion setLineNumber(106); // compilenode member var call59 = selfRequest(var_$dialect, "String", [0]); setLineNumber(108); // typecheck assertTypeOrMsg(result, call59, "result of method create(_)", "String"); return result; }; // end of method create(_) setLineNumber(106); // compilenode member var call60 = selfRequest(var_$dialect, "Number", [0]); func56.paramTypes = [call60]; var call61 = selfRequest(var_$dialect, "String", [0]); func56.returnType = call61; this.methods["create(1)"] = func56; func56.methodName = "create(1)"; func56.paramCounts = [1]; func56.paramNames = ["codepoint"]; func56.definitionLine = 106; func56.definitionModule = "unicode"; var func62 = function(argcv, var_uName) { // method lookup(_), line 112 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("lookup(_)", 0, numArgs - 1); } setLineNumber(112); // compilenode member var call63 = selfRequest(var_$dialect, "String", [0]); assertTypeOrMsg(var_uName, call63, "argument to request of `lookup(_)`", "String"); setLineNumber(117); // compilenode call var result = GraceDone; // start native code from line 117 // end native code insertion setLineNumber(112); // compilenode member var call65 = selfRequest(var_$dialect, "String", [0]); setLineNumber(117); // typecheck assertTypeOrMsg(result, call65, "result of method lookup(_)", "String"); return result; }; // end of method lookup(_) setLineNumber(112); // compilenode member var call66 = selfRequest(var_$dialect, "String", [0]); func62.paramTypes = [call66]; var call67 = selfRequest(var_$dialect, "String", [0]); func62.returnType = call67; this.methods["lookup(1)"] = func62; func62.methodName = "lookup(1)"; func62.paramCounts = [1]; func62.paramNames = ["uName"]; func62.definitionLine = 112; func62.definitionModule = "unicode"; var func68 = function(argcv, var_cs) { // method pattern(_), line 119 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 1) && (numArgs !== 1)) { raiseTypeArgError("pattern(_)", 0, numArgs - 1); } setLineNumber(119); // compilenode member var call69 = selfRequest(var_$dialect, "Collection", [0]); assertTypeOrMsg(var_cs, call69, "argument to request of `pattern(_)`", "Collection"); setLineNumber(123); // compilenode call var result = GraceDone; // start native code from line 123 return new GraceUnicodePattern(var_cs); // end native code insertion setLineNumber(119); // compilenode member var call71 = selfRequest(var_$dialect, "Pattern", [0]); setLineNumber(123); // typecheck assertTypeOrMsg(result, call71, "result of method pattern(_)", "Pattern"); return result; }; // end of method pattern(_) setLineNumber(119); // compilenode member var call72 = selfRequest(var_$dialect, "Collection", [0]); func68.paramTypes = [call72]; var call73 = selfRequest(var_$dialect, "Pattern", [0]); func68.returnType = call73; this.methods["pattern(1)"] = func68; func68.methodName = "pattern(1)"; func68.paramCounts = [1]; func68.paramNames = ["cs"]; func68.definitionLine = 119; func68.definitionModule = "unicode"; var func74 = function(argcv, var_cs, var_ncs) { // method pattern(_)not(_), line 125 var returnTarget = invocationCount; invocationCount++; const numArgs = arguments.length - 1; if ((numArgs > 2) && (numArgs !== 2)) { raiseTypeArgError("pattern(_)not(_)", 0, numArgs - 2); } setLineNumber(125); // compilenode member var call75 = selfRequest(var_$dialect, "Collection", [0]); assertTypeOrMsg(var_cs, call75, "argument 1 in request of `pattern(_)not(_)`", "Collection"); var call76 = selfRequest(var_$dialect, "Collection", [0]); assertTypeOrMsg(var_ncs, call76, "argument 2 in request of `pattern(_)not(_)`", "Collection"); setLineNumber(132); // compilenode call var result = GraceDone; // start native code from line 132 return new GraceUnicodePattern(var_cs, var_ncs); // end native code insertion setLineNumber(125); // compilenode member var call78 = selfRequest(var_$dialect, "Pattern", [0]); setLineNumber(132); // typecheck assertTypeOrMsg(result, call78, "result of method pattern(_)not(_)", "Pattern"); return result; }; // end of method pattern(_)not(_) setLineNumber(125); // compilenode member var call79 = selfRequest(var_$dialect, "Collection", [0]); var call80 = selfRequest(var_$dialect, "Collection", [0]); func74.paramTypes = [call79, call80]; var call81 = selfRequest(var_$dialect, "Pattern", [0]); func74.returnType = call81; this.methods["pattern(1)not(1)"] = func74; func74.methodName = "pattern(1)not(1)"; func74.paramCounts = [1, 1]; func74.paramNames = ["cs", "ncs"]; func74.definitionLine = 125; func74.definitionModule = "unicode"; setLineNumber(3); // compilenode yourself var var_thisModule = this; var reader82_thisModule = function() { // reader method thisModule if (var_thisModule === undefined) raiseUninitializedVariable("thisModule"); return var_thisModule; }; reader82_thisModule.isDef = true; reader82_thisModule.confidential = true; this.methods["thisModule"] = reader82_thisModule; setLineNumber(136); // compilenode call var result = GraceDone; // start native code from line 136 function GraceUnicodePattern(pos, neg) { // this.pos and this.neg are Collections of positive and negative items; neg is optional this.pos = pos._value; // APB: 2016 06 11 This is a horrible hack. // pos._value pos._value is defined => pos is a GraceSequence // TODO: check that class is sequence. if (! this.pos) { this.pos = []; var iter = callmethod(pos, "iterator", [0]); while (Grace_isTrue(callmethod(iter, "hasNext", [0]))) { var p = callmethod(iter, "next", [0]); this.pos.push(p); } } if (neg) { this.neg = neg._value; if (! this.neg) { this.neg = []; var niter = callmethod(pos, "iterator", [0]); while (Grace_isTrue(callmethod(niter, "hasNext", [0]))) { var n = callmethod(niter, "next", [0]); this.neg.push(n); } } } } GraceUnicodePattern.prototype = emptyGraceObject("unicodePattern", "unicode", lineNumber+1); GraceUnicodePattern.prototype.methods['matches(1)'] = function(argcv, o) { var success = false; var cc = o._value; if (cc.charCodeAt) cc = cc.charCodeAt(0); for (var i=0; i<this.pos.length; i++) { var t = this.pos[i]; if (typeof t._value === "number") { if (cc === t._value) { success = true; break; } } else { if (unicode.inCategory(cc, t._value)) { success = true; break; } } } if (this.neg) { if (this.pos.length === 0) success = true; for (var j=0; j<this.neg.length; j++) { var u = this.neg[j]; if (typeof u._value === "number") { if (cc === u._value) { success = false; break; } } else { if (unicode.inCategory(cc, u._value)) { success = false; break; } } } } return success ? GraceTrue : GraceFalse; }; // end native code insertion return this; } if (typeof global !== "undefined") global.gracecode_unicode = gracecode_unicode; if (typeof window !== "undefined") window.gracecode_unicode = gracecode_unicode; gracecode_unicode.definitionModule = "unicode"; gracecode_unicode.sourceFile = gracecode_unicode_sourceFile; gracecode_unicode.sha256 = gracecode_unicode_sha256; gracecode_unicode.minigraceRevision = gracecode_unicode_minigraceRevision; gracecode_unicode.minigraceGeneration = gracecode_unicode_minigraceGeneration; gracecode_unicode.imports = [ ["standard", "5016aa3a5b2e0d35a67289d21c1e41cf8d73bef931ceea7b35f6a8b10a1386cf"] ]; gracecode_unicode.definitionLine = 1;