oedipus_lex 2.5.1 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cb423b537f9675d2c16f2dea13fe319f1a9201164e8eeefa9a4275640220607
4
- data.tar.gz: b92269a7b11988954a9457a36df57c7199f1f95f74d862fbc20e7d6aec770ad6
3
+ metadata.gz: 9822a393543024bafcbb4c490751008d5ae468d3348d3397df454b622e5f8fb1
4
+ data.tar.gz: 5910e4bf0720dc2724bf01dde8629f02616958a1d8eab65005bdfd2d5da35690
5
5
  SHA512:
6
- metadata.gz: 9bd0f74cb429fd8f92b202a1dbaa38f4a69eab05da150801f59f36c2e7476b2d494304d17e8993ecbd563692dce0e7c15f20dfee5f4b0d6c92c5abc72d96b4b8
7
- data.tar.gz: ba7831924e35607b5db556c42e7d0469c8f71d8c87feb67322b05599cfe83d8884f4559e5f068570dc7e36a1b8dcc92c17b2e148685742a45a199b04caf50bdc
6
+ metadata.gz: b1c26b081d86155d0bade889a37a80e98acd35dc5dfc8bec0009fe38f18064e7d7a0c61e11a6ba037dd024fedda76597bab9787b21fed1a87d80ceaf666fb22f
7
+ data.tar.gz: e9ad55f6f9d155af3a64af6edd81ffa41c33c70f9e55148a9a002b3dfa3ac7441c819c9bfa6c885903425549926f2a2f3e823791557facb49ded71f16a2bf1df
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,9 @@
1
+ === 2.5.2 / 2020-06-14
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Speedup of column position computation. It went from roughly 10s to 2s for a big file! (vdbijl)
6
+
1
7
  === 2.5.1 / 2019-06-03
2
8
 
3
9
  * 1 minor enhancement:
@@ -30,7 +30,7 @@ require "oedipus_lex.rex"
30
30
  # books.
31
31
 
32
32
  class OedipusLex
33
- VERSION = "2.5.1" # :nodoc:
33
+ VERSION = "2.5.2" # :nodoc:
34
34
 
35
35
  ##
36
36
  # The class name to generate.
@@ -147,7 +147,7 @@ class OedipusLex
147
147
 
148
148
  cond = if exclusive or not start_state then
149
149
  check
150
- elsif start_state =~ /^:/ then
150
+ elsif /^:/.match?(start_state) then
151
151
  "(state == #{start_state}) && (#{check})"
152
152
  else # predicate method
153
153
  "#{start_state} && (#{check})"
@@ -359,7 +359,7 @@ class OedipusLex
359
359
  ##
360
360
  # Process a +state+ lexeme.
361
361
 
362
- def lex_state new_state
362
+ def lex_state _new_state
363
363
  end_group if group
364
364
  # do nothing -- lexer switches state for us
365
365
  end
@@ -379,7 +379,7 @@ class OedipusLex
379
379
  all_states = [[nil, *inclusives], # nil+incls # eg [[nil, :a],
380
380
  *exclusives.map { |s| [s] }] # [excls] # [:A], [:B]]
381
381
 
382
- encoding = header.shift if header.first =~ /encoding:/
382
+ encoding = header.shift if /encoding:/.match?(header.first)
383
383
  encoding ||= "# encoding: UTF-8"
384
384
 
385
385
  erb = if RUBY_VERSION >= "2.6.0" then
@@ -475,11 +475,16 @@ class OedipusLex
475
475
  attr_accessor :old_pos
476
476
 
477
477
  ##
478
- # The current column. Only available if the :column option is on.
478
+ # The position of the start of the current line. Only available if the
479
+ # :column option is on.
479
480
 
481
+ attr_accessor :start_of_current_line_pos
482
+
483
+ ##
484
+ # The current column, starting at 0. Only available if the
485
+ # :column option is on.
480
486
  def column
481
- idx = ss.string.rindex("\n", old_pos) || -1
482
- old_pos - idx - 1
487
+ old_pos - start_of_current_line_pos
483
488
  end
484
489
 
485
490
  % end
@@ -511,6 +516,9 @@ class OedipusLex
511
516
  self.ss = scanner_class.new str
512
517
  % if option[:lineno] then
513
518
  self.lineno = 1
519
+ % end
520
+ % if option[:column] then
521
+ self.start_of_current_line_pos = 0
514
522
  % end
515
523
  self.state ||= nil
516
524
 
@@ -556,7 +564,13 @@ class OedipusLex
556
564
 
557
565
  until ss.eos? or token do
558
566
  % if option[:lineno] then
559
- self.lineno += 1 if ss.peek(1) == "\n"
567
+ if ss.peek(1) == "\n"
568
+ self.lineno += 1
569
+ % if option[:column] then
570
+ # line starts 1 position after the newline
571
+ self.start_of_current_line_pos = ss.pos + 1
572
+ % end
573
+ end
560
574
  % end
561
575
  % if option[:column] then
562
576
  self.old_pos = ss.pos
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  #--
3
3
  # This file is automatically generated. Do not modify it.
4
- # Generated by: oedipus_lex version 2.5.0.
4
+ # Generated by: oedipus_lex version 2.5.2.
5
5
  # Source: lib/oedipus_lex.rex
6
6
  #++
7
7
 
@@ -65,11 +65,16 @@ class OedipusLex
65
65
  attr_accessor :old_pos
66
66
 
67
67
  ##
68
- # The current column. Only available if the :column option is on.
68
+ # The position of the start of the current line. Only available if the
69
+ # :column option is on.
69
70
 
71
+ attr_accessor :start_of_current_line_pos
72
+
73
+ ##
74
+ # The current column, starting at 0. Only available if the
75
+ # :column option is on.
70
76
  def column
71
- idx = ss.string.rindex("\n", old_pos) || -1
72
- old_pos - idx - 1
77
+ old_pos - start_of_current_line_pos
73
78
  end
74
79
 
75
80
  ##
@@ -97,6 +102,7 @@ class OedipusLex
97
102
  def parse str
98
103
  self.ss = scanner_class.new str
99
104
  self.lineno = 1
105
+ self.start_of_current_line_pos = 0
100
106
  self.state ||= nil
101
107
 
102
108
  do_parse
@@ -131,7 +137,11 @@ class OedipusLex
131
137
  token = nil
132
138
 
133
139
  until ss.eos? or token do
134
- self.lineno += 1 if ss.peek(1) == "\n"
140
+ if ss.peek(1) == "\n"
141
+ self.lineno += 1
142
+ # line starts 1 position after the newline
143
+ self.start_of_current_line_pos = ss.pos + 1
144
+ end
135
145
  self.old_pos = ss.pos
136
146
  token =
137
147
  case state
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oedipus_lex
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBAzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBBDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTE4MTIwNDIxMzAxNFoXDTE5MTIwNDIxMzAxNFowRTETMBEGA1UE
15
+ GRYDY29tMB4XDTE5MTIxMzAwMDIwNFoXDTIwMTIxMjAwMDIwNFowRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +22,14 @@ cert_chain:
22
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
23
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
24
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
25
- AQCbJwLmpJR2PomLU+Zzw3KRzH/hbyUWc/ftru71AopZ1fy4iY9J/BW5QYKVYwbP
26
- V0FSBWtvfI/RdwfKGtuGhPKECZgmLieGuZ3XCc09qPu1bdg7i/tu1p0t0c6163ku
27
- nDMDIC/t/DAFK0TY9I3HswuyZGbLW7rgF0DmiuZdN/RPhHq2pOLMLXJmFclCb/im
28
- 9yToml/06TJdUJ5p64mkBs0TzaK66DIB1Smd3PdtfZqoRV+EwaXMdx0Hb3zdR1JR
29
- Em82dBUFsipwMLCYj39kcyHWAxyl6Ae1Cn9r/ItVBCxoeFdrHjfavnrIEoXUt4bU
30
- UfBugfLD19bu3nvL+zTAGx/U
25
+ AQCkkcHqAa6IKLYGl93rn78J3L+LnqyxaA059n4IGMHWN5bv9KBQnIjOrpLadtYZ
26
+ vhWkunWDKdfVapBEq5+T4HzqnsEXC3aCv6JEKJY6Zw7iSzl0M8hozuzRr+w46wvT
27
+ fV2yTN6QTVxqbMsJJyjosks4ZdQYov2zdvQpt1HsLi+Qmckmg8SPZsd+T8uiiBCf
28
+ b+1ORSM5eEfBQenPXy83LZcoQz8i6zVB4aAfTGGdhxjoMGUEmSZ6xpkOzmnGa9QK
29
+ m5x9IDiApM+vCELNwDXXGNFEnQBBK+wAe4Pek8o1V1TTOxL1kGPewVOitX1p3xoN
30
+ h7iEjga8iM1LbZUfiISZ+WrB
31
31
  -----END CERTIFICATE-----
32
- date: 2019-06-04 00:00:00.000000000 Z
32
+ date: 2020-06-14 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rdoc
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '3.17'
60
+ version: '3.22'
61
61
  type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '3.17'
67
+ version: '3.22'
68
68
  description: |-
69
69
  Oedipus Lex is a lexer generator in the same family as Rexical and
70
70
  Rex. Oedipus Lex is my independent lexer fork of Rexical. Rexical was
@@ -128,7 +128,8 @@ files:
128
128
  homepage: http://github.com/seattlerb/oedipus_lex
129
129
  licenses:
130
130
  - MIT
131
- metadata: {}
131
+ metadata:
132
+ homepage_uri: http://github.com/seattlerb/oedipus_lex
132
133
  post_install_message:
133
134
  rdoc_options:
134
135
  - "--main"
@@ -146,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
147
  - !ruby/object:Gem::Version
147
148
  version: '0'
148
149
  requirements: []
149
- rubygems_version: 3.0.2
150
+ rubygems_version: 3.0.3
150
151
  signing_key:
151
152
  specification_version: 4
152
153
  summary: Oedipus Lex is a lexer generator in the same family as Rexical and Rex
metadata.gz.sig CHANGED
Binary file