Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Showing with 22 additions and 13 deletions.
  1. +6 −3 lib/kpeg/code_generator.rb
  2. +16 −10 test/test_kpeg_code_generator.rb
View
9 lib/kpeg/code_generator.rb
@@ -83,11 +83,14 @@ def handle_ast(code)
if output_node
code << " end\n"
+ code << " module #{root}Construction\n"
methods.each do |short, name, attrs|
- code << " def #{short}(#{attrs.join(', ')})\n"
- code << " #{root}::#{name}.new(#{attrs.join(', ')})\n"
- code << " end\n"
+ code << " def #{short}(#{attrs.join(', ')})\n"
+ code << " #{root}::#{name}.new(#{attrs.join(', ')})\n"
+ code << " end\n"
end
+ code << " end\n"
+ code << " include #{root}Construction\n"
end
end
View
26 test/test_kpeg_code_generator.rb
@@ -1661,15 +1661,18 @@ def initialize()
end
end
end
- def bracket(receiver, argument)
- AST::BracketOperator.new(receiver, argument)
- end
- def simple()
- AST::Simple.new()
- end
- def simple2()
- AST::Simple2.new()
+ module ASTConstruction
+ def bracket(receiver, argument)
+ AST::BracketOperator.new(receiver, argument)
+ end
+ def simple()
+ AST::Simple.new()
+ end
+ def simple2()
+ AST::Simple2.new()
+ end
end
+ include ASTConstruction
# root = .
def _root
@@ -1715,9 +1718,12 @@ def initialize(receiver, argument)
attr_reader :argument
end
end
- def bracket(receiver, argument)
- MegaAST::BracketOperator.new(receiver, argument)
+ module MegaASTConstruction
+ def bracket(receiver, argument)
+ MegaAST::BracketOperator.new(receiver, argument)
+ end
end
+ include MegaASTConstruction
# root = .
def _root

No commit comments for this range

Something went wrong with that request. Please try again.