[前][次][番号順一覧][スレッド一覧]

ruby-changes:74392

From: yui-knk <ko1@a...>
Date: Tue, 8 Nov 2022 12:30:21 +0900 (JST)
Subject: [ruby-changes:74392] f7db1affd1 (master): Set default %printer for NODE nterms

https://git.ruby-lang.org/ruby.git/commit/?id=f7db1affd1

From f7db1affd10767d729866e95c02ffb26266829ab Mon Sep 17 00:00:00 2001
From: yui-knk <spiketeika@g...>
Date: Fri, 23 Sep 2022 23:01:55 +0900
Subject: Set default %printer for NODE nterms

Before:

```
Reducing stack by rule 639 (line 5062):
   $1 = token "integer literal" (1.0-1.1: 1)
-> $$ = nterm simple_numeric (1.0-1.1: )
```

After:

```
Reducing stack by rule 641 (line 5078):
   $1 = token "integer literal" (1.0-1.1: 1)
-> $$ = nterm simple_numeric (1.0-1.1: NODE_LIT)
```

`"<*>"` is supported by Bison 2.3b (2008-05-27) or later.
https://git.savannah.gnu.org/cgit/bison.git/commit/?id=12e3584054c16ab255672c07af0ffc7bb220e8bc

Therefore developers need to install Bison 2.3b+ to build ruby from
source codes if their Bison is older.

Minimum version requirement for Bison is changed to 3.0.

See: https://bugs.ruby-lang.org/issues/19068 [Feature #19068]
---
 .github/workflows/macos.yml | 3 ++-
 ext/ripper/tools/preproc.rb | 2 +-
 parse.y                     | 8 ++++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
index e5f055f8c4..6865c218b1 100644
--- a/.github/workflows/macos.yml
+++ b/.github/workflows/macos.yml
@@ -51,11 +51,12 @@ jobs: https://github.com/ruby/ruby/blob/trunk/.github/workflows/macos.yml#L51
       - name: Install libraries
         run: |
           brew upgrade
-          brew install gmp libffi openssl@1... zlib autoconf automake libtool readline
+          brew install gmp libffi openssl@1... zlib autoconf automake libtool readline bison
         working-directory: src
       - name: Set ENV
         run: |
           echo "MAKEFLAGS=-j$((1 + $(sysctl -n hw.activecpu)))" >> $GITHUB_ENV
+          echo "PATH="/usr/local/opt/bison/bin:$PATH"" >> $GITHUB_ENV
       - run: ./autogen.sh
         working-directory: src
       - name: Run configure
diff --git a/ext/ripper/tools/preproc.rb b/ext/ripper/tools/preproc.rb
index b838a78db7..cd85a5da61 100644
--- a/ext/ripper/tools/preproc.rb
+++ b/ext/ripper/tools/preproc.rb
@@ -47,7 +47,7 @@ def prelude(f, out) https://github.com/ruby/ruby/blob/trunk/ext/ripper/tools/preproc.rb#L47
     when /\A%%/
       out << "%%\n"
       return
-    when /\A%token/
+    when /\A%token/, /\A} <node>/
       out << line.sub(/<\w+>/, '<val>')
     when /\A%type/
       out << line.sub(/<\w+>/, '<val>')
diff --git a/parse.y b/parse.y
index f4b4b8f3d1..f6b32d5c97 100644
--- a/parse.y
+++ b/parse.y
@@ -1140,6 +1140,14 @@ static int looking_at_eol_p(struct parser_params *p); https://github.com/ruby/ruby/blob/trunk/parse.y#L1140
 %define api.pure
 %define parse.error verbose
 %printer {
+#ifndef RIPPER
+    if ($$) {
+	rb_parser_printf(p, "%s", ruby_node_name(nd_type($$)));
+    }
+#else
+#endif
+} <node>
+%printer {
 #ifndef RIPPER
     rb_parser_printf(p, "%"PRIsVALUE, rb_id2str($$));
 #else
-- 
cgit v1.2.3


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]