init php-const + update makefile
This commit is contained in:
parent
ea61d8d6f0
commit
30c6e8a607
|
@ -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;
|
||||
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/**************************
|
||||
* PHP-const *
|
||||
***************************
|
||||
* Designed & Developed by *
|
||||
* Adrien Marquès *
|
||||
* <xdrm-brackets> *
|
||||
***************************
|
||||
* doowap31@gmail.com *
|
||||
**************************/
|
||||
#ifndef _LIB_PHP_CONST_H_
|
||||
#define _LIB_PHP_CONST_H_
|
||||
|
||||
typedef enum PHP_SCOPE{
|
||||
PHP = 0x00, // <?php ... ?>
|
||||
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
|
27
src/linter.c
27
src/linter.c
|
@ -8,3 +8,30 @@
|
|||
* doowap31@gmail.com *
|
||||
**************************/
|
||||
#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;
|
||||
}
|
|
@ -13,5 +13,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue