ClsRuby 1.0.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/examples/tag_any.rb +1 -1
- data/lib/cls-ruby/basic_scalars.rb +17 -5
- data/lib/cls-ruby/lexers/char_classifier.rb +14 -14
- data/lib/cls-ruby/lexers/first_stage.rb +5 -6
- data/lib/cls-ruby/tag.rb +1 -1
- data/tests/tc_lexer.rb +3 -3
- data/tests/ts_cls_ruby.rb +1 -1
- metadata +63 -52
- data/examples/hex_stream.txt +0 -1
- data/examples/space_concat.txt +0 -3
data/examples/tag_any.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
require 'set'
|
6
6
|
require 'time'
|
7
7
|
|
8
|
-
require 'cls-ruby/tag_scalar'
|
8
|
+
#require 'cls-ruby/tag_scalar'
|
9
9
|
require 'cls-ruby/ex'
|
10
10
|
|
11
11
|
module ClsRuby
|
@@ -66,10 +66,22 @@ class FormatHelper
|
|
66
66
|
end
|
67
67
|
|
68
68
|
private
|
69
|
+
# �������� ���� ��� ��������� ��������.
|
70
|
+
CURLOPEN = "{".getbyte(0)
|
71
|
+
CURLCLOSE = "}".getbyte(0)
|
72
|
+
VERTBAR = "|".getbyte(0)
|
73
|
+
BACKSLASH = "\\".getbyte(0)
|
74
|
+
QUOTE = "\"".getbyte(0)
|
75
|
+
CR = "\r".getbyte(0)
|
76
|
+
LF = "\n".getbyte(0)
|
77
|
+
TAB = "\t".getbyte(0)
|
78
|
+
|
69
79
|
# ��������������� ������, ������� �������� �� �������������
|
70
80
|
# ���������� escaping-� ����������� ��������.
|
71
81
|
class SpecCharDectector
|
72
|
-
@@spec_chars = Set.new(
|
82
|
+
@@spec_chars = Set.new(
|
83
|
+
[ CURLOPEN, CURLCLOSE, VERTBAR, BACKSLASH,
|
84
|
+
QUOTE, CR, LF, TAB ] )
|
73
85
|
|
74
86
|
def ===( byte )
|
75
87
|
@@spec_chars.member?( byte )
|
@@ -88,11 +100,11 @@ private
|
|
88
100
|
case byte
|
89
101
|
when SPEC_CHARS
|
90
102
|
r << '\\'
|
91
|
-
if
|
103
|
+
if LF == byte
|
92
104
|
r << 'n'
|
93
|
-
elsif
|
105
|
+
elsif TAB == byte
|
94
106
|
r << 't'
|
95
|
-
elsif
|
107
|
+
elsif CR == byte
|
96
108
|
r << 'r'
|
97
109
|
else
|
98
110
|
r << byte
|
@@ -109,13 +109,13 @@ private
|
|
109
109
|
start_line_no = line_no
|
110
110
|
result = ''
|
111
111
|
while nil != ( n = @lexer.next )
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
112
|
+
if '"' == n
|
113
|
+
return [ result, :tok_string ]
|
114
|
+
elsif '\\' == n
|
115
|
+
char, tok = parse_escape_seq
|
116
|
+
result << char
|
117
|
+
else
|
118
|
+
result << n
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -129,10 +129,10 @@ private
|
|
129
129
|
def parse_escape_seq
|
130
130
|
n = @lexer.next
|
131
131
|
case n
|
132
|
-
when /["\\|{}]
|
133
|
-
when 'n'
|
134
|
-
when 'r'
|
135
|
-
when 't'
|
132
|
+
when /["\\|{}]/ then [ n, :tok_nonspace ]
|
133
|
+
when 'n' then [ "\n", :tok_space ]
|
134
|
+
when 'r' then [ "\r", :tok_space ]
|
135
|
+
when 't' then [ "\t", :tok_space ]
|
136
136
|
else raise InvalidEscapeSeqEx.new(
|
137
137
|
stream_name, line_no,
|
138
138
|
"invalid escape sequence: \\#{n}" )
|
@@ -142,9 +142,9 @@ private
|
|
142
142
|
# ����������� ���� ���������� �������.
|
143
143
|
def classify_char( ch )
|
144
144
|
case ch
|
145
|
-
when '{'
|
146
|
-
when '}'
|
147
|
-
when /[[:space:]]
|
145
|
+
when '{' then :tok_open_block
|
146
|
+
when '}' then :tok_close_block
|
147
|
+
when /[[:space:]]/ then :tok_space
|
148
148
|
else :tok_nonspace
|
149
149
|
end
|
150
150
|
end
|
@@ -35,7 +35,7 @@ class FirstStage
|
|
35
35
|
def next
|
36
36
|
ch = @stream.getc
|
37
37
|
if ch
|
38
|
-
process_next_char( ch
|
38
|
+
process_next_char( ch )
|
39
39
|
else
|
40
40
|
nil
|
41
41
|
end
|
@@ -54,9 +54,9 @@ private
|
|
54
54
|
raise UnclosedEscapeSeqEx.new( stream_name, line_no,
|
55
55
|
"unexpected EOF after \\" ) unless n
|
56
56
|
|
57
|
-
case n
|
57
|
+
case n
|
58
58
|
when /[obx]/i
|
59
|
-
parse_digital_escape_seq( n
|
59
|
+
parse_digital_escape_seq( n )
|
60
60
|
else
|
61
61
|
@stream.ungetc( n )
|
62
62
|
ch
|
@@ -87,9 +87,8 @@ private
|
|
87
87
|
n = @stream.getc
|
88
88
|
break unless n
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
tmp << c
|
90
|
+
if enabled_chars =~ n
|
91
|
+
tmp << n
|
93
92
|
else
|
94
93
|
# ������ ������ ������, ������� �� �����������
|
95
94
|
# escape-������������������. �������� ����� ���������.
|
data/lib/cls-ruby/tag.rb
CHANGED
data/tests/tc_lexer.rb
CHANGED
@@ -8,18 +8,18 @@ require 'cls-ruby/lexers/lexer'
|
|
8
8
|
class TC_Lexer< Test::Unit::TestCase
|
9
9
|
EOF = ClsRuby::Lexers::Lexer::EOF
|
10
10
|
|
11
|
-
def
|
11
|
+
def _test_empty
|
12
12
|
parse_and_compare( "", [] )
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def _test_simple
|
16
16
|
parse_and_compare( 'abc',
|
17
17
|
[
|
18
18
|
[ 'abc', :tok_nonspace ],
|
19
19
|
] )
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def _test_sample_1
|
23
23
|
line = <<EOS
|
24
24
|
{smsc_map
|
25
25
|
{cprov some_name
|
data/tests/ts_cls_ruby.rb
CHANGED
metadata
CHANGED
@@ -1,33 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0
|
3
|
-
specification_version: 1
|
4
2
|
name: ClsRuby
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
-
|
11
|
-
|
12
|
-
|
13
|
-
rubyforge_project:
|
14
|
-
description:
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
25
11
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
12
|
authors:
|
30
13
|
- Yauheni Akhotnikau
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-10-25 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description:
|
22
|
+
email: eao197@yahoo.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README
|
29
|
+
- LICENSE
|
30
|
+
- docs/base_formatting_methods
|
31
|
+
- docs/base_parsing_methods
|
32
|
+
- docs/constructor_params
|
33
|
+
- docs/examples/log_single_line_format
|
34
|
+
- docs/examples/service_description
|
35
|
+
- docs/examples/sms-hist
|
36
|
+
- docs/examples/tag_any
|
37
|
+
- docs/principles
|
38
|
+
- docs/std_tags_short_description
|
39
|
+
- docs/syntax
|
40
|
+
- docs/why_cls
|
31
41
|
files:
|
32
42
|
- tests/tc_child_tag.rb
|
33
43
|
- tests/tc_constraint_one_of.rb
|
@@ -50,14 +60,11 @@ files:
|
|
50
60
|
- tests/tc_tag_vector_of_different_tags.rb
|
51
61
|
- tests/tc_tag_vector_of_tags.rb
|
52
62
|
- tests/ts_cls_ruby.rb
|
53
|
-
- lib/cls-ruby
|
54
63
|
- lib/cls-ruby/basic_scalars.rb
|
55
|
-
- lib/cls-ruby/constraints
|
56
64
|
- lib/cls-ruby/constraints/one_of.rb
|
57
65
|
- lib/cls-ruby/default_formatter.rb
|
58
66
|
- lib/cls-ruby/ex.rb
|
59
67
|
- lib/cls-ruby/formatter.rb
|
60
|
-
- lib/cls-ruby/lexers
|
61
68
|
- lib/cls-ruby/lexers/char_classifier.rb
|
62
69
|
- lib/cls-ruby/lexers/first_stage.rb
|
63
70
|
- lib/cls-ruby/lexers/lexer.rb
|
@@ -76,12 +83,10 @@ files:
|
|
76
83
|
- docs/base_formatting_methods
|
77
84
|
- docs/base_parsing_methods
|
78
85
|
- docs/constructor_params
|
79
|
-
- docs/examples
|
80
86
|
- docs/examples/log_single_line_format
|
81
87
|
- docs/examples/service_description
|
82
88
|
- docs/examples/sms-hist
|
83
89
|
- docs/examples/tag_any
|
84
|
-
- docs/fragments
|
85
90
|
- docs/fragments/custom_tag_field.rb
|
86
91
|
- docs/fragments/custom_tag_include.rb
|
87
92
|
- docs/fragments/field.cls
|
@@ -95,18 +100,18 @@ files:
|
|
95
100
|
- docs/std_tags_short_description
|
96
101
|
- docs/syntax
|
97
102
|
- docs/why_cls
|
98
|
-
- examples/hex_stream.txt
|
99
103
|
- examples/log_single_line_formatter.rb
|
100
104
|
- examples/service_description.day_time.cfg
|
101
105
|
- examples/service_description.rb
|
102
106
|
- examples/sms-hist.rb
|
103
|
-
- examples/space_concat.txt
|
104
107
|
- examples/tag_any.rb
|
105
108
|
- THANKS
|
106
109
|
- README
|
107
110
|
- LICENSE
|
108
|
-
|
111
|
+
homepage: http://www.rubyforge.com/projects/clsruby
|
112
|
+
licenses: []
|
109
113
|
|
114
|
+
post_install_message:
|
110
115
|
rdoc_options:
|
111
116
|
- -c
|
112
117
|
- windows-1251
|
@@ -116,26 +121,32 @@ rdoc_options:
|
|
116
121
|
- -F
|
117
122
|
- --main
|
118
123
|
- README
|
119
|
-
|
120
|
-
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
-
|
125
|
-
-
|
126
|
-
|
127
|
-
|
128
|
-
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
hash: 3
|
132
|
+
segments:
|
133
|
+
- 0
|
134
|
+
version: "0"
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
hash: 3
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
version: "0"
|
138
144
|
requirements: []
|
139
145
|
|
140
|
-
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 1.7.2
|
148
|
+
signing_key:
|
149
|
+
specification_version: 3
|
150
|
+
summary: Curl Like Syntax for Ruby language
|
151
|
+
test_files: []
|
141
152
|
|
data/examples/hex_stream.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
\x7b\x61\x20\x22\x62\x22\x7d
|
data/examples/space_concat.txt
DELETED