Class: TracePreprocessor::DSL
- Inherits:
-
Object
- Object
- TracePreprocessor::DSL
- Defined in:
- lib/trace_preprocessor/dsl.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#lexemes ⇒ Object
Returns the value of attribute lexemes.
-
#output_token_code ⇒ Object
Returns the value of attribute output_token_code.
-
#workspace_path ⇒ Object
Returns the value of attribute workspace_path.
Instance Method Summary collapse
- #common_code(code) ⇒ Object
- #define_lexeme(name, options) ⇒ Object
- #init(&block) ⇒ Object
-
#initialize ⇒ DSL
constructor
A new instance of DSL.
- #output_token(code) ⇒ Object
- #use_default_lexemes ⇒ Object
- #workspace(path) ⇒ Object
Constructor Details
#initialize ⇒ DSL
Returns a new instance of DSL.
11 12 13 14 15 16 |
# File 'lib/trace_preprocessor/dsl.rb', line 11 def initialize @lexemes = {} @code = "" workspace "~/.trace_preprocessor" end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
57 58 59 |
# File 'lib/trace_preprocessor/dsl.rb', line 57 def code @code end |
#lexemes ⇒ Object
Returns the value of attribute lexemes.
56 57 58 |
# File 'lib/trace_preprocessor/dsl.rb', line 56 def lexemes @lexemes end |
#output_token_code ⇒ Object
Returns the value of attribute output_token_code.
57 58 59 |
# File 'lib/trace_preprocessor/dsl.rb', line 57 def output_token_code @output_token_code end |
#workspace_path ⇒ Object
Returns the value of attribute workspace_path.
58 59 60 |
# File 'lib/trace_preprocessor/dsl.rb', line 58 def workspace_path @workspace_path end |
Instance Method Details
#common_code(code) ⇒ Object
40 41 42 |
# File 'lib/trace_preprocessor/dsl.rb', line 40 def common_code code @code += code end |
#define_lexeme(name, options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/trace_preprocessor/dsl.rb', line 22 def define_lexeme name, lexeme = @lexemes[name] || Lexeme.new(name, ) converter = [: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
18 19 20 |
# File 'lib/trace_preprocessor/dsl.rb', line 18 def init &block instance_eval &block end |
#output_token(code) ⇒ Object
44 45 46 |
# File 'lib/trace_preprocessor/dsl.rb', line 44 def output_token code @output_token_code = code end |
#use_default_lexemes ⇒ Object
35 36 37 38 |
# 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) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/trace_preprocessor/dsl.rb', line 48 def workspace path @workspace_path = File. path if not File.exist? @workspace_path FileUtils.mkdir_p @workspace_path end end |