treetop 1.5.3 → 1.6.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/Gemfile +12 -0
- data/History.txt +18 -0
- data/README.md +4 -0
- data/Rakefile +20 -40
- data/Treetop.tmbundle/Preferences/Comments.tmPreferences +28 -0
- data/Treetop.tmbundle/Snippets/grammar ___ end.tmSnippet +20 -0
- data/Treetop.tmbundle/Snippets/rule ___ end.tmSnippet +18 -0
- data/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/designable.nib +1524 -0
- data/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/keyedobjects.nib +0 -0
- data/Treetop.tmbundle/Support/syntax_tree_viewer.rb +117 -0
- data/Treetop.tmbundle/Syntaxes/Treetop Grammar.tmLanguage +358 -0
- data/Treetop.tmbundle/info.plist +10 -0
- data/doc/pitfalls_and_advanced_techniques.markdown +7 -1
- data/doc/syntactic_recognition.markdown +7 -2
- data/doc/tt.1 +1 -1
- data/examples/indented_blocks/indented_blocks.tt +73 -0
- data/examples/indented_blocks/indented_blocks_test.rb +24 -0
- data/lib/treetop/compiler/grammar_compiler.rb +6 -3
- data/lib/treetop/compiler/metagrammar.rb +301 -159
- data/lib/treetop/compiler/metagrammar.treetop +96 -13
- data/lib/treetop/compiler/node_classes/anything_symbol.rb +10 -2
- data/lib/treetop/compiler/node_classes/atomic_expression.rb +2 -2
- data/lib/treetop/compiler/node_classes/character_class.rb +10 -2
- data/lib/treetop/compiler/node_classes/choice.rb +11 -7
- data/lib/treetop/compiler/node_classes/nonterminal.rb +6 -2
- data/lib/treetop/compiler/node_classes/parenthesized_expression.rb +5 -1
- data/lib/treetop/compiler/node_classes/parsing_expression.rb +10 -1
- data/lib/treetop/compiler/node_classes/parsing_rule.rb +1 -1
- data/lib/treetop/compiler/node_classes/predicate.rb +8 -1
- data/lib/treetop/compiler/node_classes/predicate_block.rb +7 -0
- data/lib/treetop/compiler/node_classes/repetition.rb +28 -8
- data/lib/treetop/compiler/node_classes/sequence.rb +5 -1
- data/lib/treetop/compiler/node_classes/terminal.rb +36 -22
- data/lib/treetop/compiler/ruby_builder.rb +2 -2
- data/lib/treetop/ruby_extensions/string.rb +0 -6
- data/lib/treetop/runtime/compiled_parser.rb +33 -14
- data/lib/treetop/runtime/syntax_node.rb +24 -15
- data/lib/treetop/runtime/terminal_parse_failure.rb +4 -3
- data/lib/treetop/runtime/terminal_syntax_node.rb +4 -4
- data/lib/treetop/version.rb +2 -2
- data/treetop.gemspec +25 -165
- metadata +43 -98
- data/doc/site.rb +0 -112
- data/doc/sitegen.rb +0 -65
- data/examples/lambda_calculus/lambda_calculus +0 -0
- data/spec/compiler/and_predicate_spec.rb +0 -36
- data/spec/compiler/anything_symbol_spec.rb +0 -44
- data/spec/compiler/character_class_spec.rb +0 -301
- data/spec/compiler/choice_spec.rb +0 -80
- data/spec/compiler/circular_compilation_spec.rb +0 -30
- data/spec/compiler/failure_propagation_functional_spec.rb +0 -21
- data/spec/compiler/grammar_compiler_spec.rb +0 -113
- data/spec/compiler/grammar_spec.rb +0 -41
- data/spec/compiler/multibyte_chars_spec.rb +0 -38
- data/spec/compiler/namespace_spec.rb +0 -42
- data/spec/compiler/nonterminal_symbol_spec.rb +0 -40
- data/spec/compiler/not_predicate_spec.rb +0 -38
- data/spec/compiler/occurrence_range_spec.rb +0 -189
- data/spec/compiler/one_or_more_spec.rb +0 -35
- data/spec/compiler/optional_spec.rb +0 -37
- data/spec/compiler/parenthesized_expression_spec.rb +0 -19
- data/spec/compiler/parsing_rule_spec.rb +0 -61
- data/spec/compiler/repeated_subrule_spec.rb +0 -29
- data/spec/compiler/semantic_predicate_spec.rb +0 -175
- data/spec/compiler/sequence_spec.rb +0 -129
- data/spec/compiler/terminal_spec.rb +0 -170
- data/spec/compiler/terminal_symbol_spec.rb +0 -37
- data/spec/compiler/test_grammar.treetop +0 -7
- data/spec/compiler/test_grammar.tt +0 -7
- data/spec/compiler/test_grammar_do.treetop +0 -7
- data/spec/compiler/test_grammar_magic_coding.treetop +0 -8
- data/spec/compiler/test_grammar_magic_encoding.treetop +0 -8
- data/spec/compiler/tt_compiler_spec.rb +0 -224
- data/spec/compiler/zero_or_more_spec.rb +0 -56
- data/spec/composition/a.treetop +0 -11
- data/spec/composition/b.treetop +0 -11
- data/spec/composition/c.treetop +0 -10
- data/spec/composition/d.treetop +0 -10
- data/spec/composition/f.treetop +0 -17
- data/spec/composition/grammar_composition_spec.rb +0 -40
- data/spec/composition/subfolder/e_includes_c.treetop +0 -15
- data/spec/ruby_extensions/string_spec.rb +0 -32
- data/spec/runtime/compiled_parser_spec.rb +0 -123
- data/spec/runtime/interval_skip_list/delete_spec.rb +0 -147
- data/spec/runtime/interval_skip_list/expire_range_spec.rb +0 -349
- data/spec/runtime/interval_skip_list/insert_and_delete_node_spec.rb +0 -385
- data/spec/runtime/interval_skip_list/insert_spec.rb +0 -660
- data/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +0 -6175
- data/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +0 -58
- data/spec/runtime/interval_skip_list/palindromic_fixture.rb +0 -35
- data/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +0 -163
- data/spec/runtime/interval_skip_list/spec_helper.rb +0 -91
- data/spec/runtime/syntax_node_spec.rb +0 -77
- data/spec/spec_helper.rb +0 -115
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YTE1MTQyNWE0NDdkNTU1MmNiYWFiZWU2NDA3ZjJkYmUzNGU5ZmI3ZA==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5717056d3dbb9b543f988059dcd86c2b5789eac8912591c366bb36db9803ce09
|
4
|
+
data.tar.gz: 143894fceb89a090a1a558733ebda88cd9af044c9fdcd37043ae2e7c80d018e3
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NTk1ZmIyMzMxZDczNWIxYTZhNDEyMjMxMzQ5OGIyYmM4MWE1NjY2MTRjOTg0
|
11
|
-
ZmE5MGJiYzZhZjRjOTAzZjc2YTVlMGQ5Y2U2ZGVlMGE5MjgxZTI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
M2MzNmM5ZjI0MDJhMmE3NDk5MTMzNjUyOTE4MDc0ZWZiNjBmZjE1ZTgxYzc4
|
14
|
-
MzA4NmVhZWQ0ZTliZjg3YWY1Mjc3ZGNiYmMyYTRmYzNjOGJiODM1Mzg1YjIz
|
15
|
-
NmU4YjYwMGJlNjgyNmM2MGNjYjY2MDU4MDIxNWMwOTA2Y2MxYWY=
|
6
|
+
metadata.gz: 67a3c52c5a7fd0203f927e3a2cea9e433a634dbe1c016afc6375a0e5ebd4b7005f11e85623334996fc0a6c3564e866c1bd47c4dbbe7ce5b0f18697caec05f198
|
7
|
+
data.tar.gz: ffec456f918bece9ea9ede24df590d6c87622ae93541f0189bf1fe26205f997a42b7268c3a466a11b5e4007fc53a4b34111e4c9a48fcf50152c76afd393ae6ed
|
data/Gemfile
ADDED
data/History.txt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
== 1.4.1 2009-09-04
|
2
|
+
|
3
|
+
* several enhancements:
|
4
|
+
* Many small-to-medium performance improvements
|
5
|
+
* Semantic predicates
|
6
|
+
* Support for UTF-8 characters
|
7
|
+
* Generation of graphvis DOT files for visualising parse results
|
8
|
+
* Commandline revamped with help
|
9
|
+
|
10
|
+
== 1.2.5 2009-03-10
|
11
|
+
|
12
|
+
* 1 minor enhancement:
|
13
|
+
* Extensions may always be modules, instead of sometimes modules, sometimes classes
|
14
|
+
|
15
|
+
== 0.0.1 2008-05-21
|
16
|
+
|
17
|
+
* 1 major enhancement:
|
18
|
+
* Initial release
|
data/README.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/cjheath/treetop.svg)](https://travis-ci.org/cjheath/treetop)
|
2
|
+
|
1
3
|
Support
|
2
4
|
=======
|
3
5
|
|
4
6
|
Support for Treetop is provided through the mailing list you can join or browse here:
|
5
7
|
http://groups.google.com/group/treetop-dev
|
6
8
|
|
9
|
+
The gem is released from https://cjheath.github.io/treetop/ so you should check there as well.
|
10
|
+
|
7
11
|
Tutorial
|
8
12
|
========
|
9
13
|
Languages can be split into two components, their *syntax* and their *semantics*. It's your understanding of English syntax that tells you the stream of words "Sleep furiously green ideas colorless" is not a valid sentence. Semantics is deeper. Even if we rearrange the above sentence to be "Colorless green ideas sleep furiously", which is syntactically correct, it remains nonsensical on a semantic level. With Treetop, you'll be dealing with languages that are much simpler than English, but these basic concepts apply. Your programs will need to address both the syntax and the semantics of the languages they interpret.
|
data/Rakefile
CHANGED
@@ -1,33 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require 'bundler'
|
3
|
-
Bundler.setup(:default, :development)
|
4
|
-
require 'rake'
|
5
|
-
require 'jeweler'
|
1
|
+
require 'bundler/gem_tasks'
|
6
2
|
require 'rspec/core/rake_task'
|
7
3
|
require File.expand_path("../lib/treetop/version", __FILE__)
|
8
4
|
|
9
|
-
Jeweler::Tasks.new do |gem|
|
10
|
-
gem.name = "treetop"
|
11
|
-
gem.version = Treetop::VERSION::STRING
|
12
|
-
gem.author = ["Nathan Sobo", "Clifford Heath"]
|
13
|
-
gem.license = "MIT"
|
14
|
-
gem.email = "cliffordheath@gmail.com"
|
15
|
-
gem.homepage = "https://github.com/cjheath/treetop"
|
16
|
-
gem.platform = Gem::Platform::RUBY
|
17
|
-
gem.summary = "A Ruby-based text parsing and interpretation DSL"
|
18
|
-
gem.files = [
|
19
|
-
"LICENSE", "README.md", "Rakefile", "treetop.gemspec",
|
20
|
-
"{spec,lib,bin,examples}/**/*",
|
21
|
-
"doc/*"
|
22
|
-
].map{|p| Dir[p] }.flatten
|
23
|
-
gem.bindir = "bin"
|
24
|
-
gem.executables = ["tt"]
|
25
|
-
gem.require_path = "lib"
|
26
|
-
gem.autorequire = "treetop"
|
27
|
-
gem.has_rdoc = false
|
28
|
-
end
|
29
|
-
Jeweler::RubygemsDotOrgTasks.new
|
30
|
-
|
31
5
|
task :default => :spec
|
32
6
|
RSpec::Core::RakeTask.new do |t|
|
33
7
|
t.pattern = 'spec/**/*spec.rb'
|
@@ -43,21 +17,27 @@ file 'lib/treetop/compiler/metagrammar.treetop' do |t|
|
|
43
17
|
Treetop::Compiler::GrammarCompiler.new.compile(METAGRAMMAR_PATH)
|
44
18
|
end
|
45
19
|
|
46
|
-
task :
|
47
|
-
|
20
|
+
task :rebuild do
|
21
|
+
$:.unshift "lib"
|
22
|
+
require './lib/treetop'
|
23
|
+
load File.expand_path('../lib/treetop/compiler/metagrammar.rb', __FILE__)
|
24
|
+
Treetop::Compiler::GrammarCompiler.new.compile('lib/treetop/compiler/metagrammar.treetop')
|
48
25
|
end
|
49
26
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
desc 'Upload website files'
|
56
|
-
task :website_upload do
|
57
|
-
rubyforge_config_file = "#{ENV['HOME']}/.rubyforge/user-config.yml"
|
58
|
-
rubyforge_config = YAML.load_file(rubyforge_config_file)
|
59
|
-
`rsync -aCv doc/site/ #{rubyforge_config['username']}@rubyforge.org:/var/www/gforge-projects/treetop/`
|
27
|
+
task :version do
|
28
|
+
puts 'Ruby is '+RUBY_VERSION
|
29
|
+
puts 'Treetop is '+Treetop::VERSION::STRING
|
60
30
|
end
|
61
31
|
|
62
32
|
desc 'Generate and upload website files'
|
63
|
-
task :website
|
33
|
+
task :website do
|
34
|
+
system <<-END
|
35
|
+
rm -rf .doc-tmp
|
36
|
+
cp -r doc .doc-tmp
|
37
|
+
git checkout gh-pages
|
38
|
+
rm -r doc
|
39
|
+
mv .doc-tmp doc
|
40
|
+
rake website upload
|
41
|
+
git checkout master
|
42
|
+
END
|
43
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>name</key>
|
6
|
+
<string>Misc</string>
|
7
|
+
<key>scope</key>
|
8
|
+
<string>source.treetop</string>
|
9
|
+
<key>settings</key>
|
10
|
+
<dict>
|
11
|
+
<key>decreaseIndentPattern</key>
|
12
|
+
<string>^\s*end\s*$</string>
|
13
|
+
<key>increaseIndentPattern</key>
|
14
|
+
<string>^\s*(grammar|rule)\s+\w+\s*$</string>
|
15
|
+
<key>shellVariables</key>
|
16
|
+
<array>
|
17
|
+
<dict>
|
18
|
+
<key>name</key>
|
19
|
+
<string>TM_COMMENT_START</string>
|
20
|
+
<key>value</key>
|
21
|
+
<string># </string>
|
22
|
+
</dict>
|
23
|
+
</array>
|
24
|
+
</dict>
|
25
|
+
<key>uuid</key>
|
26
|
+
<string>1BC307B6-CE08-449E-9074-1AEAA5CE99F4</string>
|
27
|
+
</dict>
|
28
|
+
</plist>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>content</key>
|
6
|
+
<string>grammar ${1:GrammarName}
|
7
|
+
rule ${2:rule_name}
|
8
|
+
$0
|
9
|
+
end
|
10
|
+
end</string>
|
11
|
+
<key>name</key>
|
12
|
+
<string>grammar ... end</string>
|
13
|
+
<key>scope</key>
|
14
|
+
<string>source.treetop</string>
|
15
|
+
<key>tabTrigger</key>
|
16
|
+
<string>g</string>
|
17
|
+
<key>uuid</key>
|
18
|
+
<string>2AE73FBB-88B9-4049-B208-D2440A146164</string>
|
19
|
+
</dict>
|
20
|
+
</plist>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>content</key>
|
6
|
+
<string>rule ${1:rule_name}
|
7
|
+
$0
|
8
|
+
end</string>
|
9
|
+
<key>name</key>
|
10
|
+
<string>rule ... end</string>
|
11
|
+
<key>scope</key>
|
12
|
+
<string>meta.grammar.treetop</string>
|
13
|
+
<key>tabTrigger</key>
|
14
|
+
<string>r</string>
|
15
|
+
<key>uuid</key>
|
16
|
+
<string>498A1881-498E-4BDA-9303-7E42B425C5EE</string>
|
17
|
+
</dict>
|
18
|
+
</plist>
|