From 30c6e8a6070e060cfa0a2806d43c2cd80d981d35 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 13 May 2017 13:27:10 +0200 Subject: [PATCH] init php-const + update makefile --- src/Makefile | 6 +++-- src/lib/php-const.h | 65 +++++++++++++++++++++++++++++++++++++++++++++ src/linter.c | 29 +++++++++++++++++++- src/linter.h | 1 + 4 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 src/lib/php-const.h diff --git a/src/Makefile b/src/Makefile index 7b7441c..204cacd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,7 +9,9 @@ install: linter +linter.o: linter.h linter.c + gcc -c -o linter.o linter.c; -linter: linter.c linter.h - gcc $(GCCARGV) -o linter -c linter.c; +linter: linter.o + gcc $(GCCARGV) -o linter linter.o; diff --git a/src/lib/php-const.h b/src/lib/php-const.h new file mode 100644 index 0000000..27ef374 --- /dev/null +++ b/src/lib/php-const.h @@ -0,0 +1,65 @@ +/************************** +* PHP-const * +*************************** +* Designed & Developed by * +* Adrien Marquès * +* * +*************************** +* doowap31@gmail.com * +**************************/ +#ifndef _LIB_PHP_CONST_H_ + #define _LIB_PHP_CONST_H_ + + typedef enum PHP_SCOPE{ + PHP = 0x00, // + FUNCTION = 0x01, + CLASS = 0x02, + WHILE = 0x04, + FOR = 0x08, + FOREACH = 0x10, + IF = 0x20, + ELSE = 0x40, + ELSIF = 0x80 + }; + + typedef enum PHP_STATEMENT{ + VOID = 0x0000, // \r?\n + DECLARE_VAR = 0x0001, // \s?\$(\w+)(\[(?:["']\w+["']|\$\w+)\])*; + ASSIGN_VAR = 0x0002, // \s?\$(\w+)\s*([\.\+\/\*|&-]?=)\s*(.+); + TERNARY = 0x0004, // + FUNCTION_HEAD = 0x0008, // ((?:private|public) )?(?:static )?function \w+\(((?:|(?:\$\w+)(?: ?, ?\$\w+)*))\) + CLASS_HEAD = 0x0010, // ((?:private|public) )?(?:static )?class( extends \w+)?( implements (|\w+(, ?\w+)))? + FUNCTION_CALL = 0x0020, // \w+\(((?:|(?:\$\w+)(?: ?, ?\$\w+)*))\) + CLASS_CONSTRUCT = 0x0040, // new \w+\(\) $ + CLASS_STATIC = 0x0080, // new class $ + COMMENT = 0x0100, // //, /**/, ... + RETURN = 0x0200, // return ... + ECHO = 0x0400, // echo "", echo $var, ... + DEPENDENCY = 0x0800 // require_once, include, require, ... + PROPERTY = 0x1000 // require_once, include, require, ... + METHOD = 0x2000 // require_once, include, require, ... + }; + + typedef enum PHP_COMMENT{ + INLINE = 0x001, + MULTILINE = 0x002, + CHAPTER = 0x004, + SUBCHAPTER = 0x008, + SECTION = 0x010, + SUBSECTION = 0x020, + FUNCTION_HEAD = 0x040, + FUNCTION_CHAPTER_HEAD = 0x080, + FUNCTION_SUBCHAPTER_HEAD = 0x100, + TITLE = 0x200, + HEADER = 0x400 + }; + + typedef enum PHP_TYPE{ + NULL = 0x00, // null + STRING = 0x01, // ".+" | '.+' | STRING.STRING + INT = 0x02, // -?\d+ + FLOAT = 0x04, // -?\d*.\d+ + ARRAY = 0x08 // \[((, )?(PHP_TYPE|CLASS|FUNC|VAR))\] + }; + +#endif \ No newline at end of file diff --git a/src/linter.c b/src/linter.c index c2db99e..0fc2cde 100644 --- a/src/linter.c +++ b/src/linter.c @@ -7,4 +7,31 @@ *************************** * doowap31@gmail.com * **************************/ -#include "linter.h" \ No newline at end of file +#include "linter.h" + + +int main(int argc, char* argv[]){ + + { /* [1] Check arguments + =========================================================*/ + /* (1) argc */ + if( argc < 2 ) + return EXIT_FAILURE; + + /* (2) argv[1] : absolute path */ + if( argv[1][0] != '/' ) + return EXIT_FAILURE; + + /* (3) argv[1] : */ + if( access(argv[1], F_OK) == -1 ) + return EXIT_FAILURE; + + } + + + + + + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/src/linter.h b/src/linter.h index 5e2d4e0..c703d26 100644 --- a/src/linter.h +++ b/src/linter.h @@ -13,5 +13,6 @@ #include #include + #include #endif \ No newline at end of file