1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
Commit graph

15 commits

Author SHA1 Message Date
eileencodes
3391c51eff Add node_id_for_backtrace_location function
We want to use error highlight with eval'd code, specifically ERB
templates. We're able to recover the generated code for eval'd templates
and can get a parse tree for the ERB generated code, but we don't have a
way to get the node id from the backtrace location. So we can't pass the
right node into error highlight.

This patch gives us an API to get the node id from the backtrace
location so we can find the node in the AST.

Error Highlight PR: https://github.com/ruby/error_highlight/pull/26

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2022-10-31 13:39:56 +09:00
yui-knk
fbbdbdd891 Add error_tolerant option to RubyVM::AST
If this option is enabled, SyntaxError is not raised and Node is
returned even if passed script is broken.

[Feature #19013]
2022-10-08 17:59:11 +09:00
Yusuke Endoh
cad83fa3c4 ast.c: Rename "save_script_lines" to "keep_script_lines"
... as per ko1's preference. He is preparing to extend this feature to
ISeq for his new debugger. He prefers "keep" to "save" for this wording.
This API is internal and not included in any released version, so I
change it in advance.
2021-08-20 16:18:36 +09:00
Yusuke Endoh
ed8e265d4b Experimentally expose RubyVM::AST::Node#node_id
Now ISeq#to_a includes the node_id list for each bytecode instruction.
I want a way to retrieve the AST::Node instance corresponding to an
instruction for a research purpose including TypeProf-based LSP server.
2021-06-21 21:15:25 +09:00
Yusuke Endoh
acae5f363d ast.rb: RubyVM::AST.parse and .of accepts save_script_lines: true
This option makes the parser keep the original source as an array of
the original code lines. This feature exploits the mechanism of
`SCRIPT_LINES__` but records only the specified code that is passed to
RubyVM::AST.of or .parse, instead of recording all parsed program texts.
2021-06-18 02:34:27 +09:00
Nobuyoshi Nakada
cf92b3cc97
ast.rb: reduce nesting 2021-06-06 23:02:06 +09:00
Masataka Pocke Kuwabara
b71047cca3 Fix RubyVM::AbstractSyntaxTree document
RubyVM::AbstractSyntaxTree is a module actually, but the document says "class".
2020-06-24 15:17:53 +09:00
Nobuyoshi Nakada
63aadc237f [Feature #16254] Use Primitive.func style 2020-06-19 18:46:55 +09:00
Nobuyoshi Nakada
d863f4bccd [Feature #16254] Use __builtin.func style 2020-06-19 18:46:55 +09:00
Kazuhiro NISHIYAMA
b884eb59eb
Fix variable name and add more example [ci skip] 2020-01-03 01:27:25 +09:00
Kazuhiro NISHIYAMA
bba4916122
Fix example of node.type [ci skip]
```
% docker run -it --rm rubylang/all-ruby env ALL_RUBY_SINCE=ruby-2.6 ./all-ruby -e 'root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
p [root, root.type]
call = root.children[2]
p [call, call.type]
'
ruby-2.6.0          [#<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-1:9>, :SCOPE]
                    [#<RubyVM::AbstractSyntaxTree::Node:LASGN@1:0-1:9>, :LASGN]
...
ruby-2.7.0          [#<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-1:9>, :SCOPE]
                    [#<RubyVM::AbstractSyntaxTree::Node:LASGN@1:0-1:9>, :LASGN]
```
2020-01-03 00:02:28 +09:00
Benoit Daloze
9e02568363 Improve highlighting in RubyVM::AbstractSyntaxTree docs when using ri 2019-12-14 12:26:30 +01:00
Benoit Daloze
b4b22b9278 Clarify in the documentation that RubyVM::AbstractSyntaxTree is not stable API
* See [Feature #14844].
2019-12-14 12:21:40 +01:00
Koichi Sasada
08ff9edb53 fix line break code (fix to LF) 2019-11-08 09:30:11 +09:00
Koichi Sasada
a47d058ebf use builtin for RubyVM::AbstractSyntaxTree.
Define RubyVM::AbstractSyntaxTree in ast.rb
with __builtin functions.
2019-11-08 09:09:29 +09:00