Erro runing byebug 8.2.1 Mac M1 - ruby-on-rails

I'm new to ror and I want to run a project, but I can't because I have a problem with the byebug gem, I searched many forums but none of them solve my problem
Ruby 2.3.1 with rbenv
Rails 4.2.2
MacBook Air M1
thanks in advance..................................................................................................................................................................................................................
➜ backend-ror git:(dev) sudo gem install byebug -v '8.2.1' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
ERROR: Error installing byebug:
ERROR: Failed to build gem native extension.
current directory: /Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/byebug-8.2.1/ext/byebug
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20220828-8331-k85pho.rb extconf.rb
creating Makefile
current directory: /Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/byebug-8.2.1/ext/byebug
make "DESTDIR=" clean
current directory: /Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/byebug-8.2.1/ext/byebug
make "DESTDIR="
compiling locker.c
compiling byebug.c
byebug.c:198:27: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
return call_at(ctx, dc, rb_intern("at_line"), 0, Qnil);
^~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:23: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:198:27: note: '{' token is here
return call_at(ctx, dc, rb_intern("at_line"), 0, Qnil);
^~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1722:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
{ \
^
byebug.c:198:27: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
return call_at(ctx, dc, rb_intern("at_line"), 0, Qnil);
^~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1727:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
}
^
byebug.c:198:27: note: ')' token is here
return call_at(ctx, dc, rb_intern("at_line"), 0, Qnil);
^~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:51: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:204:27: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
return call_at(ctx, dc, rb_intern("at_tracing"), 0, Qnil);
^~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:23: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:204:27: note: '{' token is here
return call_at(ctx, dc, rb_intern("at_tracing"), 0, Qnil);
^~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1722:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
{ \
^
byebug.c:204:27: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
return call_at(ctx, dc, rb_intern("at_tracing"), 0, Qnil);
^~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1727:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
}
^
byebug.c:204:27: note: ')' token is here
return call_at(ctx, dc, rb_intern("at_tracing"), 0, Qnil);
^~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:51: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:212:27: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
return call_at(ctx, dc, rb_intern("at_breakpoint"), 1, breakpoint);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:23: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:212:27: note: '{' token is here
return call_at(ctx, dc, rb_intern("at_breakpoint"), 1, breakpoint);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1722:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
{ \
^
byebug.c:212:27: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
return call_at(ctx, dc, rb_intern("at_breakpoint"), 1, breakpoint);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1727:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
}
^
byebug.c:212:27: note: ')' token is here
return call_at(ctx, dc, rb_intern("at_breakpoint"), 1, breakpoint);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:51: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:220:27: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
return call_at(ctx, dc, rb_intern("at_catchpoint"), 1, exp);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:23: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:220:27: note: '{' token is here
return call_at(ctx, dc, rb_intern("at_catchpoint"), 1, exp);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1722:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
{ \
^
byebug.c:220:27: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
return call_at(ctx, dc, rb_intern("at_catchpoint"), 1, exp);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1727:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
}
^
byebug.c:220:27: note: ')' token is here
return call_at(ctx, dc, rb_intern("at_catchpoint"), 1, exp);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:51: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:228:27: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
return call_at(ctx, dc, rb_intern("at_return"), 1, return_value);
^~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:23: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:228:27: note: '{' token is here
return call_at(ctx, dc, rb_intern("at_return"), 1, return_value);
^~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1722:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
{ \
^
byebug.c:228:27: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
return call_at(ctx, dc, rb_intern("at_return"), 1, return_value);
^~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1727:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
}
^
byebug.c:228:27: note: ')' token is here
return call_at(ctx, dc, rb_intern("at_return"), 1, return_value);
^~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:51: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:236:27: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
return call_at(ctx, dc, rb_intern("at_end"), 0, Qnil);
^~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:23: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:236:27: note: '{' token is here
return call_at(ctx, dc, rb_intern("at_end"), 0, Qnil);
^~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1722:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
{ \
^
byebug.c:236:27: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
return call_at(ctx, dc, rb_intern("at_end"), 0, Qnil);
^~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1727:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
}
^
byebug.c:236:27: note: ')' token is here
return call_at(ctx, dc, rb_intern("at_end"), 0, Qnil);
^~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:51: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:442:35: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
rb_ivar_set(raised_exception, rb_intern("#__bb_context"), pm_context);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:23: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:442:35: note: '{' token is here
rb_ivar_set(raised_exception, rb_intern("#__bb_context"), pm_context);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1722:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
{ \
^
byebug.c:442:35: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
rb_ivar_set(raised_exception, rb_intern("#__bb_context"), pm_context);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1727:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
}
^
byebug.c:442:35: note: ')' token is here
rb_ivar_set(raised_exception, rb_intern("#__bb_context"), pm_context);
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:51: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:560:33: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
list = rb_funcall(rb_cThread, rb_intern("list"), 0);
^~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:23: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:560:33: note: '{' token is here
list = rb_funcall(rb_cThread, rb_intern("list"), 0);
^~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1722:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
{ \
^
byebug.c:560:33: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
list = rb_funcall(rb_cThread, rb_intern("list"), 0);
^~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1727:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
}
^
byebug.c:560:33: note: ')' token is here
list = rb_funcall(rb_cThread, rb_intern("list"), 0);
^~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:51: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:900:12: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
idPuts = rb_intern("puts");
^~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:23: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:900:12: note: '{' token is here
idPuts = rb_intern("puts");
^~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1722:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
{ \
^
byebug.c:900:12: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
idPuts = rb_intern("puts");
^~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1727:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
}
^
byebug.c:900:12: note: ')' token is here
idPuts = rb_intern("puts");
^~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:51: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:901:13: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
idEmpty = rb_intern("empty?");
^~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:23: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^
byebug.c:901:13: note: '{' token is here
idEmpty = rb_intern("empty?");
^~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1737:24: note: expanded from macro 'rb_intern'
__extension__ (CONST_ID_CACHE((ID), (str))) : \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1730:37: note: expanded from macro 'CONST_ID_CACHE'
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/ruby.h:1722:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
{ \
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [byebug.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/byebug-8.2.1 for inspection.
Results logged to /Users/cristopherhuarocolivera/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/-darwin-21/2.3.0-static/byebug-8.2.1/gem_make.out

Maybe try this
gem install byebug -v '8.2.1' -- --with-cppflags="-Wno-compound-token-split-by-macro"

Related

Overriding yylex() in Bison's C++ API

I have a handwritten parser in C++ which contains a next_token() method and I wanna use it inside yylex() (I already did that correctly with Bison's C API but wanna use dynamic types so moved to C++). I read these parts of documentation, read examples and tried both existing signatures but still can't do it correctly...
parser.yy:
%require "3.2"
%language "c++"
%define api.value.type variant
%define api.token.constructor
%define parse.assert
%code requires
{
#include <iostream>
#include <string>
}
%code{
yy::parser::symbol_type yy::parser::yylex();
void yy::parser::yyerror(const char *error);
}
%token VAR COL ITYPE
%token IDENTIFIER
%token INTEGER
%token EOL
%type <std::string> type PrimitiveType IDENTIFIER
%type <int> INTEGER
%%
program:
| program EOL
| program SimpleDeclaration { }
;
SimpleDeclaration: VariableDeclaration
;
VariableDeclaration: VAR IDENTIFIER COL type {std::cout<<"defined variable " << $2 << " with type " << $4 << std::endl; }
type: IDENTIFIER
| PrimitiveType
;
PrimitiveType: ITYPE { $$ = "int"; }
;
%%
void yy::parser::yyerror(const std::string& m)
{
std::cout << "syntax error" << std::endl;
}
// also 'yy::parser::symbol_type yy::parser::yylex(semantic_type* yylval)' does the same
int yy::parser::yylex(semantic_type* yylval)
{
return 0; // just returning a zero for now
}
int main()
{
yy::parser p;
return 0;
}
Errors :
bison -d parser.ypp
g++ -std=c++17 -o foobar parser.tab.cpp
parser.ypp:14:29: error: no declaration matches ‘yy::parser::symbol_type yy::parser::yylex()’
14 | yy::parser::symbol_type yy::parser::yylex();
| ^~
parser.ypp:14:29: note: no functions named ‘yy::parser::symbol_type yy::parser::yylex()’
In file included from parser.tab.cpp:41:
parser.tab.hpp:193:9: note: ‘class yy::parser’ defined here
193 | class parser
| ^~~~~~
parser.ypp:15:10: error: no declaration matches ‘void yy::parser::yyerror(const char*)’
15 | void yy::parser::yyerror(const char *error);
| ^~
parser.ypp:15:10: note: no functions named ‘void yy::parser::yyerror(const char*)’
In file included from parser.tab.cpp:41:
parser.tab.hpp:193:9: note: ‘class yy::parser’ defined here
193 | class parser
| ^~~~~~
parser.tab.cpp: In member function ‘virtual int yy::parser::parse()’:
parser.tab.cpp:453:38: error: ‘yylex’ was not declared in this scope; did you mean ‘yylen’?
453 | symbol_type yylookahead (yylex ());
| ^~~~~
| yylen
parser.ypp: At global scope:
parser.ypp:45:6: error: no declaration matches ‘void yy::parser::yyerror(const string&)’
45 | void yy::parser::yyerror(const std::string& m)
| ^~
parser.ypp:45:6: note: no functions named ‘void yy::parser::yyerror(const string&)’
In file included from parser.tab.cpp:41:
parser.tab.hpp:193:9: note: ‘class yy::parser’ defined here
193 | class parser
| ^~~~~~
parser.ypp:50:5: error: no declaration matches ‘int yy::parser::yylex(yy::parser::semantic_type*)’
50 | int yy::parser::yylex(semantic_type* yylval)
| ^~
parser.ypp:50:5: note: no functions named ‘int yy::parser::yylex(yy::parser::semantic_type*)’
In file included from parser.tab.cpp:41:
parser.tab.hpp:193:9: note: ‘class yy::parser’ defined here
193 | class parser
| ^~~~~~
I feel weird also that even without overriding, it seems to use yylex here (which causes the error to appear even though I don't try to override):
parser.tab.cpp: In member function ‘virtual int yy::parser::parse()’:
parser.tab.cpp:453:38: error: ‘yylex’ was not declared in this scope; did you mean ‘yylen’?
453 | symbol_type yylookahead (yylex ());
| ^~~~~
| yylen
What did I do wrong here ?
Thanks in advance

YACC: How to pass the string value of a token to the yacc program

I want to design a program using lex and yacc that will take input in Morse code form and the parser would generate their English meaning.
This is the lex file:
%{
#include <stdio.h>
int i=0;
char c;
%}
NewLine ".-.-"
EOF ".-.-"
NewPara "-...-"
Over "K"
SOS "...---..."
%%
".." { yylval=(char *)calloc(yyleng,sizeof(char));
strcpy(yylval,yytext);
return (I);}
".-""--" { yylval=(char *)calloc(yyleng,sizeof(char));
strcpy(yylval,yytext);
return (AM);}
".-""...-"".-""-."".." {yylval.value=(char *)calloc(yyleng,sizeof(char));
strcpy(yylval,yytext);
return (AVANI);}
. return yytext[0];
%%
The yacc file:
%{
#include <stdio.h>
#define YYSTYPE char*
char message [20];
%}
%token I AM AVANI
%start msg
%%
msg : Np Vp {printf("The sentence is I AM AVANI");}
;
Np : I
;
Vp : Aux N
;
Aux : AM
;
N : AVANI
;
%%
#include "lex.yy.c"
/*extern YYSTYPE yylval*/
void main(){
printf("Enter the message\n");
scanf("%s",message);
yyparse();
}
void yyerror(const char *s)
{
fprintf(stderr,"s\n",s);
}
yywrap ()
{
return 1;
}
This shows the following error on Compiling:
morse_code.l: In function ‘yylex’:
morse_code.l:13:10: warning: assignment makes integer from pointer
without a cast [enabled by default]
".." { yylval=(char *)calloc(yyleng,sizeof(char));
^
morse_code.l:14:2: warning: passing argument 1 of ‘strcpy’ makes
pointer from integer without a cast [enabled by default]
strcpy(yylval,yytext);
^
In file included from lex.yy.c:20:0:
/usr/include/string.h:125:14: note: expected ‘char * __restrict__’ but
argument is of type ‘YYSTYPE’
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
^
morse_code.l:17:9: warning: assignment makes integer from pointer
without a cast [enabled by default]
".-""--" { yylval=(char *)calloc(yyleng,sizeof(char));
^
morse_code.l:18:5: warning: passing argument 1 of ‘strcpy’ makes
pointer from integer without a cast [enabled by default]
strcpy(yylval,yytext);
^
In file included from lex.yy.c:20:0:
/usr/include/string.h:125:14: note: expected ‘char * __restrict__’ but
argument is of type ‘YYSTYPE’
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
^
morse_code.l:21:8: error: request for member ‘value’ in something not
a structure or union
".-""...-"".-""-."".." {yylval=(char *)calloc(yyleng,sizeof(char));
^
morse_code.l:22:4: warning: passing argument 1 of ‘strcpy’ makes
pointer from integer without a cast [enabled by default]
strcpy(yylval,yytext);
^
In file included from lex.yy.c:20:0:
/usr/include/string.h:125:14: note: expected ‘char * __restrict__’ but
argument is of type ‘YYSTYPE’
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
It'll be great if someone could help me with the correct way to pass the string value of a token to the yacc file.
Two obvious problems
You're missing a declaration for yylval in your .l file. If you include the "y.tab.h" generated by yacc, that will define it for you, but you don't have that either.
you don't allocate space for the terminating NUL character of your strings with calloc, so when you strcpy the string it will write one byte past the end of your allocation, causing undefined behavior.

How to write yacc grammar rules to identify function definitions vs function calls?

I have started learning about YACC, and I have executed a few examples of simple toy programs. But I have never seen a practical example that demonstrates how to build a compiler that identifies and implements function definitions and function calls, array implementation and so on, nor has it been easy to find an example using Google search. Can someone please provide one example of how to generate the tree using YACC? C or C++ is fine.
Thanks in advance!
Let's parse this code with yacc.
file test contains valid C code that we want to parse.
int main (int c, int b) {
int a;
while ( 1 ) {
int d;
}
}
A lex file c.l
alpha [a-zA-Z]
digit [0-9]
%%
[ \t] ;
[ \n] { yylineno = yylineno + 1;}
int return INT;
float return FLOAT;
char return CHAR;
void return VOID;
double return DOUBLE;
for return FOR;
while return WHILE;
if return IF;
else return ELSE;
printf return PRINTF;
struct return STRUCT;
^"#include ".+ ;
{digit}+ return NUM;
{alpha}({alpha}|{digit})* return ID;
"<=" return LE;
">=" return GE;
"==" return EQ;
"!=" return NE;
">" return GT;
"<" return LT;
"." return DOT;
\/\/.* ;
\/\*(.*\n)*.*\*\/ ;
. return yytext[0];
%%
file c.y for input to YACC:
%{
#include <stdio.h>
#include <stdlib.h>
extern FILE *fp;
%}
%token INT FLOAT CHAR DOUBLE VOID
%token FOR WHILE
%token IF ELSE PRINTF
%token STRUCT
%token NUM ID
%token INCLUDE
%token DOT
%right '='
%left AND OR
%left '<' '>' LE GE EQ NE LT GT
%%
start: Function
| Declaration
;
/* Declaration block */
Declaration: Type Assignment ';'
| Assignment ';'
| FunctionCall ';'
| ArrayUsage ';'
| Type ArrayUsage ';'
| StructStmt ';'
| error
;
/* Assignment block */
Assignment: ID '=' Assignment
| ID '=' FunctionCall
| ID '=' ArrayUsage
| ArrayUsage '=' Assignment
| ID ',' Assignment
| NUM ',' Assignment
| ID '+' Assignment
| ID '-' Assignment
| ID '*' Assignment
| ID '/' Assignment
| NUM '+' Assignment
| NUM '-' Assignment
| NUM '*' Assignment
| NUM '/' Assignment
| '\'' Assignment '\''
| '(' Assignment ')'
| '-' '(' Assignment ')'
| '-' NUM
| '-' ID
| NUM
| ID
;
/* Function Call Block */
FunctionCall : ID'('')'
| ID'('Assignment')'
;
/* Array Usage */
ArrayUsage : ID'['Assignment']'
;
/* Function block */
Function: Type ID '(' ArgListOpt ')' CompoundStmt
;
ArgListOpt: ArgList
|
;
ArgList: ArgList ',' Arg
| Arg
;
Arg: Type ID
;
CompoundStmt: '{' StmtList '}'
;
StmtList: StmtList Stmt
|
;
Stmt: WhileStmt
| Declaration
| ForStmt
| IfStmt
| PrintFunc
| ';'
;
/* Type Identifier block */
Type: INT
| FLOAT
| CHAR
| DOUBLE
| VOID
;
/* Loop Blocks */
WhileStmt: WHILE '(' Expr ')' Stmt
| WHILE '(' Expr ')' CompoundStmt
;
/* For Block */
ForStmt: FOR '(' Expr ';' Expr ';' Expr ')' Stmt
| FOR '(' Expr ';' Expr ';' Expr ')' CompoundStmt
| FOR '(' Expr ')' Stmt
| FOR '(' Expr ')' CompoundStmt
;
/* IfStmt Block */
IfStmt : IF '(' Expr ')'
Stmt
;
/* Struct Statement */
StructStmt : STRUCT ID '{' Type Assignment '}'
;
/* Print Function */
PrintFunc : PRINTF '(' Expr ')' ';'
;
/*Expression Block*/
Expr:
| Expr LE Expr
| Expr GE Expr
| Expr NE Expr
| Expr EQ Expr
| Expr GT Expr
| Expr LT Expr
| Assignment
| ArrayUsage
;
%%
#include"lex.yy.c"
#include<ctype.h>
int count=0;
int main(int argc, char *argv[])
{
yyin = fopen(argv[1], "r");
if(!yyparse())
printf("\nParsing complete\n");
else
printf("\nParsing failed\n");
fclose(yyin);
return 0;
}
yyerror(char *s) {
printf("%d : %s %s\n", yylineno, s, yytext );
}
A Makefile to put it together. I use flex-lexer and bison but the example will also work with lex and yacc.
miniC: c.l c.y
bison c.y
flex c.l
gcc c.tab.c -ll -ly
Compile and parse the test code:
$ make
bison c.y
flex c.l
gcc c.tab.c -ll -ly
c.tab.c: In function ‘yyparse’:
c.tab.c:1273:16: warning: implicit declaration of function ‘yylex’ [-Wimplicit-function-declaration]
yychar = yylex ();
^
c.tab.c:1402:7: warning: implicit declaration of function ‘yyerror’ [-Wimplicit-function-declaration]
yyerror (YY_("syntax error"));
^
c.y: At top level:
c.y:155:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
yyerror(char *s) {
^
$ ls
a.out c.l CMakeLists.txt c.tab.c c.y lex.yy.c Makefile README.md test
$ ./a.out test
Parsing complete
For reading resources I can recommend the books Modern Compiler Implementation in C by Andrew Appel and the flex/bison book by John Levine.

warning: nonterminal useless in grammar: const_declaration [-Wother]

I have the following yacc grammar:
%{
#include <stdio.h>
extern FILE* yyin;
extern char* yytext;
%}
%token VAR ID_NAME TYPE_STRING TYPE_BOOL TYPE_NUMBER CONST
%%
var_declaration: VAR ':' type ID_NAME ';' { printf("var\n"); }
;
const_declaration: CONST ':' type ID_NAME ';' {printf("const\n");}
;
type: TYPE_NUMBER
| TYPE_STRING
| TYPE_BOOL
;
%%
void yyerror (char const *s) {
fprintf (stderr, "%s\n", s);
}
int main(int argc, char** argv[])
{
yyparse();
return 0;
}
It should describe a little language that at this time should allow variable declarations of the form var:<type> <name>; and constants declarations of the form const:<type> <name>;.
When I run yacc -vd grammar.y I get:
yacc -vd grammar.y
grammar.y: warning: 1 nonterminal useless in grammar [-Wother]
grammar.y: warning: 1 rule useless in grammar [-Wother]
grammar.y:16.1-17: warning: nonterminal useless in grammar: const_declaration [-Wother]
const_declaration: CONST ':' type ID_NAME ';' {printf("const\n");}
^^^^^^^^^^^^^^^^^
grammar.y:16.20-67: warning: rule useless in grammar [-Wother]
const_declaration: CONST ':' type ID_NAME ';' {printf("const\n");}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Why does it say that const_declaration rule is useless?
The reason you get this error message is that the rule const_declaration does not appear in any other rule, and is thus not needed for the grammar.
The rule var_declaration is taken as the start rule (as you have not specified a start it uses the first one). This rule only uses the type rule and thus all other rules are redundant, which is what it is telling you.
Perhaps this is a subset of a larger grammar? When all the grammar is in the file and the const_declaration rule is used somewhere the error will go away.

parser for expressions in lex/yacc

I'm trying to parse statements to see whether they are valid or not according to these rules:
assignment:
id = exp ;
expression:
id op id {op id}
id is combination of digits and char, the first position contain a char.
I'm getting syntax error when I have something like this in my in.txt file: hellow = three3
but that shouldn't be a syntax error, and then when i put something like: hellow = =
that does not display a syntax error but it should. What am i doing wrong?
Lex:
%{
#include "y.tab.h"
#include <stdio.h>
%}
%%
[ \t\n]+ ;
[a-zA-Z][a-zA-Z0-9]* {
ECHO;
return ID;
}
%%
YACC:
%{
#include <stdio.h>
extern FILE * yyin;
%}
%token ID
%left '+' '-'
%left '*' '/' '%'
%right ';'
%%
assignment: expression
|
ID '=' expression
;
expression: ID
|
expression '*' expression
|
expression '/' expression
|
expression '%' expression
|
expression '+' expression
|
expression '-' expression
|
'(' expression ')'
;
%%
int main(void) {
yyin = fopen("in.txt", "r");
yyparse();
fclose(yyin);
return 0;
}
I can't say from just looking at this, but a good way to find out is running your parser when the environment variable YYDEBUG is 1, like in (unix):
YYDEBUG=1 ./a.out
You should get a detailed list of the steps the parser takes and the tokens it receives from the lexer (where the error is in most cases, like in your example: how does the parser ever get the '=' sign and the operators?). Compare this with the y.output file you get when you run yacc -v

Resources