From 1db9191a7edf7b0d6d23ddfad70f2d492b4f12c5 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sabadosh Date: Wed, 28 Feb 2018 11:19:29 +0200 Subject: [PATCH] Add parse extends and implements --- config/config.json | 4 ++-- system/processor.js | 41 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/config/config.json b/config/config.json index d0271e2..d555b55 100644 --- a/config/config.json +++ b/config/config.json @@ -1,4 +1,4 @@ { - "in" : "pphpapp/app", - "out" : "pphpapp/out" + "in" : "resources/assets/php", + "out" : "." } diff --git a/system/processor.js b/system/processor.js index 502cb62..811004b 100644 --- a/system/processor.js +++ b/system/processor.js @@ -142,10 +142,41 @@ function parseFile($filePath){ lineReader.on('line', function(line){ - // Pares [class] word - line = line.replace(/@class\s.(\w+)/, function(findedStr){ + // Pares [class] word + line = line.replace(/@class\s.\w+(\s?@extends\s.\w+){0,}(\s?@implements\s.\w+){0,}/, function(findedStr){ + + return findedStr.replace(/\@/g, '') + "{"; + + + }); + + // Pares [extends] word + line = line.replace(/@extends\s.\w+(\s?@implements\s.\w+){0,}/, function(findedStr){ + + newFileData = newFileData.replace(/class[\s|\w]{0,}\{/, function(findedSubStr){ + + return findedSubStr.replace(/\{/, ''); + + + }) + + return findedStr.replace(/\@/g, '') + "{"; + + + }); + + // Pares [implements] word + line = line.replace(/@implements\s.\w+/, function(findedStr){ + + newFileData = newFileData.replace(/class[\s|\w|\n]{0,}extends[\s|\w]{0,}\{/, function(findedSubStr){ + + return findedSubStr.replace(/\{/, ''); + + + }) + + return findedStr.replace(/[\@|\{]/g, '') + "{"; - return findedStr.substr(1) + "{"; }); @@ -160,10 +191,10 @@ function parseFile($filePath){ }); // Pares [function] word - line = line.replace(/\@def(\(static\))?\s*([\+|\-|\.])\s*(\w+)\s*\([$|\w|\s|,]*\)/, function(findedStr, static, access){ + line = line.replace(/\@def(s)?\s*([\+|\-|\.])\s*(\w+)\s*\([$|\w|\s|,]*\)/, function(findedStr, static, access){ if(static) - return accesseVals[access] + ' static function' + findedStr.substr(13) + "{"; + return accesseVals[access] + ' static function' + findedStr.substr(6) + "{"; return accesseVals[access] + ' function' + findedStr.substr(5) + "{";