# Yydebug

**URL:** <https://www.ruby-forum.com/t/yydebug/119812>\
**Category:** Development\
**Created:** [November 10, 2007, 8:27pm UTC](https://www.ruby-forum.com/t/yydebug/119812 "2007-11-10T20:27:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [November 10, 2007, 8:27pm UTC](https://www.ruby-forum.com/t/yydebug/119812/1 "2007-11-10T20:27:35Z")

</div>

e$B$J$+$@$G$9!#e(B

e$B%3%^%s%I%i%$%s%\*%W%7%g%s$+$i?($l$kFbItJQ?t$r!"%0%m!\<%P%k$+$ie(BVMe$B$+e(B  
parsere$B$K0\9T$7$?$$$H9M$($F$$$k$N$G$9$,!“e(Byydebuge$B$Oe(Bbisone$B$G@8@.$5$le(B  
e$B$k%=!\<%9$KKd$a9~$^$l$F$$$k$N$G%3%s%Q%$%i$@$1$G$O$I$&$K$b$J$i$J$$e(B  
e$B46$8$G$9!#$=$3$G!“30It%D!\<%k$G$A$g$C$HA0=hM}$rF~$l$h$&$+$H;W$&$Ne(B  
e$B$G$9$,!”$$$+$,$J$b$s$G$7$g$&$+!#e(Bsede$B\<+BN$O!“e(Bdjgppe$B$de(BWindowse$B$G$b$9e(B  
e$B$G$K;H$C$F$$$^$9$7!“e(Bautoconfe$B$r;H$&4D6-$J$iEvA3$”$k$O$:$G$9$,!”$3e(B  
e$B$&$$$&J}K!$O5$$KF~$i$s$H$+!”$b$C$H$$$$J}K!$,$"$k$H$+!#e(B

# Index: Makefile.in

— Makefile.in (revision 13873)  
+++ Makefile.in (working copy)  
@@ -170,7 +170,4 @@ lex.c: keywords  
cp “$(srcdir)/$@.blt” $@

-.y.c:

- $(YACC) $(YFLAGS) -o $@ $\<
- 

# .c.@OBJEXT@: $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c $\< Index: common.mk

— common.mk (revision 13873)  
+++ common.mk (working copy)  
@@ -349,4 +349,9 @@ PHONY:  
{$(VPATH)}parse.c: parse.y

+{$(VPATH)}.y.c:

- $(YACC) $(YFLAGS) -o y.tab.c $\<
- sed -f $(srcdir)/tool/ytab.sed -e “/^#/s!y.tab.c!$@!” y.tab.c \> $@
- @$(RM) y.tab.c
- 

# acosh.$(OBJEXT): {$(VPATH)}acosh.c alloca.$(OBJEXT): {$(VPATH)}alloca.c Index: ruby.c

— ruby.c (revision 13873)  
+++ ruby.c (working copy)  
@@ -62,5 +62,6 @@ char \*getenv();  
VALUE ruby\_debug = Qfalse;  
VALUE ruby\_verbose = Qfalse;  
-extern int ruby\_yydebug;  
+VALUE rb\_parser\_get\_yydebug(VALUE);  
+VALUE rb\_parser\_set\_yydebug(VALUE, VALUE);

char \*ruby\_inplace\_mode = 0;  
@@ -594,5 +595,5 @@ proc\_options(int argc, char \*\*argv, stru

```
 case 'y':

```

- 

```
 ruby_yydebug = 1;

```

- 

```
 opt->yydebug = 1;
 s++;
 goto reswitch;

```

@@ -839,5 +840,5 @@ proc\_options(int argc, char \*\*argv, stru  
}  
else if (strcmp(“yydebug”, s) == 0)

- ruby\_yydebug = 1;

- opt-\>yydebug = 1;  
else if (strcmp(“help”, s) == 0) {  
usage(origarg.argv[0]);  
@@ -994,4 +995,5 @@ process\_options(VALUE arg)  
ruby\_init\_gems(opt);  
parser = rb\_parser\_new();

- if (opt-\>yydebug) rb\_parser\_set\_yydebug(parser, Qtrue);  
if (opt-\>e\_script) {  
if (opt-\>enc\_index \>= 0)  
Index: parse.y  
===================================================================  
— parse.y (revision 13873)  
+++ parse.y (working copy)  
@@ -241,4 +241,6 @@ struct parser\_params {  
rb\_encoding \*utf8;

- int parser\_yydebug;

- 

#ifndef RIPPER  
/\* Ruby core only \*/  
@@ -283,7 +285,5 @@ static int parser\_yyerror(struct parser\_  
#define yyerror(msg) parser\_yyerror(parser, msg)

-#define YYPARSE\_PARAM parser\_v  
-#define YYLEX\_PARAM parser\_v  
-#define parser ((struct parser\_params\*)parser\_v)  
+#define YYLEX\_PARAM parser

#define ruby\_eval\_tree (parser-\>parser\_eval\_tree)  
@@ -318,4 +318,5 @@ static int parser\_yyerror(struct parser\_  
#define ruby\_sourceline (parser-\>parser\_ruby\_sourceline)  
#define ruby\_sourcefile (parser-\>parser\_ruby\_sourcefile)  
+#define yydebug (parser-\>parser\_yydebug)  
#ifdef RIPPER  
#else  
@@ -327,5 +328,4 @@ static int yylex(void\*, void\*);  
#ifndef RIPPER  
#define yyparse ruby\_yyparse  
-#define yydebug ruby\_yydebug

static NODE\* node\_newnode(struct parser\_params \*, enum node\_type,  
VALUE, VALUE, VALUE);  
@@ -490,5 +490,4 @@ static VALUE ripper\_dispatch5(struct par

#define yyparse ripper\_yyparse  
-#define yydebug ripper\_yydebug

static VALUE ripper\_intern(const char\*);  
@@ -588,4 +587,5 @@ static void ripper\_compile\_error(struct

%pure\_parser  
+%parse-param {struct parser\_params \*parser}

%union {  
@@ -9142,4 +9142,7 @@ parser\_free(void \*ptr)  
}

+VALUE rb\_parser\_get\_yydebug(VALUE);  
+VALUE rb\_parser\_set\_yydebug(VALUE, VALUE);  
+  
#ifndef RIPPER  
static struct parser\_params \*  
@@ -9193,4 +9196,35 @@ rb\_parser\_encoding(VALUE vparser)  
}

+/\*

- 
  - call-seq:

- 
  - ripper.yydebug -\> true or false

- 
  - 

- 
  - Get yydebug.

- \*/  
+VALUE  
+rb\_parser\_get\_yydebug(VALUE self)  
+{
- struct parser\_params \*parser;
- 
- Data\_Get\_Struct(self, struct parser\_params, parser);
- return yydebug ? Qtrue : Qfalse;  
+}
- 

+/\*

- 
  - call-seq:

- 
  - ripper.yydebug = flag

- 
  - 

- 
  - Set yydebug.

- \*/  
+VALUE  
+rb\_parser\_set\_yydebug(VALUE self, VALUE flag)  
+{
- struct parser\_params \*parser;
- 
- Data\_Get\_Struct(self, struct parser\_params, parser);
- yydebug = RTEST(flag);
- return flag;  
+}
- 

#ifdef YYMALLOC  
#define HEAPCNT(n, size) ((n) \* (size) / sizeof(YYSTYPE))  
@@ -9555,29 +9589,4 @@ ripper\_initialize(int argc, VALUE \*argv,  
}

-/\*

- 
  - call-seq:

- 
  - Ripper.yydebug -\> true or false

- 
  - 

- 
  - Get yydebug.

- \*/  
-static VALUE  
-ripper\_s\_get\_yydebug(VALUE self)  
-{
- return ripper\_yydebug ? Qtrue : Qfalse;  
-}
- 

-/\*

- 
  - call-seq:

- 
  - Ripper.yydebug = flag

- 
  - 

- 
  - Set yydebug.

- \*/  
-static VALUE  
-ripper\_s\_set\_yydebug(VALUE self, VALUE flag)  
-{
- ripper\_yydebug = RTEST(flag);
- return flag;  
-}
- 

extern VALUE rb\_thread\_pass(void);

@@ -9705,6 +9714,4 @@ Init\_ripper(void)  
Ripper = rb\_define\_class(“Ripper”, rb\_cObject);  
rb\_define\_const(Ripper, “Version”, rb\_str\_new2(RIPPER\_VERSION));

- rb\_define\_singleton\_method(Ripper, “yydebug”, ripper\_s\_get\_yydebug,  
0);
- rb\_define\_singleton\_method(Ripper, “yydebug=”,  
ripper\_s\_set\_yydebug, 1);  
rb\_define\_alloc\_func(Ripper, ripper\_s\_allocate);  
rb\_define\_method(Ripper, “initialize”, ripper\_initialize, -1);  
@@ -9714,4 +9721,6 @@ Init\_ripper(void)  
rb\_define\_method(Ripper, “end\_seen?”, rb\_parser\_end\_seen\_p, 0);  
rb\_define\_method(Ripper, “encoding”, rb\_parser\_encoding, 0);

- rb\_define\_method(Ripper, “yydebug”, rb\_parser\_get\_yydebug, 0);
- rb\_define\_method(Ripper, “yydebug=”, rb\_parser\_set\_yydebug, 1);  
#ifdef RIPPER\_DEBUG  
rb\_define\_method(rb\_mKernel, “assert\_Qundef”, ripper\_assert\_Qundef,  
2);  
Index: bcc32/Makefile.sub  
===================================================================  
— bcc32/Makefile.sub (revision 13873)  
+++ bcc32/Makefile.sub (working copy)  
@@ -210,9 +210,4 @@ VPATH = $(arch\_hdrdir)/ruby;$(hdrdir)/ru  
$(RC) $(RFLAGS) -I. -I$(\<D). $(iconinc) -I$(srcdir)/win32 $(RFLAGS)  
-fo$@ $(\<:/=)

-.y.c:

- $(YACC) $(YFLAGS) $(\<:=/)
- sed -e “s!^ _extern char \*getenv();!/_ &  
_/!;s/^(#._)y.tab/\1parse/” y.tab.c \> $(@F)
- @del y.tab.c
- 

all: $(srcdir)/bcc32/Makefile.sub $(srcdir)/common.mk

# Index: win32/Makefile.sub

— win32/Makefile.sub (revision 13873)  
+++ win32/Makefile.sub (working copy)  
@@ -579,9 +579,4 @@ lex.c: {$(srcdir)}lex.c.blt  
copy $(?:/=) $@

-{$(srcdir)}.y.c:

- $(YACC) $(YFLAGS) $(\<:=/)
- sed -e “s!^ _extern char \*getenv();!/_ &  
_/!;s/^(#._)y.tab/\1parse/” y.tab.c \> $@
- @del y.tab.c
- 

$(OBJS): {$(hdrdir)/ruby}win32.h

# Index: wince/Makefile.sub

— wince/Makefile.sub (revision 13873)  
+++ wince/Makefile.sub (working copy)  
@@ -531,9 +531,4 @@ lex.c: {$(srcdir)}lex.c.blt  
copy $(?:/=) $@

-{$(srcdir)}.y.c:

- $(YACC) $(YFLAGS) $(\<:=/)
- sed -e “s!^ _extern char \*getenv();!/_ &  
_/!;s/^(#._)y.tab/\1parse/” y.tab.c \> $@
- @del y.tab.c
- 

!include $(srcdir)/common.mk

# Index: tool/ytab.sed

— tool/ytab.sed (revision 0)  
+++ tool/ytab.sed (revision 0)  
@@ -0,0 +1,10 @@  
+#!/bin/sed -f  
+/^int yydebug;/{  
+i  
+#ifndef yydebug  
+a  
+#endif  
+}  
+s/\<(yyerror[]\*([]_parser,)/parser\_\1/  
+s!^ extern char \*getenv();!/ & /!  
+s/^(#.)"._.tab.c"/\1"parse.c"/

Property changes on: tool/ytab.sed

---

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [November 13, 2007, 9:32am UTC](https://www.ruby-forum.com/t/yydebug/119812/2 "2007-11-13T09:32:17Z")

</div>

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:32204] yydebug”  
on Sun, 11 Nov 2007 04:26:47 +0900, Nobuyoshi N.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|e$B%3%^%s%I%i%$%s%\*%W%7%g%s$+$i?($l$kFbItJQ?t$r!“%0%m!\<%P%k$+$ie(BVMe$B$+e(B  
|parsere$B$K0\9T$7$?$$$H9M$($F$$$k$N$G$9$,!“e(Byydebuge$B$Oe(Bbisone$B$G@8@.$5$le(B  
|e$B$k%=!\<%9$KKd$a9~$^$l$F$$$k$N$G%3%s%Q%$%i$@$1$G$O$I$&$K$b$J$i$J$$e(B  
|e$B46$8$G$9!#$=$3$G!“30It%D!\<%k$G$A$g$C$HA0=hM}$rF~$l$h$&$+$H;W$&$Ne(B  
|e$B$G$9$,!”$$$+$,$J$b$s$G$7$g$&$+!#e(Bsede$B\<+BN$O!“e(Bdjgppe$B$de(BWindowse$B$G$b$9e(B  
|e$B$G$K;H$C$F$$$^$9$7!“e(Bautoconfe$B$r;H$&4D6-$J$iEvA3$”$k$O$:$G$9$,!”$3e(B  
|e$B$&$$$&J}K!$O5$$KF~$i$s$H$+!”$b$C$H$$$$J}K!$,$”$k$H$+!#e(B

e$B$$$$$s$8$c$J$$$G$7$g$&$+!#e(B1.8e$B$G$Oe(Bsede$B;H$C$F$k$7!#e(B

---

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [November 13, 2007, 8:54pm UTC](https://www.ruby-forum.com/t/yydebug/119812/3 "2007-11-13T20:54:48Z")

</div>

In article [E1IrrBW-0000dQ-Ry@x31](mailto:E1IrrBW-0000dQ-Ry@x31),  
Yukihiro M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> |e$B%3%^%s%I%i%$%s%\*%W%7%g%s$+$i?($l$kFbItJQ?t$r!“%0%m!\<%P%k$+$ie(BVMe$B$+e(B  
> |parsere$B$K0\9T$7$?$$$H9M$($F$$$k$N$G$9$,!“e(Byydebuge$B$Oe(Bbisone$B$G@8@.$5$le(B  
> |e$B$k%=!\<%9$KKd$a9~$^$l$F$$$k$N$G%3%s%Q%$%i$@$1$G$O$I$&$K$b$J$i$J$$e(B  
> |e$B46$8$G$9!#$=$3$G!“30It%D!\<%k$G$A$g$C$HA0=hM}$rF~$l$h$&$+$H;W$&$Ne(B  
> |e$B$G$9$,!”$$$+$,$J$b$s$G$7$g$&$+!#e(Bsede$B\<+BN$O!“e(Bdjgppe$B$de(BWindowse$B$G$b$9e(B  
> |e$B$G$K;H$C$F$$$^$9$7!“e(Bautoconfe$B$r;H$&4D6-$J$iEvA3$”$k$O$:$G$9$,!”$3e(B  
> |e$B$&$$$&J}K!$O5$$KF~$i$s$H$+!”$b$C$H$$$$J}K!$,$”$k$H$+!#e(B
> 
> e$B$$$$$s$8$c$J$$$G$7$g$&$+!#e(B1.8e$B$G$Oe(Bsede$B;H$C$F$k$7!#e(B

parse.c e$B$N@8@.J}K!$rJQ$($k$H$-$O!"e(Bsnapshot.tar.gz e$B$N@8@.$bJQe(B  
e$B$($J$-$c$$$1$J$$$s$8$c$J$$$G$7$g$&$+!#e(B

e$B$^$!!"e(Bruby e$BB&$Ge(B snapshot e$B$Ne(B parse.c  
e$BEy$N@8@.$K4X$o$l$k$h$&$Je(B  
e$B;E3]$1$,I,MW$J$h$&$J5$$b$7$^$9$,!#e(B

---

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [November 14, 2007, 3:50am UTC](https://www.ruby-forum.com/t/yydebug/119812/4 "2007-11-14T03:50:17Z")

</div>

e$B$J$+$@$G$9!#e(B

At Wed, 14 Nov 2007 04:54:05 +0900,  
Tanaka A. wrote in [ruby-dev:32280]:

> e$B$^$!!"e(Bruby e$BB&$Ge(B snapshot e$B$Ne(B parse.c e$BEy$N@8@.$K4X$o$l$k$h$&$Je(B  
> e$B;E3]$1$,I,MW$J$h$&$J5$$b$7$^$9$,!#e(B

e$B$3$s$J$H$3$G$I$&$G$7$g$&$+!#e(B

$ sed ‘s/{$([a-zA-Z0-9\_]\*)}//g’ common.mk |   
make -f - srcdir=. VPATH=include/ruby BASERUBY=ruby RUBY=ruby prereq

# Index: common.mk

— common.mk (revision 13918)  
+++ common.mk (working copy)  
@@ -643,9 +643,12 @@ ext\_prelude.c: $(srcdir)/tool/compile\_pr  
$(MINIRUBY) -I$(srcdir) -rrbconfig $(srcdir)/tool/compile\_prelude.rb  
$(srcdir)/prelude.rb $(srcdir)/gem\_prelude.rb $@

-prereq: incs {$(VPATH)}prelude.c  
+prereq: incs {$(VPATH)}parse.c $(srcdir)/ext/ripper/ripper.c  
{$(VPATH)}prelude.c

docs:  
$(BASERUBY) -I$(srcdir) $(srcdir)/tool/makedocs.rb $(INSNS2VMOPT)

+$(srcdir)/ext/ripper/ripper.c:

- cd ext/ripper && exec $(MAKE) -f depend top\_srcdir=…/… srcdir=.
- 

##

---

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [November 14, 2007, 4:01am UTC](https://www.ruby-forum.com/t/yydebug/119812/5 "2007-11-14T04:01:59Z")

</div>

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:32280] Re: yydebug”  
on Wed, 14 Nov 2007 04:54:05 +0900, Tanaka A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
writes:

|parse.c e$B$N@8@.J}K!$rJQ$($k$H$-$O!"e(Bsnapshot.tar.gz e$B$N@8@.$bJQe(B  
|e$B$($J$-$c$$$1$J$$$s$8$c$J$$$G$7$g$&$+!#e(B

e$B$H$j$"$($:$3$A$i$OD\>$7$F$\*$-$^$7$?!#e(B
