Skip to content

Use Ripper for lexical analyser #512

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 151 commits into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
9fe38ca
Use Ripper instead of IRB's lex
aycabta Apr 6, 2017
ae8e8ce
Fix collect_first_comment for Ripper
aycabta Apr 6, 2017
d4d684c
Fix get_class_or_module for Ripper
aycabta Apr 6, 2017
c39f7f0
Fix parse_statements for Ripper
aycabta Apr 6, 2017
1e61ab1
Fix read_directive for Ripper
aycabta Apr 6, 2017
9f59a91
Remove unnecessary method calling
aycabta Apr 6, 2017
5dcc452
Fix parse_module for Ripper
aycabta Apr 6, 2017
9338eec
Fix test_get_class_or_module
aycabta Apr 9, 2017
7cd8575
Raise RDoc::Error when invalid class or module definition
aycabta Apr 9, 2017
b5443f9
Comment out some old code
aycabta Apr 29, 2017
e914d68
Fix test_parse_method for Ripper
aycabta Jun 11, 2017
9eab386
Fix for test_parse_alias
aycabta Jun 15, 2017
32eec2a
Fix for rdoc command running
aycabta Jun 15, 2017
5021a1b
Fix for test_parse_method_nil
aycabta Jun 18, 2017
abc30fd
Fix for test_parse_multi_ghost_methods
aycabta Jun 18, 2017
352f5ed
Fix for test_parse_method_constant
aycabta Jun 18, 2017
829fdba
Fix for test_parse_method_toplevel
aycabta Jun 18, 2017
1a2b601
Fix test_parse_statements_def_percent_string_pound for Ripper
aycabta Jun 18, 2017
d94a38d
Fix for test_parse_method_gvar_insane
aycabta Jun 18, 2017
e2d63ff
Fix for test_parse_method_parameters_comment
aycabta Jun 18, 2017
83b5b78
Fix for test_collect_first_comment
aycabta Jun 18, 2017
f6111fd
Fix for test_parse_method_toplevel_class
aycabta Jun 18, 2017
d10dcc5
Fix for test_parse_meta_method_name
aycabta Jun 18, 2017
b9d53b2
Fix for test_parse_meta_method_string_name
aycabta Jun 18, 2017
a104381
Fix test_parse_meta_method for Ripper
aycabta Jun 18, 2017
55a18bb
Fix for test_parse_meta_method_block
aycabta Jun 19, 2017
6fe9b92
Fix for test_parse_meta_method_unknown
aycabta Jun 19, 2017
e37e73e
Fix for test_parse_class_single
aycabta Jun 19, 2017
9d677e8
Fix for test_parse_class_single_root
aycabta Jun 20, 2017
b7ec322
Fix for test_parse_constant.*
aycabta Jun 20, 2017
7039be0
Fix for test_parse_meta_attr.*
aycabta Jun 20, 2017
789b3cf
Fix for test_parse_attr.*
aycabta Jun 20, 2017
d967b49
Fix test_parse_comment_method for Ripper
aycabta Jun 21, 2017
36f6e01
Fix for test_sanity_integer
aycabta Jun 21, 2017
11a67a4
Fix for test_scan_tomdoc_meta
aycabta Jun 21, 2017
8b98cf7
Fix for test_scan_constant_in_rescue
aycabta Jun 21, 2017
8cdad9d
Remove unnecessary condition
aycabta Jun 21, 2017
f8e44b6
Fix for test_sanity_interpolation_{curly,crazy}
aycabta Jun 21, 2017
2ff8110
Fix test_read_directive
aycabta Jun 21, 2017
d85909e
Fix test string to parse for Ripper
aycabta Jun 21, 2017
9bfac9d
Fix test_read_directive_.*
aycabta Jun 21, 2017
9710964
Fix for test_parse_statements_enddoc.*
aycabta Jun 21, 2017
f299898
Fix test_sanity_interpolation, Ripper doesn't complement newline at last
aycabta Jun 21, 2017
288e3b3
Fix for test_parse_yield_in_braces_with_parens
aycabta Jun 21, 2017
7acaf58
Fix for test_parse_statements_while_begin
aycabta Jun 21, 2017
4971265
Fix for test_parse_extend_or_include_extend
aycabta Jun 21, 2017
e91c8b1
Fix for test_parse_top_level_statements_enddoc
aycabta Jun 21, 2017
8af6e17
Fix for test_get_class_specification
aycabta Jun 21, 2017
84ff7c6
Fix for test_parse_symbol_in_arg
aycabta Jun 21, 2017
8cd6e15
Fix for test_parse_statements_identifier_require
aycabta Jun 21, 2017
659a359
Squash embdoc
aycabta Jun 22, 2017
8d12a1d
Ripper treats '=>' as one token
aycabta Jun 25, 2017
6569d87
Add RipperStateLex for analysis expr state
aycabta Jul 1, 2017
692a25a
Use RipperStateLex
aycabta Jul 1, 2017
1bf4264
Use :on_embdoc token
aycabta Jul 1, 2017
5eef8de
Remove unnecessary commented out code
aycabta Jul 1, 2017
bfcf3ac
Move squashed token method to RipperStateLex
aycabta Jul 2, 2017
375b2f9
Use RipperStateLex for markup/to_html.rb and token_stream.rb
aycabta Jul 2, 2017
b71ce89
Fix test_rdoc_any_method.rb, test_rdoc_parser_ruby.rb and test_rdoc_t…
aycabta Jul 2, 2017
d6066f1
Add closing ')', ']' and '}' token role to RipperStateLex
aycabta Jul 2, 2017
cb88303
Add RipperStateLex.end? for checking EXPR_END
aycabta Jul 2, 2017
fb6e70c
Fix for variable warnings
aycabta Jul 2, 2017
1afc442
In Ruby 1.9 String#chars gives Enumerator and Enumerator#last doesn't…
aycabta Jul 2, 2017
b5ee102
Delete ruby_lex.rb and all tests are passed at last!
aycabta Jul 4, 2017
9bae9dc
Fix for test_parse_symbol_in_paren_arg
aycabta Jul 6, 2017
9d54fa3
Fix for test_parse_for_in
aycabta Jul 6, 2017
298e698
Fix postfix if/unless
aycabta Jul 9, 2017
c658e09
Detect postfix if/unless
aycabta Jul 9, 2017
4d8fc86
Fix condition for invalid class exception
aycabta Jul 9, 2017
905b5cf
Split off dynamic string token from tstring
aycabta Jul 11, 2017
d7dc989
Fix get_symbol_or_name with supporting global, class and instance var…
aycabta Jul 11, 2017
e4e33fe
Fix get_symbol_or_name with supporting keyword
aycabta Jul 11, 2017
d645082
Remove object of RubyToken::Token in parser/c.rb
aycabta Jul 12, 2017
262c595
Fix for test_parse_class_lower_name_warning
aycabta Jul 13, 2017
07ee8b0
Fix rescue with comment in the same line
aycabta Jul 13, 2017
030d9cd
Add on_variables for on_{i,c,g}var
aycabta Jul 18, 2017
3382e39
Add on_comment to RipperStateLex
aycabta Jul 18, 2017
acc0486
Collect up number with +/-
aycabta Jul 18, 2017
f711f23
Fix string treatment
aycabta Jul 18, 2017
010a7f5
Omit '=' from operater markup
aycabta Jul 18, 2017
1633735
Add EXPR_END to postfix 'if' checking
aycabta Jul 18, 2017
6959f72
Use autoload for RipperStateLex
aycabta Jul 19, 2017
4f62d1c
Fix for test_parse_method_bracket
aycabta Jul 19, 2017
bdd07e5
Support rational and imaginary
aycabta Jul 19, 2017
9c03883
Fix for Ripper token access
aycabta Jul 19, 2017
4a3210a
Skip all tests for RubyLex
aycabta Jul 19, 2017
f2a0b08
Squash dwrods with dstring
aycabta Jul 22, 2017
012ccea
Supports % notation with unnecessary spaces
aycabta Jul 22, 2017
7df38a8
Treat operation after dot as method
aycabta Jul 22, 2017
80f6841
Handle JSON-style hash key as a value in HTML
aycabta Jul 23, 2017
93e787d
Fix for argument default value with reserved word
aycabta Jul 23, 2017
b318cf4
Treat global variable as identifier in HTML
aycabta Jul 23, 2017
7309e83
Fix %w[] treatment
aycabta Jul 23, 2017
3e036cf
Fix for on_nl ending with comment
aycabta Jul 23, 2017
54ee329
Treat class variable as identifier
aycabta Jul 23, 2017
bb4cf29
Split get_squashed_tk
aycabta Jul 24, 2017
e27c741
Support redefinable operators
aycabta Jul 24, 2017
6dc557b
Support instance, class, global variable as symbol
aycabta Jul 24, 2017
47b431b
Support postfix if/unless/do/case/begin in parse_constant_body
aycabta Jul 27, 2017
21bb9ca
Support %i, %I and %W
aycabta Jul 27, 2017
099472c
Support symbol with const
aycabta Jul 27, 2017
c1e3b83
Support % literal end token with on_tstring_end
aycabta Jul 27, 2017
5a94c0a
Fix treating comment at the same line of def
aycabta Jul 27, 2017
b26c08d
Fix ')', ']' and '}' token handling
aycabta Jul 27, 2017
e3525fd
Squash heredoc as one token
aycabta Jul 28, 2017
fe2ee65
Fix postfix while/until handling
aycabta Jul 28, 2017
0ec3a8e
Fix for test_parse_method_parameters_comment_continue
aycabta Jul 28, 2017
7c1fa22
Homologize backtick handling behavior for previous
aycabta Jul 30, 2017
e75ddc4
Treat ivar, cvar and gvar as EXPR_END
aycabta Jul 30, 2017
666bb0d
Add to treat backref with EXPR_END
aycabta Jul 30, 2017
55f2f6f
Support lambda -> operator
aycabta Jul 30, 2017
e5195ee
Fix condition of detecting dynamic string
aycabta Aug 3, 2017
783c59e
Fix for complex heredoc cases
aycabta Aug 3, 2017
10949c8
Remove hard tab from source code
aycabta Aug 5, 2017
6d0c7d0
Fix complex condition for for/while/until from 7d99dc7
aycabta Aug 5, 2017
5b65747
Set EXPR_END to @lex_state when on_heredoc_beg
aycabta Aug 5, 2017
00e88d2
Support symbol literal with quote
aycabta Aug 6, 2017
d2b01e0
Fix typo
aycabta Aug 6, 2017
3c55a39
Skip unnecessary :on_comment
aycabta Aug 6, 2017
34fb3ba
Support symbol with keyword
aycabta Aug 8, 2017
d1cfa70
If newline comes, it's end of method name
aycabta Aug 8, 2017
b7e39ce
Support safe navigation operator
aycabta Aug 11, 2017
0c5ec7d
Add EXPR_LABEL when inside args
aycabta Aug 12, 2017
1955b68
Add condition of "begin" keyword with EXPR_BEG
aycabta Aug 12, 2017
bfda75e
Fix % words syntax
aycabta Aug 12, 2017
4fa207c
Fix around newline after embdoc
aycabta Aug 14, 2017
cc208fe
Fix embdoc token's actual data
aycabta Aug 14, 2017
debdaee
Fix checking correspondence of heredoc tokens
aycabta Aug 14, 2017
b06882a
Check nil
aycabta Aug 14, 2017
1843528
Treat :on_embdoc as comment in highlighting
aycabta Aug 14, 2017
8dbd3fb
Skip create alias for module when array
aycabta Aug 21, 2017
8193399
Fix comment handling after :nodoc:
aycabta Aug 21, 2017
a110189
Fix postfix :nodoc: handling
aycabta Aug 21, 2017
6aec6b0
Read directives for singleton class definition
aycabta Aug 21, 2017
e7a504c
Support string literal ends as symbol
aycabta Aug 22, 2017
050de61
Fix heredoc end checking
aycabta Aug 22, 2017
0422275
Add :on_tlambeg for nesting in parse_constant_body
aycabta Aug 27, 2017
7b47060
Fix condition with paren
aycabta Aug 27, 2017
415a40d
Check directive in constant always
aycabta Aug 27, 2017
6d808d3
Treat float, rational and imaginary as numbers
aycabta Sep 4, 2017
1ffde6c
Set EXPR_BEG to :on_heredoc_end
aycabta Sep 4, 2017
4eb4651
Fix parse_constant_visibility for Ripper
aycabta Sep 4, 2017
d881b6b
Add EXPR_ARG to condition of postfix if
aycabta Sep 4, 2017
e26fdfc
Get constant body without last comment
aycabta Sep 5, 2017
a8ea955
Fix test_read_directive_one_liner
aycabta Sep 5, 2017
a2b511c
Remove unnecessary variable
aycabta Sep 5, 2017
2725175
Fix test_parse_statements_def_percent_string_pound
aycabta Sep 5, 2017
80b7445
Fix test_parse_redefinable_methods
aycabta Sep 5, 2017
f3807d7
Fix handling method parmeter
aycabta Sep 5, 2017
6ff1766
Add test_parse_method_parameters_with_paren_comment_continue
aycabta Sep 5, 2017
1946c08
Support earlier than Ruby 2.4
aycabta Sep 5, 2017
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
2 changes: 1 addition & 1 deletion lib/rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def self.load_yaml

autoload :KNOWN_CLASSES, 'rdoc/known_classes'

autoload :RubyLex, 'rdoc/ruby_lex'
autoload :RipperStateLex, 'rdoc/parser/ripper_state_lex'
autoload :RubyToken, 'rdoc/ruby_token'
autoload :TokenStream, 'rdoc/token_stream'

Expand Down
8 changes: 5 additions & 3 deletions lib/rdoc/markup/to_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,12 @@ def accept_verbatim verbatim

content = if verbatim.ruby? or parseable? text then
begin
tokens = RDoc::RubyLex.tokenize text, @options
tokens = RDoc::RipperStateLex.parse text
klass = ' class="ruby"'

RDoc::TokenStream.to_html tokens
result = RDoc::TokenStream.to_html tokens
result = result + "\n" unless "\n" == result[-1]
result
rescue RDoc::RubyLex::Error
CGI.escapeHTML text
end
Expand All @@ -212,7 +214,7 @@ def accept_verbatim verbatim
end

if @options.pipe then
@res << "\n<pre><code>#{CGI.escapeHTML text}</code></pre>\n"
@res << "\n<pre><code>#{CGI.escapeHTML text}\n</code></pre>\n"
else
@res << "\n<pre#{klass}>#{content}</pre>\n"
end
Expand Down
6 changes: 2 additions & 4 deletions lib/rdoc/parser/c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,7 @@ def find_body class_name, meth_name, meth_obj, file_content, quiet = false

#meth_obj.params = params
meth_obj.start_collecting_tokens
tk = RDoc::RubyToken::Token.new nil, 1, 1
tk.set_text body
tk = { :line_no => 1, :char_no => 1, :text => body }
meth_obj.add_token tk
meth_obj.comment = comment
meth_obj.line = file_content[0, offset].count("\n") + 1
Expand All @@ -684,8 +683,7 @@ def find_body class_name, meth_name, meth_obj, file_content, quiet = false
find_modifiers comment, meth_obj

meth_obj.start_collecting_tokens
tk = RDoc::RubyToken::Token.new nil, 1, 1
tk.set_text body
tk = { :line_no => 1, :char_no => 1, :text => body }
meth_obj.add_token tk
meth_obj.comment = comment
meth_obj.line = file_content[0, offset].count("\n") + 1
Expand Down
Loading