Class: XDry::PGlobal

Inherits:
Parser 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



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/xdry/parsing/parsers.rb', line 21

def parse_line! line, eol_comments, indent
  case line
    when /^@interface\s+(\w+)\s*;/
      name = $1
    when /^@protocol\s+(\w+)\s*;/
      name = $1

    when /^@interface\s+(\w+)/  #\s*(?:[:(][\w:(),\s]*)?
      name, supers, postfix = $1, $2, $'
      yield NInterfaceStart.new(name)
      yield NOpeningBrace.new if postfix =~ /\{$/

    when /^@implementation\s+(\w+)/
      name = $1
      yield NImplementationStart.new(name)

    when /^@protocol\s+(\w+)\s*;/
      puts "PREDEF protocol #{$1}"

    when /^#define\s+(\w+)/
      word = $1
      yield NDefine.new(word)
  end
end