summaryrefslogtreecommitdiff
path: root/prism
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-10-31 12:59:39 -0400
committerKevin Newton <kddnewton@gmail.com>2023-11-01 13:10:29 -0400
commit51079a89af4da2d410a069e0598e72ed454363fe (patch)
treecbf4d15feeda4ab5d2824be5cd20a4d0d550d115 /prism
parent17923cc876513707b4bedcd4437b229feb455099 (diff)
[ruby/prism] More documentation for ast.h
https://github.com/ruby/prism/commit/84e22c5581
Diffstat (limited to 'prism')
-rw-r--r--prism/templates/include/prism/ast.h.erb12
-rwxr-xr-xprism/templates/template.rb8
2 files changed, 8 insertions, 12 deletions
diff --git a/prism/templates/include/prism/ast.h.erb b/prism/templates/include/prism/ast.h.erb
index 48ad64d699..fadf461c40 100644
--- a/prism/templates/include/prism/ast.h.erb
+++ b/prism/templates/include/prism/ast.h.erb
@@ -14,9 +14,10 @@
*/
typedef enum pm_token_type {
<%- tokens.each do |token| -%>
- <%= token.declaration %>
-<%- end -%>
+ /** <%= token.comment %> */
+ PM_TOKEN_<%= token.name %><% " = #{token.value}" if token.value %>,
+<%- end -%>
/** The maximum token value. */
PM_TOKEN_MAXIMUM,
} pm_token_type_t;
@@ -69,9 +70,10 @@ typedef struct pm_node_list {
*/
enum pm_node_type {
<%- nodes.each_with_index do |node, index| -%>
+ /** <%= node.name %> */
<%= node.type %> = <%= index + 1 %>,
-<%- end -%>
+<%- end -%>
/** A special kind of node used for compilation. */
PM_SCOPE_NODE
};
@@ -153,7 +155,9 @@ typedef struct pm_<%= node.human %> {
*/
typedef enum pm_<%= flag.human %> {
<%- flag.values.each_with_index do |value, index| -%>
- PM_<%= flag.human.upcase %>_<%= value.name %> = 1 << <%= index %>,
+<%= "\n" if index > 0 -%>
+ /** <%= value.comment %> */
+ PM_<%= flag.human.upcase %>_<%= value.name %> = <%= 1 << index %>,
<%- end -%>
} pm_<%= flag.human %>_t;
<%- end -%>
diff --git a/prism/templates/template.rb b/prism/templates/template.rb
index 0d2f324456..6560af3a76 100755
--- a/prism/templates/template.rb
+++ b/prism/templates/template.rb
@@ -298,14 +298,6 @@ module Prism
@value = config["value"]
@comment = config.fetch("comment")
end
-
- def declaration
- output = []
- output << "PM_TOKEN_#{name}"
- output << " = #{value}" if value
- output << ", // #{comment}"
- output.join
- end
end
# Represents a set of flags that should be internally represented with an enum.