зеркало из https://github.com/github/ruby.git
[ruby/prism] Add comments on flags
https://github.com/ruby/prism/commit/3abd09c803
This commit is contained in:
Родитель
f12617ec98
Коммит
0a460b23e0
|
@ -333,12 +333,14 @@ flags:
|
|||
values:
|
||||
- name: KEYWORD_SPLAT
|
||||
comment: "if arguments contain keyword splat"
|
||||
comment: Flags for arguments nodes.
|
||||
- name: CallNodeFlags
|
||||
values:
|
||||
- name: SAFE_NAVIGATION
|
||||
comment: "&. operator"
|
||||
- name: VARIABLE_CALL
|
||||
comment: "a call that could have been a local variable"
|
||||
comment: Flags for call nodes.
|
||||
- name: IntegerBaseFlags
|
||||
values:
|
||||
- name: BINARY
|
||||
|
@ -349,14 +351,17 @@ flags:
|
|||
comment: "0d or no prefix"
|
||||
- name: HEXADECIMAL
|
||||
comment: "0x prefix"
|
||||
comment: Flags for integer nodes that correspond to the base of the integer.
|
||||
- name: LoopFlags
|
||||
values:
|
||||
- name: BEGIN_MODIFIER
|
||||
comment: "a loop after a begin statement, so the body is executed first before the condition"
|
||||
comment: Flags for while and until loop nodes.
|
||||
- name: RangeFlags
|
||||
values:
|
||||
- name: EXCLUDE_END
|
||||
comment: "... operator"
|
||||
comment: Flags for range and flip-flop nodes.
|
||||
- name: RegularExpressionFlags
|
||||
values:
|
||||
- name: IGNORE_CASE
|
||||
|
@ -375,10 +380,12 @@ flags:
|
|||
comment: "s - forces the Windows-31J encoding"
|
||||
- name: UTF_8
|
||||
comment: "u - forces the UTF-8 encoding"
|
||||
comment: Flags for regular expression and match last line nodes.
|
||||
- name: StringFlags
|
||||
values:
|
||||
- name: FROZEN
|
||||
comment: "frozen by virtue of a `frozen_string_literal` comment"
|
||||
comment: Flags for string nodes.
|
||||
nodes:
|
||||
- name: AliasGlobalVariableNode
|
||||
fields:
|
||||
|
|
|
@ -105,7 +105,9 @@ typedef struct pm_<%= node.human %> {
|
|||
<%- end -%>
|
||||
<%- flags.each do |flag| -%>
|
||||
|
||||
// <%= flag.name %>
|
||||
/**
|
||||
* <%= flag.comment %>
|
||||
*/
|
||||
typedef enum pm_<%= flag.human %> {
|
||||
<%- flag.values.each_with_index do |value, index| -%>
|
||||
PM_<%= flag.human.upcase %>_<%= value.name %> = 1 << <%= index %>,
|
||||
|
|
|
@ -234,6 +234,7 @@ module Prism
|
|||
<%- end -%>
|
||||
<%- flags.each_with_index do |flag, flag_index| -%>
|
||||
|
||||
# <%= flag.comment %>
|
||||
module <%= flag.name %>
|
||||
<%- flag.values.each_with_index do |value, index| -%>
|
||||
# <%= value.comment %>
|
||||
|
|
|
@ -321,12 +321,13 @@ module Prism
|
|||
end
|
||||
end
|
||||
|
||||
attr_reader :name, :human, :values
|
||||
attr_reader :name, :human, :values, :comment
|
||||
|
||||
def initialize(config)
|
||||
@name = config.fetch("name")
|
||||
@human = @name.gsub(/(?<=.)[A-Z]/, "_\\0").downcase
|
||||
@values = config.fetch("values").map { |flag| Flag.new(flag) }
|
||||
@comment = config.fetch("comment")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче