Fixed node comparison bug
This commit is contained in:
parent
ecf79c4462
commit
68b95e1cfd
8 changed files with 32 additions and 27 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -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/
|
||||
|
|
|
@ -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",
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
proposal DoExpression{
|
||||
case arrowFunction{
|
||||
applicable to {
|
||||
"() => {
|
||||
"(() => {
|
||||
<<statements: (Statement && !ReturnStatement)+>>
|
||||
return <<returnVal : Expression>>;
|
||||
}
|
||||
"
|
||||
})();"
|
||||
}
|
||||
transform to {
|
||||
"(do {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<t.Node>, aplTo: TreeNode<t.Node>) {
|
||||
|
|
|
@ -19,13 +19,13 @@ function extractValues(types: t.Statement[]): Wildcard[] {
|
|||
if (init) {
|
||||
if (init.type == "StringLiteral") {
|
||||
init = <t.StringLiteral>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"
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue