C rework (#3483) egorguslyan

* C wordlist extension

* C-like syntax

* Fix arduino tab width

* Fix Quake 3 quote

* Public domain C quotes

* IDs

* Quake 3

* Punctuation

* Prettier

* startWith

* css

* prettier

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
egorguslyan 2022-09-04 13:38:20 +03:00 committed by GitHub
parent 0dde0c7493
commit 2e98da7f3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 363 additions and 153 deletions

View file

@ -259,8 +259,50 @@ export async function punctuateWord(
}
} else if (Math.random() < 0.25 && currentLanguage == "code") {
const specials = ["{", "}", "[", "]", "(", ")", ";", "=", "+", "%", "/"];
const specialsC = [
"{",
"}",
"[",
"]",
"(",
")",
";",
"=",
"+",
"%",
"/",
"/*",
"*/",
"//",
"!=",
"==",
"<=",
">=",
"||",
"&&",
"<<",
">>",
"%=",
"&=",
"*=",
"++",
"+=",
"--",
"-=",
"/=",
"^=",
"|=",
];
word = Misc.randomElementFromArray(specials);
if (
(Config.language.startsWith("code_c") &&
!Config.language.startsWith("code_css")) ||
Config.language.startsWith("code_arduino")
) {
word = Misc.randomElementFromArray(specialsC);
} else {
word = Misc.randomElementFromArray(specials);
}
} else if (
Math.random() < 0.5 &&
currentLanguage === "english" &&

View file

@ -1,111 +1,111 @@
{
"name": "code_arduino",
"leftToRight": true,
"noLazyMode": true,
"words": [
"digitalRead",
"digitalWrite",
"pinMode",
"analogRead",
"analogReference",
"analogWrite",
"analogReadResolution",
"analogWriteResolution",
"noTone",
"pulseIn",
"pulseInLong",
"shiftIn",
"shiftOut",
"tone",
"delay",
"delayMicroseconds",
"micros",
"millis",
"abs",
"constrain",
"map",
"max",
"min",
"pow",
"sq",
"sqrt",
"cos",
"sin",
"tan",
"isAlpha",
"isAlphaNumeric",
"isAscii",
"isControl",
"isDigit",
"isGraph",
"isHexadecimalDigit",
"isLowerCase",
"isPrintable",
"isPunct",
"isSpace",
"isUpperCase",
"isWhitespace",
"random",
"randomSeed",
"bit",
"bitClear",
"bitRead",
"bitSet",
"bitWrite",
"highByte",
"lowByte",
"attachInterrupt",
"detachInterrupt",
"interrupts",
"noInterrupts",
"Serial",
"SPI",
"Stream",
"Wire",
"Keyboard",
"Mouse",
"HIGH",
"LOW",
"INPUT",
"OUTPUT",
"INPUT_PULLUP",
"LED_BUILTIN",
"true",
"false",
"bool",
"boolean",
"byte",
"char",
"double",
"float",
"int",
"long",
"short",
"size_t",
"string",
"String",
"unsigned",
"void",
"word",
"const",
"static",
"volatile",
"PROGMEM",
"sizeof",
"loop",
"setup",
"break",
"continue",
"do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"case",
"while",
"#define",
"#include"
]
"name": "code_arduino",
"leftToRight": true,
"noLazyMode": true,
"words": [
"digitalRead",
"digitalWrite",
"pinMode",
"analogRead",
"analogReference",
"analogWrite",
"analogReadResolution",
"analogWriteResolution",
"noTone",
"pulseIn",
"pulseInLong",
"shiftIn",
"shiftOut",
"tone",
"delay",
"delayMicroseconds",
"micros",
"millis",
"abs",
"constrain",
"map",
"max",
"min",
"pow",
"sq",
"sqrt",
"cos",
"sin",
"tan",
"isAlpha",
"isAlphaNumeric",
"isAscii",
"isControl",
"isDigit",
"isGraph",
"isHexadecimalDigit",
"isLowerCase",
"isPrintable",
"isPunct",
"isSpace",
"isUpperCase",
"isWhitespace",
"random",
"randomSeed",
"bit",
"bitClear",
"bitRead",
"bitSet",
"bitWrite",
"highByte",
"lowByte",
"attachInterrupt",
"detachInterrupt",
"interrupts",
"noInterrupts",
"Serial",
"SPI",
"Stream",
"Wire",
"Keyboard",
"Mouse",
"HIGH",
"LOW",
"INPUT",
"OUTPUT",
"INPUT_PULLUP",
"LED_BUILTIN",
"true",
"false",
"bool",
"boolean",
"byte",
"char",
"double",
"float",
"int",
"long",
"short",
"size_t",
"string",
"String",
"unsigned",
"void",
"word",
"const",
"static",
"volatile",
"PROGMEM",
"sizeof",
"loop",
"setup",
"break",
"continue",
"do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"case",
"while",
"#define",
"#include"
]
}

View file

@ -3,55 +3,205 @@
"leftToRight": true,
"noLazyMode": true,
"words": [
"int",
"char",
"unsigned",
"float",
"void",
"main",
"union",
"long",
"double",
"printf",
"sprintf",
"if",
"else",
"struct",
"fork",
"switch",
"for",
"define",
"return",
"include",
"case",
"&&",
"||",
"auto",
"break",
"bool",
"static",
"case",
"char",
"const",
"continue",
"default",
"do",
"double",
"else",
"enum",
"extern",
"float",
"for",
"goto",
"if",
"inline",
"int",
"long",
"register",
"restrict",
"return",
"short",
"signed",
"sizeof",
"static",
"struct",
"switch",
"typedef",
"exit",
"union",
"unsigned",
"void",
"volatile",
"while",
"_Decimal128",
"_Decimal32",
"_Decimal64",
"_Generic",
"#if",
"#elif",
"#else",
"#endif",
"#ifdef",
"#ifndef",
"#elifdef",
"#elifndef",
"#define",
"#undef",
"#include",
"#line",
"#error",
"#warning",
"#pragma",
"defined",
"__has_c_attribute",
"_Pragma",
"asm",
"fortran",
"<assert.h>",
"EDOM",
"EILSEQ",
"ERANGE",
"errno",
"assert",
"static_assert",
"<complex.h>",
"imaginary",
"complex",
"<inttypes.h>",
"int8_t",
"int16_t",
"int32_t",
"int64_t",
"int_fast8_t",
"int_fast16_t",
"int_fast32_t",
"int_fast64_t",
"int_least8_t",
"int_least16_t",
"int_least32_t",
"int_least64_t",
"intmax_t",
"intptr_t",
"uint8_t",
"uint16_t",
"uint32_t",
"uint64_t",
"uint_fast8_t",
"uint_fast16_t",
"uint_fast32_t",
"uint_fast64_t",
"uint_least8_t",
"uint_least16_t",
"uint_least32_t",
"uint_least64_t",
"uintmax_t",
"uintptr_t",
"<stdio.h>",
"FILE",
"stdin",
"stdout",
"stderr",
"fopen",
"fopen_s",
"freopen",
"freopen_s",
"fclose",
"fflush",
"setbuf",
"setvbuf",
"fgetc",
"getc",
"fputc",
"putc",
"scanf",
"fscanf",
"sscanf",
"printf",
"fprintf",
"sprintf",
"EOF",
"NULL",
"<stdlib.h>",
"malloc",
"calloc",
"free",
"realloc",
"free",
"aligned_alloc",
"abort",
"exit",
"quick_exit",
"unreachable",
"system",
"getenv",
"signal",
"raise",
"setjmp",
"longjmp",
"rand",
"srand",
"qsort",
"bsearch",
"<string.h>",
"fgets",
"strcmp",
"tolower",
"toupper",
"atof",
"atoi",
"atol",
"atoll",
"strtol",
"strtoll",
"strtoul",
"strtoull",
"strtof",
"strtod",
"strtold",
"strcpy",
"fputs",
"stdout",
"EOF",
"getc",
"while",
"fclose",
"fopen",
"do",
"fscanf",
"extern"
"strncpy",
"strcat",
"strncat",
"strlenstrnlen_s",
"strcmp",
"strncmp",
"strcoll",
"strchr",
"strrchr",
"strspn",
"strcspn",
"strpbrk",
"strstr",
"strtok",
"memchr",
"memcmp",
"memset",
"memcpy",
"memmove",
"<math.h>",
"abs",
"div",
"exp",
"log",
"pow",
"sqrt",
"sin",
"cos",
"tan",
"asin",
"acos",
"atan",
"sinh",
"cosh",
"tanh",
"asinh",
"acosh",
"atanh",
"ceil",
"floor",
"round",
"INFINITY",
"NAN"
]
}

View file

@ -14,9 +14,9 @@
"id": 1
},
{
"text": "float Q_rsqrt( float number )\\n{\\n long i;\\n float x2, y;\\n const float threehalfs = 1.5F;\\n\\n x2 = number * 0.5F;\\n y = number;\\n i = * ( long * ) &y; // evil floating point bit level hacking\\n i = 0x5f3759df - ( i >> 1 ); // what the fuck?\\n y = * ( float * ) &i;\\n y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration\\n return y;\\n}\\n",
"text": "float Q_rsqrt( float number )\\n{\\n\\tlong i;\\n\\tfloat x2, y;\\n\\tconst float threehalfs = 1.5F;\\n\\n\\tx2 = number * 0.5F;\\n\\ty = number;\\n\\ti = * ( long * ) &y;\\n\\ti = 0x5f3759df - ( i >> 1 );\\n\\ty = * ( float * ) &i;\\n\\ty = y * ( threehalfs - ( x2 * y * y ) );\\n\\treturn y;\\n}\\n",
"source": "Quake III Arena Source Code (Fast Inverse Square Root)",
"length": 377,
"length": 281,
"id": 2
},
{
@ -200,4 +200,4 @@
"id": 32
}
]
}
}

View file

@ -12,6 +12,24 @@
"source": "Linux Kernel Source Code",
"length": 73,
"id": 1
},
{
"text": "void reverse(char s[]) {\\n\\tint c, i, j;\\n\\tfor ( i = 0, j = strlen(s)-1; i < j; i++, j--) {\\n\\t\\tc = s[i];\\n\\t\\ts[i] = s[j];\\n\\t\\ts[j] = c;\\n\\t}\\n}\\nvoid itoa(int n, char s[], int width) {\\n\\tint i, sign;\\n\\tif ((sign = n) < 0)\\n\\t\\tn = -n;\\n\\ti = 0;\\n\\tdo {\\n\\t\\ts[i++] = n % 10 + '0';\\n\\t\\tprintf(\"%d %% %d + '0' = %d\\\\n\", n, 10, s[i-1]);\\n\\t} while ((n /= 10) > 0);\\n\\tif (sign < 0)\\n\\t\\ts[i++] = '-';\\n\\twhile (i < width)\\n\\t\\ts[i++] = ' ';\\n\\ts[i] = '\\\\0';\\n\\treverse(s);\\n}",
"source": "clc-wiki - atoi",
"length": 480,
"id": 2
},
{
"text": "int hexalpha_to_int(int c)\\n{\\n\\tchar hexalpha[] = \"aAbBcCdDeEfF\";\\n\\tint i;\\n\\tint answer = 0;\\n\\tfor(i = 0; answer == 0 && hexalpha[i] != '\\\\0'; i++)\\n\\t{\\n\\t\\tif(hexalpha[i] == c)\\n\\t\\t{\\n\\t\\t\\tanswer = 10 + (i / 2);\\n\\t\\t}\\n\\t}\\n\\treturn answer;\\n}\\nunsigned int htoi(const char s[])\\n{\\n\\tunsigned int answer = 0;\\n\\tint i = 0;\\n\\tint valid = 1;\\n\\tint hexit;\\n\\n\\tif(s[i] == '0')\\n\\t{\\n\\t\\t++i;\\n\\t\\tif(s[i] == 'x' || s[i] == 'X')\\n\\t\\t{\\n\\t\\t\\t++i;\\n\\t\\t}\\n\\t}\\n\\twhile(valid && s[i] != '\\\\0')\\n\\t{\\n\\t\\tanswer = answer * 16;\\n\\t\\tif(s[i] >= '0' && s[i] <= '9')\\n\\t\\t{\\n\\t\\t\\tanswer = answer + (s[i] - '0');\\n\\t\\t}\\n\\t\\telse\\n\\t\\t{\\n\\t\\t\\thexit = hexalpha_to_int(s[i]);\\n\\t\\t\\tif(hexit == 0)\\n\\t\\t\\t{\\n\\t\\t\\t\\tvalid = 0;\\n\\t\\t\\t}\\n\\t\\t\\telse\\n\\t\\t\\t{\\n\\t\\t\\t\\tanswer = answer + hexit;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t++i;\\n\\t}\\n\\tif(!valid)\\n\\t{\\n\\t\\tanswer = 0;\\n\\t}\\n\\treturn answer;\\n}",
"source": "clc-wiki - htoi",
"length": 884,
"id": 3
},
{
"text": "unsigned rightrot(unsigned x, unsigned n)\\n{\\n\\twhile (n > 0) {\\n\\t\\tif ((x & 1) == 1)\\n\\t\\t\\tx = (x >> 1) | ~(~0U >> 1);\\n\\t\\telse\\n\\t\\t\\tx = (x >> 1);\\n\\t\\tn--;\\n\\t}\\n\\treturn x;\\n}",
"source": "clc-wiki - rightrot",
"length": 183,
"id": 4
}
]
}
}