code-ruby-parser 0.1.6 → 0.1.8

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: 0e1562e25f7726713c82c2338359e0b3df960dd5377d79ce247d3bd44c2e11a9
4
- data.tar.gz: ccceda81f10d2d073ec1e1a8060f8b4ad8e59307802c42825fa13e25a760922e
3
+ metadata.gz: b4f1c3766c85835e0e849b956b2046e67d68c5f61ae462ad2bbcf436f194e8e6
4
+ data.tar.gz: 22aaf2adc257c7d481d1be68cc8dafa366fd32aeb71764e7fcf14c94c140af7f
5
5
  SHA512:
6
- metadata.gz: 22161b94175251b29784027e1c15e8f5f38d2ddcae5d62e9e2b962254dafe00959c992c91dd830d12dbff9da7291d7f2df7c24c372e35f26cc90a03e0a46bcbc
7
- data.tar.gz: 9e77b562a8908eaa4801aa27b3d98a43a54e09c1afc6784816a8d2d89157c5d5c16f716c21efad170f2310f65f1a5d5e0b780baa02bd8f2c14f9b08a675e8ff5
6
+ metadata.gz: 1928d766297e5c755bccc6c6832ad056dd77638235738489488f733f2e44cba1c3d372b0873a97db577cf4ed40805c326c876ba0860ff3df186591093f23435b
7
+ data.tar.gz: c49ba9bd87d69e3283f29553c03a5dbd474259ce2ade47d7f6f0b3da0bc36171f9355b39565d63ee6274ed6c30afad5f50db4879219772395e9170a18fde2abe
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 0.1.8 - November 13, 2022
2
+
3
+ - Allow numbers with exponents: `1e1`
4
+
5
+ ### 0.1.7 - November 13, 2022
6
+
7
+ - Fix parsing of `nothing`
8
+
1
9
  ### 0.1.6 - November 13, 2022
2
10
 
3
11
  - Add missing operator from equal, e.g. a += 1, a = 2
@@ -5,10 +5,12 @@ class Code
5
5
  previous_cursor = cursor
6
6
 
7
7
  if match(NOT_KEYWORD)
8
+ buffer!
9
+ consume while next?(WHITESPACE)
8
10
  comments = parse_comments
9
11
  right = parse_subclass(::Code::Parser::NotKeyword)
10
12
 
11
- if right
13
+ if right && (comments || buffer?)
12
14
  { not: { right: right, comments: comments }.compact }
13
15
  else
14
16
  @cursor = previous_cursor
@@ -10,18 +10,7 @@ class Code
10
10
  elsif match(B)
11
11
  parse_base(2)
12
12
  else
13
- consume while (next?(DIGITS) || next?(UNDERSCORE)) && !end_of_input?
14
-
15
- if next?(DOT) && next_next?(DIGITS)
16
- consume
17
- while (next?(DIGITS) || next?(UNDERSCORE)) && !end_of_input?
18
- consume
19
- end
20
-
21
- { decimal: buffer.gsub(UNDERSCORE, EMPTY_STRING) }
22
- else
23
- { integer: buffer.gsub(UNDERSCORE, EMPTY_STRING).to_i }
24
- end
13
+ parse_number
25
14
  end
26
15
  else
27
16
  parse_subclass(::Code::Parser::Boolean)
@@ -34,6 +23,35 @@ class Code
34
23
 
35
24
  { integer: buffer.gsub(UNDERSCORE, EMPTY_STRING).to_i(base) }
36
25
  end
26
+
27
+ def parse_number
28
+ consume while (next?(DIGITS) || next?(UNDERSCORE)) && !end_of_input?
29
+
30
+ if next?(DOT) && next_next?(DIGITS)
31
+ consume
32
+ consume while (next?(DIGITS) || next?(UNDERSCORE)) && !end_of_input?
33
+
34
+ decimal = buffer!.gsub(UNDERSCORE, EMPTY_STRING)
35
+
36
+ if match(E)
37
+ buffer!
38
+ exponent = parse_number
39
+ { decimal: { value: decimal, exponent: exponent } }
40
+ else
41
+ { decimal: decimal }
42
+ end
43
+ else
44
+ integer = buffer!.gsub(UNDERSCORE, EMPTY_STRING).to_i
45
+
46
+ if match(E)
47
+ buffer!
48
+ exponent = parse_number
49
+ { integer: { value: integer, exponent: exponent } }
50
+ else
51
+ { integer: integer }
52
+ end
53
+ end
54
+ end
37
55
  end
38
56
  end
39
57
  end
data/lib/code/parser.rb CHANGED
@@ -10,6 +10,7 @@ class Code
10
10
  X = "x"
11
11
  O = "o"
12
12
  B = "b"
13
+ E = "e"
13
14
 
14
15
  SINGLE_QUOTE = "'"
15
16
  DOUBLE_QUOTE = '"'
@@ -1,6 +1,6 @@
1
1
  class Template
2
2
  class Parser < ::Code::Parser
3
- Version = Gem::Version.new("0.1.6")
3
+ Version = Gem::Version.new("0.1.8")
4
4
 
5
5
  def parse
6
6
  parts = []
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code-ruby-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié