trace_preprocessor 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 547c48b671c56cb45f18b5c4bf9aae7c493a1da3
4
- data.tar.gz: 62b8de7da7d11076967baf68cd4059ab9c0b9668
3
+ metadata.gz: 3a93bdd1555ca28646b5cfb7c4531f3cae37b5ab
4
+ data.tar.gz: 5c51c0308fc111bc891cb004e4e4a72828c14cc2
5
5
  SHA512:
6
- metadata.gz: 9f82fbcd4855ec30ec07340bbbcffeed621eb199c7fa0e171d5c3028e41b74ac19775a091e32c8830eb893189eafba492181cc051da4851ef83a1ff21b0fe098
7
- data.tar.gz: ace8baf7e21c3c13c5e6f60b68349e97b5bfaf04ce1642111ff82877256d749f609e76b783e155e75c617c31899df90a973b91f256e3bdd8af2dad479be84623
6
+ metadata.gz: e34567424fcfd61a3dd6d59bac6498915200ffa795751984a36c77e239d504480ec972ed30306455da4f587ba4e0da4fa884feb47811b71e7ba8b59142998ccc
7
+ data.tar.gz: 905439f5e0a497266b2a95a476ebd06397430f16712ce37398d937b96c3376be9d09d6752b79335060ba68e50dd9caf10384016c02b5cff3015e57686320ad4d
@@ -57,7 +57,8 @@ LEX
57
57
  <<-CODE
58
58
  void output_token(const char* name, const char* source, long value, int value_kind) {
59
59
  #{dsl.output_token_code}
60
- }
60
+ }
61
+
61
62
  CODE
62
63
  end
63
64
 
@@ -70,6 +71,7 @@ long converter_#{name}() {
70
71
  void parse_#{name}() {
71
72
  output_token("#{name}", yytext, converter_#{name}(), #{lexeme.value_kind == :exact ? 1 : 0});
72
73
  }
74
+
73
75
  CODE
74
76
  end
75
77
 
@@ -0,0 +1,35 @@
1
+ # Defalt lexemes
2
+
3
+ common_code <<-CODE
4
+ #include <time.h>
5
+ CODE
6
+
7
+ define_lexeme :ip,
8
+ :regexp => /(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/,
9
+ :value_kind => :exact,
10
+ :converter => <<-CODE
11
+ unsigned ips[4];
12
+ sscanf(yytext, "%d.%d.%d.%d", ips, ips + 1, ips + 2, ips + 3);
13
+ return (((ips[0] << 24) & 0xFF000000) | ((ips[1] << 16) & 0xFF0000) | ((ips[2] << 8) & 0xFF00) | (ips[3] & 0xFF));
14
+ CODE
15
+
16
+ define_lexeme :uuid,
17
+ :regexp => /[A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12}/,
18
+ :value_kind => :hash,
19
+ :converter => <<-CODE
20
+ long x[5];
21
+ sscanf(yytext, "%08lx-%04lx-%04lx-%04lx-%12lx", &x[0], &x[1], &x[2], &x[3], &x[4]);
22
+ return ((((x[0] << 16) | x[1]) << 16) | x[2]) ^ ((x[3] << 48) | x[4]);
23
+ CODE
24
+
25
+ define_lexeme :date,
26
+ :regexp => /[0-9]{2}\ (?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\ [0-9]{4}\ [0-9]{2}:[0-9]{2}:[0-9]{2}/,
27
+ :value_kind => :exact,
28
+ :converter => <<-CODE
29
+ struct tm tm;
30
+ time_t t;
31
+
32
+ if (strptime(yytext, "%d %b %Y %H:%M:%S", &tm) == NULL) return -1;
33
+
34
+ return mktime(&tm);
35
+ CODE
@@ -11,6 +11,8 @@ module TracePreprocessor
11
11
  def initialize
12
12
  @lexemes = {}
13
13
  @code = ""
14
+
15
+ workspace "~/.trace_preprocessor"
14
16
  end
15
17
 
16
18
  def init &block
@@ -30,6 +32,11 @@ module TracePreprocessor
30
32
  lexeme
31
33
  end
32
34
 
35
+ def use_default_lexemes
36
+ default_lexemes_file_name = File.join(File.dirname(__FILE__), "default_lexemes.rb")
37
+ eval open(default_lexemes_file_name, "r") { |fd| fd.read }
38
+ end
39
+
33
40
  def common_code code
34
41
  @code += code
35
42
  end
@@ -1,3 +1,3 @@
1
1
  module TracePreprocessor
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trace_preprocessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-04 00:00:00.000000000 Z
11
+ date: 2013-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,7 @@ files:
52
52
  - Rakefile
53
53
  - lib/trace_preprocessor.rb
54
54
  - lib/trace_preprocessor/code_generator.rb
55
+ - lib/trace_preprocessor/default_lexemes.rb
55
56
  - lib/trace_preprocessor/dsl.rb
56
57
  - lib/trace_preprocessor/lexeme.rb
57
58
  - lib/trace_preprocessor/preprocessor.rb