Class: XDry::PInterfaceHeader

Inherits:
Parser
  • Object
show all
Defined in:
lib/xdry/parsing/parsers.rb

Instance Attribute Summary

Attributes inherited from Parser

#scope

Instance Method Summary collapse

Methods inherited from Parser

#initialize, #to_s

Constructor Details

This class inherits a constructor from XDry::Parser

Instance Method Details

#parse_line!(line, eol_comments, indent) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/xdry/parsing/parsers.rb', line 101

def parse_line! line, eol_comments, indent
  case line
  when /^\{$/
    yield NOpeningBrace.new
  when /@end/
    yield NEnd.new
  when /^@property(\s*\([\w\s,]*\))?\s+(IBOutlet\s+)?(\w+)\s*\*\s*(\w+)\s*;$/
    property_flags, iboutlet, type_name, property_name = $1, $2, $3, $4
    yield NPropertyDef.new(property_name, PointerVarType.new(type_name))
  when /^@property(\s*\([\w\s,]*\))?\s+(IBOutlet\s+)?(\w+)\s+(\w+)\s*;$/
    property_flags, iboutlet, type_name, property_name = $1, $2, $3, $4
    yield NPropertyDef.new(property_name, SimpleVarType.new(type_name))
  when /^-\s*\(([^)]+)\)\s*(\w+[\w\s():*]*);$/
    ret_type_decl, selector_decl = $1, $2
    selector_def = SelectorDef.parse(selector_decl)
    ret_type = VarType.parse(ret_type_decl)
    yield NMethodHeader.new(selector_def, ret_type)

  when /^-\s*\(([^)]+)\)\s*(\w+[\w\s():*]*)\{$/
    ret_type_decl, selector_decl = $1, $2
    selector_def = SelectorDef.parse(selector_decl)
    ret_type = VarType.parse(ret_type_decl)
    yield NMethodStart.new(selector_def, ret_type)

  when /^@synthesize/
    yield NSynthesize.parse(line)
  end
end