Class: TracePreprocessor::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/trace_preprocessor/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDSL

Returns a new instance of DSL.



11
12
13
14
# File 'lib/trace_preprocessor/dsl.rb', line 11

def initialize
  @lexemes = {}
  @code = ""
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



53
54
55
# File 'lib/trace_preprocessor/dsl.rb', line 53

def code
  @code
end

#lexemesObject

Returns the value of attribute lexemes.



52
53
54
# File 'lib/trace_preprocessor/dsl.rb', line 52

def lexemes
  @lexemes
end

#output_token_codeObject

Returns the value of attribute output_token_code.



53
54
55
# File 'lib/trace_preprocessor/dsl.rb', line 53

def output_token_code
  @output_token_code
end

#workspace_pathObject

Returns the value of attribute workspace_path.



54
55
56
# File 'lib/trace_preprocessor/dsl.rb', line 54

def workspace_path
  @workspace_path
end

Instance Method Details

#common_code(code) ⇒ Object



36
37
38
# File 'lib/trace_preprocessor/dsl.rb', line 36

def common_code code
  @code += code
end

#define_lexeme(name, options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/trace_preprocessor/dsl.rb', line 20

def define_lexeme name, options
  lexeme = @lexemes[name] || Lexeme.new(name)

  lexeme.regexp      = options[:regexp]
  lexeme.value_kind  = options[:value_kind] || :hash
  
  converter = options[:converter]
  converter_language = :c
  converter_language = :ruby if converter.instance_of? Proc
  lexeme.converter[converter_language] = converter
  
  @lexemes[lexeme.name] = lexeme
  
  lexeme
end

#init(&block) ⇒ Object



16
17
18
# File 'lib/trace_preprocessor/dsl.rb', line 16

def init &block
  instance_eval &block
end

#output_token(code) ⇒ Object



40
41
42
# File 'lib/trace_preprocessor/dsl.rb', line 40

def output_token code
  @output_token_code = code
end

#workspace(path) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/trace_preprocessor/dsl.rb', line 44

def workspace path
  @workspace_path = File.expand_path path
  
  if not File.exist? @workspace_path
    FileUtils.mkdir_p @workspace_path
  end
end