]> granicus.if.org Git - php/commitdiff
start work on resolving commands, add numeric function and method to lexer
authorkrakjoe <joe.watkins@live.co.uk>
Mon, 17 Feb 2014 22:43:53 +0000 (22:43 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Mon, 17 Feb 2014 22:43:53 +0000 (22:43 +0000)
dev/phpdbg_lexer.l
dev/phpdbg_parser.y
phpdbg_lexer.c
phpdbg_lexer.h
phpdbg_parser.c
phpdbg_parser.h

index 76c28c45dd6b342983e6d061ab55f527233b7e6c..bf74cbdc68138e52744ddde2e3eecad99c8ef465 100644 (file)
 %option reentrant noyywrap never-interactive nounistd
 %option bison-bridge
 
-C_TRUE         ?i:"true"
-C_YES          ?i:"yes"
-C_ON           ?i:"on"
-C_ENABLED      ?i:"enabled"
-C_FALSE                ?i:"false"
-C_NO           ?i:"no"
-C_OFF          ?i:"off"
-C_DISABLED     ?i:"disabled"
-C_EVAL         ?i:"eval"
-C_SHELL                ?i:"shell"
-C_IF           ?i:"if"
+C_TRUE                         ?i:"true"
+C_YES                          ?i:"yes"
+C_ON                           ?i:"on"
+C_ENABLED                      ?i:"enabled"
+C_FALSE                                ?i:"false"
+C_NO                           ?i:"no"
+C_OFF                          ?i:"off"
+C_DISABLED                     ?i:"disabled"
+C_EVAL                         ?i:"eval"
+C_SHELL                                ?i:"shell"
+C_IF                           ?i:"if"
 
-DIGITS         [0-9]+
-ID                     [a-zA-Z_\x7f-\xff\-][a-zA-Z0-9_\x7f-\xff\-]*
-NSID           [\\\\]?{ID}
-METHOD         {NSID}+::{ID}
-FILE           [^ :]+:[0-9]+
-OPLINE         0x[a-fA-F0-9]+
-LITERAL                \"(\\.|[^\\"])*\"
-WS          [ \r\n\t]+
-INPUT          [^\n]+
+DIGITS                         [0-9]+
+ID                                     [a-zA-Z_\x7f-\xff\-][a-zA-Z0-9_\x7f-\xff\-]*
+NSID                           [\\\\]?{ID}
+METHOD                         {NSID}+::{ID}
+NUMERIC_METHOD         {METHOD}[#]{DIGITS}
+NUMERIC_FUNCTION       {NSID}[#]{DIGITS}
+FILE                           [^ :]+:[0-9]+
+OPLINE                         0x[a-fA-F0-9]+
+LITERAL                                \"(\\.|[^\\"])*\"
+WS                     [ \r\n\t]+
+INPUT                          [^\n]+
 %%
 <INITIAL>
 {
@@ -75,6 +77,20 @@ INPUT                [^\n]+
                yylval->num = atoi(yytext);
                return T_DIGITS;
        }
+       {NUMERIC_METHOD}        {
+               phpdbg_init_param(yylval, NUMERIC_METHOD_PARAM);
+               yylval->method.class = "class";
+               yylval->method.name = "func";
+               yylval->num = 0;
+               return T_METHOD; 
+       }
+       {NUMERIC_FUNCTION}      {
+               phpdbg_init_param(yylval, NUMERIC_FUNCTION_PARAM);
+               yylval->str = strndup(yytext, yyleng);
+               yylval->len = yyleng;
+               yylval->num = 0;
+               return T_ID; 
+       }
        {METHOD}                {
                phpdbg_init_param(yylval, METHOD_PARAM);
                yylval->method.class = "class";
index 185283eb8e17445a067071b90e600e740c98d7f6..9d7149ff83f14c604742bf8b78e1336819075c92 100644 (file)
@@ -11,6 +11,7 @@
 #include "phpdbg.h"
 #include "phpdbg_cmd.h"
 #include "phpdbg_utils.h"
+#include "phpdbg_prompt.h"
 
 #define YYSTYPE phpdbg_param_t
 
@@ -42,6 +43,14 @@ void phpdbg_debug_param(const phpdbg_param_t *param, const char *msg) {
                                fprintf(stderr, "%s METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name);
                        break;
                        
+                       case NUMERIC_METHOD_PARAM:
+                               fprintf(stderr, "%s NUMERIC_METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name);
+                       break;
+                       
+                       case NUMERIC_FUNCTION_PARAM:
+                               fprintf(stderr, "%s NUMERIC_FUNCTION_PARAM(%s::%s)\n", msg, param->str, param->num);
+                       break;
+                       
                        case NUMERIC_PARAM:
                                fprintf(stderr, "%s NUMERIC_PARAM(%ld)\n", msg, param->num);
                        break;
@@ -102,13 +111,69 @@ static void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param) {
                next->top = stack->top;
                stack->top = next;
        }
-       
+       phpdbg_debug_param(next, "push ->");
        stack->len++;
 }
 
+phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, phpdbg_param_t **top, char **why) {
+       const phpdbg_command_t *command = commands;
+       phpdbg_param_t *name = *top;
+       phpdbg_command_t *matched[3] = {NULL, NULL, NULL};
+       ulong matches = 0L;
+       
+       while (command && command->name && command->handler) {
+               if (command->name_len >= name->len) {
+                       if (memcmp(command->name, name->str, name->len) == SUCCESS) {
+                               if (matches < 3) {
+                                       matched[matches] = command;
+                                       matches++;
+                               } else break;
+                       }
+               }
+               command++;
+       }
+       
+       switch (matches) {
+               case 0: { 
+                       asprintf(
+                               why,
+                               "The command %s could not be found", 
+                               name->str);
+               } break;
+               
+               case 1: {
+                       (*top) = (*top)->next;
+                       if (matched[0]->subs && (*top) && ((*top)->type == STR_PARAM)) {
+                               command = phpdbg_stack_resolve(matched[0]->subs, top, why);
+                               if (command) {
+                                       phpdbg_notice(
+                                               "Command matching with sub command %s %s", 
+                                               matched[0]->name, command->name);
+                                       return command;
+                               }
+                       }
+                       
+                       phpdbg_notice(
+                               "Command matching with %s", 
+                               matched[0]->name);
+                       return matched[0];
+               } break;
+               
+               default: {
+                       asprintf(
+                               why,
+                               "The command %s is ambigious, matching %d commands", 
+                               name->str, matches);
+               }
+       }
+       
+       return NULL;
+}
+
 int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
        phpdbg_param_t *command = NULL,
                                   *params = NULL;
+       phpdbg_command_t *handler = NULL;
        
        if (stack->type != STACK_PARAM) {
                asprintf(
@@ -122,7 +187,7 @@ int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
                return FAILURE;
        }
        
-       command = params = (phpdbg_param_t*) stack->next;
+       command = (phpdbg_param_t*) stack->next;
        
        switch (command->type) {
                case EVAL_PARAM:
@@ -135,6 +200,23 @@ int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
                
                case STR_PARAM: {
                        /* do resolve command(s) */
+                       handler = phpdbg_stack_resolve(
+                               phpdbg_prompt_commands, &command, why);
+                       
+                       if (handler) {
+                               /* get top of stack */
+                               params = command;
+                               
+                               /* prepare params */
+                               while (params) {
+                                       phpdbg_debug_param(params, "-> ...");
+                                       params = params->next;
+                               }
+                               
+                               return SUCCESS;
+                       } else {
+                               return FAILURE;
+                       }
                } break;
                
                default:
@@ -143,13 +225,6 @@ int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
                        return FAILURE;
        }
        
-       /* do prepare params for function */
-       
-       while (params) {
-               phpdbg_debug_param(params, "-> ...");
-               params = params->next;
-       }
-       
        return SUCCESS;
 }
 
@@ -163,7 +238,7 @@ int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
 typedef void* yyscan_t;
 #endif
 }
-%expect 1 
+%expect 1
 %output  "sapi/phpdbg/phpdbg_parser.c"
 %defines "sapi/phpdbg/phpdbg_parser.h"
  
@@ -179,14 +254,16 @@ typedef void* yyscan_t;
 %token C_SHELL         "shell"
 %token C_IF                    "if (condition)"
 
-%token T_DIGITS         "digits (numbers)"
-%token T_LITERAL "literal (string)"
-%token T_METHOD         "method"
-%token T_OPLINE         "opline"
-%token T_FILE   "file"
-%token T_ID             "identifier (command or function name)"
-%token T_INPUT  "input (input string or data)"
-%token T_UNEXPECTED "input"
+%token T_DIGITS                                "digits (numbers)"
+%token T_LITERAL                       "literal (string)"
+%token T_METHOD                                "method"
+%token T_NUMERIC_METHOD                "method opline address"
+%token T_NUMERIC_FUNCTION      "function opline address"
+%token T_OPLINE                                "opline"
+%token T_FILE                          "file"
+%token T_ID                                    "identifier (command or function name)"
+%token T_INPUT                         "input (input string or data)"
+%token T_UNEXPECTED            "input"
 %%
 
 input
@@ -199,22 +276,22 @@ parameters
        ;
 
 params
-       : /* empty */
-       | parameters
+       : parameters
+       | /* empty */
        ;
 
 normal
-       :       T_ID                                                            { $$ = $1; }
-       |       normal T_ID                                                     { $$ = $2; }
+       :       T_ID                                                            { phpdbg_stack_push(stack, &$1); }
+       |       normal T_ID                                                     { phpdbg_stack_push(stack, &$2); }
        ;
        
 special
-       : C_EVAL T_INPUT                        { $$ = $2; $$.type = EVAL_PARAM; }
-       | C_SHELL T_INPUT                                               { $$ = $2; $$.type = SHELL_PARAM;; }
+       : C_EVAL T_INPUT                        { $$ = $2; $$.type = EVAL_PARAM;  }
+       | C_SHELL T_INPUT                                               { $$ = $2; $$.type = SHELL_PARAM; }
        ;
 
 command
-       : normal                                                                { phpdbg_stack_push(stack, &$1); }
+       : normal
        | special                                                               { phpdbg_stack_push(stack, &$1); }
        ;
        
@@ -222,6 +299,8 @@ parameter
        : T_DIGITS                                                              { $$ = $1; }
        | T_FILE                                                                { $$ = $1; }
        | T_METHOD                                                              { $$ = $1; }
+       | T_NUMERIC_METHOD                                              { $$ = $1; }
+       | T_NUMERIC_FUNCTION                                    { $$ = $1; }
        | T_OPLINE                                                              { $$ = $1; }
        | T_ID                                                                  { $$ = $1; } 
        | T_LITERAL                                                             { $$ = $1; }
index cc8535fe5c612164b31841883345f6df306096f2..e9e243c5e5503715d91fd650b8cbe68ac9d4d017 100644 (file)
@@ -349,8 +349,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
        *yy_cp = '\0'; \
        yyg->yy_c_buf_p = yy_cp;
 
-#define YY_NUM_RULES 15
-#define YY_END_OF_BUFFER 16
+#define YY_NUM_RULES 17
+#define YY_END_OF_BUFFER 18
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -358,18 +358,18 @@ struct yy_trans_info
        flex_int32_t yy_verify;
        flex_int32_t yy_nxt;
        };
-static yyconst flex_int16_t yy_accept[92] =
+static yyconst flex_int16_t yy_accept[96] =
     {   0,
-        0,    0,    0,    0,   16,   14,   13,   13,   13,   14,
-       11,    6,    6,   14,   11,   11,   11,   11,   11,   11,
-       11,   11,   11,   14,   12,   12,   13,    0,    0,   13,
-       13,    0,    0,   10,    0,    0,   11,   11,    0,    0,
-        6,    0,   11,   11,   11,   11,    3,    5,   11,    4,
-       11,   11,   11,   11,   12,   12,    8,   10,    0,    8,
-        0,    0,    9,   11,   11,   11,   11,    5,   11,   11,
-        4,    7,    0,    0,   11,   11,    1,   11,   11,    4,
-        7,   11,   11,    5,    2,   11,   11,   11,    4,    5,
-        0
+        0,    0,    0,    0,   18,   16,   15,   15,   15,   16,
+       13,    6,    6,   16,   13,   13,   13,   13,   13,   13,
+       13,   13,   13,   16,   14,   14,   15,    0,    0,   15,
+       15,    0,    0,   12,    0,    0,    0,   13,   13,    0,
+        0,    6,    0,   13,   13,   13,   13,    3,    5,   13,
+        4,   13,   13,   13,   13,   14,   14,   10,   12,    0,
+       10,    8,    0,    0,   11,   13,   13,   13,   13,    5,
+       13,   13,    4,    9,    0,    0,   13,   13,    1,   13,
+       13,    4,    0,    9,   13,   13,    5,    2,    7,   13,
+       13,   13,    4,    5,    0
 
     } ;
 
@@ -378,184 +378,184 @@ static yyconst flex_int32_t yy_ec[256] =
         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
         1,    1,    2,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    4,    1,    5,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    6,    1,    1,    7,    8,    8,
-        8,    8,    8,    8,    8,    8,    8,    9,    1,    1,
-        1,    1,    1,    1,   10,   11,   12,   13,   14,   15,
-        6,   16,   17,    6,    6,   18,    6,   19,   20,    6,
-        6,   21,   22,   23,   24,   25,    6,    6,   26,    6,
-        1,   27,    1,    1,    6,    1,   28,   29,   12,   30,
-
-       31,   32,    6,   33,   34,    6,    6,   35,    6,   36,
-       37,    6,    6,   38,   39,   40,   41,   42,    6,   43,
-       44,    6,    1,    1,    1,    1,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6
+        1,    4,    1,    5,    6,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    7,    1,    1,    8,    9,    9,
+        9,    9,    9,    9,    9,    9,    9,   10,    1,    1,
+        1,    1,    1,    1,   11,   12,   13,   14,   15,   16,
+        7,   17,   18,    7,    7,   19,    7,   20,   21,    7,
+        7,   22,   23,   24,   25,   26,    7,    7,   27,    7,
+        1,   28,    1,    1,    7,    1,   29,   30,   13,   31,
+
+       32,   33,    7,   34,   35,    7,    7,   36,    7,   37,
+       38,    7,    7,   39,   40,   41,   42,   43,    7,   44,
+       45,    7,    1,    1,    1,    1,    7,    7,    7,    7,
+        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
+        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
+        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
+        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
+        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
+        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
+        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
+
+        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
+        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
+        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
+        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
+        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
+        7,    7,    7,    7,    7
     } ;
 
-static yyconst flex_int32_t yy_meta[45] =
+static yyconst flex_int32_t yy_meta[46] =
     {   0,
-        1,    1,    2,    3,    1,    4,    5,    5,    1,    4,
-        4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
-        4,    4,    4,    4,    4,    4,    1,    4,    4,    4,
-        4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
-        4,    4,    4,    4
+        1,    1,    2,    3,    1,    4,    5,    4,    4,    1,
+        5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
+        5,    5,    5,    5,    5,    5,    5,    1,    5,    5,
+        5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
+        5,    5,    5,    5,    5
     } ;
 
-static yyconst flex_int16_t yy_base[103] =
+static yyconst flex_int16_t yy_base[107] =
     {   0,
-        0,    0,   43,   46,  161,  150,   49,   52,   60,   61,
-       88,   60,   64,  433,  115,   58,   70,   42,   65,   93,
-       97,  116,  121,  155,    0,  103,  137,  125,   71,  142,
-      163,  164,  116,   77,  167,  144,   67,   92,  169,  194,
-      172,  215,  166,  176,  203,  172,   94,  102,  200,  153,
-      202,  218,  231,  175,    0,  236,  177,  433,   78,  249,
-        0,  276,    0,  241,  238,  256,  265,  246,  271,  278,
-      276,    0,  312,  339,  316,  290,  277,  318,  319,  284,
-        0,  338,  343,  309,  317,  344,  346,  351,  345,  348,
-      433,  385,  390,  395,  400,  405,  410,  415,  420,   56,
-
-      425,  427
+        0,    0,   44,   47,  160,  136,   50,   53,   62,   57,
+       85,   60,   63,  433,  113,   63,   91,   64,   89,  112,
+       41,   90,  118,  153,    0,   75,  135,  101,  126,  162,
+      140,  147,  112,   95,  162,  170,  168,   66,  150,  174,
+      190,  178,  211,  171,  199,  218,  195,  197,  198,  219,
+      220,  230,  221,  241,  231,    0,  199,  196,  433,  100,
+      252,  199,    0,  281,    0,  240,  267,  259,  270,  232,
+      280,  285,  278,   90,  320,    0,  289,  314,  296,  319,
+      317,  309,  262,   86,  320,  325,  323,  324,  264,  346,
+      348,  349,  347,  350,  433,  385,  390,  395,  400,  405,
+
+      410,  415,  420,   69,  425,  427
     } ;
 
-static yyconst flex_int16_t yy_def[103] =
+static yyconst flex_int16_t yy_def[107] =
     {   0,
-       91,    1,   92,   92,   91,   93,   93,   93,   91,   94,
-       95,   93,   93,   91,   95,   15,   15,   15,   15,   15,
-       15,   15,   15,   96,   97,   97,   91,   93,   91,   93,
-       91,   94,   98,   93,   98,   94,   15,   15,   91,   99,
-       93,   93,   15,   15,   15,   15,   15,   15,   15,   15,
-       15,   15,   15,   15,   97,   97,   91,   91,   98,   98,
-      100,  101,   42,   15,   15,   15,   15,   15,   15,   15,
-       15,  102,  101,  101,   15,   15,   15,   15,   15,   15,
-      102,   15,   15,   15,   15,   15,   15,   15,   15,   15,
-        0,   91,   91,   91,   91,   91,   91,   91,   91,   91,
-
-       91,   91
+       95,    1,   96,   96,   95,   97,   97,   97,   95,   98,
+       99,   97,   97,   95,   99,   15,   15,   15,   15,   15,
+       15,   15,   15,  100,  101,  101,   95,   97,   95,   97,
+       95,   98,  102,   97,  102,   98,   97,   15,   15,   95,
+      103,   97,   97,   15,   15,   15,   15,   15,   15,   15,
+       15,   15,   15,   15,   15,  101,  101,   95,   95,  102,
+      102,   97,  104,  105,   43,   15,   15,   15,   15,   15,
+       15,   15,   15,  106,  105,   75,   15,   15,   15,   15,
+       15,   15,   95,  106,   15,   15,   15,   15,   95,   15,
+       15,   15,   15,   15,    0,   95,   95,   95,   95,   95,
+
+       95,   95,   95,   95,   95,   95
     } ;
 
-static yyconst flex_int16_t yy_nxt[478] =
+static yyconst flex_int16_t yy_nxt[479] =
     {   0,
-        6,    7,    8,    9,   10,   11,   12,   13,   14,   11,
-       11,   11,   15,   16,   17,   11,   18,   11,   19,   20,
-       11,   21,   22,   11,   11,   23,   24,   11,   11,   15,
-       16,   17,   11,   18,   11,   19,   20,   11,   21,   22,
-       11,   11,   11,   23,   26,   27,   26,   26,   27,   26,
-       30,   30,   31,   30,   30,   31,   47,   29,   37,   72,
-       29,   31,   31,   31,   33,   34,   41,   41,   29,   35,
-       41,   41,   29,   47,   37,   37,   44,   57,   57,   46,
-       91,   37,   45,   37,   48,   29,   37,   36,   28,   28,
-       28,   37,   28,   44,   38,   38,   39,   46,   37,   45,
-
-       37,   48,   42,   37,   56,   31,   56,   49,   37,   37,
-       37,   50,   51,   37,   40,   28,   28,   28,   37,   28,
-       58,   38,   38,   39,   49,   37,   37,   37,   50,   51,
-       37,   43,   37,   29,   53,   37,   52,   37,   31,   31,
-       31,   40,   59,   30,   30,   31,   28,   33,   43,   37,
-       29,   53,   35,   52,   37,   28,   28,   28,   29,   28,
-       91,   28,   28,   29,   31,   31,   31,   33,   34,   37,
-       91,   58,   35,   60,   60,   57,   57,   61,   41,   41,
-       29,   28,   37,   57,   57,   65,   37,   64,   37,   67,
-       36,   37,   37,   59,   28,   28,   28,   91,   28,   37,
-
-       28,   28,   29,   65,   64,   37,   67,   91,   37,   37,
-       91,   91,   66,   91,   68,   69,   37,   91,   37,   37,
-       28,   63,   63,   29,   63,   63,   63,   63,   63,   63,
-       66,   68,   69,   37,   37,   37,   37,   56,   31,   56,
-       91,   70,   63,   63,   63,   63,   63,   37,   76,   91,
-       75,   37,   71,   58,   37,   60,   60,   37,   70,   91,
-       91,   91,   37,   91,   37,   91,   76,   91,   75,   71,
-       91,   37,   37,   77,   37,   59,   28,   28,   28,   37,
-       28,   37,   74,   74,   39,   91,   78,   37,   79,   37,
-       77,   80,   37,   37,   37,   91,   91,   91,   37,   91,
-
-       37,   91,   40,   78,   37,   79,   37,   83,   80,   37,
-       37,   37,   28,   28,   28,   91,   28,   37,   74,   74,
-       39,   91,   91,   37,   83,   37,   82,   91,   91,   91,
-       91,   84,   37,   37,   37,   37,   85,   91,   40,   28,
-       28,   28,   37,   28,   82,   74,   74,   39,   84,   37,
-       37,   37,   37,   85,   37,   86,   87,   88,   89,   37,
-       37,   37,   37,   90,   37,   40,   91,   37,   91,   91,
-       91,   37,   86,   87,   88,   89,   37,   37,   37,   37,
-       90,   37,   91,   91,   37,   25,   25,   25,   25,   25,
-       28,   28,   91,   28,   28,   32,   32,   32,   32,   32,
-
-       37,   37,   91,   37,   37,   54,   54,   91,   54,   54,
-       55,   91,   55,   55,   55,   33,   33,   33,   33,   33,
-       62,   62,   91,   62,   62,   73,   73,   91,   73,   73,
-       81,   81,    5,   91,   91,   91,   91,   91,   91,   91,
-       91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
-       91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
-       91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
-       91,   91,   91,   91,   91,   91,   91
+        6,    7,    8,    9,   10,    6,   11,   12,   13,   14,
+       11,   11,   11,   15,   16,   17,   11,   18,   11,   19,
+       20,   11,   21,   22,   11,   11,   23,   24,   11,   11,
+       15,   16,   17,   11,   18,   11,   19,   20,   11,   21,
+       22,   11,   11,   11,   23,   26,   27,   26,   26,   27,
+       26,   30,   30,   31,   30,   30,   31,   52,   38,   29,
+       33,   34,   29,   31,   31,   31,   35,   42,   42,   29,
+       42,   42,   29,   74,   52,   38,   57,   31,   57,   48,
+       38,   38,   45,   38,   36,   28,   28,   28,   46,   28,
+       37,   83,   39,   39,   40,   83,   48,   38,   38,   45,
+
+       38,   47,   95,   43,   29,   46,   38,   38,   38,   49,
+       29,   53,   41,   28,   28,   28,   59,   28,   37,   47,
+       39,   39,   40,   38,   38,   38,   49,   50,   53,   38,
+       44,   51,   54,   58,   58,   38,   31,   31,   31,   60,
+       41,   31,   31,   31,   50,   29,   38,   44,   51,   54,
+       33,   34,   38,   28,   28,   28,   35,   28,   28,   95,
+       28,   28,   29,   30,   30,   31,   59,   38,   95,   61,
+       61,   29,   28,   33,   36,   62,   62,   29,   95,   35,
+       28,   58,   58,   63,   38,   42,   42,   29,   38,   60,
+       28,   28,   28,   66,   28,   28,   95,   28,   28,   29,
+
+       57,   31,   57,   58,   58,   38,   62,   62,   29,   67,
+       66,   95,   38,   69,   38,   38,   38,   28,   65,   65,
+       29,   65,   65,   65,   65,   65,   65,   67,   68,   38,
+       69,   38,   38,   38,   70,   38,   38,   38,   38,   65,
+       65,   65,   65,   65,   71,   72,   68,   38,   38,   38,
+       77,   70,   38,   38,   38,   38,   59,   38,   38,   61,
+       61,   71,   72,   73,   38,   38,   38,   95,   77,   89,
+       89,   89,   89,   95,   38,   38,   38,   79,   78,   60,
+       73,   28,   28,   28,   38,   28,   28,   38,   76,   76,
+       40,   95,   80,   38,   79,   38,   78,   38,   81,   82,
+
+       85,   38,   38,   95,   38,   95,   38,   95,   41,   80,
+       95,   95,   38,   38,   38,   81,   82,   95,   85,   38,
+       28,   28,   28,   38,   28,   28,   38,   76,   76,   40,
+       38,   38,   86,   87,   38,   88,   38,   38,   90,   91,
+       38,   38,   38,   38,   95,   95,   95,   41,   38,   86,
+       87,   38,   88,   38,   38,   90,   91,   38,   38,   38,
+       92,   93,   94,   38,   38,   38,   38,   38,   95,   95,
+       95,   95,   95,   95,   95,   95,   95,   92,   93,   94,
+       38,   38,   38,   38,   38,   25,   25,   25,   25,   25,
+       28,   28,   95,   28,   28,   32,   32,   32,   32,   32,
+
+       38,   38,   95,   38,   38,   55,   55,   95,   55,   55,
+       56,   95,   56,   56,   56,   33,   33,   33,   33,   33,
+       64,   64,   95,   64,   64,   75,   75,   95,   75,   75,
+       84,   84,    5,   95,   95,   95,   95,   95,   95,   95,
+       95,   95,   95,   95,   95,   95,   95,   95,   95,   95,
+       95,   95,   95,   95,   95,   95,   95,   95,   95,   95,
+       95,   95,   95,   95,   95,   95,   95,   95,   95,   95,
+       95,   95,   95,   95,   95,   95,   95,   95
     } ;
 
-static yyconst flex_int16_t yy_chk[478] =
+static yyconst flex_int16_t yy_chk[479] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    3,    3,    3,    4,    4,    4,
-        7,    7,    7,    8,    8,    8,   18,    7,   18,  100,
-        8,    9,    9,    9,   10,   10,   12,   12,   12,   10,
-       13,   13,   13,   18,   16,   18,   16,   29,   29,   17,
-       59,   19,   16,   37,   19,   34,   17,   10,   11,   11,
-       11,   16,   11,   16,   11,   11,   11,   17,   19,   16,
-
-       37,   19,   12,   17,   26,   26,   26,   20,   38,   20,
-       47,   20,   21,   21,   11,   15,   15,   15,   48,   15,
-       33,   15,   15,   15,   20,   38,   20,   47,   20,   21,
-       21,   15,   22,   28,   23,   48,   22,   23,   27,   27,
-       27,   15,   33,   30,   30,   30,   36,   36,   15,   22,
-       30,   23,   36,   22,   23,   24,   24,   24,    6,   24,
-        5,   24,   24,   24,   31,   31,   31,   32,   32,   50,
-        0,   35,   32,   35,   35,   39,   39,   39,   41,   41,
-       41,   24,   43,   57,   57,   44,   50,   43,   46,   46,
-       32,   54,   44,   35,   40,   40,   40,    0,   40,   43,
-
-       40,   40,   40,   44,   43,   46,   46,    0,   54,   44,
-        0,    0,   45,    0,   49,   51,   49,    0,   51,   45,
-       40,   42,   42,   42,   42,   42,   42,   42,   42,   42,
-       45,   49,   51,   49,   52,   51,   45,   56,   56,   56,
-        0,   52,   42,   42,   42,   42,   42,   53,   65,    0,
-       64,   52,   53,   60,   65,   60,   60,   64,   52,    0,
-        0,    0,   68,    0,   53,    0,   65,    0,   64,   53,
-        0,   65,   66,   66,   64,   60,   62,   62,   62,   68,
-       62,   67,   62,   62,   62,    0,   67,   69,   69,   66,
-       66,   70,   71,   77,   70,    0,    0,    0,   67,    0,
-
-       80,    0,   62,   67,   69,   69,   76,   76,   70,   71,
-       77,   70,   73,   73,   73,    0,   73,   80,   73,   73,
-       73,    0,    0,   76,   76,   84,   75,    0,    0,    0,
-        0,   78,   75,   85,   78,   79,   79,    0,   73,   74,
-       74,   74,   84,   74,   75,   74,   74,   74,   78,   75,
-       85,   78,   79,   79,   82,   82,   83,   86,   87,   83,
-       86,   89,   87,   88,   90,   74,    0,   88,    0,    0,
-        0,   82,   82,   83,   86,   87,   83,   86,   89,   87,
-       88,   90,    0,    0,   88,   92,   92,   92,   92,   92,
-       93,   93,    0,   93,   93,   94,   94,   94,   94,   94,
-
-       95,   95,    0,   95,   95,   96,   96,    0,   96,   96,
-       97,    0,   97,   97,   97,   98,   98,   98,   98,   98,
-       99,   99,    0,   99,   99,  101,  101,    0,  101,  101,
-      102,  102,   91,   91,   91,   91,   91,   91,   91,   91,
-       91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
-       91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
-       91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
-       91,   91,   91,   91,   91,   91,   91
+        1,    1,    1,    1,    1,    3,    3,    3,    4,    4,
+        4,    7,    7,    7,    8,    8,    8,   21,   21,    7,
+       10,   10,    8,    9,    9,    9,   10,   12,   12,   12,
+       13,   13,   13,  104,   21,   21,   26,   26,   26,   18,
+       16,   18,   16,   38,   10,   11,   11,   11,   16,   11,
+       11,   84,   11,   11,   11,   74,   18,   16,   18,   16,
+
+       38,   17,   60,   12,   34,   16,   19,   22,   17,   19,
+       28,   22,   11,   15,   15,   15,   33,   15,   15,   17,
+       15,   15,   15,   19,   22,   17,   19,   20,   22,   20,
+       15,   20,   23,   29,   29,   23,   27,   27,   27,   33,
+       15,   31,   31,   31,   20,    6,   20,   15,   20,   23,
+       32,   32,   23,   24,   24,   24,   32,   24,   24,    5,
+       24,   24,   24,   30,   30,   30,   35,   39,    0,   35,
+       35,   30,   36,   36,   32,   37,   37,   37,    0,   36,
+       24,   40,   40,   40,   39,   42,   42,   42,   44,   35,
+       41,   41,   41,   44,   41,   41,    0,   41,   41,   41,
+
+       57,   57,   57,   58,   58,   44,   62,   62,   62,   45,
+       44,    0,   47,   47,   48,   49,   45,   41,   43,   43,
+       43,   43,   43,   43,   43,   43,   43,   45,   46,   47,
+       47,   48,   49,   45,   50,   46,   50,   51,   53,   43,
+       43,   43,   43,   43,   52,   53,   46,   52,   55,   70,
+       66,   50,   46,   50,   51,   53,   61,   66,   54,   61,
+       61,   52,   53,   54,   52,   55,   70,    0,   66,   83,
+       83,   89,   89,    0,   66,   54,   68,   68,   67,   61,
+       54,   64,   64,   64,   67,   64,   64,   69,   64,   64,
+       64,    0,   69,   68,   68,   73,   67,   71,   71,   72,
+
+       77,   67,   72,    0,   69,    0,   77,    0,   64,   69,
+        0,    0,   73,   79,   71,   71,   72,    0,   77,   72,
+       75,   75,   75,   77,   75,   75,   82,   75,   75,   75,
+       79,   78,   78,   80,   81,   81,   80,   85,   85,   86,
+       87,   88,   86,   82,    0,    0,    0,   75,   78,   78,
+       80,   81,   81,   80,   85,   85,   86,   87,   88,   86,
+       90,   91,   92,   90,   93,   91,   92,   94,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,   90,   91,   92,
+       90,   93,   91,   92,   94,   96,   96,   96,   96,   96,
+       97,   97,    0,   97,   97,   98,   98,   98,   98,   98,
+
+       99,   99,    0,   99,   99,  100,  100,    0,  100,  100,
+      101,    0,  101,  101,  101,  102,  102,  102,  102,  102,
+      103,  103,    0,  103,  103,  105,  105,    0,  105,  105,
+      106,  106,   95,   95,   95,   95,   95,   95,   95,   95,
+       95,   95,   95,   95,   95,   95,   95,   95,   95,   95,
+       95,   95,   95,   95,   95,   95,   95,   95,   95,   95,
+       95,   95,   95,   95,   95,   95,   95,   95,   95,   95,
+       95,   95,   95,   95,   95,   95,   95,   95
     } ;
 
 /* The intent behind this definition is that it'll catch
@@ -819,7 +819,7 @@ YY_DECL
        register int yy_act;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-#line 45 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 47 "sapi/phpdbg/dev/phpdbg_lexer.l"
 
 #line 825 "sapi/phpdbg/phpdbg_lexer.c"
 
@@ -876,13 +876,13 @@ yy_match:
                        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                                {
                                yy_current_state = (int) yy_def[yy_current_state];
-                               if ( yy_current_state >= 92 )
+                               if ( yy_current_state >= 96 )
                                        yy_c = yy_meta[(unsigned int) yy_c];
                                }
                        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
                        ++yy_cp;
                        }
-               while ( yy_current_state != 91 );
+               while ( yy_current_state != 95 );
                yy_cp = yyg->yy_last_accepting_cpos;
                yy_current_state = yyg->yy_last_accepting_state;
 
@@ -904,7 +904,7 @@ do_action:  /* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 48 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 50 "sapi/phpdbg/dev/phpdbg_lexer.l"
 {
                BEGIN(RAW);
                phpdbg_init_param(yylval, EMPTY_PARAM);
@@ -913,7 +913,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 53 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 55 "sapi/phpdbg/dev/phpdbg_lexer.l"
 { 
                BEGIN(RAW);
                phpdbg_init_param(yylval, EMPTY_PARAM);
@@ -922,7 +922,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 58 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 60 "sapi/phpdbg/dev/phpdbg_lexer.l"
 {
                BEGIN(RAW);
                phpdbg_init_param(yylval, EMPTY_PARAM);
@@ -931,7 +931,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 63 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 65 "sapi/phpdbg/dev/phpdbg_lexer.l"
 {
                phpdbg_init_param(yylval, NUMERIC_PARAM);
                yylval->num = 1;                
@@ -940,7 +940,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 68 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 70 "sapi/phpdbg/dev/phpdbg_lexer.l"
 {
                phpdbg_init_param(yylval, NUMERIC_PARAM);
                yylval->num = 0;
@@ -949,7 +949,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 73 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 75 "sapi/phpdbg/dev/phpdbg_lexer.l"
 {
                phpdbg_init_param(yylval, NUMERIC_PARAM);
                yylval->num = atoi(yytext);
@@ -958,18 +958,40 @@ YY_RULE_SETUP
        YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 78 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 80 "sapi/phpdbg/dev/phpdbg_lexer.l"
 {
-               phpdbg_init_param(yylval, METHOD_PARAM);
+               phpdbg_init_param(yylval, NUMERIC_METHOD_PARAM);
                yylval->method.class = "class";
                yylval->method.name = "func";
+               yylval->num = 0;
                return T_METHOD; 
        }
        YY_BREAK
 case 8:
-/* rule 8 can match eol */
 YY_RULE_SETUP
-#line 84 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 87 "sapi/phpdbg/dev/phpdbg_lexer.l"
+{
+               phpdbg_init_param(yylval, NUMERIC_FUNCTION_PARAM);
+               yylval->str = strndup(yytext, yyleng);
+               yylval->len = yyleng;
+               yylval->num = 0;
+               return T_ID; 
+       }
+       YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 94 "sapi/phpdbg/dev/phpdbg_lexer.l"
+{
+               phpdbg_init_param(yylval, METHOD_PARAM);
+               yylval->method.class = "class";
+               yylval->method.name = "func";
+               return T_METHOD; 
+       }
+       YY_BREAK
+case 10:
+/* rule 10 can match eol */
+YY_RULE_SETUP
+#line 100 "sapi/phpdbg/dev/phpdbg_lexer.l"
 {
                phpdbg_init_param(yylval, FILE_PARAM);
                yylval->file.name = strndup(yytext, yyleng);
@@ -977,19 +999,19 @@ YY_RULE_SETUP
                return T_FILE;
        }
        YY_BREAK
-case 9:
+case 11:
 YY_RULE_SETUP
-#line 90 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 106 "sapi/phpdbg/dev/phpdbg_lexer.l"
 {
                phpdbg_init_param(yylval, ADDR_PARAM);
                yylval->addr = strtoul(yytext, NULL, 10);
                return T_OPLINE; 
        }
        YY_BREAK
-case 10:
-/* rule 10 can match eol */
+case 12:
+/* rule 12 can match eol */
 YY_RULE_SETUP
-#line 95 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 111 "sapi/phpdbg/dev/phpdbg_lexer.l"
 {
                phpdbg_init_param(yylval, STR_PARAM);
                yylval->str = strndup(yytext, yyleng);
@@ -997,9 +1019,9 @@ YY_RULE_SETUP
                return T_LITERAL; 
        }
        YY_BREAK
-case 11:
+case 13:
 YY_RULE_SETUP
-#line 101 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 117 "sapi/phpdbg/dev/phpdbg_lexer.l"
 {
                phpdbg_init_param(yylval, STR_PARAM);
                yylval->str = strndup(yytext, yyleng);
@@ -1008,9 +1030,9 @@ YY_RULE_SETUP
        }
        YY_BREAK
 
-case 12:
+case 14:
 YY_RULE_SETUP
-#line 108 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 124 "sapi/phpdbg/dev/phpdbg_lexer.l"
 {
        phpdbg_init_param(yylval, STR_PARAM);
        yylval->str = strndup(yytext, yyleng);
@@ -1019,26 +1041,26 @@ YY_RULE_SETUP
        return T_INPUT;
 }
        YY_BREAK
-case 13:
-/* rule 13 can match eol */
+case 15:
+/* rule 15 can match eol */
 YY_RULE_SETUP
-#line 115 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 131 "sapi/phpdbg/dev/phpdbg_lexer.l"
 { /* ignore whitespace */ }
        YY_BREAK
-case 14:
+case 16:
 YY_RULE_SETUP
-#line 116 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 132 "sapi/phpdbg/dev/phpdbg_lexer.l"
 {
        phpdbg_init_param(yylval, EMPTY_PARAM);
        return T_UNEXPECTED; 
 }
        YY_BREAK
-case 15:
+case 17:
 YY_RULE_SETUP
-#line 120 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 136 "sapi/phpdbg/dev/phpdbg_lexer.l"
 YY_FATAL_ERROR( "flex scanner jammed" );
        YY_BREAK
-#line 1042 "sapi/phpdbg/phpdbg_lexer.c"
+#line 1064 "sapi/phpdbg/phpdbg_lexer.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(RAW):
        yyterminate();
@@ -1334,7 +1356,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
                while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                        {
                        yy_current_state = (int) yy_def[yy_current_state];
-                       if ( yy_current_state >= 92 )
+                       if ( yy_current_state >= 96 )
                                yy_c = yy_meta[(unsigned int) yy_c];
                        }
                yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1363,11 +1385,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                {
                yy_current_state = (int) yy_def[yy_current_state];
-               if ( yy_current_state >= 92 )
+               if ( yy_current_state >= 96 )
                        yy_c = yy_meta[(unsigned int) yy_c];
                }
        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-       yy_is_jam = (yy_current_state == 91);
+       yy_is_jam = (yy_current_state == 95);
 
        return yy_is_jam ? 0 : yy_current_state;
 }
@@ -2203,7 +2225,7 @@ void yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 120 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 136 "sapi/phpdbg/dev/phpdbg_lexer.l"
 
 
 
index b835a6695e18e5b27a01c7e3684aacd9d9e8afc0..40e64e159e3b341737614c828055842e76bb3f5f 100644 (file)
@@ -338,7 +338,7 @@ extern int yylex \
 #undef YY_DECL
 #endif
 
-#line 120 "sapi/phpdbg/dev/phpdbg_lexer.l"
+#line 136 "sapi/phpdbg/dev/phpdbg_lexer.l"
 
 
 #line 345 "sapi/phpdbg/phpdbg_lexer.h"
index fee118564d3ec8e47bea6b266e63a27d0dd5375d..ef9d4f4333581fa6dc5cce304a0d451be9bf6515 100644 (file)
@@ -79,6 +79,7 @@
 #include "phpdbg.h"
 #include "phpdbg_cmd.h"
 #include "phpdbg_utils.h"
+#include "phpdbg_prompt.h"
 
 #define YYSTYPE phpdbg_param_t
 
@@ -110,6 +111,14 @@ void phpdbg_debug_param(const phpdbg_param_t *param, const char *msg) {
                                fprintf(stderr, "%s METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name);
                        break;
                        
+                       case NUMERIC_METHOD_PARAM:
+                               fprintf(stderr, "%s NUMERIC_METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name);
+                       break;
+                       
+                       case NUMERIC_FUNCTION_PARAM:
+                               fprintf(stderr, "%s NUMERIC_FUNCTION_PARAM(%s::%s)\n", msg, param->str, param->num);
+                       break;
+                       
                        case NUMERIC_PARAM:
                                fprintf(stderr, "%s NUMERIC_PARAM(%ld)\n", msg, param->num);
                        break;
@@ -170,13 +179,69 @@ static void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param) {
                next->top = stack->top;
                stack->top = next;
        }
-       
+       phpdbg_debug_param(next, "push ->");
        stack->len++;
 }
 
+phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, phpdbg_param_t **top, char **why) {
+       const phpdbg_command_t *command = commands;
+       phpdbg_param_t *name = *top;
+       phpdbg_command_t *matched[3] = {NULL, NULL, NULL};
+       ulong matches = 0L;
+       
+       while (command && command->name && command->handler) {
+               if (command->name_len >= name->len) {
+                       if (memcmp(command->name, name->str, name->len) == SUCCESS) {
+                               if (matches < 3) {
+                                       matched[matches] = command;
+                                       matches++;
+                               } else break;
+                       }
+               }
+               command++;
+       }
+       
+       switch (matches) {
+               case 0: { 
+                       asprintf(
+                               why,
+                               "The command %s could not be found", 
+                               name->str);
+               } break;
+               
+               case 1: {
+                       (*top) = (*top)->next;
+                       if (matched[0]->subs && (*top) && ((*top)->type == STR_PARAM)) {
+                               command = phpdbg_stack_resolve(matched[0]->subs, top, why);
+                               if (command) {
+                                       phpdbg_notice(
+                                               "Command matching with sub command %s %s", 
+                                               matched[0]->name, command->name);
+                                       return command;
+                               }
+                       }
+                       
+                       phpdbg_notice(
+                               "Command matching with %s", 
+                               matched[0]->name);
+                       return matched[0];
+               } break;
+               
+               default: {
+                       asprintf(
+                               why,
+                               "The command %s is ambigious, matching %d commands", 
+                               name->str, matches);
+               }
+       }
+       
+       return NULL;
+}
+
 int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
        phpdbg_param_t *command = NULL,
                                   *params = NULL;
+       phpdbg_command_t *handler = NULL;
        
        if (stack->type != STACK_PARAM) {
                asprintf(
@@ -190,7 +255,7 @@ int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
                return FAILURE;
        }
        
-       command = params = (phpdbg_param_t*) stack->next;
+       command = (phpdbg_param_t*) stack->next;
        
        switch (command->type) {
                case EVAL_PARAM:
@@ -203,6 +268,23 @@ int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
                
                case STR_PARAM: {
                        /* do resolve command(s) */
+                       handler = phpdbg_stack_resolve(
+                               phpdbg_prompt_commands, &command, why);
+                       
+                       if (handler) {
+                               /* get top of stack */
+                               params = command;
+                               
+                               /* prepare params */
+                               while (params) {
+                                       phpdbg_debug_param(params, "-> ...");
+                                       params = params->next;
+                               }
+                               
+                               return SUCCESS;
+                       } else {
+                               return FAILURE;
+                       }
                } break;
                
                default:
@@ -211,13 +293,6 @@ int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
                        return FAILURE;
        }
        
-       /* do prepare params for function */
-       
-       while (params) {
-               phpdbg_debug_param(params, "-> ...");
-               params = params->next;
-       }
-       
        return SUCCESS;
 }
 
@@ -225,7 +300,7 @@ int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
 
 
 /* Line 268 of yacc.c  */
-#line 229 "sapi/phpdbg/phpdbg_parser.c"
+#line 304 "sapi/phpdbg/phpdbg_parser.c"
 
 /* Enabling traces.  */
 #ifndef YYDEBUG
@@ -248,7 +323,7 @@ int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
 /* "%code requires" blocks.  */
 
 /* Line 288 of yacc.c  */
-#line 159 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 234 "sapi/phpdbg/dev/phpdbg_parser.y"
 
 #include "phpdbg.h"
 #ifndef YY_TYPEDEF_YY_SCANNER_T
@@ -259,7 +334,7 @@ typedef void* yyscan_t;
 
 
 /* Line 288 of yacc.c  */
-#line 263 "sapi/phpdbg/phpdbg_parser.c"
+#line 338 "sapi/phpdbg/phpdbg_parser.c"
 
 /* Tokens.  */
 #ifndef YYTOKENTYPE
@@ -276,11 +351,13 @@ typedef void* yyscan_t;
      T_DIGITS = 264,
      T_LITERAL = 265,
      T_METHOD = 266,
-     T_OPLINE = 267,
-     T_FILE = 268,
-     T_ID = 269,
-     T_INPUT = 270,
-     T_UNEXPECTED = 271
+     T_NUMERIC_METHOD = 267,
+     T_NUMERIC_FUNCTION = 268,
+     T_OPLINE = 269,
+     T_FILE = 270,
+     T_ID = 271,
+     T_INPUT = 272,
+     T_UNEXPECTED = 273
    };
 #endif
 
@@ -298,7 +375,7 @@ typedef int YYSTYPE;
 
 
 /* Line 343 of yacc.c  */
-#line 302 "sapi/phpdbg/phpdbg_parser.c"
+#line 379 "sapi/phpdbg/phpdbg_parser.c"
 
 #ifdef short
 # undef short
@@ -517,20 +594,20 @@ union yyalloc
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  11
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   20
+#define YYLAST   24
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  17
+#define YYNTOKENS  19
 /* YYNNTS -- Number of nonterminals.  */
 #define YYNNTS  9
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  22
+#define YYNRULES  24
 /* YYNRULES -- Number of states.  */
-#define YYNSTATES  27
+#define YYNSTATES  29
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   271
+#define YYMAXUTOK   273
 
 #define YYTRANSLATE(YYX)                                               \
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -565,7 +642,7 @@ static const yytype_uint8 yytranslate[] =
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
-      15,    16
+      15,    16,    17,    18
 };
 
 #if YYDEBUG
@@ -573,27 +650,28 @@ static const yytype_uint8 yytranslate[] =
    YYRHS.  */
 static const yytype_uint8 yyprhs[] =
 {
-       0,     0,     3,     5,     7,    10,    11,    13,    15,    18,
+       0,     0,     3,     5,     7,    10,    12,    13,    15,    18,
       21,    24,    26,    28,    30,    32,    34,    36,    38,    40,
-      42,    44,    47
+      42,    44,    46,    48,    51
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
 static const yytype_int8 yyrhs[] =
 {
-      18,     0,    -1,    25,    -1,    24,    -1,    19,    24,    -1,
-      -1,    19,    -1,    14,    -1,    21,    14,    -1,     6,    15,
-      -1,     7,    15,    -1,    21,    -1,    22,    -1,     9,    -1,
-      13,    -1,    11,    -1,    12,    -1,    14,    -1,    10,    -1,
-       3,    -1,     4,    -1,     8,    15,    -1,    23,    20,    -1
+      20,     0,    -1,    27,    -1,    26,    -1,    21,    26,    -1,
+      21,    -1,    -1,    16,    -1,    23,    16,    -1,     6,    17,
+      -1,     7,    17,    -1,    23,    -1,    24,    -1,     9,    -1,
+      15,    -1,    11,    -1,    12,    -1,    13,    -1,    14,    -1,
+      16,    -1,    10,    -1,     3,    -1,     4,    -1,     8,    17,
+      -1,    25,    22,    -1
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
-static const yytype_uint8 yyrline[] =
+static const yytype_uint16 yyrline[] =
 {
-       0,   193,   193,   197,   198,   201,   203,   207,   208,   212,
-     213,   217,   218,   222,   223,   224,   225,   226,   227,   228,
-     229,   230,   234
+       0,   270,   270,   274,   275,   279,   280,   284,   285,   289,
+     290,   294,   295,   299,   300,   301,   302,   303,   304,   305,
+     306,   307,   308,   309,   313
 };
 #endif
 
@@ -606,8 +684,8 @@ static const char *const yytname[] =
   "\"falsy (false, off, no or disabled)\"",
   "\"string (some input, perhaps)\"", "\"eval\"", "\"shell\"",
   "\"if (condition)\"", "\"digits (numbers)\"", "\"literal (string)\"",
-  "\"method\"", "\"opline\"", "\"file\"",
-  "\"identifier (command or function name)\"",
+  "\"method\"", "\"method opline address\"", "\"function opline address\"",
+  "\"opline\"", "\"file\"", "\"identifier (command or function name)\"",
   "\"input (input string or data)\"", "\"input\"", "$accept", "input",
   "parameters", "params", "normal", "special", "command", "parameter",
   "handler", 0
@@ -620,24 +698,24 @@ static const char *const yytname[] =
 static const yytype_uint16 yytoknum[] =
 {
        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
-     265,   266,   267,   268,   269,   270,   271
+     265,   266,   267,   268,   269,   270,   271,   272,   273
 };
 # endif
 
 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const yytype_uint8 yyr1[] =
 {
-       0,    17,    18,    19,    19,    20,    20,    21,    21,    22,
-      22,    23,    23,    24,    24,    24,    24,    24,    24,    24,
-      24,    24,    25
+       0,    19,    20,    21,    21,    22,    22,    23,    23,    24,
+      24,    25,    25,    26,    26,    26,    26,    26,    26,    26,
+      26,    26,    26,    26,    27
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
 static const yytype_uint8 yyr2[] =
 {
-       0,     2,     1,     1,     2,     0,     1,     1,     2,     2,
+       0,     2,     1,     1,     2,     1,     0,     1,     2,     2,
        2,     1,     1,     1,     1,     1,     1,     1,     1,     1,
-       1,     2,     2
+       1,     1,     1,     2,     2
 };
 
 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
@@ -645,31 +723,31 @@ static const yytype_uint8 yyr2[] =
    means the default is an error.  */
 static const yytype_uint8 yydefact[] =
 {
-       0,     0,     0,     7,     0,    11,    12,     5,     2,     9,
-      10,     1,     8,    19,    20,     0,    13,    18,    15,    16,
-      14,    17,     6,    22,     3,    21,     4
+       0,     0,     0,     7,     0,    11,    12,     6,     2,     9,
+      10,     1,     8,    21,    22,     0,    13,    20,    15,    16,
+      17,    18,    14,    19,     5,    24,     3,    23,     4
 };
 
 /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int8 yydefgoto[] =
 {
-      -1,     4,    22,    23,     5,     6,     7,    24,     8
+      -1,     4,    24,    25,     5,     6,     7,    26,     8
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
-#define YYPACT_NINF -14
+#define YYPACT_NINF -16
 static const yytype_int8 yypact[] =
 {
-       6,   -13,   -12,   -14,     4,     0,   -14,    -3,   -14,   -14,
-     -14,   -14,   -14,   -14,   -14,     1,   -14,   -14,   -14,   -14,
-     -14,   -14,    -3,   -14,   -14,   -14,   -14
+       8,   -15,   -14,   -16,     4,     0,   -16,    -3,   -16,   -16,
+     -16,   -16,   -16,   -16,   -16,     1,   -16,   -16,   -16,   -16,
+     -16,   -16,   -16,   -16,    -3,   -16,   -16,   -16,   -16
 };
 
 /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int8 yypgoto[] =
 {
-     -14,   -14,   -14,   -14,   -14,   -14,   -14,    -7,   -14
+     -16,   -16,   -16,   -16,   -16,   -16,   -16,    -7,   -16
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
@@ -679,30 +757,30 @@ static const yytype_int8 yypgoto[] =
 static const yytype_uint8 yytable[] =
 {
       13,    14,     9,    10,    11,    15,    16,    17,    18,    19,
-      20,    21,     1,     2,    12,    26,    25,     0,     0,     0,
-       3
+      20,    21,    22,    23,     1,     2,    12,    28,    27,     0,
+       0,     0,     0,     0,     3
 };
 
 #define yypact_value_is_default(yystate) \
-  ((yystate) == (-14))
+  ((yystate) == (-16))
 
 #define yytable_value_is_error(yytable_value) \
   YYID (0)
 
 static const yytype_int8 yycheck[] =
 {
-       3,     4,    15,    15,     0,     8,     9,    10,    11,    12,
-      13,    14,     6,     7,    14,    22,    15,    -1,    -1,    -1,
-      14
+       3,     4,    17,    17,     0,     8,     9,    10,    11,    12,
+      13,    14,    15,    16,     6,     7,    16,    24,    17,    -1,
+      -1,    -1,    -1,    -1,    16
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
    symbol of state STATE-NUM.  */
 static const yytype_uint8 yystos[] =
 {
-       0,     6,     7,    14,    18,    21,    22,    23,    25,    15,
-      15,     0,    14,     3,     4,     8,     9,    10,    11,    12,
-      13,    14,    19,    20,    24,    15,    24
+       0,     6,     7,    16,    20,    23,    24,    25,    27,    17,
+      17,     0,    16,     3,     4,     8,     9,    10,    11,    12,
+      13,    14,    15,    16,    21,    22,    26,    17,    26
 };
 
 #define yyerrok                (yyerrstatus = 0)
@@ -1551,126 +1629,133 @@ yyreduce:
         case 3:
 
 /* Line 1806 of yacc.c  */
-#line 197 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 274 "sapi/phpdbg/dev/phpdbg_parser.y"
     { phpdbg_stack_push(stack, &(yyvsp[(1) - (1)])); }
     break;
 
   case 4:
 
 /* Line 1806 of yacc.c  */
-#line 198 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 275 "sapi/phpdbg/dev/phpdbg_parser.y"
     { phpdbg_stack_push(stack, &(yyvsp[(2) - (2)])); }
     break;
 
   case 7:
 
 /* Line 1806 of yacc.c  */
-#line 207 "sapi/phpdbg/dev/phpdbg_parser.y"
-    { (yyval) = (yyvsp[(1) - (1)]); }
+#line 284 "sapi/phpdbg/dev/phpdbg_parser.y"
+    { phpdbg_stack_push(stack, &(yyvsp[(1) - (1)])); }
     break;
 
   case 8:
 
 /* Line 1806 of yacc.c  */
-#line 208 "sapi/phpdbg/dev/phpdbg_parser.y"
-    { (yyval) = (yyvsp[(2) - (2)]); }
+#line 285 "sapi/phpdbg/dev/phpdbg_parser.y"
+    { phpdbg_stack_push(stack, &(yyvsp[(2) - (2)])); }
     break;
 
   case 9:
 
 /* Line 1806 of yacc.c  */
-#line 212 "sapi/phpdbg/dev/phpdbg_parser.y"
-    { (yyval) = (yyvsp[(2) - (2)]); (yyval).type = EVAL_PARAM; }
+#line 289 "sapi/phpdbg/dev/phpdbg_parser.y"
+    { (yyval) = (yyvsp[(2) - (2)]); (yyval).type = EVAL_PARAM;  }
     break;
 
   case 10:
 
 /* Line 1806 of yacc.c  */
-#line 213 "sapi/phpdbg/dev/phpdbg_parser.y"
-    { (yyval) = (yyvsp[(2) - (2)]); (yyval).type = SHELL_PARAM;; }
-    break;
-
-  case 11:
-
-/* Line 1806 of yacc.c  */
-#line 217 "sapi/phpdbg/dev/phpdbg_parser.y"
-    { phpdbg_stack_push(stack, &(yyvsp[(1) - (1)])); }
+#line 290 "sapi/phpdbg/dev/phpdbg_parser.y"
+    { (yyval) = (yyvsp[(2) - (2)]); (yyval).type = SHELL_PARAM; }
     break;
 
   case 12:
 
 /* Line 1806 of yacc.c  */
-#line 218 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 295 "sapi/phpdbg/dev/phpdbg_parser.y"
     { phpdbg_stack_push(stack, &(yyvsp[(1) - (1)])); }
     break;
 
   case 13:
 
 /* Line 1806 of yacc.c  */
-#line 222 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 299 "sapi/phpdbg/dev/phpdbg_parser.y"
     { (yyval) = (yyvsp[(1) - (1)]); }
     break;
 
   case 14:
 
 /* Line 1806 of yacc.c  */
-#line 223 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 300 "sapi/phpdbg/dev/phpdbg_parser.y"
     { (yyval) = (yyvsp[(1) - (1)]); }
     break;
 
   case 15:
 
 /* Line 1806 of yacc.c  */
-#line 224 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 301 "sapi/phpdbg/dev/phpdbg_parser.y"
     { (yyval) = (yyvsp[(1) - (1)]); }
     break;
 
   case 16:
 
 /* Line 1806 of yacc.c  */
-#line 225 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 302 "sapi/phpdbg/dev/phpdbg_parser.y"
     { (yyval) = (yyvsp[(1) - (1)]); }
     break;
 
   case 17:
 
 /* Line 1806 of yacc.c  */
-#line 226 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 303 "sapi/phpdbg/dev/phpdbg_parser.y"
     { (yyval) = (yyvsp[(1) - (1)]); }
     break;
 
   case 18:
 
 /* Line 1806 of yacc.c  */
-#line 227 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 304 "sapi/phpdbg/dev/phpdbg_parser.y"
     { (yyval) = (yyvsp[(1) - (1)]); }
     break;
 
   case 19:
 
 /* Line 1806 of yacc.c  */
-#line 228 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 305 "sapi/phpdbg/dev/phpdbg_parser.y"
     { (yyval) = (yyvsp[(1) - (1)]); }
     break;
 
   case 20:
 
 /* Line 1806 of yacc.c  */
-#line 229 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 306 "sapi/phpdbg/dev/phpdbg_parser.y"
     { (yyval) = (yyvsp[(1) - (1)]); }
     break;
 
   case 21:
 
 /* Line 1806 of yacc.c  */
-#line 230 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 307 "sapi/phpdbg/dev/phpdbg_parser.y"
+    { (yyval) = (yyvsp[(1) - (1)]); }
+    break;
+
+  case 22:
+
+/* Line 1806 of yacc.c  */
+#line 308 "sapi/phpdbg/dev/phpdbg_parser.y"
+    { (yyval) = (yyvsp[(1) - (1)]); }
+    break;
+
+  case 23:
+
+/* Line 1806 of yacc.c  */
+#line 309 "sapi/phpdbg/dev/phpdbg_parser.y"
     { (yyval) = (yyvsp[(2) - (2)]); (yyval).type = COND_PARAM; }
     break;
 
 
 
 /* Line 1806 of yacc.c  */
-#line 1674 "sapi/phpdbg/phpdbg_parser.c"
+#line 1759 "sapi/phpdbg/phpdbg_parser.c"
       default: break;
     }
   /* User semantic actions sometimes alter yychar, and that requires
@@ -1901,6 +1986,6 @@ yyreturn:
 
 
 /* Line 2067 of yacc.c  */
-#line 236 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 315 "sapi/phpdbg/dev/phpdbg_parser.y"
 
 
index d3ba58aa70eeec586515446e16915b822fb72610..612982c46fa80aa2c83bd49a035a02535f5abdc1 100644 (file)
@@ -33,7 +33,7 @@
 /* "%code requires" blocks.  */
 
 /* Line 2068 of yacc.c  */
-#line 159 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 234 "sapi/phpdbg/dev/phpdbg_parser.y"
 
 #include "phpdbg.h"
 #ifndef YY_TYPEDEF_YY_SCANNER_T
@@ -61,11 +61,13 @@ typedef void* yyscan_t;
      T_DIGITS = 264,
      T_LITERAL = 265,
      T_METHOD = 266,
-     T_OPLINE = 267,
-     T_FILE = 268,
-     T_ID = 269,
-     T_INPUT = 270,
-     T_UNEXPECTED = 271
+     T_NUMERIC_METHOD = 267,
+     T_NUMERIC_FUNCTION = 268,
+     T_OPLINE = 269,
+     T_FILE = 270,
+     T_ID = 271,
+     T_INPUT = 272,
+     T_UNEXPECTED = 273
    };
 #endif