Class: XDry::PInterfaceFields
- Defined in:
- lib/xdry/parsing/parsers.rb
Instance Attribute Summary
Attributes inherited from Parser
Instance Method Summary collapse
-
#initialize(scope) ⇒ PInterfaceFields
constructor
A new instance of PInterfaceFields.
- #parse_line!(line, eol_comments, indent) ⇒ Object
Methods inherited from Parser
Constructor Details
#initialize(scope) ⇒ PInterfaceFields
Returns a new instance of PInterfaceFields.
50 51 52 53 |
# File 'lib/xdry/parsing/parsers.rb', line 50 def initialize scope super @tags = Set.new end |
Instance Method Details
#parse_line!(line, eol_comments, indent) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/xdry/parsing/parsers.rb', line 55 def parse_line! line, eol_comments, indent @this_line_tags = Set.new [[/!p\b/, 'wants-property'], [/!c\b/, 'wants-constructor']].each do |regexp, tag| if line =~ regexp marker = $& is_full_line = line.gsub(marker, '').strip.empty? klass = is_full_line ? NFullLineMarker : NPartLineMarker yield klass.new(marker) (is_full_line ? @tags : @this_line_tags) << tag return if is_full_line end end case line when /\}/ yield NInterfaceFieldsEnd.new when %r~^//\s*persistent$~ @tags << 'persistent' when '' @tags.clear when /^(\w+)\s+(\w+)\s*;/ type_name, field_name = $1, $2 yield process_type_hint(NFieldDef.new(field_name, SimpleVarType.new(type_name)), eol_comments) when /^(\w+)\s*\*\s*(\w+)\s*;/ type_name, field_name = $1, $2 yield process_type_hint(NFieldDef.new(field_name, PointerVarType.new(type_name)), eol_comments) when /^id<(\w+)>\s+(\w+)\s*;/ type_name, field_name = $1, $2 yield process_type_hint(NFieldDef.new(field_name, IdVarType.new()), eol_comments) end end |