[#81492] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — normalperson@...
Issue #13618 has been reported by normalperson (Eric Wong).
12 messages
2017/06/01
[#88695] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wong <normalperson@...>
2018/08/27
> https://bugs.ruby-lang.org/issues/13618
[#81569] [Ruby trunk Feature#12589] VM performance improvement proposal — vmakarov@...
Issue #12589 has been updated by vmakarov (Vladimir Makarov).
3 messages
2017/06/04
[#81581] [Ruby trunk Bug#13632] Not processable interrupt queue for a thread after it's notified that FD is closed in some other thread. — sir.nickolas@...
Issue #13632 has been reported by nvashchenko (Nikolay Vashchenko).
4 messages
2017/06/05
[#81590] Re: [ruby-cvs:66197] ko1:r59023 (trunk): revert r59020 because it may fail some tests sometimes on some environment (http://ci.rvm.jp/). This revert is to check the reason of failures. — Eric Wong <normalperson@...>
ko1@ruby-lang.org wrote:
5 messages
2017/06/06
[#81591] Re: [ruby-cvs:66197] ko1:r59023 (trunk): revert r59020 because it may fail some tests sometimes on some environment (http://ci.rvm.jp/). This revert is to check the reason of failures.
— Eric Wong <normalperson@...>
2017/06/06
Eric Wong <normalperson@yhbt.net> wrote:
[#81596] Re: [ruby-cvs:66203] Re: Re: ko1:r59023 (trunk): revert r59020 because it may fail some tests sometimes on some environment (http://ci.rvm.jp/). This revert is to check the reason of failures.
— Eric Wong <normalperson@...>
2017/06/06
Eric Wong <normalperson@yhbt.net> wrote:
[#81825] [Ruby trunk Feature#13697] [PATCH]: futex based thread primitives — normalperson@...
Issue #13697 has been reported by normalperson (Eric Wong).
3 messages
2017/06/29
[ruby-core:81789] [Ruby trunk Feature#13686] Add states of scanner to tokens from Ripper.lex and Ripper::Filter#on_*
From:
aycabta@...
Date:
2017-06-27 12:58:41 UTC
List:
ruby-core #81789
Issue #13686 has been reported by aycabta (Code Ahss).
----------------------------------------
Feature #13686: Add states of scanner to tokens from Ripper.lex and Ripper::Filter#on_*
https://bugs.ruby-lang.org/issues/13686
* Author: aycabta (Code Ahss)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
I'm writing syntax analysis software by pure Ruby, for processing Ruby's source code and meta information what are classes, methods, constants, comments and others. I'm using Ripper for it. But the results of Ripper.sexp doesn't have comments, and the results of Ripper.lex doesn't have token states of scanner.
I think that the behavior of Ripper.sexp is correct because the position of comments in Ruby's syntax tree is blurred and unhandled.
On the other hand, Ripper.lex has comments token but Ripper.lex clearly drops the states of scanner for each tokens under "[finite-state scanner](https://ruby-hacking-guide.github.io/contextual.html)". The states are very important for many Ripper use cases. EXPR_END is especially required to know the end of statement. If the states aren't provided, we must re-implement finite-state analyzer for tokens from Ripper. For example, borderlines of conditions, args, constants and others. It's just not realistic.
In Ripper.lex's behavior as of now:
~~~ ruby
require 'ripper'
require 'pp'
pp Ripper.lex(<<EOM)
def str?(v)
String === v # check
end
EOM
#=> [[[1, 0], :on_kw, "def" ],
# [[1, 3], :on_sp, " " ],
# [[1, 4], :on_ident, "str?" ],
# [[1, 8], :on_lparen, "(" ],
# [[1, 9], :on_ident, "v" ],
# [[1, 10], :on_rparen, ")" ],
# [[1, 11], :on_ignored_nl, "\n" ],
# [[2, 0], :on_sp, " " ],
# [[2, 2], :on_const, "String" ],
# [[2, 8], :on_sp, " " ],
# [[2, 9], :on_op, "===" ],
# [[2, 12], :on_sp, " " ],
# [[2, 13], :on_ident, "v" ],
# [[2, 14], :on_sp, " " ],
# [[2, 15], :on_comment, "# check\n"],
# [[3, 0], :on_kw, "end" ],
# [[3, 3], :on_nl, "\n" ]]
~~~
In Ripper.lex's behavior with attached patch:
~~~ ruby
require 'ripper'
require 'pp'
pp Ripper.lex(<<EOM)
def str?(v)
String === v # check
end
EOM
#=> [[[1, 0], :on_kw, "def", Ripper::EXPR_FNAME ],
# [[1, 3], :on_sp, " ", Ripper::EXPR_FNAME ],
# [[1, 4], :on_ident, "str?", Ripper::EXPR_ENDFN ],
# [[1, 8], :on_lparen, "(", Ripper::EXPR_BEG | Ripper::EXPR_LABEL],
# [[1, 9], :on_ident, "v", Ripper::EXPR_ARG ],
# [[1, 10], :on_rparen, ")", Ripper::EXPR_ENDFN ],
# [[1, 11], :on_ignored_nl, "\n", Ripper::EXPR_BEG ],
# [[2, 0], :on_sp, " ", Ripper::EXPR_BEG ],
# [[2, 2], :on_const, "String", Ripper::EXPR_CMDARG ],
# [[2, 8], :on_sp, " ", Ripper::EXPR_CMDARG ],
# [[2, 9], :on_op, "===", Ripper::EXPR_BEG ],
# [[2, 12], :on_sp, " ", Ripper::EXPR_BEG ],
# [[2, 13], :on_ident, "v", Ripper::EXPR_END | Ripper::EXPR_LABEL],
# [[2, 14], :on_sp, " ", Ripper::EXPR_END | Ripper::EXPR_LABEL],
# [[2, 15], :on_comment, "# check\n", Ripper::EXPR_END | Ripper::EXPR_LABEL],
# [[3, 0], :on_kw, "end", Ripper::EXPR_END ],
# [[3, 3], :on_nl, "\n", Ripper::EXPR_BEG ]]
~~~
In Ripper::Filter#on_* with attached patch, you can use #state metohd:
~~~ ruby
require 'ripper'
require 'pp'
class MyFilter < Ripper::Filter
def on_default(event, tok, data)
data.push([event, tok, state])
end
end
# Ripper::Filter#parse works like Enumerable#inject
pp MyFilter.new(<<EOM).parse([])
def str?(v)
String === v # check
end
EOM
#=> [[:on_kw, "def", Ripper::EXPR_FNAME ],
# [:on_sp, " ", Ripper::EXPR_FNAME ],
# [:on_ident, "str?", Ripper::EXPR_ENDFN ],
# [:on_lparen, "(", Ripper::EXPR_BEG | Ripper::EXPR_LABEL],
# [:on_ident, "v", Ripper::EXPR_ARG ],
# [:on_rparen, ")", Ripper::EXPR_ENDFN ],
# [:on_ignored_nl, "\n", Ripper::EXPR_BEG ],
# [:on_sp, " ", Ripper::EXPR_BEG ],
# [:on_const, "String", Ripper::EXPR_CMDARG ],
# [:on_sp, " ", Ripper::EXPR_CMDARG ],
# [:on_op, "===", Ripper::EXPR_BEG ],
# [:on_sp, " ", Ripper::EXPR_BEG ],
# [:on_ident, "v", Ripper::EXPR_END | Ripper::EXPR_LABEL],
# [:on_sp, " ", Ripper::EXPR_END | Ripper::EXPR_LABEL],
# [:on_comment, "# check\n", Ripper::EXPR_END | Ripper::EXPR_LABEL],
# [:on_kw, "end", Ripper::EXPR_END ],
# [:on_nl, "\n", Ripper::EXPR_BEG ]]
~~~
---Files--------------------------------
add-state-to-ripper-for-trunk.patch (16.1 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>