class TracePreprocessor::DSL

Attributes

code[RW]
lexemes[RW]
output_token_code[RW]
workspace_path[RW]

Public Class Methods

new() click to toggle source
# File lib/trace_preprocessor/dsl.rb, line 11
def initialize
  @lexemes = {}
  @code = ""
  
  workspace "~/.trace_preprocessor"
end

Public Instance Methods

common_code(code) click to toggle source
# File lib/trace_preprocessor/dsl.rb, line 40
def common_code code
  @code += code
end
define_lexeme(name, options) click to toggle source
# File lib/trace_preprocessor/dsl.rb, line 22
def define_lexeme name, options
  lexeme = @lexemes[name] || Lexeme.new(name, options)
  
  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) click to toggle source
# File lib/trace_preprocessor/dsl.rb, line 18
def init &block
  instance_eval &block
end
output_token(code) click to toggle source
# File lib/trace_preprocessor/dsl.rb, line 44
def output_token code
  @output_token_code = code
end
use_default_lexemes() click to toggle source
# File lib/trace_preprocessor/dsl.rb, line 35
def use_default_lexemes
  default_lexemes_file_name = File.join(File.dirname(__FILE__), "default_lexemes.rb")
  eval open(default_lexemes_file_name, "r") { |fd| fd.read }
end
workspace(path) click to toggle source
# File lib/trace_preprocessor/dsl.rb, line 48
def workspace path
  @workspace_path = File.expand_path path
  
  if not File.exist? @workspace_path
    FileUtils.mkdir_p @workspace_path
  end
end