Class: Caphir::EventParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/caphir/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings, cparser = SimpleCParser) ⇒ EventParser

for DBC: just pass the DBC::Parser class



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/caphir/parser.rb', line 83

def initialize(settings, cparser = SimpleCParser)
    super(settings)

    @in_stream = CTokenizer::Splitter.new([], settings.source, 
        settings.src_file)

    @preproc = Preprocessor::Parser.new(settings.search_path,
        settings.search_path_limited, @in_stream )

    @preproc.configure(settings.macros, settings.includes, 
        settings.compiler, settings.version)

    if settings.preprocess_only
        @parser = @preproc
    else
        @parser = cparser.new(@preproc)
    end
        
    # clear vars and run the GC - really speeds things up
    settings.clean
    GC.start
end

Instance Attribute Details

#in_streamObject (readonly)

Returns the value of attribute in_stream.



78
79
80
# File 'lib/caphir/parser.rb', line 78

def in_stream
  @in_stream
end

#preprocObject (readonly)

Returns the value of attribute preproc.



80
81
82
# File 'lib/caphir/parser.rb', line 80

def preproc
  @preproc
end

Instance Method Details

#eachObject



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/caphir/parser.rb', line 110

def each
    if @settings.preprocess_only
        @parser.each do |t|
            yield t.at(1)
        end
    else
        @parser.each_statement do |function|
            yield function
        end
    end
end

#handlerObject



106
107
108
# File 'lib/caphir/parser.rb', line 106

def handler
    @parser
end