Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Skip instead of Scan#192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
korny wants to merge3 commits intomaster
base:master
Choose a base branch
Loading
fromruby-skip
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletionslib/coderay/scanners/ruby.rb
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,30 +62,31 @@ def scan_tokens encoder, options
if match = scan(/[ \t\f\v]+/)
encoder.text_token match, :space

elsifmatch = scan(/\n/)
elsifskip(/\n/)
if heredocs
unscan # heredoc scanning needs \n at start
state = heredocs.shift
encoder.begin_group state.type
heredocs = nil if heredocs.empty?
else
state = :initial if state == :undef_comma_expected
encoder.text_tokenmatch, :space
encoder.text_token"\n", :space
value_expected = true
end

elsif match = scan(bol? ? / \#(!)?.* | #{patterns::RUBYDOC_OR_DATA} /ox : /\#.*/)
encoder.text_token match, self[1] ? :doctype : :comment

elsifmatch = scan(/\\\n/)
elsifskip(/\\\n/)
if heredocs
unscan # heredoc scanning needs \n at start
encoder.text_token scan(/\\/), :space
skip(/\\/)
encoder.text_token '\\', :space
state = heredocs.shift
encoder.begin_group state.type
heredocs = nil if heredocs.empty?
else
encoder.text_tokenmatch, :space
encoder.text_token"\\\n", :space
end

elsif state == :initial
Expand All@@ -96,7 +97,7 @@ def scan_tokens encoder, options
/#{patterns::METHOD_NAME}/o)

kind = patterns::IDENT_KIND[match]
if value_expected != :colon_expected &&scan(/:(?!:)/)
if value_expected != :colon_expected &&skip(/:(?!:)/)
value_expected = true
encoder.text_token match, :key
encoder.text_token ':', :operator
Expand DownExpand Up@@ -185,9 +186,9 @@ def scan_tokens encoder, options
value_expected = false
encoder.text_token match, :instance_variable

elsif value_expected &&match = scan(/\//)
elsif value_expected &&skip(/\//)
encoder.begin_group :regexp
encoder.text_tokenmatch, :delimiter
encoder.text_token'/', :delimiter
state = self.class::StringState.new :regexp, true, '/'

elsif match = scan(value_expected ? /[-+]?#{patterns::NUMERIC}/o : /#{patterns::NUMERIC}/o)
Expand DownExpand Up@@ -232,10 +233,10 @@ def scan_tokens encoder, options
value_expected = match == '?' ? :colon_expected : true
encoder.text_token match, :operator

elsifmatch = scan(/`/)
elsifskip(/`/)
encoder.begin_group :shell
encoder.text_tokenmatch, :delimiter
state = self.class::StringState.new :shell, true,match
encoder.text_token'`', :delimiter
state = self.class::StringState.new :shell, true,'`'

elsif match = scan(unicode ? /#{patterns::GLOBAL_VARIABLE}/uo :
/#{patterns::GLOBAL_VARIABLE}/o)
Expand All@@ -247,8 +248,8 @@ def scan_tokens encoder, options
encoder.text_token match, :class_variable
value_expected = false

elsifmatch = scan(/\\\z/)
encoder.text_tokenmatch, :space
elsifskip(/\\\z/)
encoder.text_token'\\', :space

else
if method_call_expected
Expand DownExpand Up@@ -300,8 +301,8 @@ def scan_tokens encoder, options
end

elsif state == :module_expected
ifmatch = scan(/<</)
encoder.text_tokenmatch, :operator
ifskip(/<</)
encoder.text_token'<<', :operator
else
state = :initial
if match = scan(unicode ? / (?:#{patterns::IDENT}::)* #{patterns::IDENT} /oux :
Expand DownExpand Up@@ -332,8 +333,8 @@ def scan_tokens encoder, options
end

elsif state == :undef_comma_expected
ifmatch = scan(/,/)
encoder.text_tokenmatch, :operator
ifskip(/,/)
encoder.text_token',', :operator
state = :undef_expected
else
state = :initial
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp