diff --git a/code-parser-module/domain/Function.js b/code-parser-module/domain/FunctionObj.js similarity index 92% rename from code-parser-module/domain/Function.js rename to code-parser-module/domain/FunctionObj.js index 1f9b46c..9c9a814 100644 --- a/code-parser-module/domain/Function.js +++ b/code-parser-module/domain/FunctionObj.js @@ -1,4 +1,4 @@ -class Function { +class FunctionObj { constructor(name, args, body, type) { this._name = name; @@ -41,4 +41,4 @@ class Function { } } -module.exports = Function; \ No newline at end of file +module.exports = FunctionObj; \ No newline at end of file diff --git a/code-parser-module/parser.js b/code-parser-module/parser.js index 3c6d233..56cea90 100644 --- a/code-parser-module/parser.js +++ b/code-parser-module/parser.js @@ -1,5 +1,6 @@ const recast = require("recast"); const FunctionAst = require("./domain/FunctionAst"); +const FunctionObj = require("./domain/FunctionObj"); class Parser { static parse (functionString){ @@ -12,13 +13,13 @@ class Parser { const functionType = ast.getFunctionType(); const functionBody = ast.getFunctionBody(); - console.log(recast.parse(functionString.join("\n"))) + return new FunctionObj(functionName,functionArgs,functionBody,functionType); } } -Parser.parse([ +let func = Parser.parse([ "function add(a, b) {", "let x = a+b;", " return x;",