summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-10 01:18:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-10 01:18:27 +0000
commitae32e9a225d075d28a95da0537e098989fb42494 (patch)
tree73d7441a34967f56d80a7389a7afe55f4a1b59ce
parent2924c95347ce9dd37029cee358eba91102f29ceb (diff)
parse.y: debugging stuff
* parse.y (lex_state_name): returns name for lex_state_e, for debug use. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--parse.y32
2 files changed, 37 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 1175ee1618a..0e010d99f77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu May 10 10:18:10 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (lex_state_name): returns name for lex_state_e, for debug
+ use.
+
Wed May 9 16:36:01 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (MakeMakefile#pkg_config): check if libs resulted from
diff --git a/parse.y b/parse.y
index ede3a3efb28..7dd3a8a1596 100644
--- a/parse.y
+++ b/parse.y
@@ -11,6 +11,9 @@
%{
+#ifndef PARSER_DEBUG
+#define PARSER_DEBUG 0
+#endif
#define YYDEBUG 1
#define YYERROR_VERBOSE 1
#define YYSTACK_USE_ALLOCA 0
@@ -74,6 +77,10 @@ enum lex_state_e {
EXPR_MAX_STATE
};
+#if PARSER_DEBUG
+static const char *lex_state_name(enum lex_state_e state);
+#endif
+
typedef VALUE stack_type;
# define BITSTACK_PUSH(stack, n) ((stack) = ((stack)<<1)|((n)&1))
@@ -8479,6 +8486,28 @@ id_is_var_gen(struct parser_params *parser, ID id)
}
#endif /* !RIPPER */
+#if PARSER_DEBUG
+static const char *
+lex_state_name(enum lex_state_e state)
+{
+ switch (state) {
+ case EXPR_BEG: return "EXPR_BEG";
+ case EXPR_END: return "EXPR_END";
+ case EXPR_ENDARG: return "EXPR_ENDARG";
+ case EXPR_ENDFN: return "EXPR_ENDFN";
+ case EXPR_ARG: return "EXPR_ARG";
+ case EXPR_CMDARG: return "EXPR_CMDARG";
+ case EXPR_MID: return "EXPR_MID";
+ case EXPR_FNAME: return "EXPR_FNAME";
+ case EXPR_DOT: return "EXPR_DOT";
+ case EXPR_CLASS: return "EXPR_CLASS";
+ case EXPR_VALUE: return "EXPR_VALUE";
+ case EXPR_MAX_STATE: break;
+ }
+ return NULL;
+}
+#endif
+
#ifdef RIPPER
static VALUE
assignable_gen(struct parser_params *parser, VALUE lhs)
@@ -9807,6 +9836,9 @@ Init_sym(void)
(void)nodetype;
(void)nodeline;
+#if PARSER_DEBUG
+ (void)lex_state_name(-1);
+#endif
Init_id();
}