public
Description: A Ruby-based parsing DSL based on parsing expression grammars.
Homepage: http://treetop.rubyforge.org
Clone URL: git://github.com/nathansobo/treetop.git
put back ruby_source (although refactored) as it is refered by 
lib/treetop/bootstrap_gen_1_metagrammar.rb
add tests for ruby_source_string and load_string
hagabaka (author)
Sat May 24 22:25:32 -0700 2008
commit  f55034d35fa1460282b33a2da6330dee3fca4458
tree    8168eeeb03e8e303c695de3f7e9d47d79b32d14e
parent  06ee20f48e71ee6c4d95fce6b498005f4d838dce
...
7
8
9
10
 
 
 
 
 
 
11
12
13
...
7
8
9
 
10
11
12
13
14
15
16
17
18
0
@@ -7,7 +7,12 @@ module Treetop
0
         end
0
       end
0
 
0
- # compile a string containing treetop source
0
+ # compile a treetop file into ruby
0
+ def ruby_source(source_path)
0
+ ruby_source_string(File.read(source_path))
0
+ end
0
+
0
+ # compile a string containing treetop source into ruby
0
       def ruby_source_string(s)
0
         parser = MetagrammarParser.new
0
         result = parser.parse(s)
...
39
40
41
 
 
 
 
 
 
 
 
 
42
43
44
...
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
0
@@ -39,6 +39,15 @@ describe Compiler::GrammarCompiler do
0
   specify "compilation of a single file without writing it to an output file" do
0
     compiler.ruby_source(source_path_with_treetop_extension).should_not be_nil
0
   end
0
+
0
+ specify "ruby_source_string compiles a grammar stored in string" do
0
+ compiler.ruby_source_string(File.read(source_path_with_treetop_extension)).should_not be_nil
0
+ end
0
+
0
+ specify "Treetop.load_string compiles and evaluates a source grammar stored in string" do
0
+ Treetop.load_string File.read(source_path_with_treetop_extension)
0
+ Test::GrammarParser.new.parse('foo').should_not be_nil
0
+ end
0
 
0
   specify "Treetop.load compiles and evaluates a source grammar with a .treetop extension" do
0
     Treetop.load source_path_with_treetop_extension

Comments

    No one has commented yet.