* @desc Parses the abstract syntax tree for generically to its respective function * @param {Object} ast - the AST object to parse * @param {Array} retArr - return array string * @returns {Array} the parsed string array
(ast, retArr)
| 881 | * @returns {Array} the parsed string array |
| 882 | */ |
| 883 | astGeneric(ast, retArr) { |
| 884 | if (ast === null) { |
| 885 | throw this.astErrorOutput('NULL ast', ast); |
| 886 | } else { |
| 887 | if (Array.isArray(ast)) { |
| 888 | for (let i = 0; i < ast.length; i++) { |
| 889 | this.astGeneric(ast[i], retArr); |
| 890 | } |
| 891 | return retArr; |
| 892 | } |
| 893 | |
| 894 | switch (ast.type) { |
| 895 | case 'FunctionDeclaration': |
| 896 | return this.astFunctionDeclaration(ast, retArr); |
| 897 | case 'FunctionExpression': |
| 898 | return this.astFunctionExpression(ast, retArr); |
| 899 | case 'ReturnStatement': |
| 900 | return this.astReturnStatement(ast, retArr); |
| 901 | case 'Literal': |
| 902 | return this.astLiteral(ast, retArr); |
| 903 | case 'BinaryExpression': |
| 904 | return this.astBinaryExpression(ast, retArr); |
| 905 | case 'Identifier': |
| 906 | return this.astIdentifierExpression(ast, retArr); |
| 907 | case 'AssignmentExpression': |
| 908 | return this.astAssignmentExpression(ast, retArr); |
| 909 | case 'ExpressionStatement': |
| 910 | return this.astExpressionStatement(ast, retArr); |
| 911 | case 'EmptyStatement': |
| 912 | return this.astEmptyStatement(ast, retArr); |
| 913 | case 'BlockStatement': |
| 914 | return this.astBlockStatement(ast, retArr); |
| 915 | case 'IfStatement': |
| 916 | return this.astIfStatement(ast, retArr); |
| 917 | case 'SwitchStatement': |
| 918 | return this.astSwitchStatement(ast, retArr); |
| 919 | case 'BreakStatement': |
| 920 | return this.astBreakStatement(ast, retArr); |
| 921 | case 'ContinueStatement': |
| 922 | return this.astContinueStatement(ast, retArr); |
| 923 | case 'ForStatement': |
| 924 | return this.astForStatement(ast, retArr); |
| 925 | case 'WhileStatement': |
| 926 | return this.astWhileStatement(ast, retArr); |
| 927 | case 'DoWhileStatement': |
| 928 | return this.astDoWhileStatement(ast, retArr); |
| 929 | case 'VariableDeclaration': |
| 930 | return this.astVariableDeclaration(ast, retArr); |
| 931 | case 'VariableDeclarator': |
| 932 | return this.astVariableDeclarator(ast, retArr); |
| 933 | case 'ThisExpression': |
| 934 | return this.astThisExpression(ast, retArr); |
| 935 | case 'SequenceExpression': |
| 936 | return this.astSequenceExpression(ast, retArr); |
| 937 | case 'UnaryExpression': |
| 938 | return this.astUnaryExpression(ast, retArr); |
| 939 | case 'UpdateExpression': |
| 940 | return this.astUpdateExpression(ast, retArr); |
no test coverage detected