Skip to content

Commit

Permalink
Merge branch 'el841:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
el841 authored Mar 10, 2024
2 parents 338c744 + d94ad00 commit 95ab2cd
Show file tree
Hide file tree
Showing 50 changed files with 933 additions and 498 deletions.
6 changes: 3 additions & 3 deletions doc/rdoc/markup_reference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,9 @@
# The file content is shifted to have the same indentation as the colon
# at the start of the directive.
#
# The file is searched for in the directories
# given with the <tt>--include</tt> command-line option,
# or by default in the current directory.
# The file is searched for in the directory containing the current file,
# and then in each of the directories given with the <tt>--include</tt>
# command-line option.
#
# For C code, the directive may appear in a stand-alone comment
#
Expand Down
8 changes: 0 additions & 8 deletions internal/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,6 @@ rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
#define RUBY_GC_INFO if(0)printf
#endif

#define RUBY_MARK_MOVABLE_UNLESS_NULL(ptr) do { \
VALUE markobj = (ptr); \
if (RTEST(markobj)) {rb_gc_mark_movable(markobj);} \
} while (0)
#define RUBY_MARK_UNLESS_NULL(ptr) do { \
VALUE markobj = (ptr); \
if (RTEST(markobj)) {rb_gc_mark(markobj);} \
} while (0)
#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;}

#if STACK_GROW_DIRECTION > 0
Expand Down
2 changes: 1 addition & 1 deletion lib/irb/irb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = Gem::Requirement.new(">= 2.7")

spec.add_dependency "reline", ">= 0.4.2"
spec.add_dependency "rdoc"
spec.add_dependency "rdoc", ">= 4.0.0"
end
8 changes: 6 additions & 2 deletions lib/prism/translation/parser/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,19 @@ def to_a
start_offset = offset_cache[token.location.start_offset]
lines.map do |line|
end_offset = start_offset + line.length
tokens << [:tSTRING_CONTENT, [line, Range.new(source_buffer, start_offset, offset_cache[end_offset])]]
tokens << [:tSTRING_CONTENT, [line, Range.new(source_buffer, offset_cache[start_offset], offset_cache[end_offset])]]
start_offset = end_offset
end
next
end
when :tSTRING_DVAR
value = nil
when :tSTRING_END
if token.type == :REGEXP_END
if token.type == :HEREDOC_END && value.end_with?("\n")
newline_length = value.end_with?("\r\n") ? 2 : 1
value = value.sub(/\r?\n\z/, '')
location = Range.new(source_buffer, offset_cache[token.location.start_offset], offset_cache[token.location.end_offset - newline_length])
elsif token.type == :REGEXP_END
value = value[0]
location = Range.new(source_buffer, offset_cache[token.location.start_offset], offset_cache[token.location.start_offset + 1])
end
Expand Down
25 changes: 25 additions & 0 deletions lib/rdoc/markup/to_bs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,31 @@ def accept_heading heading
@res << "\n"
end

##
# Prepares the visitor for consuming +list_item+

def accept_list_item_start list_item
type = @list_type.last

case type
when :NOTE, :LABEL then
bullets = Array(list_item.label).map do |label|
attributes(label).strip
end.join "\n"

bullets << ":\n" unless bullets.empty?

@prefix = ' ' * @indent
@indent += 2
@prefix << bullets + (' ' * @indent)
else
bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
@prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
width = bullet.length + 1
@indent += width
end
end

##
# Turns on or off regexp handling for +convert_string+

Expand Down
8 changes: 4 additions & 4 deletions lib/rdoc/markup/to_markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def handle_regexp_HARD_BREAK target
# Finishes consumption of `list`

def accept_list_end list
@res << "\n"

super
end

Expand All @@ -60,6 +58,8 @@ def accept_list_item_end list_item
when :NOTE, :LABEL then
use_prefix

@res << "\n"

4
else
@list_index[-1] = @list_index.last.succ
Expand All @@ -81,11 +81,11 @@ def accept_list_item_start list_item
attributes(label).strip
end.join "\n"

bullets << "\n:"
bullets << "\n" unless bullets.empty?

@prefix = ' ' * @indent
@indent += 4
@prefix << bullets + (' ' * (@indent - 1))
@prefix << bullets << ":" << (' ' * (@indent - 1))
else
bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
@prefix = (' ' * @indent) + bullet.ljust(4)
Expand Down
14 changes: 11 additions & 3 deletions lib/rdoc/markup/to_rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,19 @@ def accept_list_item_start list_item

case type
when :NOTE, :LABEL then
bullets = Array(list_item.label).map do |label|
stripped_labels = Array(list_item.label).map do |label|
attributes(label).strip
end.join "\n"
end

bullets = case type
when :NOTE
stripped_labels.map { |b| "#{b}::" }
when :LABEL
stripped_labels.map { |b| "[#{b}]" }
end

bullets << ":\n" unless bullets.empty?
bullets = bullets.join("\n")
bullets << "\n" unless stripped_labels.empty?

@prefix = ' ' * @indent
@indent += 2
Expand Down
31 changes: 19 additions & 12 deletions prism/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
errors:
- CANNOT_PARSE_EXPRESSION
- ALIAS_ARGUMENT
- AMPAMPEQ_MULTI_ASSIGN
- ARGUMENT_AFTER_BLOCK
Expand Down Expand Up @@ -34,6 +33,7 @@ errors:
- BLOCK_PARAM_PIPE_TERM
- BLOCK_TERM_BRACE
- BLOCK_TERM_END
- CANNOT_PARSE_EXPRESSION
- CANNOT_PARSE_STRING_PART
- CASE_EXPRESSION_AFTER_CASE
- CASE_EXPRESSION_AFTER_WHEN
Expand Down Expand Up @@ -82,13 +82,13 @@ errors:
- EXPECT_ARGUMENT
- EXPECT_EOL_AFTER_STATEMENT
- EXPECT_EXPRESSION_AFTER_AMPAMPEQ
- EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ
- EXPECT_EXPRESSION_AFTER_COMMA
- EXPECT_EXPRESSION_AFTER_EQUAL
- EXPECT_EXPRESSION_AFTER_LESS_LESS
- EXPECT_EXPRESSION_AFTER_LPAREN
- EXPECT_EXPRESSION_AFTER_QUESTION
- EXPECT_EXPRESSION_AFTER_OPERATOR
- EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ
- EXPECT_EXPRESSION_AFTER_QUESTION
- EXPECT_EXPRESSION_AFTER_SPLAT
- EXPECT_EXPRESSION_AFTER_SPLAT_HASH
- EXPECT_EXPRESSION_AFTER_STAR
Expand All @@ -113,23 +113,25 @@ errors:
- HASH_VALUE
- HEREDOC_TERM
- INCOMPLETE_QUESTION_MARK
- INCOMPLETE_VARIABLE_CLASS_3_3_0
- INCOMPLETE_VARIABLE_CLASS
- INCOMPLETE_VARIABLE_INSTANCE_3_3_0
- INCOMPLETE_VARIABLE_CLASS_3_3_0
- INCOMPLETE_VARIABLE_INSTANCE
- INCOMPLETE_VARIABLE_INSTANCE_3_3_0
- INVALID_CHARACTER
- INVALID_ENCODING_MAGIC_COMMENT
- INVALID_FLOAT_EXPONENT
- INVALID_MULTIBYTE_CHAR
- INVALID_MULTIBYTE_CHARACTER
- INVALID_MULTIBYTE_ESCAPE
- INVALID_NUMBER_BINARY
- INVALID_NUMBER_DECIMAL
- INVALID_NUMBER_HEXADECIMAL
- INVALID_NUMBER_OCTAL
- INVALID_NUMBER_UNDERSCORE
- INVALID_CHARACTER
- INVALID_MULTIBYTE_CHARACTER
- INVALID_PRINTABLE_CHARACTER
- INVALID_PERCENT
- INVALID_VARIABLE_GLOBAL_3_3_0
- INVALID_PRINTABLE_CHARACTER
- INVALID_VARIABLE_GLOBAL
- INVALID_VARIABLE_GLOBAL_3_3_0
- IT_NOT_ALLOWED_NUMBERED
- IT_NOT_ALLOWED_ORDINARY
- LAMBDA_OPEN
Expand All @@ -150,8 +152,8 @@ errors:
- MODULE_TERM
- MULTI_ASSIGN_MULTI_SPLATS
- MULTI_ASSIGN_UNEXPECTED_REST
- NOT_EXPRESSION
- NO_LOCAL_VARIABLE
- NOT_EXPRESSION
- NUMBER_LITERAL_UNDERSCORE
- NUMBERED_PARAMETER_IT
- NUMBERED_PARAMETER_ORDINARY
Expand All @@ -173,8 +175,8 @@ errors:
- PARAMETER_UNEXPECTED_FWD
- PARAMETER_WILD_LOOSE_COMMA
- PATTERN_EXPRESSION_AFTER_BRACKET
- PATTERN_EXPRESSION_AFTER_HROCKET
- PATTERN_EXPRESSION_AFTER_COMMA
- PATTERN_EXPRESSION_AFTER_HROCKET
- PATTERN_EXPRESSION_AFTER_IN
- PATTERN_EXPRESSION_AFTER_KEY
- PATTERN_EXPRESSION_AFTER_PAREN
Expand All @@ -191,7 +193,12 @@ errors:
- PATTERN_TERM_BRACKET
- PATTERN_TERM_PAREN
- PIPEPIPEEQ_MULTI_ASSIGN
- REGEXP_ENCODING_OPTION_MISMATCH
- REGEXP_INCOMPAT_CHAR_ENCODING
- REGEXP_INVALID_UNICODE_RANGE
- REGEXP_NON_ESCAPED_MBC
- REGEXP_TERM
- REGEXP_UTF8_CHAR_NON_UTF8_REGEXP
- RESCUE_EXPRESSION
- RESCUE_MODIFIER_VALUE
- RESCUE_TERM
Expand All @@ -213,9 +220,9 @@ errors:
- TERNARY_EXPRESSION_FALSE
- TERNARY_EXPRESSION_TRUE
- UNARY_RECEIVER
- UNDEF_ARGUMENT
- UNEXPECTED_TOKEN_CLOSE_CONTEXT
- UNEXPECTED_TOKEN_IGNORE
- UNDEF_ARGUMENT
- UNTIL_TERM
- VOID_EXPRESSION
- WHILE_TERM
Expand Down
14 changes: 13 additions & 1 deletion prism/encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,22 @@ extern const pm_encoding_t pm_encodings[PM_ENCODING_MAXIMUM];
/**
* This is the ASCII-8BIT encoding. We need a reference to it so that pm_strpbrk
* can compare against it because invalid multibyte characters are not a thing
* in this encoding.
* in this encoding. It is also needed for handling Regexp encoding flags.
*/
#define PM_ENCODING_ASCII_8BIT_ENTRY (&pm_encodings[PM_ENCODING_ASCII_8BIT])

/**
* This is the EUC-JP encoding. We need a reference to it to quickly process
* regular expression modifiers.
*/
#define PM_ENCODING_EUC_JP_ENTRY (&pm_encodings[PM_ENCODING_EUC_JP])

/**
* This is the Windows-31J encoding. We need a reference to it to quickly
* process regular expression modifiers.
*/
#define PM_ENCODING_WINDOWS_31J_ENTRY (&pm_encodings[PM_ENCODING_WINDOWS_31J])

/**
* Parse the given name of an encoding and return a pointer to the corresponding
* encoding struct if one can be found, otherwise return NULL.
Expand Down
6 changes: 6 additions & 0 deletions prism/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,12 @@ struct pm_parser {
* a true value.
*/
bool frozen_string_literal;

/**
* True if the current regular expression being lexed contains only ASCII
* characters.
*/
bool current_regular_expression_ascii_only;
};

#endif
Loading

0 comments on commit 95ab2cd

Please sign in to comment.