Skip to content

Commit 43174d4

Browse files
committed
+ ruby-next/lexer.rl: upgrade lexer
1 parent 5cc4f3a commit 43174d4

File tree

9 files changed

+38
-21
lines changed

9 files changed

+38
-21
lines changed

.dockerdev/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
ARG RUBY_VERSION
22
FROM ruby:${RUBY_VERSION}-slim
33

4-
ARG BUNDLER_VERSION
5-
64
# Install system dependencies
75
RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade && \
86
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
@@ -27,8 +25,8 @@ ENV BUNDLE_APP_CONFIG=${BUNDLE_PATH} \
2725
BUNDLE_BIN=${BUNDLE_PATH}/bin
2826
ENV PATH /app/bin:${BUNDLE_BIN}:${PATH}
2927

30-
# Upgrade RubyGems and install required Bundler version
28+
# Upgrade RubyGems and install latest Bundler version
3129
RUN gem update --system && \
32-
gem install bundler:${BUNDLER_VERSION}
30+
gem install bundler
3331

3432
WORKDIR /app

.dockerdev/docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ services:
77
context: ../
88
dockerfile: .dockerdev/Dockerfile
99
args:
10-
RUBY_VERSION: '2.6'
11-
BUNDLER_VERSION: '2.0.2'
10+
RUBY_VERSION: '3.1'
1211
environment:
1312
- HISTFILE=/bundle/.bash_history
1413
- bundler_data:/bundle

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ lib/parser/ruby34.rb
4040
lib/parser/macruby.rb
4141
lib/parser/rubymotion.rb
4242
lib/parser/rubynext.rb
43-
lib/parser/ruby-next/lexer.rb
43+
lib/parser/ruby-next/lexer-F0.rb
44+
lib/parser/ruby-next/lexer-F1.rb

Rakefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ GENERATED_FILES = %w(lib/parser/lexer-F0.rb
4141
lib/parser/macruby.rb
4242
lib/parser/rubymotion.rb
4343
lib/parser/rubynext.rb
44-
lib/parser/ruby-next/lexer.rb)
44+
lib/parser/ruby-next/lexer-F0.rb
45+
lib/parser/ruby-next/lexer-F1.rb)
4546

4647
CLEAN.include(GENERATED_FILES)
4748

@@ -164,6 +165,14 @@ file 'lib/parser/lexer-F0.rb' => 'lib/parser/lexer.rl' do |t|
164165
sh "ragel -F0 -R #{t.source} -o #{t.name}"
165166
end
166167

168+
file 'lib/parser/ruby-next/lexer-F1.rb' => 'lib/parser/ruby-next/lexer.rl' do |t|
169+
sh "ragel -F1 -R #{t.source} -o #{t.name}"
170+
end
171+
172+
file 'lib/parser/ruby-next/lexer-F0.rb' => 'lib/parser/ruby-next/lexer.rl' do |t|
173+
sh "ragel -F0 -R #{t.source} -o #{t.name}"
174+
end
175+
167176
file 'lib/parser/lexer-strings.rb' => 'lib/parser/lexer-strings.rl' do |t|
168177
sh "ragel -F0 -R #{t.source} -o #{t.name}"
169178
end

lib/parser/ruby-next/lexer-F0.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Parser::Lexer
8383
class Next
8484

8585

86-
# line 86 "lib/parser/ruby-next/lexer-F0.rb"
86+
# line 83 "lib/parser/ruby-next/lexer-F0.rb"
8787
class << self
8888
attr_accessor :_lex_actions
8989
private :_lex_actions, :_lex_actions=
@@ -8598,7 +8598,7 @@ def advance
85988598
@command_start = false
85998599

86008600

8601-
# line 8601 "lib/parser/ruby-next/lexer-F0.rb"
8601+
# line 8596 "lib/parser/ruby-next/lexer-F0.rb"
86028602
begin # ragel flat
86038603
testEof = false
86048604
_slen, _trans, _keys, _inds, _acts, _nacts = nil
@@ -8633,7 +8633,7 @@ def advance
86338633
begin
86348634
@ts = p
86358635
end
8636-
# line 8636 "lib/parser/ruby-next/lexer-F0.rb"
8636+
# line 8631 "lib/parser/ruby-next/lexer-F0.rb"
86378637
end # from state action switch
86388638
end
86398639
if _trigger_goto
@@ -12652,7 +12652,7 @@ def advance
1265212652

1265312653
end
1265412654
end
12655-
# line 12655 "lib/parser/ruby-next/lexer-F0.rb"
12655+
# line 12650 "lib/parser/ruby-next/lexer-F0.rb"
1265612656
end # action switch
1265712657
end
1265812658
end
@@ -12672,7 +12672,7 @@ def advance
1267212672
# line 1 "NONE"
1267312673
begin
1267412674
@ts = nil; end
12675-
# line 12675 "lib/parser/ruby-next/lexer-F0.rb"
12675+
# line 12670 "lib/parser/ruby-next/lexer-F0.rb"
1267612676
end # to state action switch
1267712677
end
1267812678
if _trigger_goto

lib/parser/ruby-next/lexer-F1.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Parser::Lexer
8383
class Next
8484

8585

86-
# line 86 "lib/parser/ruby-next/lexer-F1.rb"
86+
# line 83 "lib/parser/ruby-next/lexer-F1.rb"
8787
class << self
8888
attr_accessor :_lex_trans_keys
8989
private :_lex_trans_keys, :_lex_trans_keys=
@@ -8463,7 +8463,7 @@ def advance
84638463
@command_start = false
84648464

84658465

8466-
# line 8466 "lib/parser/ruby-next/lexer-F1.rb"
8466+
# line 8461 "lib/parser/ruby-next/lexer-F1.rb"
84678467
begin
84688468
testEof = false
84698469
_slen, _trans, _keys, _inds, _acts, _nacts = nil
@@ -8491,7 +8491,7 @@ def advance
84918491
begin
84928492
@ts = p
84938493
end
8494-
# line 8494 "lib/parser/ruby-next/lexer-F1.rb"
8494+
# line 8489 "lib/parser/ruby-next/lexer-F1.rb"
84958495
end
84968496
_keys = @cs << 1
84978497
_inds = _lex_index_offsets[ @cs]
@@ -14675,7 +14675,7 @@ def advance
1467514675
# line 1799 "lib/parser/ruby-next/lexer.rl"
1467614676
begin
1467714677
@act = 115; end
14678-
# line 14678 "lib/parser/ruby-next/lexer-F1.rb"
14678+
# line 14673 "lib/parser/ruby-next/lexer-F1.rb"
1467914679
end
1468014680
end
1468114681
end
@@ -14685,7 +14685,7 @@ def advance
1468514685
# line 1 "NONE"
1468614686
begin
1468714687
@ts = nil; end
14688-
# line 14688 "lib/parser/ruby-next/lexer-F1.rb"
14688+
# line 14683 "lib/parser/ruby-next/lexer-F1.rb"
1468914689
end
1469014690

1469114691
if @cs == 0

lib/parser/ruby-next/lexer.rl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ class Next
490490
'=>' => :tASSOC, '::' => :tCOLON2, '===' => :tEQQ,
491491
'<=>' => :tCMP, '[]' => :tAREF, '[]=' => :tASET,
492492
'{' => :tLCURLY, '}' => :tRCURLY, '`' => :tBACK_REF2,
493-
'!@' => :tBANG, '&.' => :tANDDOT,
493+
'!@' => :tBANG, '&.' => :tANDDOT, '.:' => :tMETHREF,
494494
}
495495

496496
PUNCTUATION_BEGIN = {

lib/parser/ruby-next/parser_ext.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# frozen_string_literal: true
22

3-
require_relative "lexer"
3+
4+
if RUBY_ENGINE == 'truffleruby'
5+
require_relative "lexer-F0"
6+
else
7+
require_relative "lexer-F1"
8+
end
49
require_relative "builder"
510
require_relative "ast/processor"
611

test/ruby-next/test_lexer.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
require 'helper'
55
require 'complex'
66

7-
require 'parser/ruby-next/lexer'
7+
8+
if RUBY_ENGINE == 'truffleruby'
9+
require 'parser/ruby-next/lexer-F0'
10+
else
11+
require 'parser/ruby-next/lexer-F1'
12+
end
813

914
class TestLexerNext < Minitest::Test
1015
def setup_lexer(version)

0 commit comments

Comments
 (0)