Skip to content

Commit

Permalink
More documentation for ast.h
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Nov 1, 2023
1 parent 9c648ce commit 84e22c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
12 changes: 8 additions & 4 deletions templates/include/prism/ast.h.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -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 -%>
Expand Down
8 changes: 0 additions & 8 deletions templates/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,6 @@ def initialize(config)
@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.
Expand Down

0 comments on commit 84e22c5

Please sign in to comment.