Skip to content

Commit

Permalink
It works!
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Jan 5, 2025
1 parent ff74bce commit 5e6bdb2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions static/js/appbundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -100994,11 +100994,11 @@ def note_with_error(value, err):
specializeTranslations.set(key, value);
}
}
console.log("specializations of", level2, keywordLang, specializeTranslations);
return (name2, stack) => {
for (const [key, value] of specializeTranslations) {
const regexString = value.replace(/ /g, "|");
if (new RegExp(`^(${regexString})$`, "gu").test(name2)) {
console.log(regexString, name2, "yup", keywordToToken[level2].specialize[key]);
if (stack.canShift(keywordToToken[level2].specialize[key])) {
return keywordToToken[level2].specialize[key];
}
Expand All @@ -101010,16 +101010,16 @@ def note_with_error(value, err):
function extendKeywordGen(level2, keywordLang) {
const extendTranslations = new Map();
for (const [key, value] of traductionMap(keywordLang)) {
if (key in keywordToToken[level2].specialize) {
if (key in keywordToToken[level2].extend) {
extendTranslations.set(key, value);
}
}
console.log("extendations of", level2, keywordLang, extendTranslations);
return (name2, stack) => {
for (const [key, value] of extendTranslations) {
const regexString = value.replace(/ /g, "|");
if (new RegExp(`^(${regexString})$`, "gu").test(name2)) {
if (stack.canShift(keywordToToken[level2].extend[key])) {
console.log("found extend ", level2, key, keywordToToken[level2].extend[key]);
return keywordToToken[level2].extend[key];
}
}
Expand Down
4 changes: 2 additions & 2 deletions static/js/appbundle.js.map

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions static/js/lezer-parsers/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ const keywordToToken: Record<number, tokenSpecilizer> = {
let converted_cache: Map<string, Map<string,string>> | undefined;
/**
* Return the keyword translations (historically called "traductions") for a given language
*
* The return value is `{ keyword -> regex }` for keywords, or the special keyword 'DIGIT'.
*/
function traductionMap(language: string) {
if (!converted_cache) {
Expand All @@ -730,12 +732,11 @@ export function specializeKeywordGen(level: number, keywordLang: string) {
}
}

console.log('specializations of', level, keywordLang, specializeTranslations);

return (name: string, stack: Stack) => {
for (const [key, value] of specializeTranslations) {
const regexString = value.replace(/ /g, '|');
if (new RegExp(`^(${regexString})$`, 'gu').test(name)) {
console.log(regexString, name, 'yup', keywordToToken[level].specialize[key]);
if (stack.canShift(keywordToToken[level].specialize[key])) {
return keywordToToken[level].specialize[key];
}
Expand All @@ -748,13 +749,11 @@ export function specializeKeywordGen(level: number, keywordLang: string) {
export function extendKeywordGen(level: number, keywordLang: string) {
const extendTranslations = new Map();
for (const [key, value] of traductionMap(keywordLang)) {
if (key in keywordToToken[level].specialize) {
if (key in keywordToToken[level].extend) {
extendTranslations.set(key, value);
}
}

console.log('extendations of', level, keywordLang, extendTranslations);

return (name: string, stack: Stack) => {
for (const [key, value] of extendTranslations) {
const regexString = value.replace(/ /g, '|');
Expand Down

0 comments on commit 5e6bdb2

Please sign in to comment.