srl_ruby 0.4.4 → 0.4.5
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +10 -0
- data/LICENSE.txt +1 -1
- data/appveyor.yml +8 -9
- data/bin/srl2ruby +4 -3
- data/bin/srl2ruby_cli_parser.rb +3 -3
- data/lib/regex/char_range.rb +1 -0
- data/lib/regex/character.rb +2 -0
- data/lib/regex/multiplicity.rb +1 -0
- data/lib/regex/polyadic_expression.rb +2 -0
- data/lib/srl_ruby/ast_builder.rb +8 -1
- data/lib/srl_ruby/tokenizer.rb +1 -1
- data/lib/srl_ruby/version.rb +1 -1
- data/spec/acceptance/support/rule_file_tokenizer.rb +1 -1
- data/srl_ruby.gemspec +2 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09e2d0e45cb7094a048508eaf8af5e3d081a279b
|
4
|
+
data.tar.gz: 50017e8623af0c0f034746541f430f21f4df7660
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 911f5c56ba1fcd7fcefa97b23ca8d3f76c228f84d21eeb742c40415fa81763a2ba0d296b045f38e727be94ea2bc0517141cf7e593493596e98c4f8a4e55a2e95
|
7
|
+
data.tar.gz: e0b9b5e7a2a9a87520fe632f37e5ed89484be85d16f02519628ac44c0716dad669352cd86e465a46b225cc009d8e9eddc06328348e98243ad470c007cd0f2a8f
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## [0.4.5] - 2019-01-02
|
2
|
+
### Changed
|
3
|
+
- Minor code re-styling to please Rubocop 0.62.0.
|
4
|
+
- File `.travis.yml` Updated Ruby versions for CI builds
|
5
|
+
- File `.appveyor.yml` Sequence of Ruby versions refactored
|
6
|
+
- File `LICENSE.txt`: updated years in copyright text.
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
- Method `ASTBuilder#reduce_pattern_sequence` was broken for lookbehind assertions.
|
10
|
+
|
1
11
|
## [0.4.4] - 2018-11-24
|
2
12
|
### Changed
|
3
13
|
- File `srl_ruby.gemspec` Updated Rley dependency.
|
data/LICENSE.txt
CHANGED
@@ -5,7 +5,7 @@ the 'srl_test' directory, which is subject to its own license.
|
|
5
5
|
|
6
6
|
The MIT License (MIT)
|
7
7
|
|
8
|
-
Copyright (c) 2018 Dimitri Geshef
|
8
|
+
Copyright (c) 2018-2019 Dimitri Geshef
|
9
9
|
|
10
10
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
11
11
|
of this software and associated documentation files (the "Software"), to deal
|
data/appveyor.yml
CHANGED
@@ -2,17 +2,16 @@ version: '{build}'
|
|
2
2
|
max_jobs: 3
|
3
3
|
environment:
|
4
4
|
matrix:
|
5
|
-
- Ruby_version:
|
6
|
-
- Ruby_version:
|
7
|
-
- Ruby_version: 22
|
8
|
-
- Ruby_version: 22-x64
|
9
|
-
- Ruby_version: 23
|
5
|
+
- Ruby_version: 25-x64
|
6
|
+
- Ruby_version: 24-x64
|
10
7
|
- Ruby_version: 23-x64
|
11
|
-
- Ruby_version:
|
12
|
-
- Ruby_version:
|
8
|
+
- Ruby_version: 22-x64
|
9
|
+
- Ruby_version: 21-x64
|
13
10
|
- Ruby_version: 25
|
14
|
-
- Ruby_version:
|
15
|
-
|
11
|
+
- Ruby_version: 24
|
12
|
+
- Ruby_version: 23
|
13
|
+
- Ruby_version: 22
|
14
|
+
- Ruby_version: 21
|
16
15
|
# These are failing
|
17
16
|
# - Ruby_version: 26
|
18
17
|
# - Ruby_version: 26-x64
|
data/bin/srl2ruby
CHANGED
@@ -23,11 +23,12 @@ class Srl2RubyProg
|
|
23
23
|
def run!(file_names)
|
24
24
|
if cli_options.include?(:pattern)
|
25
25
|
srl_source = cli_options[:pattern]
|
26
|
-
process_srl(srl_source)
|
26
|
+
process_srl(srl_source)
|
27
27
|
end
|
28
28
|
file_names.each do |srl_file|
|
29
29
|
fname = validate_filename(srl_file)
|
30
30
|
next unless file_exist?(fname)
|
31
|
+
|
31
32
|
puts "Parsing file '#{fname}'"
|
32
33
|
srl_source = File.read(fname)
|
33
34
|
process_srl(srl_source)
|
@@ -76,7 +77,7 @@ class Srl2RubyProg
|
|
76
77
|
|
77
78
|
exists
|
78
79
|
end
|
79
|
-
|
80
|
+
|
80
81
|
def process_srl(srl_source)
|
81
82
|
result = SrlRuby.parse(srl_source)
|
82
83
|
destination = $stdout
|
@@ -85,7 +86,7 @@ class Srl2RubyProg
|
|
85
86
|
destination = File.open(filepath, 'w')
|
86
87
|
end
|
87
88
|
puts "Writing to file '#{filepath}'" unless destination == $stdout
|
88
|
-
destination.puts emit_code(template, srl_source, result)
|
89
|
+
destination.puts emit_code(template, srl_source, result)
|
89
90
|
end
|
90
91
|
|
91
92
|
def emit_code(template, srl_source, regexp)
|
data/bin/srl2ruby_cli_parser.rb
CHANGED
@@ -13,7 +13,7 @@ class Srl2RubyCLIParser < OptionParser
|
|
13
13
|
|
14
14
|
heading
|
15
15
|
separator 'Options:'
|
16
|
-
add_p_option
|
16
|
+
add_p_option
|
17
17
|
add_o_option
|
18
18
|
add_t_option
|
19
19
|
separator ''
|
@@ -63,14 +63,14 @@ DESCR
|
|
63
63
|
@parsed_options[:output] = pathname
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def add_p_option
|
68
68
|
explanation = 'One-liner SRL pattern.'
|
69
69
|
|
70
70
|
on '-p', '--pattern SRL_PATT', explanation do |pattern_arg|
|
71
71
|
@parsed_options[:pattern] = pattern_arg.gsub(/^'|'$/, '')
|
72
72
|
end
|
73
|
-
end
|
73
|
+
end
|
74
74
|
|
75
75
|
def add_t_option
|
76
76
|
explanation = <<-EXPLANATION
|
data/lib/regex/char_range.rb
CHANGED
@@ -43,6 +43,7 @@ module Regex # This module is used as a namespace
|
|
43
43
|
def validated_range(theLowerBound, theUpperBound)
|
44
44
|
msg = 'Character range error: lower bound is greater than upper bound.'
|
45
45
|
raise StandardError, msg if theLowerBound.codepoint > theUpperBound.codepoint
|
46
|
+
|
46
47
|
return [theLowerBound, theUpperBound]
|
47
48
|
end
|
48
49
|
end # class
|
data/lib/regex/character.rb
CHANGED
@@ -103,6 +103,7 @@ module Regex # This module is used as a namespace
|
|
103
103
|
def self.esc2codepoint(esc_seq)
|
104
104
|
msg = "Escape sequence #{esc_seq} does not begin with a backslash (\)."
|
105
105
|
raise StandardError, msg unless esc_seq[0] == '\\'
|
106
|
+
|
106
107
|
result = (esc_seq.length == 2) ? digram2codepoint(esc_seq) : esc_number2codepoint(esc_seq)
|
107
108
|
|
108
109
|
return result
|
@@ -155,6 +156,7 @@ module Regex # This module is used as a namespace
|
|
155
156
|
# Otherwise the character corresponding to the codepoint is returned.
|
156
157
|
def text_repr
|
157
158
|
return char if lexeme.nil?
|
159
|
+
|
158
160
|
return lexeme.dup
|
159
161
|
end
|
160
162
|
|
data/lib/regex/multiplicity.rb
CHANGED
@@ -30,6 +30,7 @@ module Regex # This module is used as a namespace
|
|
30
30
|
children.each(&:done!)
|
31
31
|
children.each_with_index do |child, index|
|
32
32
|
break if index == children.size - 1
|
33
|
+
|
33
34
|
next_child = children[index + 1]
|
34
35
|
if next_child.kind_of?(Lookaround) && next_child.dir == :behind
|
35
36
|
# Swap children: lookbehind regex must precede pattern
|
@@ -57,6 +58,7 @@ module Regex # This module is used as a namespace
|
|
57
58
|
top = visit_stack.pop
|
58
59
|
if top.kind_of?(Array)
|
59
60
|
next if top.empty?
|
61
|
+
|
60
62
|
currChild = top.pop
|
61
63
|
visit_stack.push top
|
62
64
|
else
|
data/lib/srl_ruby/ast_builder.rb
CHANGED
@@ -44,6 +44,7 @@ module SrlRuby
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
return if regexp_opts.empty?
|
47
|
+
|
47
48
|
new_root = Regex::MatchOption.new(tree_root, regexp_opts)
|
48
49
|
result.instance_variable_set(:@root, new_root)
|
49
50
|
end
|
@@ -120,7 +121,13 @@ module SrlRuby
|
|
120
121
|
|
121
122
|
# rule('pattern' => %w[pattern separator sub_pattern]).as 'pattern_sequence'
|
122
123
|
def reduce_pattern_sequence(_production, _range, _tokens, theChildren)
|
123
|
-
|
124
|
+
third_member = theChildren[2]
|
125
|
+
if third_member.kind_of?(Regex::Lookaround) && third_member.dir == :behind
|
126
|
+
Regex::Concatenation.new(theChildren[2], theChildren[0])
|
127
|
+
else
|
128
|
+
Regex::Concatenation.new(theChildren[0], theChildren[2])
|
129
|
+
end
|
130
|
+
|
124
131
|
end
|
125
132
|
|
126
133
|
# rule('pattern' => 'sub_pattern').as 'basic_pattern'
|
data/lib/srl_ruby/tokenizer.rb
CHANGED
@@ -132,7 +132,7 @@ module SrlRuby
|
|
132
132
|
token = build_token('LETTER_LIT', lexeme)
|
133
133
|
elsif (lexeme = scanner.scan(/[a-zA-Z_][a-zA-Z0-9_]+/))
|
134
134
|
keyw = @@keywords[lexeme.upcase]
|
135
|
-
tok_type = keyw
|
135
|
+
tok_type = keyw || 'IDENTIFIER'
|
136
136
|
token = build_token(tok_type, lexeme)
|
137
137
|
elsif (lexeme = scanner.scan(/[^,"\s]{2,}/))
|
138
138
|
token = build_token('CHAR_CLASS', lexeme)
|
data/lib/srl_ruby/version.rb
CHANGED
@@ -84,7 +84,7 @@ module Acceptance
|
|
84
84
|
@state = :expecting_srl if lexeme == 'srl:'
|
85
85
|
elsif (lexeme = scanner.scan(/[a-zA-Z_][a-zA-Z0-9_]*/))
|
86
86
|
keyw = @@keywords[lexeme]
|
87
|
-
token_type = keyw
|
87
|
+
token_type = keyw || 'IDENTIFIER'
|
88
88
|
token = build_token(token_type, lexeme)
|
89
89
|
elsif (lexeme = scanner.scan(/"([^"]|\\")*"/)) # Double quotes literal?
|
90
90
|
unquoted = lexeme.gsub(/(^")|("$)/, '')
|
data/srl_ruby.gemspec
CHANGED
@@ -46,7 +46,7 @@ Gem::Specification.new do |spec|
|
|
46
46
|
spec.email = ['famished.tiger@yahoo.com']
|
47
47
|
|
48
48
|
spec.description = <<-DESCR
|
49
|
-
A compiler and library that transforms highly readable Simple Regex Language
|
49
|
+
A compiler and library that transforms highly readable Simple Regex Language
|
50
50
|
patterns into regular expressions.
|
51
51
|
DESCR
|
52
52
|
spec.summary = <<-SUMMARY
|
@@ -66,7 +66,7 @@ SUMMARY
|
|
66
66
|
spec.required_ruby_version = '>= 2.1.0'
|
67
67
|
|
68
68
|
# Runtime dependencies
|
69
|
-
spec.add_dependency 'rley', '~> 0.7'
|
69
|
+
spec.add_dependency 'rley', '~> 0.7.00'
|
70
70
|
|
71
71
|
# Development dependencies
|
72
72
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: srl_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rley
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.7.00
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.7.00
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,8 +80,9 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
-
description:
|
84
|
-
|
83
|
+
description: |2
|
84
|
+
A compiler and library that transforms highly readable Simple Regex Language
|
85
|
+
patterns into regular expressions.
|
85
86
|
email:
|
86
87
|
- famished.tiger@yahoo.com
|
87
88
|
executables:
|