📄 phpbrowser.c
字号:
79, 78, 76, 75, 73, 68, 66, 65, 63, 61, 59, 54, 50, 47, 46, 45, 42, 41, 34, 33, 30, 29, 25, 24, 22, 19, 17, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975, 975 } ;static yy_state_type yy_last_accepting_state;static char *yy_last_accepting_cpos;/* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */#define REJECT reject_used_but_not_detected#define yymore() yymore_used_but_not_detected#define YY_MORE_ADJ 0#define YY_RESTORE_YY_MORE_OFFSETchar *yytext;#line 1 "phpbrowser.l"#define INITIAL 0/*Copyright (c) 2003, Mo DeJongThis file is part of Source-Navigator.Source-Navigator is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public License as publishedby the Free Software Foundation; either version 2, or (at your option)any later version.Source-Navigator is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public License alongwith Source-Navigator; see the file COPYING. If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330, Boston,MA 02111-1307, USA.*//* * phpbrowser.l * * Copyright (C) 2003 Mo DeJong * * Description: * Lex input file for an php language processor. */#line 36 "phpbrowser.l"#include <ctype.h>#include <stdlib.h>#include <stdio.h>#include "snptools.h"#include "lexinput.h"#include "longstr.h"#include "srchtbl.h"#include "tcl.h"#undef YY_INPUT#define YY_INPUT(buf,r,ms) (r = sn_encoded_input(buf, ms))#undef yywrap#define YY_SKIP_YYWRAPtypedef enum { OPEN_PAREN, /* '(' */ CLOSE_PAREN, /* ')' */ OPEN_BRACE, /* '{' */ CLOSE_BRACE, /* '}' */ OPEN_BRACKET, /* '[' */ CLOSE_BRACKET, /* ']' */ SEMICOLON, /* ';' */ COMMA, /* ',' */ PERIOD, /* '.' */ VARIABLE, /* $var */ ASSIGNMENT_OPERATOR, /* '=' */ ASSIGNMENT_OPERATORS, /* = -= += and so on */ COMPARISON_OPERATORS, /* == === != >= and so on */ INCREMENT_OPERATORS, /* ++ and -- */ REFERENCE_OPERATOR, /* & */ SOMEWORD, /* a sequence of text */ KEYWORD, /* a key sequence in this language */ FUNCTION_KEYWORD, /* The keyword "function" */ GLOBAL_KEYWORD, /* The keyword "global" */ INCLUDE_KEYWORD, /* The keyword "include" */ VDOUBLE_QUOTED_STRING, /* "I am a $variable string" */ DOUBLE_QUOTED_STRING, /* "I am a double quoted string" */ SINGLE_QUOTED_STRING, /* 'I am a double quoted string' */ UNKNOWN, /* Token that parser does not know about */ COMMENT, /* Emit COMMENT token only when debugging */ HTML /* Emit HTML token only when debugging */} TokenType;typedef enum { VAR_READ, VAR_WRITE, VAR_READWRITE} VarAccess;typedef struct Token { TokenType type; char * strval; /* String value of token, NULL if single character */ long start_line; int start_column; long end_line; int end_column; struct Token* vars; /* for variables embedded in a DOUBLE_QUOTED_STRING token */ struct Token* next;} Token;typedef struct NestedBracket { int count; int prefix_incr; struct Token* var; struct NestedBracket* next;} NestedBracket;typedef struct NestedFunction { char* name; char* args; int high_line; int high_col_start; int high_col_end; int line_start; int line_end; int col_start; int col_end; int brace_count; struct NestedFunction* next;} NestedFunction;/* Uncomment this to see debug output in token parsing stage *//* #define TOKEN_DEBUG */#ifdef TOKEN_DEBUGFILE* tokenout = NULL;#endifstatic char * token_dump_file = NULL;static int highlight_file = 0;Token* tokens_head = NULL;Token* tokens_tail = NULL;int token_index = 0; /* current offset from original token_head */static char group[] = "php";#define MAX_SIZE 512/* FIXME: Can't pass NULL or "" as current function (core dump) */static char* current_function = (char *) NULL;static char* current_function_args = (char *) NULL;/* line number where highlight starts and ends */static int current_function_highlight_line;/* in "function fog() {}" column of 'f' in "fog" */static int current_function_highlight_column_start;/* in "function fog() {}" column of 'g' in "fog" */static int current_function_highlight_column_end;/* line where "function" appears */static int current_function_line_start;/* line where closing brace of function appears */static int current_function_line_end;/* in "function fog() {}" column of 'f' in "function" */static int current_function_column_start;/* in "function fog() {}" column of '}' in "{}" */static int current_function_column_end;static int current_function_brace_count;static NestedFunction* function_nest_head = NULL;static NestedFunction* function_nest_tail = NULL;static int current_array_bracket_count = 0;static Token* current_array_token = NULL;static int current_array_prefix_incr = 0;static NestedBracket* array_nest_head = NULL;static NestedBracket* array_nest_tail = NULL;static int result;static SearchTable * global_var_table = (SearchTable *) NULL;static SearchTable * super_global_var_table;/* Stores the contents of a special processing mode over * multiple lines/rules. */LongString mode_buff;long mode_start_line;int mode_start_column;#define COMMENT_DUMP 0#define DQSTRING_DUMP 0#define SQSTRING_DUMP 0#define HDSTRING_DUMP 0#define HTML_DUMP 0#define MATCH_DUMP 0static YY_BUFFER_STATE original_buffer;static char* heredoc_id = (char *) NULL; /* End marker for a heredoc string */static Token* embedded_dq_string_vars_head = NULL;static Token* embedded_dq_string_vars_tail = NULL;#if MATCH_DUMPstatic void matched_pattern(char * pattern, char * text);#endifvoid enter_html_mode();static char* modestring();static void FreeGlobalEntry(SearchEntry *entry);void FreeToken(Token* tok);Token* pop_head_token();void free_head_token();void push_bracket_counter();void pop_bracket_counter();void push_function();void pop_function();void append_token(TokenType type, char* strval, long start_line, int start_column, long end_line, int end_column);void append_dqstring_var_token(char* var, long start_line, int start_column, long end_line, int end_column);void append_dqstring_token(char* strval, long start_line, int start_column, long end_line, int end_column);void emit_var_access_for_dqstring(Token* tok);char * TokenTypeToString(Token *tok);int get_num_tokens_matched(char *match);void emit_function_declaration();void emit_comment();void emit_dqstring();void emit_sqstring();void emit_hdstring();void emit_html();void emit_var_access(Token* tok, VarAccess acc);int yywrap() { return 1; }#define COMMENT_MODE 1#define HTML_MODE 2#define DQSTRING 3#define SQSTRING 4#define HDSTRING 5#define PHP 6#define TOKEN 7/* Macros after this point can all be overridden by user definitions in * section 1. */#ifndef YY_SKIP_YYWRAP#ifdef __cplusplusextern "C" int yywrap YY_PROTO(( void ));#elseextern int yywrap YY_PROTO(( void ));#endif#endif#ifndef YY_NO_UNPUTstatic void yyunput YY_PROTO(( int c, char *buf_ptr ));#endif#ifndef yytext_ptrstatic void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));#endif#ifdef YY_NEED_STRLENstatic int yy_flex_strlen YY_PROTO(( yyconst char * ));#endif#ifndef YY_NO_INPUT#ifdef __cplusplusstatic int yyinput YY_PROTO(( void ));#elsestatic int input YY_PROTO(( void ));#endif#endif#if YY_STACK_USEDstatic int yy_start_stack_ptr = 0;static int yy_start_stack_depth = 0;static int *yy_start_stack = 0;#ifndef YY_NO_PUSH_STATEstatic void yy_push_state YY_PROTO(( int new_state ));#endif#ifndef YY_NO_POP_STATE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -