mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 17:43:59 +02:00
[ruby/yarp] Print information about type, flags on AST templated
code
(https://github.com/ruby/yarp/pull/1380)
This commit adds the node type and the node flags as comments to
the AST templated code.
f603f2037c
This commit is contained in:
parent
cfe1edddbf
commit
c0bf4029e3
1 changed files with 10 additions and 2 deletions
|
@ -70,8 +70,7 @@ typedef struct yp_node {
|
||||||
// existed in the original grammar and ripper, but it's not a 1:1 mapping.
|
// existed in the original grammar and ripper, but it's not a 1:1 mapping.
|
||||||
yp_node_type_t type;
|
yp_node_type_t type;
|
||||||
|
|
||||||
// This represents any flags on the node. Currently, this is only a newline
|
// This represents any flags on the node
|
||||||
// flag
|
|
||||||
yp_node_flags_t flags;
|
yp_node_flags_t flags;
|
||||||
|
|
||||||
// This is the location of the node in the source. It's a range of bytes
|
// This is the location of the node in the source. It's a range of bytes
|
||||||
|
@ -81,6 +80,15 @@ typedef struct yp_node {
|
||||||
<%- nodes.each do |node| -%>
|
<%- nodes.each do |node| -%>
|
||||||
|
|
||||||
// <%= node.name %>
|
// <%= node.name %>
|
||||||
|
//
|
||||||
|
// Type: <%= node.type %>
|
||||||
|
<%- if (node_flags = node.fields.find { |field| field.is_a? YARP::FlagsField }) -%>
|
||||||
|
// Flags:
|
||||||
|
<%- found = flags.find { |flag| flag.name == node_flags.kind }.tap { |found| raise "Expected to find #{field.kind}" unless found } -%>
|
||||||
|
<%- found.values.each do |value| -%>
|
||||||
|
// YP_<%= found.human.upcase %>_<%= value.name %>
|
||||||
|
<%- end -%>
|
||||||
|
<%- end -%>
|
||||||
typedef struct yp_<%= node.human %> {
|
typedef struct yp_<%= node.human %> {
|
||||||
yp_node_t base;
|
yp_node_t base;
|
||||||
<%- node.fields.grep_v(YARP::FlagsField).each do |field| -%>
|
<%- node.fields.grep_v(YARP::FlagsField).each do |field| -%>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue