jaina 0.5.0 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9a98b33875e25f9b5133548da379b6a4af1886c09cb1a942a4b600c7841014d
4
- data.tar.gz: 8ca16e944faa24ef61e2467a63718a75fd9e7d87f176e320d63f2247b9814497
3
+ metadata.gz: 0f175d89fcc7f3abb8f1c7583273fa909f6026059e3cd77a1a6c4ec5a4c6b9a8
4
+ data.tar.gz: 3fbc8716d947b5f760e5a1b766d130d51fbb2a9da6fc9de441ae49cf5fc1aaa6
5
5
  SHA512:
6
- metadata.gz: fb36863a52b5dcae3af2852710d4208d40942305a8fa296b32b92615afa1b3fae94629aea2f28185dfa99c2c02e1dd836b7da6177549f04d3ad6e54b977e3f35
7
- data.tar.gz: 8caac2e609dcbe5973dd0e61c031b21d0bed24ae43ae5f69ed8450f23ecdea9f7befd38eaabe9f9a9ff97ba1b34e25bced17dbcffac2dcfef1fb4f2ba59c8fa9
6
+ metadata.gz: 86527dab36b24534feb23200fa97c2c42762be632693bf41268b0b624be951c8f5e9e27cce68c10c29282212a02bbb49a467d3b489560cce626a769578483000
7
+ data.tar.gz: '0628d3f9dc415a0c638c84df22e2fd3d83015db71d4702373d6d38f34221ec689a01805c145efefe8532b84ed7be0bcbcdfdcb933a7664967d5d656000d02707'
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.6.0] - 2019-06-28
5
+ ### Added
6
+ - New token symbols (`-`, `=`, `>`, `<`): you can use these in your operands and operators;
7
+
8
+ ### Fixed
9
+ - Expression inheritance (internal state of the child of child isnt copied but should);
10
+
4
11
  ## [0.5.0] - 2019-06-27
5
12
  ### Added
6
13
  - An ability to redefine existing expressions (`Jaina.redefine(expression_klass)`);
@@ -3,7 +3,6 @@
3
3
  # @api private
4
4
  # @since 0.1.0
5
5
  class Jaina::Parser::CodeConverter::ToPostfixForm
6
- # @api private
7
6
  # @since 0.1.0
8
7
  extend Forwardable
9
8
 
@@ -37,47 +37,19 @@ module Jaina::Parser::Expression::Operator::Abstract::DSL
37
37
  base_klass.instance_variable_set(:@acts_as_binary_term, false)
38
38
  base_klass.instance_variable_set(:@acts_as_unary_term, false)
39
39
 
40
- base_klass.extend ClassMethods
41
- base_klass.include InstanceMethods
42
- base_klass.singleton_class.prepend(ClassInheritance)
43
- end
44
- end
45
-
46
- # @api private
47
- # @since 0.1.0
48
- module ClassInheritance
49
- # @param child_klass [Class]
50
- # @return [void]
51
- #
52
- # @api private
53
- # @since 0.1.0
54
- def inherited(child_klass)
55
- child_klass.instance_variable_set(
56
- :@token,
57
- instance_variable_get(:@token)
58
- )
59
-
60
- child_klass.instance_variable_set(
61
- :@precedence_level,
62
- instance_variable_get(:@precedence_level)
63
- )
64
-
65
- child_klass.instance_variable_set(
66
- :@associativity_direction,
67
- instance_variable_get(:@associativity_direction)
68
- )
69
-
70
- child_klass.instance_variable_set(
71
- :@acts_as_binary_term,
72
- instance_variable_get(:@acts_as_binary_term)
73
- )
74
-
75
- child_klass.instance_variable_set(
76
- :@acts_as_unary_term,
77
- instance_variable_get(:@acts_as_unary_term)
78
- )
79
-
80
- super
40
+ base_klass.extend(ClassMethods)
41
+ base_klass.include(InstanceMethods)
42
+
43
+ # NOTE: inheritance
44
+ base_klass.singleton_class.prepend(Module.new do
45
+ def inherited(child_klass)
46
+ child_klass.instance_variable_set(:@token, @token)
47
+ child_klass.instance_variable_set(:@precedence_level, @precedence_level)
48
+ child_klass.instance_variable_set(:@associativity_direction, @associativity_direction)
49
+ child_klass.instance_variable_set(:@acts_as_binary_term, @acts_as_binary_term)
50
+ child_klass.instance_variable_set(:@acts_as_unary_term, @acts_as_unary_term)
51
+ end
52
+ end)
81
53
  end
82
54
  end
83
55
 
@@ -39,7 +39,7 @@ class Jaina::Parser::Tokenizer::Token
39
39
  # @api private
40
40
  # @since 0.4.0
41
41
  def dup
42
- self.class.new(raw_token.dup, token.dup, *arguments)
42
+ self.class.new(raw_token.dup, token.dup, *arguments.dup)
43
43
  end
44
44
 
45
45
  # @return [String]
@@ -57,7 +57,7 @@ class Jaina::Parser::Tokenizer::TokenBuilder
57
57
  check_for_correctness!
58
58
 
59
59
  # NOTE:
60
- # format: token [ attr1, attr2, attr3 ]
60
+ # format: token[attr1,attr2,attr3]
61
61
  # TOKEN => parts[0]
62
62
  # OPENING BRAKET => parts[1]
63
63
  # CLOSING BRAKET => parts[-1]
@@ -95,7 +95,7 @@ class Jaina::Parser::Tokenizer::TokenBuilder
95
95
  raise(
96
96
  IncorrectTokenDefinitionError,
97
97
  "Incorrect token definition `#{raw_token}`: " \
98
- "token should contain `[` and `]` if `[` is provided)"
98
+ "token should contain `[` and `]` if `[` is provided"
99
99
  ) if parts.count < 3
100
100
 
101
101
  # NOTE:
@@ -110,19 +110,15 @@ class Jaina::Parser::Tokenizer::TokenBuilder
110
110
  arguments = parts[2..-2]
111
111
 
112
112
  # rubocop:disable Metrics/LineLength
113
- if arguments.include?(OPENING_ATTRIBUTE_GROUP_SYMBOL) || opening_corner != OPENING_ATTRIBUTE_GROUP_SYMBOL
114
- raise(
115
- IncorrectTokenDefinitionError,
116
- "Incorrect token definition `#{raw_token}`: `[` should be the first arguments opening symbol."
117
- )
118
- end
113
+ raise(
114
+ IncorrectTokenDefinitionError,
115
+ "Incorrect token definition `#{raw_token}`: `[` should be the first arguments opening symbol."
116
+ ) if arguments.include?(OPENING_ATTRIBUTE_GROUP_SYMBOL) || opening_corner != OPENING_ATTRIBUTE_GROUP_SYMBOL
119
117
 
120
- if arguments.include?(CLOSING_ATTRIBUTE_GROUP_SYMBOL) || closing_corner != CLOSING_ATTRIBUTE_GROUP_SYMBOL
121
- raise(
122
- IncorrectTokenDefinitionError,
123
- "Incorrect token definition `#{raw_token}`: `]` should be the last arguments closing symbol."
124
- )
125
- end
118
+ raise(
119
+ IncorrectTokenDefinitionError,
120
+ "Incorrect token definition `#{raw_token}`: `]` should be the last arguments closing symbol."
121
+ ) if arguments.include?(CLOSING_ATTRIBUTE_GROUP_SYMBOL) || closing_corner != CLOSING_ATTRIBUTE_GROUP_SYMBOL
126
122
  # rubocop:enable Metrics/LineLength
127
123
  end
128
124
  end
@@ -10,7 +10,7 @@ module Jaina::Parser::Tokenizer
10
10
  #
11
11
  # @api private
12
12
  # @since 0.1.0
13
- TOKEN_SCAN_PATTERN = /\(|\)|[\"\'\.\,\w\[\]]+/.freeze
13
+ TOKEN_SCAN_PATTERN = /\(|\)|[\<\=\-\>\:\"\'\.\,\w\[\]]+/.freeze
14
14
 
15
15
  # @return [String]
16
16
  #
data/lib/jaina/version.rb CHANGED
@@ -5,5 +5,5 @@ module Jaina
5
5
  #
6
6
  # @api public
7
7
  # @since 0.0.0
8
- VERSION = '0.5.0'
8
+ VERSION = '0.6.0'
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jaina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-27 00:00:00.000000000 Z
11
+ date: 2019-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls