Skip to content

Commit

Permalink
Cast a parsed function to internal object
Browse files Browse the repository at this point in the history
  • Loading branch information
a-krikorian committed May 14, 2022
1 parent 7264ec2 commit 92f33a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Function {
class FunctionObj {

constructor(name, args, body, type) {
this._name = name;
Expand Down Expand Up @@ -41,4 +41,4 @@ class Function {
}
}

module.exports = Function;
module.exports = FunctionObj;
5 changes: 3 additions & 2 deletions code-parser-module/parser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const recast = require("recast");
const FunctionAst = require("./domain/FunctionAst");
const FunctionObj = require("./domain/FunctionObj");
class Parser {

static parse (functionString){
Expand All @@ -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;",
Expand Down

0 comments on commit 92f33a0

Please sign in to comment.