Add a tt manual page

40 views
Skip to first unread message

Carl Worth

unread,
Mar 5, 2012, 8:57:18 PM3/5/12
to treet...@googlegroups.com
It's nice for each program to come with a manual page. Most of the text
here comes from:

http://treetop.rubyforge.org/using_in_ruby.html

Some additional text, (including the available options), come from the
output of "tt --help".
---
doc/tt.1 | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 82 insertions(+), 0 deletions(-)
create mode 100644 doc/tt.1

diff --git a/doc/tt.1 b/doc/tt.1
new file mode 100644
index 0000000..e2adebd
--- /dev/null
+++ b/doc/tt.1
@@ -0,0 +1,82 @@
+.\" treetop - Bringing the simplicity of Ruby to syntactic analysis
+.\"
+.\" Copyright (c) 2007 Nathan Sobo.
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining a copy
+.\" of this software and associated documentation files (the "Software"), to deal
+.\" in the Software without restriction, including without limitation the rights
+.\" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+.\" copies of the Software, and to permit persons to whom the Software is
+.\" furnished to do so, subject to the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included in
+.\" all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+.\" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+.\" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+.\" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+.\" THE SOFTWARE.
+.TH tt 1 2012-03-01 Treetop "Treetop v1.4.10"
+.SH NAME
+tt \- Compile a treetop grammar file to ruby source code
+.SH SYNOPSIS
+.B tt
+[options] grammar_file[.treetop|.tt] ...
+
+.SH DESCRIPTION
+The
+.B tt
+program is a command-line script to compile .treetop files into Ruby
+source code.
+
+The
+.B tt
+program takes a list of files with a .treetop extension and compiles
+them into .rb files of the same name. You can then require these files
+like any other Ruby script.
+
+Alternately, you can supply just one .treetop file and a -o flag to
+specify the name of the output file.
+
+Note: While treetop grammar files
+.B must
+have a supported filename extensions, (.treetop or .tt), the extension
+name is not required when calling the compiler with grammar file
+names.
+.SH OPTIONS
+.TP 4
+.BR "\-o, \-\-output" " FILENAME"
+
+Write parser source to FILENAME.
+.TP 4
+.B \-f, \-\-force
+
+Overwrite existing output file(s)
+.TP 4
+.B \-v, \-\-version
+
+Show Treetop version
+.TP 4
+.B \-h, \-\-help
+
+.SH EXAMPLES
+.TP 4
+1 grammar -> 1 parser source
+
+tt foo.tt
+.TP 4
+2 grammars -> 2 separate parsers
+
+tt foo bar.treetop
+.TP 4
+Alternately named output file
+
+tt -o alterate_name.rb foo
+.SH SEE ALSO
+
+The treetop website:
+
+.B http://treetop.rubyforge.org

Carl Worth

unread,
Mar 5, 2012, 8:55:42 PM3/5/12
to treet...@googlegroups.com
Since treetop cannot know how the user installed the library, (whether
via rubygems or through some other mechanism such as a distribution
package), the implementation should not require rubygems, (nor should
it instruct the user to require rubygems in order to use treetop).
---
README.md | 1 -
bin/tt | 1 -
doc/site.rb | 3 +--
examples/lambda_calculus/test_helper.rb | 3 +--
lib/treetop/bootstrap_gen_1_metagrammar.rb | 2 --
spec/spec_helper.rb | 1 -
6 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md
index 52ea59e..e89a758 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,6 @@ Next, you start filling your grammar with rules. Each rule associates a name wit
The first rule becomes the *root* of the grammar, causing its expression to be matched when a parser for the grammar is fed a string. The above grammar can now be used in a Ruby program. Notice how a string matching the first rule parses successfully, but a second nonmatching string does not.

# use_grammar.rb
- require 'rubygems'
require 'treetop'
Treetop.load 'my_grammar'
# or just:
diff --git a/bin/tt b/bin/tt
index f0f8113..1dcf278 100755
--- a/bin/tt
+++ b/bin/tt
@@ -1,6 +1,5 @@
#!/usr/bin/env ruby
require 'optparse'
-require 'rubygems'

$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
require 'treetop'
diff --git a/doc/site.rb b/doc/site.rb
index c65f5b1..1220624 100644
--- a/doc/site.rb
+++ b/doc/site.rb
@@ -1,4 +1,3 @@
-require 'rubygems'
require 'erector'
require "#{File.dirname(__FILE__)}/sitegen"
require 'fileutils'
@@ -109,4 +108,4 @@ class Contribute < Layout
end


-Layout.generate_site
\ No newline at end of file
+Layout.generate_site
diff --git a/examples/lambda_calculus/test_helper.rb b/examples/lambda_calculus/test_helper.rb
index bfdb7ad..cbb56d4 100644
--- a/examples/lambda_calculus/test_helper.rb
+++ b/examples/lambda_calculus/test_helper.rb
@@ -1,5 +1,4 @@
require 'test/unit'
-require 'rubygems'
require 'treetop'

module ParserTestHelper
@@ -15,4 +14,4 @@ module ParserTestHelper
assert !result.nil?
result
end
-end
\ No newline at end of file
+end
diff --git a/lib/treetop/bootstrap_gen_1_metagrammar.rb b/lib/treetop/bootstrap_gen_1_metagrammar.rb
index eeea9ab..e86a421 100644
--- a/lib/treetop/bootstrap_gen_1_metagrammar.rb
+++ b/lib/treetop/bootstrap_gen_1_metagrammar.rb
@@ -1,8 +1,6 @@
# This file's job is to load a Treetop::Compiler::Metagrammar and Treetop::Compiler::MetagrammarParser
# into the environment by compiling the current metagrammar.treetop using a trusted version of Treetop.

-require 'rubygems'
-
TREETOP_VERSION_REQUIRED_TO_BOOTSTRAP = '>= 1.1.5'

# Loading trusted version of Treetop to compile the compiler
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 8870005..450e5cf 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,4 +1,3 @@
-require 'rubygems'
require 'benchmark'
require 'rspec'
require 'polyglot'

Carl Worth

unread,
Mar 5, 2012, 8:52:28 PM3/5/12
to treet...@googlegroups.com
I recently started using some software (taskjuggler) which indirectly
uses treetop (via mail-ruby). It was nice to discover treetop since it
looks like a fine piece of software. So, thanks!

I've started maintaining a package of treetop for Debian, and in order
to do so, wrote a couple of patches. I'd like to offer them here for
your consideration, (as they should be of general use—not only for
Debian).

The first patch removes all uses of "require rubygems" from the
code. This makes sense for since the treetop implementation cannot know
if the user installed treetop (and other ruby libraries) through
rubygems or through some other mechanism, (for instance, through a
Debian package). This issue is described in general for Ruby libraries here:

https://gist.github.com/54177

The second patch adds a manual page for the tt program.

I'll followup with each patch in its own message. I hope that one or the
both will be helpful.

-Carl

--
carl.d...@intel.com

Reply all
Reply to author
Forward
0 new messages