treetop 1.6.10 → 1.6.11

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
- SHA1:
3
- metadata.gz: 7fecaf04cfab9ba6103bfb17b2d339e57b7752b4
4
- data.tar.gz: 4591c839d1bd86ea34fc05519ba6f29cf8428c03
2
+ SHA256:
3
+ metadata.gz: 479a05ee2597d0a16e55fef607e2dabc61aca6eb0dd32fe7c09c1da57c26c249
4
+ data.tar.gz: 2ce5744718e261584c53809ac8248468bae57ec0caea18b1c14fb26c03c0aaa0
5
5
  SHA512:
6
- metadata.gz: a45e30b3c1667a03e2a25b3073ffafae7bb138f89af92eb4ae27aeb60ddc22ea7a51fbc3c26dad169ba0a5e25f511414c19df6c852cd38148879286e36b80f86
7
- data.tar.gz: 9d1c4be003280c12692ba0745c38ea6f900c56692217db1be7de91b40493f0056900c55c6271586676984e6aba327d4d11e9b8dfe710e2a391c72ce12955f149
6
+ metadata.gz: 8cef679ab06930e13ace292dc7abbb17004c4bad6225db29264198a6695698f6bbc0514fbd6dba6ded1a04d7ba522e7f58a9352d738ea78608dbd901589e3489
7
+ data.tar.gz: 5c47cf26a21d43c5ab2aad2f8627905d52d9ed88a8bbb2d0a810c000d316579d1cd054497877ecb59de6ce33778fd45b1d3886bf15051c6d9a73a49da6a1e7af
data/Rakefile CHANGED
@@ -29,23 +29,15 @@ task :version do
29
29
  puts 'Treetop is '+Treetop::VERSION::STRING
30
30
  end
31
31
 
32
- desc 'Generate website files'
33
- task :website_generate do
34
- `cd doc; ruby ./site.rb`
35
- end
36
-
37
- desc 'Upload website files'
38
- task :website_upload do
39
- # The website is now done using gh-pages
32
+ desc 'Generate and upload website files'
33
+ task :website do
40
34
  system <<-END
35
+ rm -rf .doc-tmp
36
+ cp -r doc .doc-tmp
41
37
  git checkout gh-pages
42
- cp website/*.html .
43
- git add *.html
44
- git commit -m"Website update `date`"
45
- git push
38
+ rm -r doc
39
+ mv .doc-tmp doc
40
+ rake website upload
46
41
  git checkout master
47
42
  END
48
43
  end
49
-
50
- desc 'Generate and upload website files'
51
- task :website => [:website_generate, :website_upload]
@@ -49,3 +49,9 @@ This says that `'end'` must be followed by a space, but this space is not consum
49
49
  end
50
50
 
51
51
  In general, when the syntax gets tough, it helps to focus on what you really mean. A keyword is a character not followed by another character that isn't a space.
52
+
53
+ ## Poor Performance with Large Unicode Strings
54
+
55
+ Treetop may perform poorly when parsing very large (more than 100KB) unicode strings. This is due to the fact that substring lookups on Ruby unicode strings are linear-time operations, and not constant-time operations like they are on ASCII encoded strings. This means that parse times for larger strings can be exponentially worse than for smaller strings.
56
+
57
+ If your input and grammar only expect ASCII strings, you can achieve significant performance improvements for large strings by re-encoding them to ASCII using `input.encode(Encoding::US_ASCII)`. See [this issue on GitHub](https://github.com/cjheath/treetop/issues/31) for more information and other possible workarounds for unicode strings.
@@ -9,11 +9,11 @@ module Treetop
9
9
  def initialize
10
10
  @level = 0
11
11
  @address_space = LexicalAddressSpace.new
12
- @ruby = ""
12
+ @ruby = String.new("")
13
13
  end
14
14
 
15
15
  def <<(ruby_line)
16
- return if ruby_line.blank?
16
+ return if ruby_line == ''
17
17
  ruby << ruby_line.tabto(level) << "\n"
18
18
  end
19
19
 
@@ -13,12 +13,6 @@ class String
13
13
  self[0...index].count("\n") + 1
14
14
  end
15
15
 
16
- unless method_defined?(:blank?)
17
- def blank?
18
- self == ""
19
- end
20
- end
21
-
22
16
  # The following methods are lifted from Facets 2.0.2
23
17
  def tabto(n)
24
18
  if self =~ /^( *)\S/
@@ -2,7 +2,7 @@ module Treetop #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 6
5
- TINY = 10
5
+ TINY = 11
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: treetop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.10
4
+ version: 1.6.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Sobo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-20 00:00:00.000000000 Z
12
+ date: 2020-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: polyglot
@@ -123,8 +123,6 @@ files:
123
123
  - doc/index.markdown
124
124
  - doc/pitfalls_and_advanced_techniques.markdown
125
125
  - doc/semantic_interpretation.markdown
126
- - doc/site.rb
127
- - doc/sitegen.rb
128
126
  - doc/syntactic_recognition.markdown
129
127
  - doc/tt.1
130
128
  - doc/using_in_ruby.markdown
@@ -201,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
199
  version: '0'
202
200
  requirements: []
203
201
  rubyforge_project:
204
- rubygems_version: 2.4.5
202
+ rubygems_version: 2.7.6.2
205
203
  signing_key:
206
204
  specification_version: 4
207
205
  summary: A Ruby-based text parsing and interpretation DSL
@@ -1,112 +0,0 @@
1
- require 'rubygems'
2
- require 'erector'
3
- require "#{File.dirname(__FILE__)}/sitegen"
4
- require 'fileutils'
5
- require 'bluecloth'
6
-
7
- class Layout < Erector::Widget
8
- def content
9
- html do
10
- head do
11
- link :rel => "stylesheet",
12
- :type => "text/css",
13
- :href => "./screen.css"
14
-
15
- rawtext %(
16
- <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
17
- </script>
18
- <script type="text/javascript">
19
- _uacct = "UA-3418876-1";
20
- urchinTracker();
21
- </script>
22
- )
23
- end
24
-
25
- body do
26
- div :id => 'top' do
27
- div :id => 'main_navigation' do
28
- main_navigation
29
- end
30
- end
31
- div :id => 'middle' do
32
- div :id => 'main_content' do
33
- main_content
34
- end
35
- end
36
- div :id => 'bottom' do
37
-
38
- end
39
- end
40
- end
41
- end
42
-
43
- def main_navigation
44
- ul do
45
- li { link_to "Documentation", SyntacticRecognition, Documentation }
46
- li { link_to "Contribute", Contribute }
47
- li { link_to "Home", Index }
48
- end
49
- end
50
-
51
- def main_content
52
- end
53
- end
54
-
55
- class Index < Layout
56
- def main_content
57
- bluecloth "index.markdown"
58
- end
59
- end
60
-
61
- class Documentation < Layout
62
- abstract
63
-
64
- def main_content
65
- div :id => 'secondary_navigation' do
66
- ul do
67
- li { link_to 'Syntax', SyntacticRecognition }
68
- li { link_to 'Semantics', SemanticInterpretation }
69
- li { link_to 'Using In Ruby', UsingInRuby }
70
- li { link_to 'Advanced Techniques', PitfallsAndAdvancedTechniques }
71
- end
72
- end
73
-
74
- div :id => 'documentation_content' do
75
- documentation_content
76
- end
77
- end
78
- end
79
-
80
- class SyntacticRecognition < Documentation
81
- def documentation_content
82
- bluecloth "syntactic_recognition.markdown"
83
- end
84
- end
85
-
86
- class SemanticInterpretation < Documentation
87
- def documentation_content
88
- bluecloth "semantic_interpretation.markdown"
89
- end
90
- end
91
-
92
- class UsingInRuby < Documentation
93
- def documentation_content
94
- bluecloth "using_in_ruby.markdown"
95
- end
96
- end
97
-
98
- class PitfallsAndAdvancedTechniques < Documentation
99
- def documentation_content
100
- bluecloth "pitfalls_and_advanced_techniques.markdown"
101
- end
102
- end
103
-
104
-
105
- class Contribute < Layout
106
- def main_content
107
- bluecloth "contributing_and_planned_features.markdown"
108
- end
109
- end
110
-
111
-
112
- Layout.generate_site
@@ -1,78 +0,0 @@
1
- class Layout < Erector::Widget
2
-
3
- class << self
4
- def inherited(page_class)
5
- puts page_class
6
- (@@page_classes ||= []) << page_class
7
- end
8
-
9
- def generate_site
10
- FileUtils.mkdir_p(site_dir)
11
- @@page_classes.each do |page_class|
12
- page_class.generate_html unless page_class.abstract?
13
- puts page_class
14
- end
15
- end
16
-
17
- def generate_html
18
- File.open(absolute_path, 'w') do |file|
19
- file.write(new.to_html)
20
- end
21
- end
22
-
23
- def absolute_path
24
- absolutize(relative_path)
25
- end
26
-
27
- def relative_path
28
- "#{name.gsub('::', '_').underscore}.html"
29
- end
30
-
31
- def absolutize(relative_path)
32
- File.join(site_dir, relative_path)
33
- end
34
-
35
- def abstract
36
- @abstract = true
37
- end
38
-
39
- def abstract?
40
- @abstract
41
- end
42
-
43
- def site_dir
44
- File.join(File.dirname(__FILE__), "../website")
45
- end
46
- end
47
-
48
- def bluecloth(relative_path)
49
- File.open(File.join(File.dirname(__FILE__), relative_path)) do |file|
50
- rawtext BlueCloth.new(file.read).to_html
51
- end
52
- end
53
-
54
- def absolutize(relative_path)
55
- self.class.absolutize(relative_path)
56
- end
57
-
58
- def link_to(link_text, page_class, section_class=nil)
59
- if instance_of?(page_class) || section_class && is_a?(section_class)
60
- text link_text
61
- else
62
- a link_text, :href => page_class.relative_path
63
- end
64
- end
65
- end
66
-
67
- class String
68
- def underscore
69
- camel_cased_word = self
70
- return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/
71
- word = camel_cased_word.to_s.gsub('::'.freeze, '/'.freeze)
72
- word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'.freeze)
73
- word.gsub!(/([a-z\d])([A-Z])/, '\1_\2'.freeze)
74
- word.tr!("-".freeze, "_".freeze)
75
- word.downcase!
76
- word
77
- end
78
- end