Skip to content

Commit 1fdd4c5

Browse files
committed
rbs-inline
1 parent d895319 commit 1fdd4c5

78 files changed

Lines changed: 30777 additions & 1442 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ test/prism/fixtures/seattlerb/**/*.txt linguist-vendored
77
test/prism/fixtures/unparser/**/*.txtlinguist-vendored
88
test/prism/fixtures/whitequark/**/*.txtlinguist-vendored
99
test/prism/snapshots/**/*.txtlinguist-generated
10+
sig/generated/**/*.rbslinguist-generated
1011

1112
# All .rb files should have LF line ending, even on Windows, regardless of the git config core.autocrlf value.
1213
# All .txt should have their line endings as committed in the repository (there are some intentional CR in there),

‎.gitignore‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ out.svg
5959
/src/serialize.c
6060
/src/token_type.c
6161
/src/**/*.o
62-
/sig/prism.rbs
63-
/sig/prism/dsl.rbs
64-
/sig/prism/mutation_compiler.rbs
65-
/sig/prism/node.rbs
66-
/sig/prism/visitor.rbs
67-
/sig/prism/_private/dot_visitor.rbs
6862
/rbi/prism/dsl.rbi
6963
/rbi/prism/node.rbi
7064
/rbi/prism/visitor.rbi

‎Steepfile‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
# frozen_string_literal: true
22

33
target:libdo
4+
check"lib"
45
signature"sig"
56

6-
library"cgi"# in lib/prism/dot_visitor.rb (Prism::DotVisitor)
7-
8-
check"lib"
7+
library"cgi"
8+
library"pp"
99

10-
# TODO: Type-checking these files is still WIP
11-
ignore"lib/prism/desugar_compiler.rb"
12-
ignore"lib/prism/lex_compat.rb"
13-
ignore"lib/prism/serialize.rb"
14-
ignore"lib/prism/ffi.rb"
10+
# Ignored because it requires other libraries.
1511
ignore"lib/prism/translation"
1612

17-
ignore"lib/prism/polyfill/append_as_bytes.rb"
18-
ignore"lib/prism/polyfill/byteindex.rb"
19-
ignore"lib/prism/polyfill/scan_byte.rb"
20-
ignore"lib/prism/polyfill/unpack1.rb"
13+
# Ignored because they are only for older Rubies.
14+
ignore"lib/prism/polyfill"
15+
16+
# Ignored because we do not want to overlap with the C extension.
17+
ignore"lib/prism/ffi.rb"
2118
end

‎gemfiles/typecheck/Gemfile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ source "https://rubygems.org"
55
gem"parser"
66
gem"rake-compiler"
77
gem"rake"
8+
gem"rbs-inline"
89
gem"ruby_parser"
910
gem"sorbet","<= 0.6.12666"# until tapioca is bumped
1011
gem"steep",">= 1.7.0.dev.1"
1112
gem"tapioca"
1213
gem"test-unit"
14+
gem"tsort"# until rbs is bumped

‎gemfiles/typecheck/Gemfile.lock‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ GEM
2323
csv (3.3.5)
2424
drb (2.2.3)
2525
erubi (1.13.1)
26-
ffi (1.17.3-arm64-darwin)
27-
ffi (1.17.3-x86_64-linux-gnu)
26+
ffi (1.17.3)
2827
fileutils (1.8.0)
2928
i18n (1.14.7)
3029
concurrent-ruby (~>1.0)
@@ -57,12 +56,15 @@ GEM
5756
rbs (>=3.4.4)
5857
rbs (3.10.2)
5958
logger
59+
rbs-inline (0.13.0)
60+
prism (>=0.29)
61+
rbs (>=3.8.0)
6062
rexml (3.4.4)
6163
ruby_parser (3.22.0)
6264
racc (~>1.5)
6365
sexp_processor (~>4.16)
6466
securerandom (0.4.1)
65-
sexp_processor (4.17.4)
67+
sexp_processor (4.17.5)
6668
sorbet (0.6.12666)
6769
sorbet-static (=0.6.12666)
6870
sorbet-runtime (0.6.12666)
@@ -111,11 +113,12 @@ GEM
111113
test-unit (3.7.7)
112114
power_assert
113115
thor (1.4.0)
116+
tsort (0.2.0)
114117
tzinfo (2.0.6)
115118
concurrent-ruby (~>1.0)
116119
unicode-display_width (3.2.0)
117120
unicode-emoji (~>4.1)
118-
unicode-emoji (4.1.0)
121+
unicode-emoji (4.2.0)
119122
uri (1.1.1)
120123
yard (0.9.37)
121124
yard-sorbet (0.9.0)
@@ -130,11 +133,13 @@ DEPENDENCIES
130133
parser
131134
rake
132135
rake-compiler
136+
rbs-inline
133137
ruby_parser
134138
sorbet (<=0.6.12666)
135139
steep (>=1.7.0.dev.1)
136140
tapioca
137141
test-unit
142+
tsort
138143

139144
BUNDLED WITH
140145
2.5.16

‎lib/prism.rb‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
# rbs_inline: enabled
23
# :markup: markdown
34

45
# The Prism Ruby parser.
@@ -37,6 +38,8 @@ module Prism
3738
# Raised when requested to parse as the currently running Ruby version but Prism has no support for it.
3839
classCurrentVersionError < ArgumentError
3940
# Initialize a new exception for the given ruby version string.
41+
#--
42+
#: (String version) -> void
4043
definitialize(version)
4144
message= +"invalid version: Requested to parse as `version: 'current'`; "
4245
segments=
@@ -61,6 +64,8 @@ def initialize(version)
6164
# resembles the return value of Ripper.lex.
6265
#
6366
# For supported options, see Prism.parse.
67+
#--
68+
#: (String source, **untyped options) -> LexCompat::Result
6469
defself.lex_compat(source, **options)
6570
LexCompat.new(source, **options).result# steep:ignore
6671
end
@@ -69,9 +74,37 @@ def self.lex_compat(source, **options)
6974
# load(source, serialized, freeze) -> ParseResult
7075
#
7176
# Load the serialized AST using the source as a reference into a tree.
77+
#--
78+
#: (String source, String serialized, ?bool freeze) -> ParseResult
7279
defself.load(source,serialized,freeze=false)
7380
Serialize.load_parse(source,serialized,freeze)
7481
end
82+
83+
# @rbs!
84+
# VERSION: String
85+
# BACKEND: :CEXT | :FFI
86+
#
87+
# interface _Stream
88+
# def gets: (?Integer integer) -> (String | nil)
89+
# end
90+
#
91+
# def self.parse: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult
92+
# def self.profile: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> void
93+
# def self.lex: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> LexResult
94+
# def self.parse_lex: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseLexResult
95+
# def self.dump: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> String
96+
# def self.parse_comments: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> Array[Comment]
97+
# def self.parse_success?: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool
98+
# def self.parse_failure?: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool
99+
# def self.parse_stream: (_Stream stream, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult
100+
# def self.parse_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult
101+
# def self.profile_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> void
102+
# def self.lex_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> LexResult
103+
# def self.parse_lex_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseLexResult
104+
# def self.dump_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> String
105+
# def self.parse_file_comments: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> Array[Comment]
106+
# def self.parse_file_success?: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool
107+
# def self.parse_file_failure?: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool
75108
end
76109

77110
require_relative"prism/polyfill/byteindex"

0 commit comments

Comments
 (0)