posxml_parser 2.7.1 → 2.8.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
  SHA1:
3
- metadata.gz: d60bf50fa7ab91550cbf08f242e3bc99de1bf0f6
4
- data.tar.gz: db6e74583f24eea84485164847143ef8bcae67f8
3
+ metadata.gz: e0f79b2e53edf5b30845ed0b52dd45d6a68130c1
4
+ data.tar.gz: c2aabe64c1d84a47b02a23ae5de401704a4ca432
5
5
  SHA512:
6
- metadata.gz: f8bb0e307d4ed7b3463fcc279131905ad42b00be15ca298400c9065def91713c20e5605d4713c9905582cde1b4b48b2d2910880c89a6179f2c98f06c9346b58f
7
- data.tar.gz: 2d0b84facc1030f1dec6cb2f8c38148ab011705761b273a7d88715071ca29a427bf482cef741191e0476a989bc896690d366e30b2521fd4863a76a2e6c626700
6
+ metadata.gz: fe118e0b98a77595bbf4f65c71562d17704589ca360d7350a59b36c0d4032a6e41a7785a7e5cf92ebe088aacf3a0da8fb73888a9142912ac2c6c1753e5ecd289
7
+ data.tar.gz: 9835dc9a42b38bc3f6d90c46bf084a631e32f2e31bf5b1b13074e28e28700e265f88478f15ca2872ee824c76b147e2744234bbe14ecd1a3fb73ce51f02032a9f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- posxml_parser (2.7.1)
4
+ posxml_parser (2.8.0)
5
5
  funky-emv (~> 0.3)
6
6
 
7
7
  GEM
data/RELEASE_NOTES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Posxml Parser
2
2
 
3
+ ### 2.8.0 - 2018-08-24
4
+
5
+ - Support float variable compilation.
6
+ - Add file line number to compilation error.
7
+
3
8
  ### 2.7.1 - 2018-08-20
4
9
 
5
10
  - Fix incompatible character encodings on compilation.
@@ -56,7 +56,7 @@ module PosxmlCompiler
56
56
  stack_while << [index, instruction[:point]]
57
57
  when INSTRUCTION_BREAK
58
58
  reference, point = stack_while.last
59
- raise PosxmlCompilerError.new("While not found for <break") unless reference
59
+ raise PosxmlCompilerError.new("#{instruction[:line_number]}:While not found for <break") unless reference
60
60
  @jumps << JumpPoint.new(self, INSTRUCTION_BREAK, index, reference, point)
61
61
  when INSTRUCTION_WHILE
62
62
  reference, point = stack_while.pop
@@ -86,8 +86,9 @@ module PosxmlCompiler
86
86
 
87
87
  def check_function_tree(tree, instruction)
88
88
  function_name = instruction[:parameters]["name"][:original]
89
+ line_number = instruction[:line_number]
89
90
  unless function = tree[function_name]
90
- raise PosxmlCompilerError.new("Function #{function_name} not found") unless reference
91
+ raise PosxmlCompilerError.new("#{line_number}:Function #{function_name} not found") unless reference
91
92
  end
92
93
  function_indexed = tree[function_name][0]
93
94
  [function_indexed[1], function_indexed[0][:point]]
@@ -25,6 +25,8 @@ module PosxmlCompiler
25
25
  puts "Application size limit(#{self.limit}) exceed"
26
26
  end
27
27
  txt
28
+ rescue => e
29
+ raise e.class.new("#{number}:#{e.message}")
28
30
  end
29
31
 
30
32
  private
@@ -54,25 +56,35 @@ module PosxmlCompiler
54
56
  def split_instructions(txt)
55
57
  txt_new = ""
56
58
  ignore = false
57
- txt.split("\n").compact.each do |str|
59
+ txt.split("\n").compact.each_with_index do |str, number|
58
60
  line = str.strip
59
61
  if line[0..3] == "<!--" || ignore # Check comentaries
60
62
  ignore = true
61
63
  ignore = false if line.include?("-->")
62
64
  elsif line.include?("<!--") # Check end of comentaries
63
65
  line_without_comment = line.split("<!--")[0].strip
64
- txt_new << instruction_check_close(line_without_comment)
66
+ txt_new << add_line_number(number, instruction_check_close(line_without_comment))
65
67
  elsif line.include?("<") || line.include?(">")
66
- txt_new << instruction_check_close(line)
68
+ txt_new << add_line_number(number, instruction_check_close(line))
67
69
  else !ignore # For middle of instruction between lines
68
70
  # Avoid this <pinpad.getpindukptmessage="$(sDisplayMsg)"type="3"pan="$(sPAN)"maxlen="12"variablereturnpin="$(sPIN)"variablereturnksn="$(sKSN)"variablereturn="$(iRet)"
69
71
  txt_new << " " if txt_new[-1] != " "
70
- txt_new << instruction_check_close(line)
72
+ txt_new << add_line_number(number, instruction_check_close(line))
71
73
  end
72
74
  end
75
+ #p txt_new
73
76
  txt_new.split("\n")
74
77
  end
75
78
 
79
+ def add_line_number(line, string)
80
+ # necessary check to avoid add line on commands devide in two lines
81
+ if string[0] == "<"
82
+ "#{line+1}\x00#{string}"
83
+ else
84
+ string
85
+ end
86
+ end
87
+
76
88
  def instruction_check_close(str)
77
89
  if str[-1] == ">"
78
90
  "#{str[0..-2]}\n"
@@ -83,9 +95,15 @@ module PosxmlCompiler
83
95
 
84
96
  def parse(txt)
85
97
  point = 0
98
+ number = 0
86
99
  # Split in lines and remove nil's
87
100
  split_instructions(sanitize(txt)).inject([]) do |array, str|
88
- value = str.strip
101
+ if str.include?("\x00")
102
+ number, value = str.split("\x00", 2)
103
+ else
104
+ value = str
105
+ end
106
+ value = value.strip
89
107
  next(array) if value.empty?
90
108
  # => "if", {"variable" => "$(sKeyTouchScreen)", "operator" => "equalto", "value" => "KEY_CLEAR"}
91
109
  name, parameters = parse_line(value)
@@ -96,11 +114,13 @@ module PosxmlCompiler
96
114
  line = parse_instruction(name, parameters)
97
115
  size = line.size
98
116
  array << {
99
- :name => name, :parameters => parameters, :line => line, :size => size, :point => point
117
+ :name => name, :parameters => parameters, :line => line, :size => size, :point => point, :line_number => number
100
118
  }
101
119
  point += size
102
120
  array
103
121
  end
122
+ rescue => e
123
+ raise e.class.new("#{number}:#{e.message}")
104
124
  end
105
125
 
106
126
  # Receive:
@@ -157,7 +157,7 @@ module PosxmlCompiler
157
157
  end
158
158
 
159
159
  def type_string_or_integer?(str)
160
- str.match(/(string ou inteiro|string or integer)/)
160
+ str.match(/(string ou inteiro|string or integer|float)/)
161
161
  end
162
162
 
163
163
  #def type_string?(str)
@@ -1,5 +1,5 @@
1
1
 
2
2
  module PosxmlParser
3
- VERSION = "2.7.1"
3
+ VERSION = "2.8.0"
4
4
  end
5
5
 
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posxml_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CloudWalk Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-20 00:00:00.000000000 Z
11
+ date: 2018-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler