treetop 1.6.10 → 1.6.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +1 -7
- data/README.md +1 -1
- data/Rakefile +7 -15
- data/doc/pitfalls_and_advanced_techniques.markdown +6 -0
- data/lib/treetop/compiler/ruby_builder.rb +2 -2
- data/lib/treetop/ruby_extensions/string.rb +0 -6
- data/lib/treetop/version.rb +1 -1
- data/treetop.gemspec +4 -4
- metadata +14 -17
- data/doc/site.rb +0 -112
- data/doc/sitegen.rb +0 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5717056d3dbb9b543f988059dcd86c2b5789eac8912591c366bb36db9803ce09
|
4
|
+
data.tar.gz: 143894fceb89a090a1a558733ebda88cd9af044c9fdcd37043ae2e7c80d018e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67a3c52c5a7fd0203f927e3a2cea9e433a634dbe1c016afc6375a0e5ebd4b7005f11e85623334996fc0a6c3564e866c1bd47c4dbbe7ce5b0f18697caec05f198
|
7
|
+
data.tar.gz: ffec456f918bece9ea9ede24df590d6c87622ae93541f0189bf1fe26205f997a42b7268c3a466a11b5e4007fc53a4b34111e4c9a48fcf50152c76afd393ae6ed
|
data/Gemfile
CHANGED
@@ -2,13 +2,7 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gem "polyglot", "~> 0.3"
|
4
4
|
|
5
|
-
|
6
|
-
gem "activesupport", "~> 4"
|
7
|
-
gem "i18n", "~> 0.6"
|
8
|
-
gem "rr", "~> 1.0"
|
9
|
-
gem "rspec", "~> 3"
|
10
|
-
gem "rake"
|
11
|
-
end
|
5
|
+
gemspec
|
12
6
|
|
13
7
|
group :website do
|
14
8
|
platforms :ruby do
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Support
|
|
6
6
|
Support for Treetop is provided through the mailing list you can join or browse here:
|
7
7
|
http://groups.google.com/group/treetop-dev
|
8
8
|
|
9
|
-
The gem is released from https://github.
|
9
|
+
The gem is released from https://cjheath.github.io/treetop/ so you should check there as well.
|
10
10
|
|
11
11
|
Tutorial
|
12
12
|
========
|
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 :
|
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
|
-
|
43
|
-
|
44
|
-
|
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
|
16
|
+
return if ruby_line == ''
|
17
17
|
ruby << ruby_line.tabto(level) << "\n"
|
18
18
|
end
|
19
19
|
|
data/lib/treetop/version.rb
CHANGED
data/treetop.gemspec
CHANGED
@@ -25,10 +25,10 @@ Gem::Specification.new do |spec|
|
|
25
25
|
]
|
26
26
|
|
27
27
|
spec.add_runtime_dependency(%q<polyglot>, ["~> 0.3"])
|
28
|
-
spec.add_development_dependency(%q<activesupport>, ["
|
29
|
-
spec.add_development_dependency(%q<i18n>, ["~> 0
|
30
|
-
spec.add_development_dependency(%q<rr>, ["~>
|
28
|
+
spec.add_development_dependency(%q<activesupport>, [">= 4"])
|
29
|
+
spec.add_development_dependency(%q<i18n>, ["~> 1.0"])
|
30
|
+
spec.add_development_dependency(%q<rr>, ["~> 3.0"])
|
31
31
|
spec.add_development_dependency(%q<rspec>, ["~> 3"])
|
32
|
-
spec.add_development_dependency(%q<rake>, ["
|
32
|
+
spec.add_development_dependency(%q<rake>, [">= 11"])
|
33
33
|
end
|
34
34
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: treetop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Sobo
|
8
8
|
- Clifford Heath
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: polyglot
|
@@ -29,14 +29,14 @@ dependencies:
|
|
29
29
|
name: activesupport
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '4'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '4'
|
42
42
|
- !ruby/object:Gem::Dependency
|
@@ -45,28 +45,28 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '0
|
48
|
+
version: '1.0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0
|
55
|
+
version: '1.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rr
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '3.0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '3.0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rspec
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,14 +85,14 @@ dependencies:
|
|
85
85
|
name: rake
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - "
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '11'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - "
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '11'
|
98
98
|
description: A Parsing Expression Grammar (PEG) Parser generator DSL for Ruby
|
@@ -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
|
@@ -185,7 +183,7 @@ homepage: https://github.com/cjheath/treetop
|
|
185
183
|
licenses:
|
186
184
|
- MIT
|
187
185
|
metadata: {}
|
188
|
-
post_install_message:
|
186
|
+
post_install_message:
|
189
187
|
rdoc_options: []
|
190
188
|
require_paths:
|
191
189
|
- lib
|
@@ -200,9 +198,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
198
|
- !ruby/object:Gem::Version
|
201
199
|
version: '0'
|
202
200
|
requirements: []
|
203
|
-
|
204
|
-
|
205
|
-
signing_key:
|
201
|
+
rubygems_version: 3.2.22
|
202
|
+
signing_key:
|
206
203
|
specification_version: 4
|
207
204
|
summary: A Ruby-based text parsing and interpretation DSL
|
208
205
|
test_files: []
|
data/doc/site.rb
DELETED
@@ -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
|
data/doc/sitegen.rb
DELETED
@@ -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
|