Skip to content
Browse files

Added module grammar

  • Loading branch information...
1 parent bf636f8 commit 64d12e4f0832e02b05841d0f8558286c8a6d8aff @jamesbirtles committed
Showing with 18 additions and 4 deletions.
  1. +1 −1 CHANGELOG.md
  2. +5 −1 lib/SweetTea/grammar.treetop
  3. +2 −0 lib/SweetTea/nodes.rb
  4. +2 −2 lib/SweetTea/version.rb
  5. +8 −0 spec/grammar_spec.rb
View
2 CHANGELOG.md
@@ -1,5 +1,5 @@
# Change Log
-
+### Release 0.0.7 - In Development
### Release 0.0.6 - 6th April 2012
* 1 Major Feature
* Added executable to compile javascript
View
6 lib/SweetTea/grammar.treetop
@@ -1,6 +1,10 @@
grammar SweetTea
rule body
- (class / expression / space)* <BodyNode>
+ (class / module / expression / space)* <BodyNode>
+ end
+
+ rule module
+ ('module->' / 'mod->' / 'm->') gap? specialName (body)* ('<-module' / '<-mod' / '<-m') <ModuleNode>
end
rule class
View
2 lib/SweetTea/nodes.rb
@@ -1,6 +1,8 @@
module SweetTea
class BodyNode < Treetop::Runtime::SyntaxNode
end
+ class ModuleNode < Treetop::Runtime::SyntaxNode
+ end
class ClassNode < Treetop::Runtime::SyntaxNode
end
class FunctionNode < Treetop::Runtime::SyntaxNode
View
4 lib/SweetTea/version.rb
@@ -1,3 +1,3 @@
module SweetTea
- VERSION = "0.0.6"
-end
+ VERSION = "0.0.7.dev"
+end
View
8 spec/grammar_spec.rb
@@ -5,6 +5,14 @@
describe "SweetTea grammer" do
subject { SweetTeaParser.new }
+ context "module" do
+ it "should recognise all three ways of creating a function" do
+ subject.parse("module-> ModuleName <-module").should_not be_nil
+ subject.parse("mod-> ModuleName <-mod").should_not be_nil
+ subject.parse("m-> ModuleName <-m").should_not be_nil
+ end
+ end
+
context "class" do
it "should recognise both ways of creating a class" do
subject.parse("class-> ClassName <-class").should_not be_nil

0 comments on commit 64d12e4

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