Skip to content
Browse files

Add (bundler) gem infrastructure, and a spec or two.

  • Loading branch information...
1 parent ef548b8 commit 0264ae3ebeaa2313e5a9e22c851520b77593f565 @matthewd committed Nov 23, 2010
Showing with 55 additions and 4 deletions.
  1. +4 −0 .gitignore
  2. +4 −0 Gemfile
  3. +2 −0 Rakefile
  4. +2 −2 lib/rasp/parser.citrus
  5. +3 −2 lib/rasp/parser.rb
  6. +3 −0 lib/rasp/version.rb
  7. +23 −0 rasp.gemspec
  8. +14 −0 spec/parser/simple_spec.rb
View
4 .gitignore
@@ -2,3 +2,7 @@
*.tab.rb
*.aspc
*.vbsc
+pkg/*
+*.gem
+.bundle
+Gemfile.lock
View
4 Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in rasp.gemspec
+gemspec
View
2 Rakefile
@@ -0,0 +1,2 @@
+require 'bundler'
+Bundler::GemHelper.install_tasks
View
4 lib/rasp/parser.citrus
@@ -328,7 +328,7 @@ grammar Rasp::Parser
end
rule ENDSTATEMENT
- /[ \t]*(?::|(?:'[^\n]+)?\n)[ \t]*/ { nil }
+ /[ \t]*(?::[ \t]*|(?:'[^\n]+)?\n[ \t]*)/ { nil }
end
rule expression_list
(lhs:expression list:(SP? "," SP? rhs:expression
@@ -337,7 +337,7 @@ grammar Rasp::Parser
rule EOL
- /[ \t]*(?:(?:'[^\n]+)?\n[ \t]*)+/ { nil }
+ /[ \t]*(?:(?:(?:'[^\n]+)?\n[ \t]*)+)/ { nil }
end
rule comment
/'[^\n]+/ { nil }
View
5 lib/rasp/parser.rb
@@ -2,8 +2,9 @@
Citrus.load( File.dirname(__FILE__) + '/parser' )
class << Rasp::Parser
- def read(string, root=nil)
- self.parse(string, :consume => true, :root => root)
+ def nodes(string, root=nil)
+ string = string.sub(/\n?$/, "\n")
+ self.parse(string, :consume => true, :root => root).value
end
end
View
3 lib/rasp/version.rb
@@ -0,0 +1,3 @@
+module Rasp
+ VERSION = "0.0.1"
+end
View
23 rasp.gemspec
@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "rasp/version"
+
+Gem::Specification.new do |s|
+ s.name = "rasp"
+ s.version = Rasp::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["Matthew Draper"]
+ s.email = ["matthew@trebex.net"]
+ s.homepage = ""
+ s.summary = %q{A VBScript runtime. Just because.}
+ s.description = %q{A VBScript runtime. Just because. I really hope no-one is in the unfortunate position of having a use for it.}
+
+ s.add_dependency "citrus", "~> 2.2.2"
+
+ s.add_development_dependency "rspec", "~> 2.1.0"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+end
View
14 spec/parser/simple_spec.rb
@@ -0,0 +1,14 @@
+require 'rasp'
+
+describe "Option Explicit" do
+ it "parses to an OptionExplicit node" do
+ Rasp::Parser.nodes("Option Explicit", :statement).node_summary.should == "OptionExplicit"
+ end
+end
+
+describe "Single Line If" do
+ it "parses simple case" do
+ Rasp::Parser.nodes("If True Then x", :statement).node_summary.should == "If<TrueValue,[NullCall],0>"
+ end
+end
+

0 comments on commit 0264ae3

Please sign in to comment.
Something went wrong with that request. Please try again.