diff --git a/.gitignore b/.gitignore index f81d56e..b32ebe4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore - # Logs logs @@ -167,3 +166,5 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.\* + +output_testing/ diff --git a/JSTQL/src/language/jstql-validator.ts b/JSTQL/src/language/jstql-validator.ts index a048b09..2c4f79a 100644 --- a/JSTQL/src/language/jstql-validator.ts +++ b/JSTQL/src/language/jstql-validator.ts @@ -18,26 +18,26 @@ export function registerValidationChecks(services: JstqlServices) { * Implementation of custom validations. */ export class JstqlValidator { - validateWildcards(pair: Case, accept: ValidationAcceptor): void { + validateWildcards(case_: Case, accept: ValidationAcceptor): void { try { let validationResultAplTo = validateWildcardAplTo( - collectWildcard(pair.aplTo.apl_to_code.split("")) + collectWildcard(case_.aplTo.apl_to_code.split("")) ); if (validationResultAplTo.errors.length != 0) { accept("error", validationResultAplTo.errors.join("\n"), { - node: pair.aplTo, + node: case_.aplTo, property: "apl_to_code", }); } let validationResultTraTo = validateWildcardTraTo( - collectWildcard(pair.traTo.transform_to_code.split("")), + collectWildcard(case_.traTo.transform_to_code.split("")), validationResultAplTo.env ); if (validationResultTraTo.length != 0) { accept("error", validationResultTraTo.join("\n"), { - node: pair.traTo, + node: case_.traTo, property: "transform_to_code", }); } diff --git a/dsl_files/do.jstql b/dsl_files/do.jstql index 06fbad0..5e656a8 100644 --- a/dsl_files/do.jstql +++ b/dsl_files/do.jstql @@ -1,11 +1,10 @@ proposal DoExpression{ case arrowFunction{ applicable to { - "() => { + "(() => { <> return <>; - } - " + })();" } transform to { "(do { diff --git a/src/evalRunner.ts b/src/evalRunner.ts index e866042..09eb372 100644 --- a/src/evalRunner.ts +++ b/src/evalRunner.ts @@ -3,7 +3,7 @@ import { readdir } from "node:fs/promises"; import { parseJSTQL } from "./langium/langiumRunner"; const main = async () => { - let basepathExamplesJSFiles = "../atom"; + let basepathExamplesJSFiles = "../next.js"; let examples = (await readdir(basepathExamplesJSFiles, { recursive: true })) .filter((x) => x.endsWith(".js")) .map((x) => basepathExamplesJSFiles + "/" + x); diff --git a/src/matcher/matcher.ts b/src/matcher/matcher.ts index 1cd4b85..0847e09 100644 --- a/src/matcher/matcher.ts +++ b/src/matcher/matcher.ts @@ -201,9 +201,18 @@ export class Matcher { } } - return codeNode.type === aplToNode.type - ? MatchResult.Matched - : MatchResult.NoMatch; + for (let [key, val] of Object.entries(aplToNode)) { + if (keys_to_ignore.includes(key)) { + continue; + } + if (typeof val !== "object") { + if (codeNode[key] !== val) { + return MatchResult.NoMatch; + } + } + } + + return MatchResult.Matched; } multiStatementMatcher(code: TreeNode, aplTo: TreeNode) { diff --git a/src/parser/preludeBuilder.ts b/src/parser/preludeBuilder.ts index a24b69d..25d1dc0 100644 --- a/src/parser/preludeBuilder.ts +++ b/src/parser/preludeBuilder.ts @@ -19,13 +19,13 @@ function extractValues(types: t.Statement[]): Wildcard[] { if (init) { if (init.type == "StringLiteral") { init = init; - prelude.push( - new WildcardParser( - new WildcardTokenizer( - innerDSLVariableName + ":" + init - ).tokenize() - ).parse() - ); + let wildcard = new WildcardParser( + new WildcardTokenizer( + innerDSLVariableName + ":" + init + ).tokenize() + ).parse(); + + prelude.push(wildcard); } else { throw new Error( "Invalid usage of right side declaration in prelude" diff --git a/src/transform/transform.ts b/src/transform/transform.ts index 215a120..7ab7208 100644 --- a/src/transform/transform.ts +++ b/src/transform/transform.ts @@ -54,10 +54,8 @@ export function transform( let { cleanedJS: applicableTo, prelude } = parseInternalAplTo( recipe.applicableTo ); - console.log(applicableTo); let transformTo = parseInternalTraTo(recipe.transformTo); - console.log(transformTo); - console.log(prelude); + let temp = transformSelfHosted( { applicableTo, transformTo }, prelude, @@ -93,10 +91,8 @@ function transformSelfHosted( throw new Error("This no worky LOL"); } let matches = runMatch(codeTree, applicableToTree, internals); - //showTreePaired(matches[0].statements[0]); let outputAST = transformer(matches, transformToTree, codeAST, transformTo); - //console.log("Finished transforming"); return [outputAST, matches.length]; } diff --git a/test_files/do_test.js b/test_files/do_test.js index 6358119..55aa3a1 100644 --- a/test_files/do_test.js +++ b/test_files/do_test.js @@ -1,9 +1,9 @@ -let aaaa = () => { +let aaaa = (() => { let g = 100; let ff = 10; let ggg = a(b); return 100; -}; +})(); var bbaaa = (function () { let lllll = 1 + 1;